hapi-middleman-paypal-intacct
Advanced tools
Comparing version 0.0.78 to 0.0.79
@@ -126,2 +126,5 @@ "use strict"; | ||
} | ||
if (!invoice.payments || invoice.payments.length < 1) { | ||
throw new Error("No recorded PayPal Payments. This should not happen and is most likely an issue with the paypal api."); | ||
} | ||
const account = this.options.paymentaccounts.currencies[invoice.total_amount.currency] || this.options.paymentaccounts.default; | ||
@@ -196,2 +199,3 @@ try { | ||
const invoices = yield this.intacct.query(query); | ||
this.server.log(["info", "paypal-intacct", "invoice", "refundInvoicesSync"], { count: invoices.length, invoices: invoices.map((inv) => inv.RECORDID) }); | ||
for (const invoice of invoices) { | ||
@@ -237,5 +241,6 @@ try { | ||
const invoices = yield Promise.all([ | ||
this.intacct.query(query, ["RECORDNO", "RECORDID"]), | ||
this.intacct.query(query, ["RECORDNO", "RECORDID", "PAYPALINVOICEID"]), | ||
this.paypal.invoice.search({ status: ["SENT", "UNPAID"] }), | ||
]); | ||
this.server.log(["info", "paypal-intacct", "invoice", "createInvoiceSync"], { count: invoices[0].length, invoices: invoices[0].map((inv) => inv.RECORDID) }); | ||
for (const invoice of invoices[0]) { | ||
@@ -274,6 +279,6 @@ const intacctUpdate = { | ||
this.intacct.get(invoice.RECORDNO), | ||
this.paypal.invoice.search({ number: invoice.RECORDID }), | ||
invoice.PAYPALINVOICEID ? this.paypal.invoice.get(invoice.PAYPALINVOICEID) : null, | ||
]); | ||
const intacctInvoice = invoices[0]; | ||
let paypalInvoice = invoices[1][0]; | ||
let paypalInvoice = invoices[1]; | ||
if (!paypalInvoice) { | ||
@@ -329,2 +334,3 @@ paypalInvoice = new this.paypal.invoice(this.toPaypalInvoice(intacctInvoice)); | ||
if (this.options.reminderDays) { | ||
yield invoice.get(); | ||
const now = new Date(); | ||
@@ -389,6 +395,9 @@ const lastSend = invoice.model.metadata.first_sent_date || invoice.model.metadata.last_sent_date; | ||
toPayPalLineItems(arrInvoiceItems) { | ||
if (!Array.isArray(arrInvoiceItems)) { | ||
arrInvoiceItems = [arrInvoiceItems]; | ||
} | ||
const arrPPInvItems = []; | ||
if (arrInvoiceItems.length > 0) { | ||
for (const item of arrInvoiceItems) { | ||
const ritem = { | ||
arrPPInvItems.push({ | ||
name: item.ITEMNAME, | ||
@@ -400,4 +409,3 @@ quantity: 1, | ||
}, | ||
}; | ||
arrPPInvItems.push(ritem); | ||
}); | ||
} | ||
@@ -404,0 +412,0 @@ } |
{ | ||
"name": "hapi-middleman-paypal-intacct", | ||
"version": "0.0.78", | ||
"version": "0.0.79", | ||
"description": "hapi-middleman module for integrating paypal with intacct", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
66604
832