projects
/
fa-stable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
The aging reports / inquiries had a 1 day error in presentation. Fixed.
[fa-stable.git]
/
sales
/
includes
/
db
/
customers_db.inc
diff --git
a/sales/includes/db/customers_db.inc
b/sales/includes/db/customers_db.inc
index 3a67e4edb895d29189e5307c8e526ff328066ca9..ca940bcde2633477e6808272e754384710bdd59d 100644
(file)
--- a/
sales/includes/db/customers_db.inc
+++ b/
sales/includes/db/customers_db.inc
@@
-68,8
+68,9
@@
function get_customer_details($customer_id, $to=null, $all=true)
$todate = date("Y-m-d");
else
$todate = date2sql($to);
$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)
// 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)
@@
-83,7
+84,7
@@
function get_customer_details($customer_id, $to=null, $all=true)
".TB_PREF."debtors_master.credit_limit, ".TB_PREF."credit_status.dissallow_invoices, ".TB_PREF."credit_status.reason_description,
Sum(IFNULL($value,0)) AS Balance,
".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
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
@@
-155,8
+156,11
@@
function get_customer_contacts($customer_id, $action=null)
$results = array();
$res = get_crm_persons('customer', $action, $customer_id);
while($contact = db_fetch($res))
$results = array();
$res = get_crm_persons('customer', $action, $customer_id);
while($contact = db_fetch($res))
+ {
+ if ($contact['lang'] == 'C') // Fix for improper lang in demo sql files.
+ $contact['lang'] = '';
$results[] = $contact;
$results[] = $contact;
-
+ }
return $results;
}
return $results;
}
@@
-174,4
+178,14
@@
function is_new_customer($id)
return !key_in_foreign_table($id, $tables, 'debtor_no');
}
return !key_in_foreign_table($id, $tables, 'debtor_no');
}
+
+function get_customer_by_ref($reference)
+{
+ $sql = "SELECT * FROM ".TB_PREF."debtors_master WHERE debtor_ref=".db_escape($reference);
+
+ $result = db_query($sql, "could not get customer");
+
+ return db_fetch($result);
+}
+
?>
\ No newline at end of file
?>
\ No newline at end of file