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";
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";
}
$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
{
$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,
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
}
$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++)
{