Topic: Item is not getting update in via sales invoice api
Hi .
I have followed the code from Sales_Test.php as below.
// Write back
$response = $client->put('/modules/api/sales/' . $id . '/' . ST_SALESINVOICE, array(
'headers' => TestEnvironment::headers(),
'form_params' => array(
'trans_type' => ST_SALESINVOICE,
'ref' => $ref, // TODO Ideally the api would default this and return.
'comments' => 'new comments',
'order_date' => '02/03/2013',
'delivery_date' => '04/05/2013',
'cust_ref' => 'cust_ref',
'deliver_to' => 'new deliver_to',
'delivery_address' => 'new delivery_address',
'phone' => 'new phone',
'ship_via' => 'new ship_via',
'location' => 'DEF',
'freight_cost' => '0',
'customer_id' => '2',
'branch_id' => '2',
'sales_type' => '1',
'dimension_id' => '0',
'dimension2_id' => '0',
// 'items' => array(
// 0 => array(
// 'stock_id' => 'TEST_ITEM',
// 'qty' => '2',
// 'price' => '3',
// 'discount' => '0',
// 'description' => 'new description'
// )
// ),
)
));
$this->assertEquals('200', $response->getStatusCode());
$result = $response->getBody();
$result = json_decode($result);
But if you can see ITEM CODE is disabled in the sample code.
I've tried to enable this code and update invoice.
But its now working as it should be . The error is ( THIS ITEM IS ALREADY ATTACHED TO THE INVOICE ) which is correct. All i need to update this product's price or details. Which it should basically just let it update.
I did further study . I found out it it always use add_to_order() function
if (isset($info["items"])) {
foreach($info['items'] as $item) {
add_to_order($cart, $item['stock_id'], $item['qty'], $item['price'], $item['discount'], $item['description']);
}
}
So.. basically its not working . And i guess that is why item editing part was disabled in sample code.
Is there any new update for this ?