fix: Update the retentions#160
Conversation
ZATCA Integration – Changes Summary (24 May 2026)1. Foreign Company Buyers (Non–Saudi Arabia)ProblemForeign company customers could not submit invoices without Saudi VAT or registration details, even though ZATCA export rules do not require them. Changes
XML Behaviour
NoteZATCA may still return warning
Invoice clearance can still succeed with a warning. Additional FixFixed Saudi building-number validation in
2. BR-KSA-81 Follow-Up (Reverted)Attempted
ResultReverted after BR-KSA-81 warnings during clearance. RetainedOnly the foreign-customer validation relaxation from Section 1 was kept. 3. Sales Retention Recalculation When Line Items ChangeProblemRetention amount updated when the retention percentage changed, but not when item quantities, rates, or totals changed. Cause
Changes
|
Retention GL was always added on submit
make_retention_gl_entryran whenever retention fields were filled in.Customer GL was never reduced
make_customer_gl_entryalways debited the fullgrand_total, because nothing reliably lowered it for posting.Broken server logic
The old
set_grand_total_with_retentionhook only patched tax calculation after ERPNext had already recalculated totals, and it never ran that calculation again. So on every save,grand_totalwas reset to the full tax total and retention was never subtracted server-side.What we changed (in one sentence)
We stopped trying to shrink
grand_total(so ZATCA still sees the full amount), and instead:grand_total − retentiongrand_total − retentionfor paymentsNow both sides of the journal add up to 22,698.20 while ZATCA keeps reporting the full invoice total.