- IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= 0,$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
-
- FROM ".TB_PREF."suppliers,
- ".TB_PREF."payment_terms,
- ".TB_PREF."supp_trans
-
- WHERE ".TB_PREF."suppliers.payment_terms = ".TB_PREF."payment_terms.terms_indicator
- AND ".TB_PREF."suppliers.supplier_id = ".TB_PREF."supp_trans.supplier_id
- AND ".TB_PREF."supp_trans.supplier_id = $supplier_id
- AND ".TB_PREF."supp_trans.tran_date <= '$todate'
- AND ABS(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount) > ".FLOAT_COMP_DELTA." ";
+ IF ((TO_DAYS('$todate') - TO_DAYS($due)) > 0,$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
+
+ FROM ".TB_PREF."suppliers supplier,
+ ".TB_PREF."supp_trans trans
+
+ WHERE supplier.supplier_id = trans.supplier_id
+ AND trans.supplier_id = $supplier_id
+ AND trans.tran_date <= '$todate'
+ AND ABS(trans.ov_amount + trans.ov_gst + trans.ov_discount) > ".FLOAT_COMP_DELTA;