Inventory Item Movements: Purcase Order Delivery and Credit Note has in reference...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 18 Jul 2019 10:00:54 +0000 (12:00 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 18 Jul 2019 10:00:54 +0000 (12:00 +0200)
instead of reference. Fixed.

inventory/includes/inventory_db.inc

index 901ddcfd9dae68c561c10c65f9135fce4e2c7c51..7b672fae8a3609d517ab1d659e9988b4e3e0bb6d 100644 (file)
@@ -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