xero-python icon indicating copy to clipboard operation
xero-python copied to clipboard

What Is The Best Practice for Mapping Backend Invoice Items with Xero Line Items?

Open kamrulhasan2020 opened this issue 5 months ago • 2 comments

We're integrating with Xero using the Accounting API and need to maintain a reliable mapping between our backend InvoiceItem records and the corresponding LineItems in Xero for future updates.

Since LineItemID is only returned after invoice creation, we're looking for a robust strategy to match our local items with those returned by Xero ideally without modifying visible fields like description, and without relying on item_code (as it's already used for referencing Xero inventory items).

Questions: What is the recommended best practice for associating backend invoice items with the corresponding Xero line items in the response after creation?

1.Is the ordering of line items preserved in the response from Xero's create_invoices() call?

Specifically, if we send line items in a known order, will created_invoice.line_items return them in the same order?

2.Can we safely rely on this order to map local items to Xero line items?

We want to ensure a reliable mapping between local and remote line items particularly to store the Xero LineItemID for update/delete operations later.

Any guidance would be appreciated!

kamrulhasan2020 avatar Jul 11 '25 06:07 kamrulhasan2020