Invoice duplication in Xero due to incorrect reference field in a query

Created on 2 March 2016, about 9 years ago
Updated 9 January 2025, 3 months ago

Hi there.
I worked with this module some time ago, it did the job almost perfect, but I noticed one annoying bug.
function commerce_xero_get_invoice() never returns existing invoice and always create new one in the xero system. This happens because when you try to query the invoice you use the following code:

  $invoice = xero_query('get', 'Invoices', FALSE, FALSE, array('Reference' => $order->order_number->value()));

And when you create new invoice you use the following one:

  $invoice['Invoice']['Reference'] = t('Order #@num', array('@num' =>  $order->order_number->value()));

This cause difference in reference ID used in query and in an invoice creation and that's why query always return nothing.
I've tried to change invoice querying code to

  $invoice = xero_query('get', 'Invoices', FALSE, FALSE, array('Reference' => t('Order #@num', array('@num' =>  $order->order_number->value())));

but this caused some error, so I've got rid from translatable string in reference field at all (See patch attached).
I'm not very familiar with the Xero and probably missed something, so feel free to suggest better way.

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine artem_sylchuk Lutsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024