rangka / quickbooks

PHP Library for connecting to QuickBooks.
MIT License
8 stars 11 forks source link

Vendor Update issue #20

Closed code2prog closed 6 years ago

code2prog commented 6 years ago

When i try to create new Vendor every things work fine, but when i try update i get exception like Calling undefined method in Rangka\Quickbooks\Builders\Vendor this is my code:

$ex        = getVendorByID( $vendor->Id );
$syncToken = $ex->SyncToken;
$service   = new Vendor();
$builder   = $service->getBuilder();
$builder->setDisplayName( $ex->DisplayName );
$builder->setPrimaryEmailAddr( [
    'Address' => $ex->PrimaryEmailAddr->Address
] );
$builder->setBillAddr( [
    "Line1"                  => $address['address1'],
    "Line2"                  => $address['address2'],
    "City"                   => $address['city'],
    "Country"                => $address['country'],
    "CountrySubDivisionCode" => $address['state'],
    "PostalCode"             => $address['postal_code'],
] );

$builder->setPrimaryPhone( [
    'FreeFormNumber' => $ex->PrimaryPhone->FreeFormNumber
] );

$builder->setSyncToken( $syncToken );
$ret = $builder->update();

Sync token are set and all variables like address, phone and email address. createVendor function is on the same file and Rangka\Quickbooks\Services\Vendor is declared properly on top How to fix this? Where is the issue?

Thanks

code2prog commented 6 years ago

any help? :)

khairulashraff commented 6 years ago

Apologies, caught up in my day work.

The error is due to missing ID. Since you are updating, you need to provide an ID.

$builder->setId( $vendor->Id )

code2prog commented 6 years ago

Thats works. Thank you for your help.