From b10cf2fb652bfba79a7e9ecc5fb533daf2d00993 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Thu, 25 Jun 2026 14:39:05 +0530 Subject: [PATCH] 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). --- erpnext/selling/page/point_of_sale/point_of_sale.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py index a96fc309687..8f0bc136458 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -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)