X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep115.php;h=484746b61c11ddb6c02acbd026f16efbf2af3eca;hb=4618ee761a2d5ea779858009710ed43e12325c6f;hp=ee03bf8a8fa06dbea9ed905ae3392724ba8c369d;hpb=efa47c3c14d52adf0566652ac1b02aa3ade9d94b;p=fa-stable.git diff --git a/reporting/rep115.php b/reporting/rep115.php index ee03bf8a..484746b6 100644 --- a/reporting/rep115.php +++ b/reporting/rep115.php @@ -35,7 +35,7 @@ function get_open_balance($debtorno, $to) $to = date2sql($to); $sql = "SELECT SUM(IF(t.type = ".ST_SALESINVOICE." OR (t.type IN (".ST_JOURNAL." , ".ST_BANKPAYMENT.") AND t.ov_amount>0), - -abs(t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount), 0)) AS charges,"; + -abs(IF(prep_amount, prep_amount, ov_amount + ov_gst + ov_freight + ov_freight_tax + ov_discount)), 0)) AS charges,"; $sql .= "SUM(IF(t.type != ".ST_SALESINVOICE." AND NOT(t.type IN (".ST_JOURNAL." , ".ST_BANKPAYMENT.") AND t.ov_amount>0), abs(t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount) * -1, 0)) AS credits,"; $sql .= "SUM(IF(t.type != ".ST_SALESINVOICE." AND NOT(t.type IN (".ST_JOURNAL." , ".ST_BANKPAYMENT.")), @@ -216,7 +216,11 @@ function print_customer_balances() $accumulate = 0; $rate = $convert ? get_exchange_rate_from_home_currency($myrow['curr_code'], Today()) : 1; $bal = get_open_balance($myrow['debtor_no'], $from, $convert); - $init[0] = $init[1] = 0.0; + $init = array(); + $bal['charges'] = isset($bal['charges']) ? $bal['charges'] : 0; + $bal['credits'] = isset($bal['credits']) ? $bal['credits'] : 0; + $bal['Allocated'] = isset($bal['Allocated']) ? $bal['Allocated'] : 0; + $bal['OutStanding'] = isset($bal['OutStanding']) ? $bal['OutStanding'] : 0; $init[0] = round2(abs($bal['charges'] * $rate), $dec); $init[1] = round2(Abs($bal['credits'] * $rate), $dec); $init[2] = round2($bal['Allocated'] * $rate, $dec);