Commit c26d3425 authored by 邱阿朋's avatar 邱阿朋

fix(spa): 修复资金类型字段兼容性问题

-增加对 'Funding Type' 和 'Funding type' 两种字段名称的支持
- 修复部分合作协议缺少资金类型字段导致的错误
- 优化代码逻辑,提高数据处理的健壮性
parent e3be3a16
......@@ -91,7 +91,7 @@ class Spa(AutoInterface):
os.remove(report_file)
continue
save_report_file = os.path.join(os.getcwd(), "spa", invoice_id, "BackupReport.xls")
save_report_file = os.path.join(os.getcwd(), "spa", str(invoice_id), "BackupReport.xls")
file.move_file(report_file, save_report_file)
# 创建 ExcelFile 对象
excel_file = pd.ExcelFile(save_report_file)
......@@ -117,11 +117,15 @@ class Spa(AutoInterface):
rebate = item.get("Rebate In Agreement Currency", None)
vendor_funding = item.get("Vendor Funding In Agreement Currency", None)
funding_type = coop.get('Funding Type', "")
if funding_type == "":
funding_type = coop.get('Funding type', "")
processed_item = item.copy()
processed_item.pop("Asin")
processed_item["Agreement title"] = coop.get("Agreement title")
processed_item["Invoice date"] = coop.get("Invoice date")
processed_item['Funding Type'] = coop.get("Funding Type")
processed_item['Funding Type'] = funding_type
processed_item['Asin'] = asin
processed_item['ERP SKU'] = relation.get("erp_sku")
processed_item['Group Name'] = relation.get("name")
......@@ -150,9 +154,13 @@ class Spa(AutoInterface):
processed_item.pop("Invoice date")
if "Funding Type" in processed_item.keys():
processed_item.pop("Funding Type")
funding_type = coop.get('Funding Type', "")
else:
processed_item.pop("Funding type")
funding_type = coop.get('Funding type', "")
processed_item["Invoice date"] = coop.get("Invoice date")
processed_item['Funding Type'] = coop.get("Funding Type")
processed_item['Funding Type'] = funding_type
processed_item["Order Date"] = item.get("Order Date")
processed_item['Purchase Order'] = relation.get("Purchase Order")
processed_item["Agreement Currency"] = item.get("Agreement Currency")
......@@ -218,13 +226,17 @@ class Spa(AutoInterface):
if "10.0%" in agreement_title:
agreement_type = 1
if 'Funding Type' in item_row.keys():
funding_type = item_row.get('Funding Type', "")
else:
funding_type = item_row.get('Funding type', "")
push_data = {
'ad_date': item_row.get('Invoice date', ""), # spa费用数据日期
'erp_sku': item_row.get('ERP SKU', ""), # ERP SKU
'ad_amount': item_row.get('Original balance', ""), # spa费用金额
'ad_amount_currency': item_row.get('Agreement Currency', ""), # spa费用币制
'funding_type': item_row.get('Funding Type', ""), # 资金类型
'transaction_type': item_row.get('Transaction Type', ""), # 交易类型
'funding_type': funding_type, # 资金类型
'group_name': item_row.get('Group Name', ""), # 组别 运营一组 运营二组
'group_code': item_row.get('Group Code', ""), # 组别 T1 T2
'asin': item_row.get('Asin', ""), # ASIN
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment