$todate = date("Y-m-d");
else
$todate = date2sql($to);
- $past1 = get_company_pref('past_due_days');
- $past2 = 2 * $past1;
+ $current = 1;
+ $past1 = get_company_pref('past_due_days') + $current;
+ $past2 = 2 * $past1 + $current;
// removed - supp_trans.alloc from all summations
if ($all)
Sum(IFNULL($value,0)) AS Balance,
- Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= 0,$value,0)) AS Due,
+ Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $current,$value,0)) AS Due,
Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past1,$value,0)) AS Overdue1,
Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past2,$value,0)) AS Overdue2,
supp.credit_limit - Sum(IFNULL(IF(trans.type=".ST_SUPPCREDIT.", -1, 1)
function get_invoices($customer_id, $to, $all=true)
{
$todate = date2sql($to);
- $PastDueDays1 = get_company_pref('past_due_days');
- $PastDueDays2 = 2 * $PastDueDays1;
+ $current = 1;
+ $PastDueDays1 = get_company_pref('past_due_days') + $current;
+ $PastDueDays2 = 2 * $PastDueDays1 + $current;
// Revomed allocated from sql
if ($all)
$sql = "SELECT ".TB_PREF."debtor_trans.type, ".TB_PREF."debtor_trans.reference,
".TB_PREF."debtor_trans.tran_date,
$value as Balance,
- IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= 0,$value,0) AS Due,
+ IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $current,$value,0) AS Due,
IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $PastDueDays1,$value,0) AS Overdue1,
IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $PastDueDays2,$value,0) AS Overdue2
function get_invoices($supplier_id, $to, $all=true)
{
$todate = date2sql($to);
- $PastDueDays1 = get_company_pref('past_due_days');
- $PastDueDays2 = 2 * $PastDueDays1;
+ $current = 1;
+ $PastDueDays1 = get_company_pref('past_due_days') + $current;
+ $PastDueDays2 = 2 * $PastDueDays1 + $current;
// Revomed allocated from sql
if ($all)
".TB_PREF."supp_trans.reference,
".TB_PREF."supp_trans.tran_date,
$value as Balance,
- IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= 0,$value,0) AS Due,
+ IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $current,$value,0) AS Due,
IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $PastDueDays1,$value,0) AS Overdue1,
IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $PastDueDays2,$value,0) AS Overdue2
$todate = date("Y-m-d");
else
$todate = date2sql($to);
- $past1 = get_company_pref('past_due_days');
- $past2 = 2 * $past1;
+ $current = 1;
+ $past1 = get_company_pref('past_due_days') + $current;
+ $past2 = 2 * $past1 + $current;
// removed - debtor_trans.alloc from all summations
if ($all)
$value = "IFNULL(IF(trans.type=11 OR trans.type=12 OR trans.type=2, -1, 1)
".TB_PREF."debtors_master.credit_limit, ".TB_PREF."credit_status.dissallow_invoices, ".TB_PREF."credit_status.reason_description,
Sum(IFNULL($value,0)) AS Balance,
- Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= 0,$value,0)) AS Due,
+ Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $current,$value,0)) AS Due,
Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past1,$value,0)) AS Overdue1,
Sum(IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $past2,$value,0)) AS Overdue2