quickbooks api to add a payment against an invoice with RubyRails app - ruby-on-rails

I am trying to mark an invoice mark as paid and as per my understanding I have to add a payment against the invoice. I am using qbwc gem and it is using qbxml v.13.
I have found out few examples of creating the payment object here https://community-intuit.force.com/developer/s/article/QBO-REST-Apply-payments-to-invoice but the qbxml tag for creating payment is not clear to me.
Here are few xml tags that I have found in OSR ReceivePaymentAddRq, ItemPaymentAddRq etc
But I am still not sure how to create the payment object and which xml tags should be used and help is appreciated, thanks in advance.

A minimal qbXML example looks like this:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="10.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<ReceivePaymentAddRq>
<ReceivePaymentAdd>
<CustomerRef>
<ListID>F230000-1196864585</ListID>
<!--<FullName>Keith Palmer</FullName>--> <!-- You can specify either ListID or FullName -->
</CustomerRef>
<TxnDate>2007-12-14</TxnDate>
<RefNumber>00612361</RefNumber>
<TotalAmount>195.00</TotalAmount>
<!-- Specify the Invoice TxnID here, or see below for auto-apply... -->
<AppliedToTxnAdd>
<TxnID>12006-1196864828</TxnID>
<PaymentAmount>195.00</PaymentAmount>
</AppliedToTxnAdd>
<!-- If you don't want to apply payments manually to a particular transaction, use <IsAutoApply>true</IsAutoApply> -->
<!-- instead of the <AppliedToTxn> node. QuickBooks will make it's best guess how to apply the payment. -->
</ReceivePaymentAdd>
</ReceivePaymentAddRq>
</QBXMLMsgsRq>
</QBXML>

Related

How to create an invoice for a sales order Quickbooks Desktop

I have a customer in Quickbook Desktop, so that I have generated a slaes order for the particular customer, now for the customer sales order I have to generate a invoice. . When I tried it I got the following error. How to link a quickbook desktop customer sales order to a invoice?
I tried using IDTYPE attribute. What is wrong here? Kindly help
0x80040400: QuickBooks found an error when parsing the provided XML text stream.
Parsing response.
Processing response.
Job 'create_invoice' received response: ''.
This is my sales order xml response.
{"xml_attributes"=>{},
"txn_id"=>"75-1640702627",
"time_created"=>"2021-12-28T14:43:47+00:00",
"time_modified"=>"2021-12-28T14:43:47+00:00",
"edit_sequence"=>"1640702627",
"txn_number"=>37,
"customer_ref"=>{"xml_attributes"=>{}, "list_id"=>"80000001-1640593593", "full_name"=>"Test Customer"},
"template_ref"=>{"xml_attributes"=>{}, "list_id"=>"80000008-1640593060", "full_name"=>"Custom Sales Order"},
"txn_date"=>"2021-12-28",
"ref_number"=>"18",
"bill_address"=>{"xml_attributes"=>{}, "addr1"=>"212 W. Chskskss St.", "addr2"=>"Ste.100", "addr3"=>"wqw, Parròquia d'Encamp www", "addr4"=>"Andorra"},
"bill_address_block"=>{"xml_attributes"=>{}, "addr1"=>"212 W. Chskskss St.", "addr2"=>"Ste.100", "addr3"=>"wqw, Parròquia d'Encamp www", "addr4"=>"Andorra"},
"due_date"=>"2021-12-28",
"ship_date"=>"2021-12-28",
"subtotal"=>1.0,
"sales_tax_percentage"=>0.0,
"sales_tax_total"=>0.0,
"total_amount"=>1.0,
"is_manually_closed"=>false,
"is_fully_invoiced"=>false,
"is_to_be_printed"=>true,
"is_to_be_emailed"=>false}
Trying to generate invoice for this particular sales order
Here is my invoice XML attributes that I am sending to Quickbook Desktop
xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="7.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceAddRq >
<InvoiceAdd>
<CustomerRef>
<FullName>Test Customer</FullName >
</CustomerRef>
<BillAddress>
<Addr1>212 W. Chskskss St.</Addr1>
<Addr2>Ste.100</Addr2>
<City>wqw</City>
<State>Parròquia d'Encamp www</State>
<PostalCode>06268</PostalCode>
<Country>Andorra</Country>
</BillAddress>
<InvoiceLineAdd>
<ItemRef>
<FullName >Inspection Request</FullName>
</ItemRef>
<Desc >plants</Desc>
<Quantity >1</Quantity>
<Amount >50.00</Amount>
</InvoiceLineAdd>
<LinkToTxnID>75-1640702627<LinkToTxnID>
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>'
First thing coming to my mind is: "Where is your closing QBXML tag?"
</QBXML>
Beside that. The SDK includes an XML Validator tool which you can use to validate the XML structure. Try to use this to see where your structure probably does not meet the requirements.

Is there a way to delete a customer from Quickbooks offline using qbsdk and qbxml?

I want to delete a particular customer from quickbooks using the ListId of that customer . What would be my qbxml request in that case ?
You can use the ListDelRq to delete list-type things (Customers, Items, Vendors, etc.) from QuickBooks.
Refer to the OSR for full syntax:
https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html
Your request will look something like this:
?xml version="1.0" encoding="utf-8"?>
<?qbxml version="9.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<ListDelRq>
<!-- ListDelType may have one of the following values: Account, BillingRate, Class, Currency, Customer, CustomerMsg, CustomerType, DateDrivenTerms, Employee, InventorySite, ItemDiscount, ItemFixedAsset, ItemGroup, ItemInventory, ItemInventoryAssembly, ItemNonInventory, ItemOtherCharge, ItemPayment, ItemSalesTax, ItemSalesTaxGroup, ItemService, ItemSubtotal, JobType, OtherName, PaymentMethod, PayrollItemNonWage, PayrollItemWage, PriceLevel, SalesRep, SalesTaxCode, ShipMethod, StandardTerms, ToDo, UnitOfMeasureSet, Vehicle, Vendor, VendorType, WorkersCompCode -->
<ListDelType>ENUMTYPE</ListDelType>
<ListID>IDTYPE</ListID>
</ListDelRq>
</QBXMLMsgsRq>
</QBXML>

how to add payment method to quickbooks through qbxml?

I'm using consolibyte php with web connector.I'm trying to create payment method add request using following xml.But i'm getting following error.but in quickbooks with that name no term existed.can you help any one?
3100: The name "cashondelivery" of the list element is already in use.
$xml='<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="8.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<PaymentMethodAddRq>
<PaymentMethodAdd>
<Name>cashondelivery</Name>
<IsActive>true</IsActive>
<PaymentMethodType>AmericanExpress</PaymentMethodType>
</PaymentMethodAdd>
</PaymentMethodAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
That means that cashondelivery is already in QB.
Look for deleted entries as well. You might need to check the other lists and see if it is there.

qbfc/qbxml ReceivePaymentAdd assign Payment to Invoice

When I try to associate a Payment with an Invoice, I get the following error:
ReceivePaymentAdd
ORApplyPayment:
OR object has multiple values
End of ORApplyPayment
End of ReceivePaymentAdd
What does that error mean? How do I get this to work?
Note that I am pushing the Invoice into QuickBooks in a separate session, so I cannot use Macros. If I use IsAutoApply true without the AppliedToTxnAdd block, the payment pushes just fine.
Here is the generated xml:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="10.0"?>
<QBXML>
<QBXMLMsgsRq onError = "continueOnError">
<ReceivePaymentAddRq requestID = "0">
<ReceivePaymentAdd>
<CustomerRef>
<ListID>8000003F-1415364262</ListID>
</CustomerRef>
<ARAccountRef>
<FullName>Accounts Receivable</FullName>
</ARAccountRef>
<TxnDate>2014-02-14</TxnDate>
<RefNumber>1003 - P1</RefNumber>
<TotalAmount>850.00</TotalAmount>
<PaymentMethodRef>
<FullName>20 - Check</FullName>
</PaymentMethodRef>
<Memo/>
<IsAutoApply>0</IsAutoApply>
<AppliedToTxnAdd>
<TxnID>C7-1415364350</TxnID>
<PaymentAmount>850.00</PaymentAmount>
</AppliedToTxnAdd>
</ReceivePaymentAdd>
</ReceivePaymentAddRq>
</QBXMLMsgsRq>
</QBXML>
This:
ORApplyPayment:
OR object has multiple values
End of ORApplyPayment
Means that the specification (see the QuickBooks OSR) specifies that you can use EITHER AppliedToTxnAdd OR you can use IsAutoApply, but you may not use both of them. You can use one, OR the other.
You're using both, so you're getting an error message. Either remove <IsAutoApply> or remove your <AppliedToTxnAdd> tag.
Here's an example for you:
http://consolibyte.com/wiki/doku.php/quickbooks_qbxml_receivepaymentadd
http://consolibyte.com/wiki/doku.php/quickbooks

Getting DataExtRet from QuickBooks SDK

I am performing an invoice query using the QuickBooks SDK and I'd like to pull back custom fields at the item level as well. The request I am sending is:
<?xml version="1.0" ?>
<?qbxml version="8.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceQueryRq>
<RefNumber>8</RefNumber>
<IncludeLineItems>true</IncludeLineItems>
<OwnerID>0</OwnerID>
</InvoiceQueryRq>
</QBXMLMsgsRq>
</QBXML>
I get a successful response, however, there are no <DataExtRet> elements with my custom field information. I can get this data if I do an item query with the <OwnerID> element however, according to IDN, I should be able to get these custom fields in an invoice query as well. I am testing my queries using SDK Tester Plus 3. Any suggestions?
The template being used did not contain the "Serial Number" UDF I was looking for. Adding this to the invoice template and then calling InvoicequeryRq pulled back the information I was looking for.

Resources