Global API
...
Request
Bill
Create
1 min
in xero, the "invoice" object includes invoices, bills, and credit notes so, when creating a bill, set the field "type" with the value "accpay" note for accpay records, use "invoicenumber" as the reference field request // create a map to store all the data of a bill list\<object> billlist = new list\<object>(); map\<string, object> billmap = new map\<string, object>(); billmap put('type', 'accpay'); billmap put('datestring', '2021 11 11t00 00 00'); billmap put('duedatestring', '2021 12 06t00 00 00'); billmap put('status', 'draft'); billmap put('invoicenumber', 'this is the reference for bill'); // initializing the bill map\<string, object> contactmap = new map\<string, object>(); contactmap put('contactid', 'c84ebb15 0a8d 4145 933f 203e68d014a0'); billmap put('contact', contactmap); // initializing the bill line items list\<object> lineitemlist = new list\<object>(); map\<string, object> lineitemmap = new map\<string, object>(); lineitemmap put('description', 'line item description'); lineitemmap put('unitamount', 100); lineitemmap put('quantity', 10); 	 lineitemmap put('accountcode', '310'); lineitemlist add(lineitemmap); // adding the line items to bill billmap put('lineitems', lineitemlist); billlist add(billmap); // initializing the requestjson data to be passed map\<string, object> reqjsonmap = new map\<string, object>(); reqjsonmap put('invoices', billlist); string reqjson = json serialize(reqjsonmap); map\<string, object> finalreqmap = new map\<string, object>(); finalreqmap put('version', '1 0'); finalreqmap put('action', 'createbill'); 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); response { action=createbill, responsejson={ "statuscode" 200, "bills" \[ { "updateddateutc"\ null, "type" "accpay", "totaltax" 0 00, "totaldiscount"\ null, "total" 1000 00, "telephone" "", "subtotal" 1000 00, "status" "draft", "senttocontact"\ false, "salesforcerecordid" "a0k7f00001eft7ouas", "reference" "", "purchaseordernumber"\ null, "purchaseorderid"\ null, "payments"\ null, "lineitems" \[ { "unitamount" 100 00, "tracking" \[ ], "taxtype" "input", "taxamount" 0 00, "quantity" 10 0000, "lineitemid" "1294d14b 30e6 4c76 85f5 d66de2c02b83", "lineamount" 1000 00, "itemcode"\ null, "discountrate"\ null, "description" "line item description", "accountcode" "310" } ], "lineamounttypes" "exclusive", "isdiscounted"\ false, "invoicenumber" "this is the reference for bill", "invoiceid" "192d2166 7cfa 4f30 89c1 9ad1dc1f55df", "haserrors"\ false, "duedatestring" "2021 12 06t00 00 00", "duedate" "/date(1638748800000+0000)/", "deliveryinstructions" "", "deliverydatestring"\ null, "deliverydate"\ null, "deliveryaddress" "", "datevariable" "/date(1636588800000+0000)/", "datestring" "2021 11 11t00 00 00", "currencyrate" 1 0000000000, "currencycode" "inr", "creditnotes"\ null, "contact" { "name" "test contact 2", "contactstatus" "active", "contactid" "c84ebb15 0a8d 4145 933f 203e68d014a0" }, "brandingthemeid"\ null, "attentionto" "", "amountpaid" 0 00, "amountdue" 1000 00, "amountcredited" 0 00 } ], "errors" \[ ] }, timestamp=1636631567378, validrequest=true, version=1 0 }