fix - transaction hesab fucking asli tokhmi

This commit is contained in:
2025-11-30 16:58:30 +03:30
parent 2b2e2d51ab
commit d447e1f074
3 changed files with 14 additions and 4 deletions

View File

@@ -7,7 +7,7 @@ ENV_NAME=DEV
# Database secrets # Database secrets
DB_HOST=31.7.78.133 DB_HOST=31.7.78.133
DB_PORT=14352 DB_PORT=14352
DB_NAME=Development DB_NAME=Production
DB_USERNAME=postgres DB_USERNAME=postgres
DB_PASSWORD=pfLIVXupbDetvFMt2gUvxLXUL9b4HIOHaPcKXsBEZ1i8zl0iLUjmhUfXlGfJKcTV DB_PASSWORD=pfLIVXupbDetvFMt2gUvxLXUL9b4HIOHaPcKXsBEZ1i8zl0iLUjmhUfXlGfJKcTV

View File

@@ -3,7 +3,7 @@ from collections import defaultdict
from django.db.models import Sum, Count, Case, When, Q, Value from django.db.models import Sum, Count, Case, When, Q, Value
from django.db.models.functions import Coalesce 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.authentication.services.service import get_all_org_child
from apps.core.services.filter.search import DynamicSearchService from apps.core.services.filter.search import DynamicSearchService
from apps.warehouse.models import InventoryQuotaSaleTransaction, InventoryQuotaSaleItem from apps.warehouse.models import InventoryQuotaSaleTransaction, InventoryQuotaSaleItem
@@ -103,6 +103,11 @@ class TransactionDashboardService:
# calculate sum of item share percentage by product # calculate sum of item share percentage by product
items_by_product = defaultdict(list) 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: for item in items:
pid = item.gov_product_id or item.free_product_id pid = item.gov_product_id or item.free_product_id
@@ -117,8 +122,14 @@ class TransactionDashboardService:
for share in item.item_share: for share in item.item_share:
# share: {"name": "", "price": "", ....} # share: {"name": "", "price": "", ....}
name = share.get("name") name = share.get("name")
shaba = str(share.get("shaba", 0)) # noqa
if shaba.startswith("IR"):
shaba = shaba[2:] # noqa
price = share.get("price", 0) 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]["total_price"] += price
share_totals[name]["count"] += 1 share_totals[name]["count"] += 1

View File

@@ -26,7 +26,6 @@ djangorestframework-jwt
djangorestframework_simplejwt djangorestframework_simplejwt
djangorestframework-recursive djangorestframework-recursive
docopt docopt
excelstyler
gunicorn gunicorn
idna idna
importlib-metadata importlib-metadata