update excel

This commit is contained in:
2025-12-16 15:21:59 +03:30
parent d6a30705b5
commit 3cb5766961
3 changed files with 36 additions and 5 deletions

View File

@@ -14,7 +14,7 @@
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.10 (env)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.9 (dam_env)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">

2
.idea/misc.xml generated
View File

@@ -3,5 +3,5 @@
<component name="Black">
<option name="sdkName" value="Python 3.10 (env)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (env)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (dam_env)" project-jdk-type="Python SDK" />
</project>

View File

@@ -248,13 +248,16 @@ class WareHouseExcelViewSet(viewsets.ModelViewSet, ExcelDynamicSearchMixin):
excel_options = [
"ردیف",
"تعاونی دامدار",
"کد ملی دامدار",
"شهر تعاونی",
"نام و نام خانوادگی دامدار",
"کد ملی دامدار",
"شهر دامدار",
"تاریخ",
"محصولات",
"شناسه تراکنش",
"شماره کارت",
"مبلغ",
"ماهیت وزن",
"وضعیت",
]
# اضافه کردن ستون‌های داینامیک سهم‌ها
@@ -296,7 +299,7 @@ class WareHouseExcelViewSet(viewsets.ModelViewSet, ExcelDynamicSearchMixin):
m = 1
# دیکشنری برای نگهداری جمع سهم‌ها
share_column_totals = {name: 0 for name in share_names}
all_weight = 0
if ser_data:
for data in ser_data:
items = data.get('items', [])
@@ -308,11 +311,13 @@ class WareHouseExcelViewSet(viewsets.ModelViewSet, ExcelDynamicSearchMixin):
products_str = '، '.join(products_list) if products_list else '-'
rancher_data = data.get('rancher')
rancher_city = rancher_data.get('city', '-') if rancher_data else '-'
national_code = rancher_data.get('national_code', '-') if rancher_data else '-'
rancher_name = data.get('rancher_fullname', '-') if rancher_data else '-'
seller_org = data.get('seller_organization')
org_name = seller_org.get('name', '-') if seller_org else '-'
org_city = seller_org.get('city', '-') if seller_org else '-'
status = TRANSACTION_STATUS_MAP.get(data.get('transaction_status'), '-')
@@ -326,18 +331,41 @@ class WareHouseExcelViewSet(viewsets.ModelViewSet, ExcelDynamicSearchMixin):
)
share_values.append(share_value)
share_column_totals[share_name] += share_value
items = data.get('items', [])
quota_sale_units = [
item.get('quota_sale_unit')
for item in items
if item.get('quota_sale_unit')
]
# جمع وزن کل
total_weight = sum(item.get('weight', 0) for item in items)
all_weight += total_weight
# تعیین ماهیت وزن
if quota_sale_units:
all_equal = (
len(items) > 0 and len(quota_sale_units) == len(items) and len(set(quota_sale_units)) == 1)
if all_equal:
weight_nature = f"{total_weight:,} {quota_sale_units[0] or ''}"
else:
weight_nature = "ترکیبی"
else:
weight_nature = "{0} کیلوگرم".format(total_weight)
list1 = [
m,
org_name,
national_code,
org_city,
rancher_name,
national_code,
rancher_city,
str(shamsi_date(convert_str_to_date(data['transaction_date']), in_value=True)) if data.get(
'transaction_date') else '',
products_str,
data.get('transaction_id') or '-',
data.get('payer_cart') or '-',
data.get('price_paid') or 0,
weight_nature,
status,
]
# اضافه کردن مقادیر سهم‌ها
@@ -368,7 +396,10 @@ class WareHouseExcelViewSet(viewsets.ModelViewSet, ExcelDynamicSearchMixin):
'',
'',
'',
'',
'',
total_price,
all_weight,
'',
]
# اضافه کردن جمع سهم‌ها به ردیف مجموع