-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Line items are recreated instead of being updated #480
Comments
Is this the expected behaviour? |
The expected behavior according the the docs is that It will update the line item (when a |
This gem was created before Lineitems had Id's. Lineitem Id's were introduced as part of "Linked Transactions", which is used for Billable Expenses. Docs: https://developer.xero.com/documentation/api/accounting/linkedtransactions#overview Prior to this Linked Transactions, lineitems were only relevant to the invoice they appears on (for calculating totals). After Linked Transactions a lineitem could be referenced by another document (AccRec for example). In terms of the actual fix, you are correct. A lineitem with LineItemId should be updated, not recreated. So I'd classify this as a feature / improvement to the SDK. Tho, considering Billable Expenses was released in 2015 (6 years ago), I can see why it would also be classified as a bug at this stage. If someone would like to fix this, please submit a PR, happy to merge & release |
I just hit this problem with my app and after talking it through with Xero, it seems the problem is that Xero's XML is case-sensitive. The key should be LineItemID not LineItemId. |
Looking through the code it looks like the problem is that LineItemId has been set as a string not as a guid - which has the fix for Id vs ID. |
This is a
bug report
;Expected:
invoice.save!
should update line items;What happens:
invoice.save!
deletes and recreates line items with new ids.Hi! I'm not sure what's going on because following documentation and the way the gem is working it should work properly.
Documentation says that
It is recommended that you include LineItemIDs on update requests. If LineItemIDs are not included with line items in an update request then the line items are deleted and recreated.
However it seems even though LineItemID is automatically included into a
invoice.save!
request, their ids are still changed.Here's the LIneItems part of the request I got from
invoice.to_xml
(some params including LineItemID are modified for security). As you can see the LineItemID is included here and I verified that it's correct.Here I just updated the
UnitAmount
of a single line item. Though seems like line items are always recreated even if nothing was changed.If I'm not mistaken, following the code
invoice.save!
should directly pass this xml to the http request to XERO. So theLineItemID
is included and it should just update those line items, but right afterinvoice.save!
method, line items in this sameinvoice
object get newline_item_id
's meaning they were recreated.The text was updated successfully, but these errors were encountered: