forked from erp-dev/erp
beta
This commit is contained in:
@@ -14,6 +14,7 @@ from django.db import transaction
|
||||
from basic_info import models as basic_models
|
||||
from . import models as business_models
|
||||
from . import services as business_services
|
||||
from .amounts import calculate_settlement_amount, normalize_money_amount
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -524,10 +525,19 @@ def _normalize_external_receipt_record(*, record: dict[str, Any], record_kind: s
|
||||
markup = str(record.get('JieSunFS') or '').strip() or None
|
||||
receipt_date = _parse_external_date(record.get('RiQi') or record.get('KdRiQi'))
|
||||
if record_kind == 'receipt':
|
||||
amount = _to_decimal(record.get('FkJinE'), field_name='FkJinE')
|
||||
discount_amount = _to_decimal(record.get('ZkJinE'), field_name='ZkJinE', default=Decimal('0'))
|
||||
amount = normalize_money_amount(
|
||||
_to_decimal(record.get('FkJinE'), field_name='FkJinE'),
|
||||
field_name='FkJinE',
|
||||
)
|
||||
discount_amount = normalize_money_amount(
|
||||
_to_decimal(record.get('ZkJinE'), field_name='ZkJinE', default=Decimal('0')),
|
||||
field_name='ZkJinE',
|
||||
)
|
||||
elif record_kind == 'refund':
|
||||
amount = _to_decimal(record.get('YfJinE'), field_name='YfJinE')
|
||||
amount = normalize_money_amount(
|
||||
_to_decimal(record.get('YfJinE'), field_name='YfJinE'),
|
||||
field_name='YfJinE',
|
||||
)
|
||||
discount_amount = Decimal('0')
|
||||
else:
|
||||
raise ExternalFinanceSyncError(f'不支持的 record_kind: {record_kind}')
|
||||
@@ -537,7 +547,10 @@ def _normalize_external_receipt_record(*, record: dict[str, Any], record_kind: s
|
||||
'receipt_date': receipt_date,
|
||||
'amount': amount,
|
||||
'discount_amount': discount_amount,
|
||||
'settlement_amount': amount + discount_amount,
|
||||
'settlement_amount': calculate_settlement_amount(
|
||||
amount=amount,
|
||||
discount_amount=discount_amount,
|
||||
),
|
||||
'customer_name': customer_name,
|
||||
'markup': markup,
|
||||
'remarks': _build_external_remarks(record=record, record_kind=record_kind),
|
||||
|
||||
Reference in New Issue
Block a user