X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep201.php;h=de1d47e461d8526abef07b569791fcc83d352797;hb=34f8e554ed5ac52648b5a542f02b39b6c6e3fc46;hp=9ff6a0c67cb9df122e10a23ab7018020cd7ffffc;hpb=ba60807d6ca1ead4f5ce582e22b164c6ab945eac;p=fa-stable.git diff --git a/reporting/rep201.php b/reporting/rep201.php index 9ff6a0c6..de1d47e4 100644 --- a/reporting/rep201.php +++ b/reporting/rep201.php @@ -27,17 +27,29 @@ include_once($path_to_root . "/gl/includes/gl_db.inc"); print_supplier_balances(); -function get_open_balance($supplier_id, $to) +function get_open_balance($supplier_id, $to, $convert) { $to = date2sql($to); $sql = "SELECT SUM(IF(".TB_PREF."supp_trans.type = 20, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + - ".TB_PREF."supp_trans.ov_discount) * rate, 0)) AS charges, + ".TB_PREF."supp_trans.ov_discount)"; + if ($convert) + $sql .= " * rate"; + $sql .= ", 0)) AS charges, SUM(IF(".TB_PREF."supp_trans.type <> 20, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + - ".TB_PREF."supp_trans.ov_discount) * rate, 0)) AS credits, - SUM(".TB_PREF."supp_trans.alloc * rate) AS Allocated, + ".TB_PREF."supp_trans.ov_discount)"; + if ($convert) + $sql .= "* rate"; + $sql .= ", 0)) AS credits, + SUM(".TB_PREF."supp_trans.alloc"; + if ($convert) + $sql .= " * rate"; + $sql .= ") AS Allocated, SUM((".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + - ".TB_PREF."supp_trans.ov_discount - ".TB_PREF."supp_trans.alloc) * rate) AS OutStanding + ".TB_PREF."supp_trans.ov_discount - ".TB_PREF."supp_trans.alloc)"; + if ($convert) + $sql .= " * rate"; + $sql .= ") AS OutStanding FROM ".TB_PREF."supp_trans WHERE ".TB_PREF."supp_trans.tran_date < '$to' AND ".TB_PREF."supp_trans.supplier_id = '$supplier_id' GROUP BY supplier_id"; @@ -134,7 +146,7 @@ function print_supplier_balances() if ($convert) $rep->TextCol(2, 3, $myrow['curr_code']); $rep->fontSize -= 2; - $bal = get_open_balance($myrow['supplier_id'], $from); + $bal = get_open_balance($myrow['supplier_id'], $from, $convert); $init[0] = $init[1] = 0.0; $rep->TextCol(3, 4, _("Open Balance")); $init[0] = round2(abs($bal['charges']), $dec);