Global API
...
Request
Invoice

Create

1min
the following is an example of creating an invoice where we are setting every possible field (see invoice docid\ gee1fj42amxfapeumyyqi for the available fields) the response will return the exact request data, the new quickbooks invoice id (id), and the newly created salesforce invoice id (salesforcerecordid) @code this create and send invoice docid\ rjdfc8 k6czuomp3kz6cs if you also want to send the invoice during creation note you can only create one record at a time request // 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('txndate', '2021/08/11'); invoicemap put('duedate', '2021/09/11'); invoicemap put('docnumber', 'inv 1201'); invoicemap put('exchangerate', 1 0); // initializing the invoice custom fields list\<object> customfieldlist = new list\<object>(); map\<string, object> customfiel1dmap = new map\<string, object>(); customfiel1dmap put('definitionid','1'); customfiel1dmap put('type','stringtype'); customfiel1dmap put('stringvalue','received'); customfieldlist add(customfiel1dmap); // adding the invoice custom fields invoicemap put('customfield',customfieldlist); invoicemap put('address',new map\<string, object>{'freeformnumber' => '+919090909090'}); invoicemap put('salestermref',new map\<string, object>{'value' => '4'}); invoicemap put('customerref',new map\<string, object>{'value' => '29'}); // initializing the billing address map\<string, object> billaddrmap = new map\<string, object>(); billaddrmap put('city' , 'suryapet'); billaddrmap put('country' , 'india'); billaddrmap put('line3' , 'kodad'); billaddrmap put('line2' , 'first lane'); billaddrmap put('line1' , '1 24'); billaddrmap put('postalcode' , '508238'); billaddrmap put('countrysubdivisioncode' , ''); invoicemap put('billaddr',billaddrmap); // initializing the invoice line items list\<object> lineitemlist = new list\<object>(); map\<string, object> lineitemmap = new map\<string, object>(); lineitemmap put('linenum',1); lineitemmap put('amount',100); lineitemmap put('description','description'); &#x9; lineitemmap put('detailtype', 'salesitemlinedetail'); map\<string, object> saleslineitemdetailmap = new map\<string, object>(); saleslineitemdetailmap put('itemref' , new map\<string, object>{'value' => '1'}); &#x9; saleslineitemdetailmap put('taxcoderef' , new map\<string, object>{'value' => 'tax'}); saleslineitemdetailmap put('classref' , new map\<string, object>{'value' => '5000000000000193289'}); saleslineitemdetailmap put('servicedate','1993/05/25'); //yyyy/mm/dd saleslineitemdetailmap put('qty',2); saleslineitemdetailmap put('unitprice',50); saleslineitemdetailmap put('taxinclusiveamt',22); lineitemmap put('salesitemlinedetail', saleslineitemdetailmap); lineitemlist add(lineitemmap); // shipping charge is applied as a part of line items map\<string, object> shippinglineitemmap = new map\<string, object>(); shippinglineitemmap put('amount',10); &#x9; shippinglineitemmap put('detailtype', 'salesitemlinedetail'); map\<string, object> shippingsaleslineitemdetailmap = new map\<string, object>(); shippingsaleslineitemdetailmap put('itemref' , new map\<string, object>{'value' => 'shipping item id'}); &#x9; shippingsaleslineitemdetailmap put('taxcoderef' , new map\<string, object>{'value' => 'tax'}); shippinglineitemmap put('salesitemlinedetail', shippingsaleslineitemdetailmap); lineitemlist add(shippinglineitemmap); // adding the line items to invoice invoicemap put('line',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('options' , reqoptions); finalreqmap put('version' , '1 0'); finalreqmap put('action' , 'createinvoice'); finalreqmap put('requestjson' , reqjson); finalreqmap put('skipdml' , false); //required, if quickbooks multi org is enabled in breadwinner finalreqmap put('qborgid', '4620816365285051610'); system debug('request ' + finalreqmap); // placing a request to breadwinner global api map\<string, object> respmap = breadwinner qbo breadwinnerqbapi call(finalreqmap); system debug('response ' + respmap); response { action=createinvoice, responsejson={ "statuscode" 200, "invoices" \[ { "txntaxdetail" { "totaltax" 0 }, "txndate" "2021 08 11", "totalamt" 110 00, "synctoken" "0", "sparse" false, "sfrecordid" "a0a5j000000u97ueaa", "metadata" { "lastupdatedtime" "2021 11 01t02 40 26 07 00", "createtime" "2021 11 01t02 40 26 07 00" }, "line" \[ { "salesitemlinedetail" { "unitprice" 50, "taxcoderef" { "value" "tax" }, "servicedate" "1993 05 25", "qty" 2, "itemref" { "value" "1", "name" "services" } }, "linenum" 1, "id" "1", "detailtype" "salesitemlinedetail", "description" "description", "amount" 100 00 }, { "detailtype" "subtotallinedetail", "amount" 100 00 }, { "detailtype" "salesitemlinedetail", "amount" 10 00, "salesitemlinedetail" { "taxcoderef" { "value" "tax" }, "itemref" { "value" "shipping item id", } } } ], "id" "158", "emailstatus" "notset", "duedate" "2021 09 11", "docnumber" "inv 1201", "customfield" \[ { "type" "stringtype", "stringvalue" "received", "name" "crew #", "definitionid" "1" } ], "customerref" { "value" "29", "name" "weiskopf consulting" }, "currencyref" { "value" "usd", "name" "united states dollar" }, "billaddr" { "postalcode" "508238", "line3" "kodad", "line2" "first lane", "line1" "1 24", "id" "132", "country" "india", "city" "suryapet" }, "balance" 110 00, "allowonlinecreditcardpayment" false, "allowonlineachpayment" false } ] }, timestamp=1635759628120, validrequest=true, version=1 0 }