X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep115.php;fp=reporting%2Frep115.php;h=484746b61c11ddb6c02acbd026f16efbf2af3eca;hb=a67b7a07178dd92bb8e8bf60b6f7b474a1cbf433;hp=0ed751930cfdc56ff19e56ce681facb8599c6c1a;hpb=8d809a4d7562cde8931bf4a69d3e63f63157973c;p=fa-stable.git diff --git a/reporting/rep115.php b/reporting/rep115.php index 0ed75193..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.")),