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
Allowing re-use of the same invoice numbers in ACCPAY invoices #125
Comments
This makes sense. AP has never been part of my use case. Happy to receive a On 28 January 2014 04:51, sinad notifications@github.com wrote:
|
Still happy to receive a PR on this issue. Sounds like something Xeroizer should have but I haven't run into this problem specifically myself. |
There's a lot of other calls that have foo_id vs foo_number
Is raising an exception on update the only purpose of possible_primary_keys?
|
@sinad can you maybe do up a test case that demonstrates the behaviour? Under the hood, methods like find are just doing:
and all is doing
Unless the underlying API is returning the wrong invoices by ID (ie: looking up invoice number) or you are calling things a bit funny, it's hard to see how invoice_number could be returning the wrong records after create/first save.
... has some pretty straight forward example tests to copy |
This seems to have been resolved, invoices are created as expected. xero_invoice = xero.Invoice.build(type: 'ACCPAY', date: Date.today, due_date: 30.days.from_now, invoice_number: '1001', line_amount_types: 'NoTax', status: 'AUTHORISED')
xero_invoice.add_line_item(:description => 'test', :unit_amount => '200.00', :quantity => '1', :account_code => '200')
xero_invoice.build_contact(:name => "test123")
xero_invoice.save
another_xero_invoice = xero.Invoice.build(type: 'ACCPAY', date: Date.today, due_date: 30.days.from_now, invoice_number: '1001', line_amount_types: 'NoTax', status: 'AUTHORISED')
another_xero_invoice.add_line_item(:description => 'test', :unit_amount => '200.00', :quantity => '1', :account_code => '200')
another_xero_invoice.build_contact(:name => "test123")
another_xero_invoice.save Returning an invoice by invoice_number works, but if there are multiple invoices with that invoice_number, it will only return one. You should use the invoice_id instead. # find by invoice_number (possible duplicates)
invoice = xero.Invoice.find("1001")
# find by invoice_id (no possible duplicates)
invoice = xero.Invoice.find("6a5f03b1-7307-4554-b236-1f7c33589e06") If I'm missing the point here, please re-open the issue. |
We often have cases where we use the same invoice numbers for different purchase invoices. (E.g. Vendor 1 has invoice #1001 and then Vendor 2 also bills us with an invoice #1001.)
When attempting to create a new invoice with the same invoice number, it looks like Xeroizer is fetching the existing invoice with the same invoice number and updating / overwriting it (or throwing an error if the original invoice can't be modified).
I was just wondering why it's necessary for Xeroizer to use "invoice_number" in the "possible_primary_keys" hash given that "invoice_id" seems like a solid unique identifier.
The Xero API docs state ACCPAY invoice numbers are non-unique (http://developer.xero.com/documentation/api/invoices/), which I would argue makes it an unreliable field as a possible primary key.
The code I'm using looks something like this:
My workaround is to save the new invoice without an invoice number, assign the invoice, and then re-save (adding some extraneous API calls):
Thoughts on removing "invoice_number" as a possible primary key?
The text was updated successfully, but these errors were encountered: