Skip to content

Instantly share code, notes, and snippets.

@jordanwalsh23
Created May 4, 2017 01:00
Show Gist options
  • Select an option

  • Save jordanwalsh23/0c36beee2d236fa9bb7706e545d486fb to your computer and use it in GitHub Desktop.

Select an option

Save jordanwalsh23/0c36beee2d236fa9bb7706e545d486fb to your computer and use it in GitHub Desktop.
Developers Guide to Lending - Snippet 7
let invoiceTemplate = {
Type: 'ACCPAY',
Status: 'AUTHORISED',
Contact: {
ContactID: contactID
},
LineItems: [],
Reference: `LOAN Loan Id ${loanID}/`
}
// . . .
// some other code....
// . . .
while (loanAmount > 0) {
//. . .
//Add the principal payment
invoiceTemplate.LineItems.push({
Description: 'Principal repayment',
UnitAmount: principal.toFixed(2),
Quantity: 1,
AccountCode: 'LOANC' + loanID
})
invoiceTemplate.LineItems.push({
Description: 'Interest repayment',
UnitAmount: interest.toFixed(2),
Quantity: 1,
AccountCode: 'LOANE' + loanID
})
//. . .
//create the payment
let invoice = xeroClient.core.invoices.newInvoice(invoiceTemplate);
invoice.save();
//. . .
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment