1 select xt.install_js('XM','Invoice','xtuple', $$
2 /* Copyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.
3 See www.xm.ple.com/CPAL for the full text of the software license. */
7 XM.Invoice.isDispatchable = true;
9 XM.Invoice.authorizedCredit = function(invoiceNumber) {
10 var sql = "select xt.invc_authorized_credit($1) AS result";
12 return plv8.execute(sql, [invoiceNumber])[0].result;
15 XM.Invoice.outstandingCredit = function(customerNumber, currencyAbbreviation, invoiceDate) {
16 var sql = "select xt.invc_outstanding_credit($1, $2, $3) AS result",
17 customerId = XT.Data.getId(XT.Orm.fetch('XM', 'Customer'), customerNumber),
18 currencyId = XT.Data.getId(XT.Orm.fetch('XM', 'Currency'), currencyAbbreviation);
20 return plv8.execute(sql, [customerId, currencyId, invoiceDate])[0].result;
23 XM.Invoice.post = function(invoiceNumber) {
24 var invoiceId = XT.Data.getId(XT.Orm.fetch('XM', 'Invoice'), invoiceNumber);
25 return XT.executeFunction("postinvoice", [invoiceId]);
28 XM.Invoice.void = function(invoiceNumber) {
29 var invoiceId = XT.Data.getId(XT.Orm.fetch('XM', 'Invoice'), invoiceNumber);
30 return XT.executeFunction("voidinvoice", [invoiceId]);