From: Joe Hunt Date: Thu, 18 Apr 2013 08:10:36 +0000 (+0200) Subject: A couple of small bugs in customer and supplier balances report fixed. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=ad3707c1e51a4a81296d678f938d2641f8735310;p=textcart.git A couple of small bugs in customer and supplier balances report fixed. --- diff --git a/reporting/rep101.php b/reporting/rep101.php index 2826c94..b098dad 100644 --- a/reporting/rep101.php +++ b/reporting/rep101.php @@ -35,12 +35,12 @@ function get_open_balance($debtorno, $to, $convert) if($to) $to = date2sql($to); - $sql = "SELECT SUM(IF(t.type = ".ST_SALESINVOICE.", + $sql = "SELECT SUM(IF(t.type = ".ST_SALESINVOICE." OR t.type = ".ST_BANKPAYMENT.", (t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount)"; if ($convert) $sql .= " * rate"; $sql .= ", 0)) AS charges, - SUM(IF(t.type <> ".ST_SALESINVOICE.", + SUM(IF(t.type <> ".ST_SALESINVOICE." AND t.type <> ".ST_BANKPAYMENT.", (t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount)"; if ($convert) $sql .= " * rate"; @@ -49,7 +49,7 @@ function get_open_balance($debtorno, $to, $convert) if ($convert) $sql .= " * rate"; $sql .= ") AS Allocated, - SUM(IF(t.type = ".ST_SALESINVOICE.", + SUM(IF(t.type = ".ST_SALESINVOICE." OR t.type = ".ST_BANKPAYMENT.", (t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount - t.alloc)"; if ($convert) $sql .= " * rate"; @@ -219,12 +219,6 @@ function print_customer_balances() } $item[2] = round2($trans['Allocated'] * $rate, $dec); $rep->AmountCol(6, 7, $item[2], $dec); - /* - if ($trans['type'] == 10) - $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; - else - $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; - */ if ($trans['type'] == ST_SALESINVOICE || $trans['type'] == ST_BANKPAYMENT) $item[3] = $item[0] + $item[1] - $item[2]; else diff --git a/reporting/rep201.php b/reporting/rep201.php index 895c3a5..6e2af1c 100644 --- a/reporting/rep201.php +++ b/reporting/rep201.php @@ -31,13 +31,13 @@ function get_open_balance($supplier_id, $to, $convert) { $to = date2sql($to); - $sql = "SELECT SUM(IF(".TB_PREF."supp_trans.type = ".ST_SUPPINVOICE.", (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + - ".TB_PREF."supp_trans.ov_discount)"; + $sql = "SELECT SUM(IF(".TB_PREF."supp_trans.type = ".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type = ".ST_BANKDEPOSIT.", + (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; if ($convert) $sql .= " * rate"; $sql .= ", 0)) AS charges, - SUM(IF(".TB_PREF."supp_trans.type <> ".ST_SUPPINVOICE.", (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + - ".TB_PREF."supp_trans.ov_discount)"; + SUM(IF(".TB_PREF."supp_trans.type <> ".ST_SUPPINVOICE." AND ".TB_PREF."supp_trans.type <> ".ST_BANKDEPOSIT.", + (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; if ($convert) $sql .= "* rate"; $sql .= ", 0)) AS credits, @@ -45,8 +45,9 @@ function get_open_balance($supplier_id, $to, $convert) 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)"; + SUM(IF(".TB_PREF."supp_trans.type = ".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type = ".ST_BANKDEPOSIT.", + (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount - ".TB_PREF."supp_trans.alloc), + (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount + ".TB_PREF."supp_trans.alloc))"; if ($convert) $sql .= " * rate"; $sql .= ") AS OutStanding @@ -203,16 +204,10 @@ function print_supplier_balances() } $item[2] = round2($trans['Allocated'] * $rate, $dec); $rep->AmountCol(6, 7, $item[2], $dec); - /* - if ($trans['type'] == 20) - $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; - else - $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; - */ - if ($trans['type'] == ST_SUPPINVOICE || $trans['type'] == ST_BANKDEPOSIT) - $item[3] = $item[0] + $item[1] - $item[2]; + if ($trans['TotalAmount'] > 0.0) + $item[3] = $item[0] - $item[2]; else - $item[3] = $item[0] - $item[1] + $item[2]; + $item[3] = ($item[1] - $item[2]) * -1; $rep->AmountCol(7, 8, $item[3], $dec); for ($i = 0; $i < 4; $i++) {