答案 0 :(得分:1)
invoice = Quickbooks::Model::Invoice.new
invoice.customer_id = 1
invoice.txn_date = Date.civil(2014, 3, 27)
invoice.doc_number = "001"
transaction_tax = Quickbooks::Model::TransactionTaxDetail.new
# Point to a saved tax code in QBO, e.g. this points to id = 2,
# which is a NYC tax code saved on QBO account = 10% sales tax
transaction_tax.txn_tax_code_id = 2
transaction_tax.total_tax = 134.10
invoice.txn_tax_detail = transaction_tax
sales_line_item = Quickbooks::Model::InvoiceLineItem.new
sales_line_item.amount = 1490
sales_line_item.description = "CCM ice skates"
sales_line_item.sales_item! do |detail|
detail.unit_price = 149
detail.quantity = 10
detail.item_id = 1 # Item ID here
detail.tax_code_id = 'TAX' # for US must be 'NON' or 'TAX'
end
discount_line_item = Quickbooks::Model::InvoiceLineItem.new
discount_line_item.amount = 149
discount_line_item.discount_item! do |detail|
detail.discount_percent = 10
detail.percent_based = true
detail.discount_account_id = 99
end
invoice.line_items << sales_line_item
invoice.line_items << discount_line_item
service = Quickbooks::Service::Invoice.new
service.access_token = OAuth::AccessToken.new($qb_oauth_consumer, "token", "secret")
service.company_id = "9991111222"
created_invoice = service.create(invoice)
答案 1 :(得分:0)
对于序列化/反序列化,ruby中应该有类似JAXB的东西。
从以下链接,您可以下载QB端点定义和数据类定义(作为XSD)。您需要从中生成数据类。
https://developer.intuit.com/docs/@api/deki/files/2466/v3.1_dataservices.zip
然后使用任何标准的基于ruby的OAuth lib,您可以调用QB API端点。 您可以使用数据类的setter方法(在您的情况下 - 发票)来填充数据/以构造有效负载。 (我没有任何现成的例子。但我想在网上找到并不难)
对于doc,您可以参考以下两个链接。
由于