feat: income

This commit is contained in:
2024-12-12 20:23:19 +04:00
parent daa34b2808
commit e5712224e1
16 changed files with 574 additions and 463 deletions

View File

@@ -10,7 +10,8 @@ from schemas.statistics import GetProfitChartDataResponse, GetProfitChartDataReq
GetProfitTableDataResponse, GetProfitTableDataRequest, ProfitTableDataItem, CommonProfitFilters
from services.base import BaseService
from services.statistics.common import generate_date_range
from services.statistics.expenses_statistics import ExpensesStatisticsService
from services.statistics.expenses_statistics import PaymentStatisticsService
from services.statistics.transactions_statistics import TransactionsStatisticsService
class ProfitStatisticsService(BaseService):
@@ -302,13 +303,18 @@ class ProfitStatisticsService(BaseService):
sub_grouped_by_deals = self._group_by_deals(sub_union)
sub_deals_grouped_by_date = self._group_by_date(sub_grouped_by_deals).subquery()
expenses_statistics_service = ExpensesStatisticsService(self.session)
stmt_deals_applied_expenses = expenses_statistics_service.apply_expenses(
expenses_statistics_service = PaymentStatisticsService(self.session)
stmt_deals_applied_expenses = expenses_statistics_service.apply_payments(
self.filters,
sub_deals_grouped_by_date
)
transactions_statistics_service = TransactionsStatisticsService(self.session)
stmt_deals_applied_transactions = transactions_statistics_service.apply_transactions(
self.filters,
stmt_deals_applied_expenses.subquery()
)
result = await self.session.execute(stmt_deals_applied_expenses)
result = await self.session.execute(stmt_deals_applied_transactions)
rows = result.all()
return rows