Open vanboom opened 4 years ago
Thanks for the feedback. Yes it does look like the library is not auto-inserting the DetailType
. I pulled up some of my own code which uses taxes and it looks like this:
tax_detail = Quickbooks::Model::TransactionTaxDetail.new
tax_detail.txn_tax_code_ref = Quickbooks::Model::BaseReference.new(invoice_transaction_tax_code_rate_ref())
tax_detail.total_tax = supplier_order.total_tax
tax_line = Quickbooks::Model::TaxLine.new
tax_line.amount = tax_detail.total_tax
tax_line.detail_type = 'TaxLineDetail'
tax_line_detail = Quickbooks::Model::TaxLineDetail.new
tax_line_detail.percent_based = true
tax_line_detail.net_amount_taxable = supplier_order.total_excluding_taxes_cents
tax_line_detail.tax_percent = supplier_order.tax_percent_rate.to_f
tax_line_detail.tax_rate_ref = Quickbooks::Model::BaseReference.new(invoice_transaction_tax_detail_rate_ref())
tax_line.tax_line_detail = tax_line_detail
tax_detail.lines = [tax_line]
invoice.txn_tax_detail = tax_detail
So yeah I am doing it pretty manually.
Thanks @ruckus, oddly this just started happening with no code changes on our end.
When I use your method above to build the TaxLine manually, I get a different error...
Required param missing, need to supply the required value for the API: Required parameter TxnTaxDetail.TaxLineDetail.TaxLine.TaxRateRef is missing in the request
This is very odd, when I specify the TaxRateRef by setting .tax_rate_id
, the invoice is accepted without error.
tl = Quickbooks::Model::TaxLine.new(detail_type: "TaxLineDetail")
tld = Quickbooks::Model::TaxLineDetail.new
tld.percent_based = true
#tld.tax_rate_ref = code <-- this causes an error
tld.tax_rate_id = code.id
tl.tax_line_detail = tld
txn_tax_detail.lines ||= []
txn_tax_detail.lines << tl
The generated
I am not sure why things stopped working, possibly a change on the QBO side so I am trying to post as much debug info as possible if that helps.
I am using a numeric reference to the tax_rate_ref
(which is not clear from your right hand value of code
). So to clarify that code from my end:
def invoice_transaction_tax_detail_rate_ref
184
end
...
tax_line_detail.tax_rate_ref = Quickbooks::Model::BaseReference.new(invoice_transaction_tax_detail_rate_ref())
...
What is the value of your code
in
#tld.tax_rate_ref = code <-- this causes an error
?
I had an issue when creating new QB invoices that were untaxed for QB Canada. Ultimately I needed to set global_tax_calculation
to "NotApplicable"
. Hope this saves someone some pain.
This is probably user error but I think worth mentioning as an issue for posterity.
I am building an invoice in Canadian Quickbooks and assigning the TransactionTaxDetail like this...
Adding the TaxLine like this results in a Quickbooks Business Validation Error:
TxnTaxDetail.TaxLine.DetailTypeEnum is missing in the request
It appears that
quickbooks-ruby
is creating theTaxLine
wrapper automatically but theTaxLine
element is missing the detail type attribute.Notice the
TaxLine
entries are missing theDetailType
attribute, which should beTaxLineDetail
.