X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep308.php;h=53f8195eecdb1b57db556fc89e809c4fd312efaa;hb=1c84758e3c602dba85b819b011c55fb47b1a5b12;hp=feb92d78903353caf7b4074fffdea6e4666b32ff;hpb=bec7b31331653d096dc14734cdc742e32a469298;p=fa-stable.git diff --git a/reporting/rep308.php b/reporting/rep308.php index feb92d78..53f8195e 100644 --- a/reporting/rep308.php +++ b/reporting/rep308.php @@ -126,7 +126,7 @@ function avg_unit_cost($stock_id, $location=null, $to_date) AND move.tran_date < '$to_date' AND standard_cost > 0.001 AND qty <> 0 AND move.type <> ".ST_LOCTRANSFER; if ($location != '') - $sql .= " AND loc_code = ".db_escape($location); + $sql .= " AND move.loc_code = ".db_escape($location); $sql .= " ORDER BY tran_date"; $result = db_query($sql, "No standard cost transactions were returned"); @@ -163,12 +163,18 @@ function trans_qty_unit_cost($stock_id, $location=null, $from_date, $to_date, $i $to_date = date2sql($to_date); - $sql = "SELECT standard_cost, tran_date, qty FROM ".TB_PREF."stock_moves + $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.debtor_no, supplier.supplier_id) person_id + 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."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 WHERE stock_id=".db_escape($stock_id)." - AND tran_date <= '$to_date' AND standard_cost > 0.001 AND qty <> 0 AND type <> ".ST_LOCTRANSFER; + AND move.tran_date <= '$to_date' AND standard_cost > 0.001 AND qty <> 0 AND move.type <> ".ST_LOCTRANSFER; if ($location != '') - $sql .= " AND loc_code = ".db_escape($location); + $sql .= " AND move.loc_code = ".db_escape($location); if ($inward) $sql .= " AND qty > 0 ";