NewPath-Consulting/warm

Retrieve invoice order details

Closed this issue · 4 comments

Add a configuration parameter to invoices that is called

"Retrieve invoice details"

When checked the end point iterates through all invoices from

/accounts/{accountId}/invoices end point and retrieve order details. The most important is the OrderDetails which needs to be break out the object into multiple rows depending on how many items are on an invoice. This will allow analysis of various items bought on an invoice.

Retrieve the following items from each invoice

{

"Contact": {
"Name": "string"
},
"OrderDetails": [
{
"Value": 0,
"OrderDetailType": "Unspecified",
"Notes": "string",
"Taxes": {
"Amount": 0,
"CalculatedTax1": 0,
"CalculatedTax2": 0,
"NetAmount": 0,
"RoundedAmount": 0
}
}
],
"VoidedDate": "2020-04-09"
}

When looking at the invoices for our account 221748, I don't see the OrderDetails field in any of the returned invoices. Is this an API issue?
https://api.wildapricot.org/v2.1/accounts/221748/invoices?unpaidOnly=false&idsOnly=false&EndDate=4-10-2020

It looks like OrderDetails is returned only on /invoices/{invoiceid} -- so each invoice has to be accessed individually to get the order details.

Invoice 57217464 is a good sample invoice because it has taxes. Taxes sub array can be broken out into the same line as there are zero, 1 or 2 maximum taxes applied.
"Value": 265.875, "Notes": "Membership application. Level: Premium", "OrderDetailType": "MemberLevel", "Taxes": { "Amount": 265.875, "CalculatedTax1": 15.875, "CalculatedTax2": 0, "NetAmount": 250, "RoundedAmount": 265.88, "IsTaxIncludeIntoPrice": false,

I think there should be a configuration parameter so when it is turned on, you instead retrieve all IDs first using the idsOnly string on /invoices. Then you can iterate over the invoice IDs retrieve with the /accounts/{accountId}/invoices/{invoiceId} call.

You should also add a filter for startdate and enddate so we can limit number of invoices to retrieve.

Added a separate dropdown option for invoice details. It will call /invoices?idsOnly=true, then iterate over /invoices/${id} adding a row for every item in invoice.OrderDetails. This has the same schema as Invoices with the addition of the fields specified here.