X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep308.php;h=0837704d37bda96a4d1c23df5103e16959e62b1c;hb=ec98559a543b666f4824149e8522d0aa65818936;hp=84f43a79a04bf745d0ace6f436800134d22d3ade;hpb=936e862fe67af1b6113aee0d727eb86e7f021cc1;p=fa-stable.git diff --git a/reporting/rep308.php b/reporting/rep308.php index 84f43a79..0837704d 100644 --- a/reporting/rep308.php +++ b/reporting/rep308.php @@ -32,17 +32,23 @@ inventory_movements(); function get_domestic_price($myrow, $stock_id) { - $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; - } - 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['unit_cost']; //pick unit_cost for sales deliveries + + return $price; +} function fetch_items($category=0) { @@ -98,7 +104,7 @@ function avg_unit_cost($stock_id, $location=null, $to_date) $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 @@ -145,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