mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-16 10:20:31 +00:00
fix(accounts): tie-break open Payment Request ordering for cross-engine parity
get_open_payment_requests_for_references orders by Coalesce(transaction_date, creation); when transaction_date is set the coalesce never falls back to creation, so PRs sharing a transaction_date have no tiebreaker and MariaDB/Postgres can allocate a different PR first. Append creation, name keys. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2795,6 +2795,9 @@ def get_open_payment_requests_for_references(references=None):
|
|||||||
.where(PR.docstatus == 1)
|
.where(PR.docstatus == 1)
|
||||||
.where(PR.outstanding_amount > 0) # to avoid old PRs with 0 outstanding amount
|
.where(PR.outstanding_amount > 0) # to avoid old PRs with 0 outstanding amount
|
||||||
.orderby(Coalesce(PR.transaction_date, PR.creation), order=frappe.qb.asc)
|
.orderby(Coalesce(PR.transaction_date, PR.creation), order=frappe.qb.asc)
|
||||||
|
# unique tiebreaker so PRs sharing a transaction_date allocate in the same order on both engines
|
||||||
|
.orderby(PR.creation, order=frappe.qb.asc)
|
||||||
|
.orderby(PR.name, order=frappe.qb.asc)
|
||||||
).run(as_dict=True)
|
).run(as_dict=True)
|
||||||
|
|
||||||
if not response:
|
if not response:
|
||||||
|
|||||||
Reference in New Issue
Block a user