if (isset($_GET['SInvoice'])) {
// get date and supplier
- $inv = get_customer_trans($_GET['SInvoice'], ST_SALESINVOICE);
+ $type = !isset($_GET['Type']) ? ST_SALESINVOICE : $_GET['Type'];
+ $inv = get_customer_trans($_GET['SInvoice'], $type);
$dflt_act = get_default_bank_account($inv['curr_code']);
$_POST['bank_account'] = $dflt_act['id'];
if ($inv) {
$_POST['BranchID'] = $inv['branch_code'];
$_POST['DateBanked'] = sql2date($inv['tran_date']);
foreach($_SESSION['alloc']->allocs as $line => $trans) {
- if ($trans->type == ST_SALESINVOICE && $trans->type_no == $_GET['SInvoice']) {
+ if ($trans->type == $type && $trans->type_no == $_GET['SInvoice']) {
$un_allocated = $trans->amount - $trans->amount_allocated;
if ($un_allocated){
$_SESSION['alloc']->allocs[$line]->current_allocated = $un_allocated;
debtor.name,
branch.br_name,
debtor.curr_code,
- IF(prep_amount, prep_amount, abs(trans.ov_amount) + trans.ov_gst + trans.ov_freight
+ IF(prep_amount, prep_amount, trans.ov_amount + trans.ov_gst + trans.ov_freight
+ trans.ov_freight_tax + trans.ov_discount) AS TotalAmount,"
// if ($filter != ALL_TEXT)
// $sql .= "@bal := @bal+IF(prep_amount, prep_amount, trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount), ";
{
$today = date2sql(Today());
$sql .= " AND trans.due_date < '$today'
- AND (trans.ov_amount + trans.ov_gst + trans.ov_freight_tax +
+ AND (ABS(trans.ov_amount) + trans.ov_gst + trans.ov_freight_tax +
trans.ov_freight + trans.ov_discount - trans.alloc > 0) ";
}
}
{
/*its a negative receipt */
return '';
- } elseif (($row["type"] == ST_SALESINVOICE && ($row['TotalAmount'] - $row['Allocated']) > 0) || $row["type"] == ST_BANKPAYMENT)
+ } elseif (($row["type"] == ST_SALESINVOICE && ($row['TotalAmount'] - $row['Allocated']) > 0) ||
+ ($row["type"] == ST_JOURNAL && (ABS($row['TotalAmount']) - $row['Allocated']) > 0) || $row["type"] == ST_BANKPAYMENT)
return pager_link(_("Payment"),
- "/sales/customer_payments.php?customer_id=".$row["debtor_no"]."&SInvoice=" . $row["trans_no"], ICON_MONEY);
+ "/sales/customer_payments.php?customer_id=".$row["debtor_no"]."&SInvoice=" . $row["trans_no"]."&Type=".$row["type"], ICON_MONEY);
}
function fmt_amount($row)
{
+ /*
$value =
- $row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT || $row['type']==ST_JOURNAL ?
- -$row["TotalAmount"] : $row["TotalAmount"];
+ $row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT ||
+ ($row['type']==ST_JOURNAL && $row['TotalAmount'] < 0) ? -$row["TotalAmount"] : $row["TotalAmount"];
+ */
+ $value =
+ $row['type']==ST_CUSTCREDIT || $row['type']==ST_CUSTPAYMENT || $row['type']==ST_BANKDEPOSIT ? -$row["TotalAmount"] : $row["TotalAmount"];
return price_format($value);
}
function check_overdue($row)
{
return $row['OverDue'] == 1
- && floatcmp($row["TotalAmount"], $row["Allocated"]) != 0;
+ && floatcmp(ABS($row["TotalAmount"]), $row["Allocated"]) != 0;
}
//------------------------------------------------------------------------------------------------