Comments (13)
Okay, I managed to do it.
connection.Invoice.batch_save do
xero_invoices = invoices.map { |invoice| XeroInvoiceParser.from_invoice invoice }
end
xero_invoices.map(&:id) #ids
The reason why I took a while to realize this is because if one the invoice syncs to fail, the xero_invoice.errors
array will have the error message but the batch_save will still return true. Is this expected? If it is, how do I know which invoice failed to sync?
from xeroizer.
I didn't write it, but I wouldn't expect the result of a batch save to be
either true or false. Xero doesn't handle this in batches so any successful
saves actually get committed.
On Friday, October 18, 2013, Bruno wrote:
Okay, I managed to do it.
connection.Invoice.batch_save do
xero_invoices = invoices.map { |invoice| XeroInvoiceParser.from_invoice invoice }end
xero_invoices.map(&:id) #idsThe reason why I took a while to realize this is because if one the
invoice syncs to fail, the xero_invoice.errors array will have the error
message but the batch_save will still return true. Is this expected?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/109#issuecomment-26566900
.
from xeroizer.
What do you mean by it doesn't handle it in batches? Isn't it possible to batch sync invoices? Isn't the return of batch_save
only true or false? https://github.com/waynerobinson/xeroizer#bulk-creates--updates
from xeroizer.
Sorry, I meant to write transactional.
It doesn't handle this transactionally and so neither a true nor a false
are very useful results. You should check that each invoice was
successfully saved in the original batch.
On Friday, October 18, 2013, Bruno wrote:
What do you mean by it doesn't handle it in batches? Isn't it possible to
batch sync invoices?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/109#issuecomment-26567042
.
from xeroizer.
Okay, I'm checking if xero_errors.blank?
, is there a better way to check if the invoice was successfully saved?
As this is not transactional, will this batch save still only use one request? (I'm asking this because I'm hitting the daily limit and this is why I'm moving the sync to batch).
On this subject, in order to sync a payment to Xero, for instance, I need the account and the invoice that were pushed previously to Xero, is there any way to do this without counting 3 requests (2 get and 1 post)?
from xeroizer.
That's probably the easiest way to get the errors.
A batch is only one request. Any correction of errors will be further
requests.
My suggestion would be to cache the invoice IDs, etc locally so that you
can refer to them when you push the payment.
Xero has an unenforced soft limit of about 400 invoices a month (depending
on complexity) and I believe it has to do with solving some of their own
performance problems.
Is there some way you could manage this process as a batch transaction
daily, instead of pushing individual invoices?
If you want to discuss your options further, the Xero team are usually
pretty helpful.
On Friday, October 18, 2013, Bruno wrote:
Okay, I'm checking if xero_errors.blank?, is there a better way to check
if the invoice was successfully saved?As this is not transactional, will this batch save still only use one
request? (I'm asking this because I'm hitting the daily limit and this is
why I'm moving the sync to batch).On this subject, in order to sync a payment to Xero, for instance, I need
the account and the invoice that were pushed previously to Xero, is there
any way to do this without counting 3 requests (2 get and 1 post)?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/109#issuecomment-26567554
.
from xeroizer.
I have the invoice ID cached, but how can I assign this invoice to a payment (it requires a Xeroizer::Record::Invoice and not a invoice_id). If I could do this, I'd significantly decrease the amount of requests to Xero.
P.S.: I'm reaching the limit when syncing past invoices, not when syncing daily invoices.
from xeroizer.
I'm not near a computer but I'm reasonably sure you can just add an invoice
stub with just the ID to the payment.
On Friday, October 18, 2013, Bruno wrote:
I have the invoice ID cached, but how can I assign this invoice to a
payment (it requires a Xeroizer::Record::Invoice and not a invoice_id). If
I could do this, I'd significantly decrease the amount of requests to Xero.P.S.: I'm reaching the limit when syncing past invoices, not when syncing
daily invoices.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/109#issuecomment-26568179
.
from xeroizer.
Like Xeroizer::Record::Invoice.new account_id: account_id
?
I'll try this tomorrow! Thanks for the response, you'll be my saviour! :)
On Thu, Oct 17, 2013 at 11:32 PM, Wayne Robinson
[email protected]:
I'm not near a computer but I'm reasonably sure you can just add an
invoice
stub with just the ID to the payment.On Friday, October 18, 2013, Bruno wrote:
I have the invoice ID cached, but how can I assign this invoice to a
payment (it requires a Xeroizer::Record::Invoice and not a invoice_id).
If
I could do this, I'd significantly decrease the amount of requests to
Xero.P.S.: I'm reaching the limit when syncing past invoices, not when
syncing
daily invoices.—
Reply to this email directly or view it on GitHub<
https://github.com/waynerobinson/xeroizer/issues/109#issuecomment-26568179>.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/109#issuecomment-26568440
.
Atenciosamente,
Bruno Ferreira Pinto
from xeroizer.
Basically. I don't know if you need the account ID in the invoice. But just
the invoice ID (which is just ID on all the ruby models) should be fine.
There may even be an invoice ID option in Payment somewhere. I just don't
have it in front of me.
On Friday, October 18, 2013, Bruno wrote:
Like
Xeroizer::Record::Invoice.new account_id: account_id
?I'll try this tomorrow! Thanks for the response, you'll be my saviour! :)
On Thu, Oct 17, 2013 at 11:32 PM, Wayne Robinson
<[email protected] <javascript:_e({}, 'cvml',
'[email protected]');>>wrote:I'm not near a computer but I'm reasonably sure you can just add an
invoice
stub with just the ID to the payment.On Friday, October 18, 2013, Bruno wrote:
I have the invoice ID cached, but how can I assign this invoice to a
payment (it requires a Xeroizer::Record::Invoice and not a
invoice_id).
If
I could do this, I'd significantly decrease the amount of requests to
Xero.P.S.: I'm reaching the limit when syncing past invoices, not when
syncing
daily invoices.—
Reply to this email directly or view it on GitHub<https://github.com/waynerobinson/xeroizer/issues/109#issuecomment-26568179>
.
—
Reply to this email directly or view it on GitHub<
https://github.com/waynerobinson/xeroizer/issues/109#issuecomment-26568440>.
Atenciosamente,
Bruno Ferreira Pinto—
Reply to this email directly or view it on GitHubhttps://github.com//issues/109#issuecomment-26568491
.
from xeroizer.
Great! Tested today and I was able to do xero_payment.invoice = connection.Invoice.build id: invoice_id
.
One other question, if I build a contact inside an invoice and send the invoice to Xero, that will count as only one request right?
from xeroizer.
Yes. Although I'm not sure you can embed a complete contact record. You
might want to test it to see if you get the desired results.
On 19 Oct 2013, at 12:59 am, Bruno [email protected] wrote:
Great! Tested today and I was able to do xero_payment.invoice =
connection.Invoice.build id: invoice_id.
One other question, if I build a contact inside an invoice and send the
invoice to Xero, that will count as only one request right?
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/109#issuecomment-26602508
.
from xeroizer.
Tested, and it works. Thanks for everything!
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.