get tests passing
authorjulesstp <julianmcarlin@gmail.com>
Thu, 30 Jan 2014 21:58:53 +0000 (15:58 -0600)
committerjulesstp <julianmcarlin@gmail.com>
Thu, 30 Jan 2014 21:58:53 +0000 (15:58 -0600)
enyo-client/database/source/xt/functions/invc_outstanding_credit.sql [deleted file]
enyo-client/extensions/source/billing/database/source/xm/javascript/invoice.sql

diff --git a/enyo-client/database/source/xt/functions/invc_outstanding_credit.sql b/enyo-client/database/source/xt/functions/invc_outstanding_credit.sql
deleted file mode 100644 (file)
index 6e28621..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-create or replace function xt.invc_outstanding_credit(cust_id integer, applicable_currency integer, applicable_date date) returns numeric stable as $$
--- sum of all unallocated credits for a customer
-    -- TODO: subtract cash receipts pending
-
--- second convert the currency of the receivable to the currency of the invoice
-SELECT COALESCE(SUM(currToCurr(aropen_curr_id, $2,
-  unallocated, $3)),0) AS amount
-from (
-  -- select distinct on allows us to add the aggregated aropenalloc_amount column
-  -- without having to inner join a temporarily grouped table
-  select distinct on (aropen_id) aropen_id, aropen_cust_id, aropen_curr_id,
-  coalesce(aropen_amount, 0) - 
-    -- first convert the currency of the allocation to the currency of the receivable
-    COALESCE(SUM(currToCurr(aropenalloc_curr_id, aropen_curr_id,
-    aropenalloc_amount, aropen_duedate)),0) AS unallocated
-  from aropen
-  left join aropenalloc on aropen_id = aropenalloc_aropen_id
-  where aropen_cust_id = $1
-  and aropen_open
-  --and aropen_posted = false
-  group by aropen_id
-) unalloc;
-
-$$ language sql;
index 2feef83..27e0e15 100644 (file)
@@ -13,7 +13,7 @@ select xt.install_js('XM','Invoice','xtuple', $$
   };
 
   XM.Invoice.outstandingCredit = function(customerNumber, currencyAbbreviation, invoiceDate) {
-    var sql = "select xt.invc_outstanding_credit($1, $2, $3) AS result",
+    var sql = "select xt.cust_outstanding_credit($1, $2, $3) AS result",
       customerId = XT.Data.getId(XT.Orm.fetch('XM', 'Customer'), customerNumber),
       currencyId = XT.Data.getId(XT.Orm.fetch('XM', 'Currency'), currencyAbbreviation);