diff --git a/.env.local b/.env.local index 13815d0..3402c15 100644 --- a/.env.local +++ b/.env.local @@ -7,7 +7,7 @@ ENV_NAME=DEV # Database secrets DB_HOST=31.7.78.133 DB_PORT=14352 -DB_NAME=Development +DB_NAME=Production DB_USERNAME=postgres DB_PASSWORD=pfLIVXupbDetvFMt2gUvxLXUL9b4HIOHaPcKXsBEZ1i8zl0iLUjmhUfXlGfJKcTV diff --git a/apps/warehouse/services/transaction_dashboard_service.py b/apps/warehouse/services/transaction_dashboard_service.py index 1e54899..22300ed 100644 --- a/apps/warehouse/services/transaction_dashboard_service.py +++ b/apps/warehouse/services/transaction_dashboard_service.py @@ -3,7 +3,7 @@ from collections import defaultdict from django.db.models import Sum, Count, Case, When, Q, Value from django.db.models.functions import Coalesce -from apps.authentication.models import Organization +from apps.authentication.models import Organization, BankAccountInformation from apps.authentication.services.service import get_all_org_child from apps.core.services.filter.search import DynamicSearchService from apps.warehouse.models import InventoryQuotaSaleTransaction, InventoryQuotaSaleItem @@ -103,6 +103,11 @@ class TransactionDashboardService: # calculate sum of item share percentage by product items_by_product = defaultdict(list) + bank_accounts = BankAccountInformation.objects.all() + + bank_accounts_dict = { + f'{account.sheba}': account.organization.name for account in bank_accounts + } for item in items: pid = item.gov_product_id or item.free_product_id @@ -117,8 +122,14 @@ class TransactionDashboardService: for share in item.item_share: # share: {"name": "", "price": "", ....} name = share.get("name") + shaba = str(share.get("shaba", 0)) # noqa + if shaba.startswith("IR"): + shaba = shaba[2:] # noqa price = share.get("price", 0) - shaba = share.get("shaba", 0) # noqa + + # get name of org from their shaba + if shaba in bank_accounts_dict.keys(): + name = bank_accounts_dict[shaba] share_totals[name]["total_price"] += price share_totals[name]["count"] += 1 diff --git a/requirements.txt b/requirements.txt index 1bbfcff..791975f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,7 +26,6 @@ djangorestframework-jwt djangorestframework_simplejwt djangorestframework-recursive docopt -excelstyler gunicorn idna importlib-metadata