Global API
...
Request
Bill
Update
1min
To update a Bill in Xero, make sure you set the field "InvoiceID" with the unique reference value (ID generated by Xero for the Bill)
Request
Response
1// Create a Map to store all the data of a Bill
2List<Object> invoiceList = new List<Object>();
3Map<String, Object> invoiceMap = new Map<String, Object>();
4 invoiceMap.put('InvoiceID', '192d2166-7cfa-4f30-89c1-9ad1dc1f55df');
5 invoiceMap.put('Status', 'AUTHORISED');
6 invoiceMap.put('InvoiceNumber', 'Test Bill');
7
8 // Updating the Bill Line Items
9 List<Object> lineItemList = new List<Object>();
10 Map<String, Object> lineItemMap = new Map<String, Object>();
11 lineItemMap.put('Description', 'Line Item Description Updated');
12 lineItemMap.put('LineItemID', '1294d14b-30e6-4c76-85f5-d66de2c02b83');
13 lineItemMap.put('UnitAmount', 100);
14 lineItemMap.put('Quantity', 10);
15 lineItemMap.put('AccountCode', '200');
16 lineItemList.add(lineItemMap);
17
18 // Adding the Line Items to Bill
19 invoiceMap.put('LineItems', lineItemList);
20 invoiceList.add(invoiceMap);
21
22// Initializing the RequestJSON Data to be passed.
23 Map<String, Object> reqJSONMap = new Map<String, Object>();
24 reqJSONMap.put('invoices', invoiceList);
25 String reqJSON = JSON.serialize(reqJSONMap);
26
27 Map<String, Object> finalReqMap = new Map<String, Object>();
28 finalReqMap.put('version', '1.0');
29 finalReqMap.put('action', 'updateBill');
30 finalReqMap.put('RequestJSON', reqJSON);
31 finalReqMap.put('skipDML', false);
32 //Required, if Xero Multi-Org is enabled in Breadwinner.
33 finalReqMap.put('xeroOrgId', '!aa00TM');
34 System.debug('Request ::: ' + finalReqMap);
35
36// Placing a request to Breadwinner Global API
37 Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(finalReqMap);
38 System.debug('Response ::: ' + respMap);