1// Create a Map to store all the data of a Invoice
2List<Object> invoiceList = new List<Object>();
3Map<String, Object> invoiceMap = new Map<String, Object>();
4 invoiceMap.put('Id', '13');
5 invoiceMap.put('SyncToken','2');
6 invoiceMap.put('CustomerRef',new Map<String, Object>{'value' => '9'});
7
8 // Initializing the Invoice 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 Invoice
24 invoiceMap.put('Line',lineItemList);
25 invoiceList.add(invoiceMap);
26
27// Initializing the RequestJSON Data to be passed.
28 Map<String, Object> reqJSONMap = new Map<String, Object>();
29 reqJSONMap.put('invoices' , invoiceList);
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' , 'updateinvoice');
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);