Global API
...
Request
Sales Receipt
Update
1min
The following is an example of update Sales Receipt. The QuickBooks Invoice Id (id) is required to update the Invoice (See Sales Receipt for the available fields).
Note: You can only update one record at a time.
Request
Response
1// Create a Map to store all the data of a Sales REeceipt
2List<Object> salesReceiptList = new List<Object>();
3Map<String, Object> salesReceiptMap = new Map<String, Object>();
4 salesReceiptMap.put('Id', '159');
5 salesReceiptMap.put('SyncToken','0');
6 salesReceiptMap.put('CustomerRef',new Map<String, Object>{'value' => '9'});
7
8 // Initializing the Sales Receipt Line Items
9 List<Object> lineItemList = new List<Object>();
10 Map<String, Object> lineItemMap = new Map<String, Object>();
11 lineItemMap.put('LineNum',1);
12 lineItemMap.put('Amount',100);
13 lineItemMap.put('Description','Description Updated');
14 lineItemMap.put('DetailType', 'SalesItemLineDetail');
15 Map<String, Object> salesLineItemDetailMap = new Map<String, Object>();
16 salesLineItemDetailMap.put('Qty',2);
17 salesLineItemDetailMap.put('UnitPrice',50);
18 salesLineItemDetailMap.put('TaxCodeRef' , new Map<String, Object>{'value' => 'TAX'});
19
20 lineItemMap.put('SalesItemLineDetail', salesLineItemDetailMap);
21 lineItemList.add(lineItemMap);
22
23 // Adding the Line Items to Sales Receipt
24 salesReceiptMap.put('Line',lineItemList);
25 salesReceiptList.add(salesReceiptMap);
26
27// Initializing the RequestJSON Data to be passed.
28 Map<String, Object> reqJSONMap = new Map<String, Object>();
29 reqJSONMap.put('salesReceipts' , salesReceiptList);
30 String reqJSON = JSON.serialize(reqJSONMap);
31
32 Map<String, Object> finalReqMap = new Map<String, Object>();
33 Map<String, Object> reqOptions = new Map<String, Object>();
34 finalReqMap.put('options' , reqOptions);
35 finalReqMap.put('version' , '1.0');
36 finalReqMap.put('action' , 'updateSalesReceipt');
37 finalReqMap.put('RequestJSON' , reqJSON);
38 finalReqMap.put('skipDML' , false);
39 //Required, if QuickBooks Multi-Org is enabled in Breadwinner.
40 finalReqMap.put('qbOrgId', '4620816365285051610');
41 System.debug('Request ::: ' + finalReqMap);
42
43// Placing a request to Breadwinner Global API
44 Map<String, Object> respMap = breadwinner_qbo.BreadwinnerQBAPI.call(finalReqMap);
45 System.debug('Response ::: ' + respMap);