From f098cfbe80eab277d929afd255b727574523cf13 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Thu, 18 Jul 2019 12:00:54 +0200 Subject: [PATCH] Inventory Item Movements: Purcase Order Delivery and Credit Note has in reference column trans_no or Return memo presented instead of reference. Fixed. --- inventory/includes/inventory_db.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inventory/includes/inventory_db.inc b/inventory/includes/inventory_db.inc index 901ddcfd..7b672fae 100644 --- a/inventory/includes/inventory_db.inc +++ b/inventory/includes/inventory_db.inc @@ -34,14 +34,16 @@ function get_stock_movements($stock_id, $StockLocation, $BeforeDate, $AfterDate) { $before_date = date2sql($BeforeDate); $after_date = date2sql($AfterDate); - $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.name, supplier.supp_name) name"; + // PO Delivery and Customer Credit Notes references should be saved in stock moves reference in 2.5 + $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.name, supplier.supp_name) name, + IF(move.type=".ST_SUPPRECEIVE.", grn.reference, IF(move.type=".ST_CUSTCREDIT.", cust_trans.reference, move.reference)) reference"; if(!$StockLocation) { $sql .= ", move.loc_code"; } $sql.= " FROM ".TB_PREF."stock_moves move LEFT JOIN ".TB_PREF."supp_trans credit ON credit.trans_no=move.trans_no AND credit.type=move.type - LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=move.trans_no AND 25=move.type + LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=move.trans_no AND move.type=".ST_SUPPRECEIVE." LEFT JOIN ".TB_PREF."suppliers supplier ON IFNULL(grn.supplier_id, credit.supplier_id)=supplier.supplier_id LEFT JOIN ".TB_PREF."debtor_trans cust_trans ON cust_trans.trans_no=move.trans_no AND cust_trans.type=move.type LEFT JOIN ".TB_PREF."debtors_master debtor ON cust_trans.debtor_no=debtor.debtor_no -- 2.30.2