Global API
...
Request
Bill
Create
1min
The following is an example of creating a Bill where we are setting every possible field (See Bill for the available fields). The response will return the exact request data plus the new QuickBooks Bill ID (Id).
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 //Assign value of Opportunity to QuickBook Bill
6 billMap.put('TxnDate','2024-04-26');
7 billMap.put('DueDate','2024-05-26');
8 billMap.put('DocNumber', '0001');
9 billMap.put('PrivateNote','Create Bill');
10 billMap.put('TrackingNumber','12');
11 billMap.put('GlobalTaxCalculation','NotApplicable');
12 billMap.put('SalesTermRef' , new Map<String, Object>{'value' => '2' });
13 billMap.put('VendorRef' , new Map<String, Object>{'value' => '67' });
14
15// Assign value of OpportunityLineItem to QuickBook Bill
16 Map<String, Object> lineItemMap = new Map<String, Object>();
17 Map<String, Object> salesLineItemDetailMap = new Map<String, Object>();
18 Map<String, Object> discountItemDetailMap = new Map<String, Object>();
19 lineItemMap.put('Description','Description');
20 lineItemMap.put('DetailType','ItemBasedExpenseLineDetail');
21 lineItemMap.put('Amount',10000);
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','1000');
26 if(lineItemMap.get('DetailType') == 'AccountBasedExpenseLineDetail'){
27 lineItemMap.put('AccountBasedExpenseLineDetail',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' , 'createBill');
44 finalReqMap.put('RequestJSON' , reqJSON);
45 //Required, if QuickBooks Multi-Org is enabled in Breadwinner.
46 finalReqMap.put('qbOrgId' , '4620816365285051610');
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);