mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-10 21:21:46 +00:00
fix(postgres): POS item price ignores NULL valid_from ordering on Postgres
get_items orders Item Price by valid_from and picks the first match. MariaDB sorts NULL valid_from last under DESC (so a dated price wins); Postgres sorts it first, so the undated base price wins and POS shows the wrong rate. Order by (valid_from IS NULL) asc, valid_from desc so NULLs sort last on both backends regardless of any real date value (MariaDB unchanged).
This commit is contained in:
@@ -231,6 +231,7 @@ def get_items(
|
||||
.where(ItemPrice.selling == 1)
|
||||
.where((ItemPrice.valid_from <= current_date) | (ItemPrice.valid_from.isnull()))
|
||||
.where((ItemPrice.valid_upto >= current_date) | (ItemPrice.valid_upto.isnull()))
|
||||
.orderby(ItemPrice.valid_from.isnull(), order=Order.asc)
|
||||
.orderby(ItemPrice.valid_from, order=Order.desc)
|
||||
).run(as_dict=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user