Global API
...
Request
Sales Receipt
Create
1min
The following is an example of create Sales Receipt where we are setting every possible field (See Sales Receipt for the available fields). The response will return the exact request data plus the new QuickBooks Sales Receipt Id (Id) and the newly created Salesforce Sales Receipt Id (salesforceRecordId).
Note: You can only create one record at a time.
Request
Response
1// Create a Map to store all the data of a Sales Receipt
2List<Object> salesReceiptList = new List<Object>();
3Map<String, Object> salesReceiptMap = new Map<String, Object>();
4 salesReceiptMap.put('TxnDate', '2021/08/11');
5 salesReceiptMap.put('DueDate', '2021/09/11');
6
7 // Initializing the Sales Receipt Custom Fields
8 List<Object> customFieldList = new List<Object>();
9 Map<String, Object> customFiel1dMap = new Map<String, Object>();
10 customFiel1dMap.put('DefinitionId','1');
11 customFiel1dMap.put('Type','StringType');
12 customFiel1dMap.put('StringValue','Received');
13 customFieldList.add(customFiel1dMap);
14
15 // Adding the Sales Receipt Custom Fields
16 salesReceiptMap.put('CustomField',customFieldList);
17
18 salesReceiptMap.put('Address',new Map<String, Object>{'FreeFormNumber' => '+919090909090'});
19 salesReceiptMap.put('CustomerRef',new Map<String, Object>{'value' => '29'});
20
21 // Initializing the Billing Address
22 Map<String, Object> billAddrMap = new Map<String, Object>();
23 billAddrMap.put('City' , 'Suryapet');
24 billAddrMap.put('Country' , 'India');
25 billAddrMap.put('Line3' , 'Kodad');
26 billAddrMap.put('Line2' , 'First Lane');
27 billAddrMap.put('Line1' , '1-24');
28 billAddrMap.put('PostalCode' , '508238');
29 billAddrMap.put('CountrySubDivisionCode' , '');
30 salesReceiptMap.put('BillAddr',billAddrMap);
31
32 // Initializing the Sales Receipt Line Items
33 List<Object> lineItemList = new List<Object>();
34 Map<String, Object> lineItemMap = new Map<String, Object>();
35 lineItemMap.put('LineNum',1);
36 lineItemMap.put('Amount',100);
37 lineItemMap.put('Description','Description');
38 lineItemMap.put('DetailType', 'SalesItemLineDetail');
39
40 Map<String, Object> salesLineItemDetailMap = new Map<String, Object>();
41 salesLineItemDetailMap.put('ItemRef' , new Map<String, Object>{'value' => '1'});
42 salesLineItemDetailMap.put('TaxCodeRef' , new Map<String, Object>{'value' => 'TAX'});
43 salesLineItemDetailMap.put('ServiceDate','1993/05/25'); //yyyy/MM/dd
44 salesLineItemDetailMap.put('Qty',2);
45 salesLineItemDetailMap.put('UnitPrice',50);
46 salesLineItemDetailMap.put('TaxInclusiveAmt',22);
47
48 lineItemMap.put('SalesItemLineDetail', salesLineItemDetailMap);
49 lineItemList.add(lineItemMap);
50
51 // Adding the Line Items to Sales Receipt
52 salesReceiptMap.put('Line',lineItemList);
53 salesReceiptList.add(salesReceiptMap);
54
55// Initializing the RequestJSON Data to be passed.
56 Map<String, Object> reqJSONMap = new Map<String, Object>();
57 reqJSONMap.put('salesReceipts' , salesReceiptList);
58 String reqJSON = JSON.serialize(reqJSONMap);
59
60 Map<String, Object> finalReqMap = new Map<String, Object>();
61 Map<String, Object> reqOptions = new Map<String, Object>();
62 finalReqMap.put('options' , reqOptions);
63 finalReqMap.put('version' , '1.0');
64 finalReqMap.put('action' , 'createSalesReceipt');
65 finalReqMap.put('RequestJSON' , reqJSON);
66 finalReqMap.put('skipDML' , false);
67 //Required, if QuickBooks Multi-Org is enabled in Breadwinner.
68 finalReqMap.put('qbOrgId', '4620816365285051610');
69 System.debug('Request ::: ' + finalReqMap);
70
71// Placing a request to Breadwinner Global API
72 Map<String, Object> respMap = breadwinner_qbo.BreadwinnerQBAPI.call(finalReqMap);
73 System.debug('Response ::: ' + respMap);