X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=inline;f=reporting%2Frep308.php;h=ffd880ebc804b86c2b34c04cc5f2c21f3df83793;hb=0b44975d1b3c8f3e3fb28d24d8b45b1a6f71d12c;hp=ba546b214a82ae4fd102430a04a07219e7cefc8d;hpb=65e616be727190bf216daac6a14ee253873e9f3c;p=fa-stable.git diff --git a/reporting/rep308.php b/reporting/rep308.php index ba546b21..ffd880eb 100644 --- a/reporting/rep308.php +++ b/reporting/rep308.php @@ -32,22 +32,23 @@ inventory_movements(); function get_domestic_price($myrow, $stock_id) { - if ($myrow['type'] == ST_SUPPRECEIVE || $myrow['type'] == ST_SUPPCREDIT) - { - $price = $myrow['price']; - if ($myrow['person_id'] > 0) - { - // Do we have foreign currency? - $supp = get_supplier($myrow['person_id']); - $currency = $supp['curr_code']; - $ex_rate = get_exchange_rate_to_home_currency($currency, sql2date($myrow['tran_date'])); - $price /= $ex_rate; - } - } - else - $price = $myrow['standard_cost']; // Item Adjustments just have the real cost - return $price; -} + if ($myrow['type'] == ST_SUPPRECEIVE || $myrow['type'] == ST_SUPPCREDIT) + { + $price = $myrow['price']; + if ($myrow['person_id'] > 0) + { + // Do we have foreign currency? + $supp = get_supplier($myrow['person_id']); + $currency = $supp['curr_code']; + $ex_rate = $myrow['ex_rate']; + $price *= $ex_rate; + } + } + else + $price = $myrow['standard_cost']; //pick standard_cost for sales deliveries + + return $price; +} function fetch_items($category=0) { @@ -63,7 +64,7 @@ function fetch_items($category=0) return db_query($sql,"No transactions were returned"); } -function trans_qty($stock_id, $location=null, $from_date, $to_date, $inward = true) +function trans_qty($stock_id, $location, $from_date, $to_date, $inward = true) { if ($from_date == null) $from_date = Today(); @@ -96,14 +97,14 @@ function trans_qty($stock_id, $location=null, $from_date, $to_date, $inward = tr } -function avg_unit_cost($stock_id, $location=null, $to_date) +function avg_unit_cost($stock_id, $location, $to_date) { if ($to_date == null) $to_date = Today(); $to_date = date2sql($to_date); - $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.debtor_no, supplier.supplier_id) person_id + $sql = "SELECT move.*, supplier.supplier_id person_id, IF(ISNULL(grn.rate), credit.rate, grn.rate) ex_rate 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 @@ -138,7 +139,7 @@ function avg_unit_cost($stock_id, $location=null, $to_date) //---------------------------------------------------------------------------------------------------- -function trans_qty_unit_cost($stock_id, $location=null, $from_date, $to_date, $inward = true) +function trans_qty_unit_cost($stock_id, $location, $from_date, $to_date, $inward = true) { if ($from_date == null) $from_date = Today(); @@ -150,7 +151,7 @@ function trans_qty_unit_cost($stock_id, $location=null, $from_date, $to_date, $i $to_date = date2sql($to_date); - $sql = "SELECT move.*, IF(ISNULL(supplier.supplier_id), debtor.debtor_no, supplier.supplier_id) person_id + $sql = "SELECT move.*, supplier.supplier_id person_id, IF(ISNULL(grn.rate), credit.rate, grn.rate) ex_rate 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