Coder Social home page Coder Social logo

Comments (9)

waynerobinson avatar waynerobinson commented on July 18, 2024

I will have a look at this in a couple of hours and get back to you. Nothing has changed that should effect this, although I know there were some OAuth issues that caused me to have to lock in an older version of that gem until Xero changes the way it handles PUT requests.

from xeroizer.

waynerobinson avatar waynerobinson commented on July 18, 2024

Sorry for the delay, but I've discovered the issue.

Invoices when returned in a list from Xero are only summary stubs without contact, lines, etc.

The #first method uses the list/filter GET method in the Xero API and thus only returns this summary record.

Before saving a summary record, Xeroizer downloads the rest of the record (this actually happens when a stubbed-out association is accessed when building the XML to send to Xero). This has the effect of overwriting whatever you have changed in the summary stub record with the data from Xero.

If you were using the #find method with either the invoice number or the invoice ID this would not be an issue (and would only use a single API request).

The best work-around for this issue would be something like:

xero_invoice = xero.Invoice.first(:where => {:reference => 122343434})
xero_invoice.download_complete_record!
xero_invoice.status = "AUTHORISED"
xero_invoice.save

This forces the invoice to be turned into its complete version.

from xeroizer.

mtdurling avatar mtdurling commented on July 18, 2024

Thanks for the clarification on this! This seems to work for me.

from xeroizer.

minhajuddin avatar minhajuddin commented on July 18, 2024

This is a very sneaky issue, It drove me nuts for a couple of days. Xeroizer should probably throw an exception when the attributes don't change. I tried the following code

invoices = $xero.Invoice.all
invoice = invoices.find{|x| x.invoice_number == '4232' }
invoice.update_attributes(date: Date.today - 100.days)

This returned a true, even when the date was not saved. Maybe this can be added in a FAQ or something, will definitely help others.

P.S: Thanks for creating an awesome gem, it is very easy to use.

from xeroizer.

levity avatar levity commented on July 18, 2024

What would the effect be, if the code skipped the step of downloading the rest of the record? Would it overwrite other fields besides the status field?

from xeroizer.

waynerobinson avatar waynerobinson commented on July 18, 2024

I believe so, this is why it was implemented this way. You could always do
a small test though to see if the APIA still works that way.

On Friday, March 14, 2014, Lawrence Wang [email protected] wrote:

What would the effect be, if the code skipped the step of downloading the
rest of the record? Would it overwrite other fields besides the status
field?

Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-37571466
.

from xeroizer.

levity avatar levity commented on July 18, 2024

I got a response from a Xero support rep that suggests it's changed:

If you only want to change the invoices status from DRAFT to AUTHORISED then you do not need to specify the complete content. You only need to specify the content if you want to change the line items of the invoices.

Thus you can do something like this to batch convert the invoices to AUTHORISED:

<Invoice>
<InvoiceID>381b51c9-6b7f-43a6-8566-7315490c393f</InvoiceID>
<Status>AUTHORISED</Status>
</Invoice>
<Invoice>
<InvoiceID>571fa4ec-2ee4-4320-98ac-cddb31561d94</InvoiceID>
<Status>AUTHORISED</Status>
</Invoice>
<Invoice>
<InvoiceID>cb7cea19-4692-4099-b77e-bb4e88cc2bdd</InvoiceID>
<Status>AUTHORISED</Status>
</Invoice>
</Invoices>

Hope this helps.

Any pointers I might want to know before I try changing the xeroizer code to skip download_complete_record! for this case?

from xeroizer.

waynerobinson avatar waynerobinson commented on July 18, 2024

That sounds good. That might be something to try at the moment and then
implement some type of logic that determines if you just want to change the
status (or some type of explicit status changing method).

Cheers

On 14 March 2014 09:53, Lawrence Wang [email protected] wrote:

I got a response from a Xero support rep that suggests it's changed:

If you only want to change the invoices status from DRAFT to AUTHORISED
then you do not need to specify the complete content. You only need to
specify the content if you want to change the line items of the invoices.

Thus you can do something like this to batch convert the invoices to
AUTHORISED:

381b51c9-6b7f-43a6-8566-7315490c393f AUTHORISED 571fa4ec-2ee4-4320-98ac-cddb31561d94 AUTHORISED cb7cea19-4692-4099-b77e-bb4e88cc2bdd AUTHORISED ```

Hope this helps.

Any pointers I might want to know before I try changing the xeroizer
code to skip download_complete_record! for this case?

Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-37596965
.

from xeroizer.

stevenou avatar stevenou commented on July 18, 2024

Just curious if code was ever implemented to skip download_complete_record!? I just ran into this issue and discovered that saving twice worked (I guess on the first save it downloads the complete record, and then on the second save it actually saves).

Nonetheless, when changing the status of 1000 records, download_complete_record! would cause it to hit rate limits, so the ability to skip download_complete_record! would be very helpful. That way we can update 1000 records in a batch_save and not have rate limit issues.

In my opinion, it would make sense to implement it in the way Rails has the includes or preload methods. That way when we select the entries, we can choose whether to also load associations or not?

from xeroizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.