Closed ghost closed 7 years ago
When i try test Json Request in browser https://developer.intuit.com/v2/apiexplorer?apiname=V3QBO#?id=Invoice
{"line_items":[{"amount":"112.0","description":"QB Test Product Sept 15, 14\n","detail_type":"SalesItemLineDetail","sales_line_item_detail":{"unit_price":"8.0","quantity":14,"item_ref":{"value":123}}},{"amount":67.2,"detail_type":"DiscountLineDetail","discount_line_detail":{"discount_percent":60,"percent_based":true,"discount_account_ref":{"value":86}}},{"amount":"0.0","detail_type":"DiscountLineDetail","discount_line_detail":{"discount_account_ref":{"value":86}}}],"customer_ref":{"value":"115"},"txn_date":"2015-09-17","doc_number":"","custom_fields":[{"id":1,"name":"LFI Invoice #","type":"StringType","string_value":"LFI5003"}]}
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2015-09-17T05:43:09.854-07:00">
<Fault type="SystemFault">
<Error code="10000">
<Message>An application error has occurred while processing your request</Message>
<Detail>System Failure Error: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.</Detail>
</Error>
</Fault>
</IntuitResponse>
When I try to use test invoice XML using this link in Quick book https://developer.intuit.com/v2/apiexplorer?apiname=V3QBO#?id=Invoice
<Invoice>
<CustomField>
<DefinitionId>1</DefinitionId>
<Name>LFI Invoice #</Name>
<Type>StringType</Type>
<StringValue>LFI5003</StringValue>
</CustomField>
<DocNumber/>
<TxnDate>2015-09-17</TxnDate>
<Line>
<Description>QB Test Product Sept 15, 14</Description>
<Amount>112.0</Amount>
<DetailType>SalesItemLineDetail</DetailType>
<SalesItemLineDetail>
<ItemRef>123</ItemRef>
<UnitPrice>8.0</UnitPrice>
<Qty>14.0</Qty>
</SalesItemLineDetail>
</Line>
<Line>
<Amount>67.2</Amount>
<DetailType>DiscountLineDetail</DetailType>
<DiscountLineDetail>
<PercentBased>true</PercentBased>
<DiscountPercent>60.0</DiscountPercent>
<DiscountAccountRef>86</DiscountAccountRef>
</DiscountLineDetail>
</Line>
<Line>
<Amount>0.0</Amount>
<DetailType>DiscountLineDetail</DetailType>
<DiscountLineDetail>
<DiscountAccountRef>86</DiscountAccountRef>
</DiscountLineDetail>
</Line>
<CustomerRef>115</CustomerRef>
</Invoice>
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2015-09-17T05:52:01.051-07:00">
<Fault type="SystemFault">
<Error code="10000">
<Message>An application error has occurred while processing your request</Message>
<Detail>System Failure Error: unexpected element (uri:"", local:"Invoice"). Expected elements are <{http://schema.intuit.com/finance/v3}Account>,<{http://schema.intuit.com/finance/v3}Attachable>,<{http://schema.intuit.com/finance/v3}Bill>,<{http://schema.intuit.com/finance/v3}BillPayment>,<{http://schema.intuit.com/finance/v3}BooleanTypeCustomFieldDefinition>,<{http://schema.intuit.com/finance/v3}Budget>,<{http://schema.intuit.com/finance/v3}ChargeCredit>,<{http://schema.intuit.com/finance/v3}Class>,<{http://schema.intuit.com/finance/v3}Company>,<{http://schema.intuit.com/finance/v3}CompanyCurrency>,<{http://schema.intuit.com/finance/v3}CompanyInfo>,<{http://schema.intuit.com/finance/v3}CreditMemo>,<{http://schema.intuit.com/finance/v3}CustomFieldDefinition>,<{http://schema.intuit.com/finance/v3}Customer>,<{http://schema.intuit.com/finance/v3}DateTypeCustomFieldDefinition>,<{http://schema.intuit.com/finance/v3}Department>,<{http://schema.intuit.com/finance/v3}Deposit>,<{http://schema.intuit.com/finance/v3}EmailDeliveryInfo>,<{http://schema.intuit.com/finance/v3}Employee>,<{http://schema.intuit.com/finance/v3}Estimate>,<{http://schema.intuit.com/finance/v3}ExchangeRate>,<{http://schema.intuit.com/finance/v3}FixedAsset>,<{http://schema.intuit.com/finance/v3}IntuitBatchRequest>,<{http://schema.intuit.com/finance/v3}IntuitObject>,<{http://schema.intuit.com/finance/v3}IntuitResponse>,<{http://schema.intuit.com/finance/v3}InventorySite>,<{http://schema.intuit.com/finance/v3}Invoice>,<{http://schema.intuit.com/finance/v3}Item>,<{http://schema.intuit.com/finance/v3}JournalCode>,<{http://schema.intuit.com/finance/v3}JournalEntry>,<{http://schema.intuit.com/finance/v3}MasterAccount>,<{http://schema.intuit.com/finance/v3}NumberTypeCustomFieldDefinition>,<{http://schema.intuit.com/finance/v3}OLBStatus>,<{http://schema.intuit.com/finance/v3}OtherName>,<{http://schema.intuit.com/finance/v3}Payment>,<{http://schema.intuit.com/finance/v3}PaymentMethod>,<{http://schema.intuit.com/finance/v3}Preferences>,<{http://schema.intuit.com/finance/v3}PriceLevel>,<{http://schema.intuit.com/finance/v3}Purchase>,<{http://schema.intuit.com/finance/v3}PurchaseOrder>,<{http://schema.intuit.com/finance/v3}QbdtEntityIdMapping>,<{http://schema.intuit.com/finance/v3}RefundReceipt>,<{http://schema.intuit.com/finance/v3}ReimburseCharge>,<{http://schema.intuit.com/finance/v3}Report>,<{http://schema.intuit.com/finance/v3}SalesOrder>,<{http://schema.intuit.com/finance/v3}SalesReceipt>,<{http://schema.intuit.com/finance/v3}SalesRep>,<{http://schema.intuit.com/finance/v3}StatementCharge>,<{http://schema.intuit.com/finance/v3}Status>,<{http://schema.intuit.com/finance/v3}StringTypeCustomFieldDefinition>,<{http://schema.intuit.com/finance/v3}SyncActivity>,<{http://schema.intuit.com/finance/v3}SyncErrorResponse>,<{http://schema.intuit.com/finance/v3}TDSMetadata>,<{http://schema.intuit.com/finance/v3}Task>,<{http://schema.intuit.com/finance/v3}TaxAgency>,<{http://schema.intuit.com/finance/v3}TaxCode>,<{http://schema.intuit.com/finance/v3}TaxRate>,<{http://schema.intuit.com/finance/v3}Term>,<{http://schema.intuit.com/finance/v3}TimeActivity>,<{http://schema.intuit.com/finance/v3}Transfer>,<{http://schema.intuit.com/finance/v3}UserAlert>,<{http://schema.intuit.com/finance/v3}Vendor>,<{http://schema.intuit.com/finance/v3}VendorCredit>,<{http://schema.intuit.com/finance/v3}VendorType></Detail>
</Error>
</Fault>
</IntuitResponse>
Do you have in the company preference Sales Form Entry -> Discounts enabled?
On the JSON request you probably didn't have the Content-Type application/json . I believe you get that error because Intuit defaults to application/xml.
Thanks for you reply , attached screen for discount already enabled
Now trying with json with content-type= application/json
{"line_items":[{"amount":"160.0","description":"QB Test Product Sept 15, 20\n","detail_type":"SalesItemLineDetail","sales_line_item_detail":{"unit_price":"8.0","quantity":20,"item_ref":{"value":123}}},{"amount":"0.0","detail_type":"DiscountLineDetail","discount_line_detail":{"discount_account_ref":{"value":86}}}],"customer_ref":{"value":"115"},"txn_date":"2015-09-18","doc_number":"","custom_fields":[{"id":1,"name":"LFI Invoice #","type":"StringType","string_value":"LFI5007"}]}
{"Fault":{"Error":[{"Message":"Request has invalid or unsupported property","Detail":"Property Name:Unrecognized field \"line_items\" (class com.intuit.schema.finance.v3.Invoice), not marked as ignorable (67 known properties: \"DocNumber\", \"HomeTotalAmt\", \"TotalAmt\", \"TxnSource\", \"AllowOnlinePayment\", \"EmailSt specified is unsupported or invalid","code":"2010"}],"type":"ValidationFault"},"time":"2015-09-18T04:22:32.355-07:00"}
Needs to be "Line": not "line_items": Actually, all of your JSON is in snake case. See proper JSON -> https://developer.intuit.com/docs/api/accounting/Invoice
If you're using this gem you need to be using XML. If you prefer JSON build something basic with Faraday, HTTParty, or Unirest.
If i use line instead of line_item it gives me below error
undefined method `line' for #Quickbooks::Model::Invoice:0x00000007d11440
AND I just render invoice object in json and xml format and try to double check with query browser
discount_line_item = Quickbooks::Model::InvoiceLineItem.new
discount_line_item.amount = discount_amount#149
discount_line_item.discount_item! do |detail|
detail.discount_account_id = 86
end
invoice.line_items << discount_line_item
return render :json => invoice
#or
return render :xml => invoice
For reference here's some code I'm using to build a discount:
discount_item = Quickbooks::Model::InvoiceLineItem.new(
amount: discount_amount.abs.round(2),
description: "Coupon"
)
discount_item.discount_item! do |detail|
detail.percent_based = false
end
invoice.line_items << discount_item
One thing that was surprising to me is that you can put multiple discounts on an invoice, but QBO ignores all but the last one. I was expecting it to act more like QB Desktop where you can put a discount line below each sale line.
Hi, I am trying to apply discount value in Quick book but for some reason discount does not apply in Quickbook. Can you please guide me how can i resolve this issue?
Discount value code:
Discount percentage code:
Set Service:
Also please tell me is there any problem with CurrentBalance with 0 balance?. please tell me how can i update this value.