Fix Jasmin customer key and amount mapping

This commit is contained in:
plx
2026-07-29 14:27:17 +00:00
parent 0c5ee4e581
commit bbfadfa0fd
3 changed files with 240 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
from app.external_reconciliation_sync import _external_customer_key, _jasmin_amount
def test_jasmin_customer_key_prefers_party_code_over_document_natural_key():
record = {
"naturalKey": "ORC.ORC2026.136",
"buyerCustomerParty": "0569",
"accountingParty": "0569",
}
assert _external_customer_key(record, source_system="jasmin") == "0569"
def test_jasmin_customer_key_does_not_use_document_natural_key():
record = {"naturalKey": "ORC.ORC2026.136", "id": "document-uuid"}
assert _external_customer_key(record, source_system="jasmin") == ""
def test_jasmin_amount_reads_flattened_payable_total():
record = {
"payableAmountAmount": 441.57,
"grossValueAmount": 359.00,
}
assert _jasmin_amount(record) == "441.57"
def test_jasmin_amount_reads_nested_money_object():
record = {
"payableAmount": {
"amount": 441.57,
"baseAmount": 441.57,
"reportingAmount": 441.57,
}
}
assert _jasmin_amount(record) == "441.57"