From fadad2d1c432438f4131b45ae32cd69e94a264ee Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 22 Jun 2026 23:13:29 +0530 Subject: [PATCH] fix(regional): deterministic IRS-1099 payer-address pick across engines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit get_payer_address_html picks one company address with ORDER BY (Postal DESC, Billing DESC) LIMIT 1 and no column tie-break. When a company has two addresses of the same address_type the two CASE keys tie, so the LIMIT-1 row is implementation-defined and MariaDB and PostgreSQL can return a different address.name — i.e. a different payer address on the rendered IRS-1099 form for identical data. Add a final .orderby(address.name), mirroring the sibling get_street_address_html in the same file (which already carries the "deterministic LIMIT-1 tie-break across engines" order). The pick is now the lexicographically-smallest name on both engines. --- erpnext/regional/report/irs_1099/irs_1099.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/regional/report/irs_1099/irs_1099.py b/erpnext/regional/report/irs_1099/irs_1099.py index 52b397843cf..cebc60d1aec 100644 --- a/erpnext/regional/report/irs_1099/irs_1099.py +++ b/erpnext/regional/report/irs_1099/irs_1099.py @@ -131,6 +131,7 @@ def get_payer_address_html(company): .where(address.is_your_company_address == 1) .orderby(Case().when(address.address_type == "Postal", 1).else_(0), order=frappe.qb.desc) .orderby(Case().when(address.address_type == "Billing", 1).else_(0), order=frappe.qb.desc) + .orderby(address.name) # deterministic LIMIT-1 tie-break across engines .limit(1) .run(as_dict=True) )