Website logo
Product Overview
NetSuite
Payments
QuickBooks
Xero
Navigate through spaces
⌘K
Getting Started
Guided Wizard
Guided Wizard Settings
Custom Guided Wizard
Button URL Structure
Button URL Generator
Support
Global API
API Overview
Request
Response
Code Examples
Advanced Topics
Batch Invoicing
Technical Resources
Breadwinner Setup
Requirements
ERD / Object Structure
Getting Help
Version History
Docs powered by Archbee
Global API
...
Request
Invoice

Update

1min

To update an Invoice in Xero, make sure you set the field "InvoiceID" with the unique reference value (ID generated by Xero for the Invoice)

Request
Response
//  Create a Map to store all the data of a Invoice
List<Object> invoiceList = new List<Object>();
Map<String,Object> invoiceMap = new Map<String,Object>();
    invoiceMap.put('InvoiceID', 'c473fb66-9e4c-445a-9855-bba92d6629e9');
    invoiceMap.put('Status', 'AUTHORISED');
    invoiceMap.put('Reference', 'Test Invoice');

    //  Updating the Invoice Line Items
    List<Object> lineItemList = new List<Object>();
        Map<String, Object> lineItemMap = new Map<String, Object>(); 
        lineItemMap.put('Description','Line Item Description Updated');
        lineItemMap.put('LineItemID','c638e3bd-3427-485f-a5f4-ea8b2b4742d4');
        lineItemMap.put('UnitAmount',100);
        lineItemMap.put('Quantity',10);
		lineItemMap.put('AccountCode', '200');
        lineItemList.add(lineItemMap);
        
    //  Adding the Line Items to Invoice
    invoiceMap.put('LineItems',lineItemList);
    invoiceList.add(invoiceMap);

//  Initializing the RequestJSON Data to be passed.
    Map<String, Object> reqJSONMap = new Map<String, Object>(); 
    reqJSONMap.put('invoices' , invoiceList); 
    String reqJSON = JSON.serialize(reqJSONMap); 

    Map<String, Object> finalReqMap = new Map<String, Object>(); 
    Map<String,Object> reqOptions = new Map<String,Object>(); 
    finalReqMap.put('queryParameters' , reqOptions); 
    finalReqMap.put('version' , '1.0'); 
    finalReqMap.put('action' , 'updateInvoice'); 
    finalReqMap.put('RequestJSON' , reqJSON); 
    finalReqMap.put('skipDML' , false); 
    //Required, if Xero Multi-Org is enabled in Breadwinner. 
    finalReqMap.put('xeroOrgId', '!aa00TM');
    System.debug('Request ::: ' + finalReqMap);

//  Placing a request to Breadwinner Global API
    Map<String, Object> respMap = bread_winner.BreadwinnerXeroAPI.call(finalReqMap);
    System.debug('Response ::: ' + respMap);




Updated 03 Mar 2023
Did this page help you?
PREVIOUS
Create
NEXT
Bill
Docs powered by Archbee
Docs powered by Archbee