Comments (9)
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.
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.
Thanks for the clarification on this! This seems to work for me.
from xeroizer.
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.
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.
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.
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.
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
381b51c9-6b7f-43a6-8566-7315490c393f AUTHORISED 571fa4ec-2ee4-4320-98ac-cddb31561d94 AUTHORISED cb7cea19-4692-4099-b77e-bb4e88cc2bdd AUTHORISED ```
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.
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)
- Question: Does Xeroizer support OAuth 2? HOT 2
- `.sent_to_contact` on Invoices is undefined HOT 3
- Update the readme/documentation to include Oauth2Application HOT 2
- Xero Deprecation Notice - OAuth 1.0a HOT 1
- Timeout option not set correctly on OAuth 2 client HOT 3
- invoice.save returns false but invoice.errors is empty HOT 15
- New gem release? HOT 6
- How to get all the Items from Xero account HOT 1
- NameError: uninitialized constant Xeroizer::OAuth2Application HOT 4
- Double raise for expired tokens? HOT 2
- GET ERROR WHE do any object.save HOT 2
- trying to run tests as a developer... HOT 5
- syntax error, unexpected ',' in branding_theme.rb HOT 1
- Line Amount can not explicity be set to 0.00 if there is a discount
- Missing require somewhere: "uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState" when used outside of Rails HOT 3
- AuthorizationUnsuccessful error HOT 2
- ApiExceptions result in parse error
- Saving Quotes
- BankAccount Model Not Available?
- How to revoke token / delete current_connection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xeroizer.