Global API
...
Request
Bill
Update
1min
The following is an example of updating a Bill. The QuickBooks Bill ID (id), Vendor Reference Id (VendorRef) and Sync Token (SyncToken) are required to update the Bill. (See Bill for the available fields).
Note: You can only create one record at a time.
Request
Response
1// Create a Map to store all the data of a Bill
2 Map<String, Object> billMap = new Map<String, Object>();
3 List<Object> lineItemList = new List<Object>();
4 List<Object> billList = new List<Object>();
5
6// Assign value of Opportunity to QuickBook Bill
7 billMap.put('TxnDate','2024-04-26');
8 billMap.put('DueDate','2024-05-26');
9 billMap.put('Id','191');
10 billMap.put('SyncToken','0');
11 billMap.put('TrackingNumber','12');
12 billMap.put('GlobalTaxCalculation','TaxInclusive');
13 billMap.put('SalesTermRef' , new Map<String, Object>{'value' => '2' });
14 billMap.put('VendorRef' , new Map<String, Object>{'value' => '83' });
15 billMap.put('PrivateNote' , 'updated');
16
17// Assign value of OpportunityLineItem to QuickBook Bill
18 Map<String, Object> lineItemMap = new Map<String, Object>();
19 Map<String, Object> salesLineItemDetailMap = new Map<String, Object>();
20 lineItemMap.put('DetailType','ItemBasedExpenseLineDetail');
21 lineItemMap.put('Amount',100);
22 salesLineItemDetailMap.put('ItemRef' , new Map<String, Object>{'value' => '19' });
23 salesLineItemDetailMap.put('TaxCodeRef', new Map<String, Object>{'value' => 'NON' });
24 salesLineItemDetailMap.put('Qty','10');
25 salesLineItemDetailMap.put('UnitPrice','10');
26 if(lineItemMap.get('DetailType') == 'SalesItemLineDetail'){
27 lineItemMap.put('SalesItemLineDetail',salesLineItemDetailMap);
28 }else if(lineItemMap.get('DetailType') == 'ItemBasedExpenseLineDetail'){
29 lineItemMap.put('ItemBasedExpenseLineDetail',salesLineItemDetailMap);
30 }
31 lineItemList.add(lineItemMap);
32
33// Adding the Line Items to QuickBook Bill
34 billMap.put('Line',lineItemList);
35 billList.add(billMap);
36 Map<String, Object> reqJSONMap = new Map<String, Object>();
37 reqJSONMap.put('Bill' , billList);
38 String reqJSON = JSON.serialize(reqJSONMap);
39 Map<String, Object> finalReqMap = new Map<String, Object>();
40 Map<String,Object> reqOptions = new Map<String,Object>();
41 finalReqMap.put('options' , reqOptions);
42 finalReqMap.put('version' , '1.0');
43 finalReqMap.put('action' , 'updateBill');
44 finalReqMap.put('RequestJSON' , reqJSON);
45 finalReqMap.put('qbOrgId' , '4620816365285051610');
46 // Required, if QuickBooks Multi-Org is enabled in Breadwinner.
47 finalReqMap.put('skipDML' , false);
48 System.debug('Request ::: ' + finalReqMap);
49 Map<String, Object> respMap = breadwinner_qbo.BreadwinnerQBAPI.call(finalReqMap);
50 System.debug('Response ::: ' + respMap);