X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fincludes%2Fdb%2Fcustalloc_db.inc;h=a1f6a61c5e6ac2af3694a4563bd7f25404c7f8b3;hb=f01cb25258d7b619f820d8f78e9bccf4501fc58e;hp=42eaff59536c7bdcd2f5ccf4c309ec65718b714d;hpb=95ff74b5722826544743a01daf527aa3c9efe11a;p=fa-stable.git diff --git a/sales/includes/db/custalloc_db.inc b/sales/includes/db/custalloc_db.inc index 42eaff59..a1f6a61c 100644 --- a/sales/includes/db/custalloc_db.inc +++ b/sales/includes/db/custalloc_db.inc @@ -119,11 +119,12 @@ function get_allocatable_from_cust_sql($customer_id=null, $settled) .TB_PREF."debtor_trans as trans, " .TB_PREF."debtors_master as debtor" ." WHERE trans.debtor_no=debtor.debtor_no - AND (((type=".ST_CUSTPAYMENT." OR type=".ST_BANKDEPOSIT.") AND (trans.ov_amount > 0))" - ." OR ( (type=".ST_CUSTCREDIT. " OR type=".ST_JOURNAL. ") AND (ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount)>0))"; + AND (((type=".ST_CUSTPAYMENT." OR type=".ST_BANKDEPOSIT.") AND (trans.ov_amount > 0)) + OR (type=".ST_CUSTCREDIT. " AND (ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount)>0) + OR (type=".ST_JOURNAL. " AND (trans.ov_amount < 0)))"; if (!$settled) - $sql .= " AND (round(abs(ov_amount+ov_gst+ov_freight+ov_freight_tax-ov_discount-alloc),6) > 0)"; + $sql .= " AND (round(abs(ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount-alloc),6) > 0)"; if ($customer_id != null) $sql .= " AND trans.debtor_no = ".db_escape($customer_id); @@ -216,7 +217,7 @@ function get_allocatable_to_cust_transactions($customer_id = null, $trans_no=nul AND round(-IF(prep_amount, prep_amount, ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount)-alloc,6) > 0 OR trans.type = '". ST_JOURNAL."' - AND ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount<0 + AND ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount>0 OR trans.type = '". ST_BANKPAYMENT."' AND ov_amount+ov_gst+ov_freight+ov_freight_tax+ov_discount>0