Closed code2prog closed 7 years ago
According to the docs, Line
is an array. So I would assume you just add more elements to that array.
https://developer.intuit.com/docs/api/accounting/bill
Sorry I can't test it out. Having weird issue with my local server.
but Line should be set as
$builder->setLine([ [ //line 1], [ //line 2 ] ]);
?
Yes that is what I meant. Is there a problem with that?
i get error like this: {"Fault":{"Error":[{"Message":"Request has invalid or unsupported property","Detail":"Property Name:Unrecognized field \"Vendor\" (class com.intuit.schema.finance.v3.Bill), not marked as ignorable (37 known properties: \"DocNumber\", \"ExchangeR specified is unsupported or invalid","code":"2010"}],"type":"ValidationFault"},"time":"2017-04-26T02:44:30.912-07:00"}
this is my code: `function createBill( $vendor_id, $positions = [] ) { try { $bill = new Bill(); $builder = $bill->getBuilder(); $builder->setLine( [ [ "Amount" => 3.00, "Description" => "Test 1" ], [ "Amount" => 8.00, "Description" => "Test 2" ] ] ); $builder->setVendor( $vendor_id );
return $builder->create(); } catch ( ClientException $e ) { return (string) $e->getResponse()->getBody(); } }`
The error as given by Quickbooks is on the Vendor property, not Line.
I have not added any shorthand methods to Bill, so you have to use the full name and structure of each property.
In the case of vendor, try
$builder->setVendorRef(["value" => $vendor_id]);
Now works :) Thanks for your help.
How to create new Bill with multiple line items? Thanks for answer.