ej2 / python-quickbooks

A Python library for accessing the Quickbooks API.
MIT License
407 stars 195 forks source link

payment.save(qb=client) silently failing #292

Closed appfuse-io closed 1 year ago

appfuse-io commented 1 year ago

I have an intermittent issue where I successfully create an invoice (works), query for it to check it exists (works) and then apply a payment to it (payments work perfectly for a whole month then there will be an issue with a duplicate). Looking at the logs it happens with the payment_processed = payment.save(qb=client) my debug code is there still so I see the output from print(type(payment.Line)) then 10 seconds later, on the logs' timestamp, I can see the loop restart, it never makes it to the print('>>>>> PAYMENT') line.

Is there a timeout or was to debug this as there is no error?

print(type(payment.Line))
payment_processed = payment.save(qb=client)
print('>>>>> PAYMENT')
print('payment_processed:', payment_processed)
ej2 commented 1 year ago

I am not sure I understand your question. Do you have your code wrapped in a try/except? If an error is raised from QBO you can catch it with an except.

appfuse-io commented 1 year ago

I have this code:

print('>>>>> INVOICE PROCESSED')
print(new_invoice.to_dict())
print('>>>>> INVOICE SENDING STARTED')

try:
    qb_resp = new_invoice.save(qb=client)
except QuickbooksException as e:
    print(e.message) 
    print(e.error_code)  
    print(e.detail)  

print('>>>>> INVOICE SENDING ENDED')
print(qb_resp)

There is no exception, no message, just hangs before my payment code duplicating the invoice. Maybe a better question is what do I need to check to see if qb_resp contains a successful invoice creation?

ej2 commented 1 year ago

Hmm... not sure what is going on.

I would first verify that your duplicated invoice is valid. You can call invoice.to_json(). Take that json and use it in the "Try it" on the QBO Invoice docs page. Also check the docs for required fields and constraints on an invoice. The docs say that an invoice requires:

When you copied the invoice, did you also copy the CustomerRef and Lines?

If you don't find anything, then post your complete code and I can try to track down the issue.