Created
May 4, 2017 01:00
-
-
Save jordanwalsh23/0c36beee2d236fa9bb7706e545d486fb to your computer and use it in GitHub Desktop.
Developers Guide to Lending - Snippet 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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