Coder Social home page Coder Social logo

Comments (13)

bpinto avatar bpinto commented on August 17, 2024

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.

waynerobinson avatar waynerobinson commented on August 17, 2024

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) #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?


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

from xeroizer.

bpinto avatar bpinto commented on August 17, 2024

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.

waynerobinson avatar waynerobinson commented on August 17, 2024

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.

bpinto avatar bpinto commented on August 17, 2024

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.

waynerobinson avatar waynerobinson commented on August 17, 2024

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.

bpinto avatar bpinto commented on August 17, 2024

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.

waynerobinson avatar waynerobinson commented on August 17, 2024

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.

bpinto avatar bpinto commented on August 17, 2024

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.

waynerobinson avatar waynerobinson commented on August 17, 2024

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.

bpinto avatar bpinto commented on August 17, 2024

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.

waynerobinson avatar waynerobinson commented on August 17, 2024

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.

bpinto avatar bpinto commented on August 17, 2024

Tested, and it works. Thanks for everything!

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.