fix - transaction hesab fucking asli tokhmi
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user