Skip to content

creating INV through web services does not set summary or tax value - vtiger 7.0.1

The following demo code creates invoice but does not show summary(Items Total)/tax. After editing invoice via web interface and clicking a single time e.g. in the amount field, summary is updated and tax applied:

include_once("Vtiger/WSClient.php");

        $client = new Vtiger_WSClient("http://crm.intern/crm");
        $result = $client->doLogin("user", "key");

$accountId = '11x3202';
$product_1_id = '14x7464';
$CRM_user_id = '19x1';

$values =  array (
        'assigned_user_id' => $CRM_user_id,
        'subject' => 'REST salesOrderSubject 6',
        'conversion_rate' => '1.000',
        'currency_id' => '21x1',
        'description' => 'Producten in deze verkooporder: 2 X Heart of David - songbook 2',
        'duedate' => '2018-11-06',
        'enable_recurring' => '0',
        'end_period' => NULL,
        'payment_duration' => NULL,
        'potential_id' => NULL,
        'invoicedate' => '2018-02-26',
        'cf_797' => '2018-02-26',
        'salescommission' => '0.000',
        'account_id' => $accountId,
        'sostatus' => 'Approved',
        'invoicestatus' => 'Erstellt',
        'productid' => $product_1_id,
        'discount_type_final' => 'zero',  //  zero/amount/percentage
        'pre_tax_total' => '20',
        'hdnSubTotal' => '10',
        'hdnGrandTotal' => '30',
        'shipping_handling_charge' => 0,
        'shtax1' => 1,   // apply this tax, MUST exist in the application with this internal taxname
        'adjustmentType' => 'add',  //  none/add/deduct
        'hdnTaxType' => 'group', // group or individual  taxes are obtained from the application
        'LineItems' => Array(
                '0' => Array (
                    'sequence_no' => '1',
                    'productid' => '14x7464',
                    'quantity' => '1.000',
                    'listprice' => '500.00',
        'pre_tax_total' => '20',
        'hdnSubTotal' => '10',
        'hdnGrandTotal' => '30',

                    'discount_percent' => null,
                    'discount_amount' => null,
                    'comment' => 'sample comment product',
                    'description' => 'product description',
                    'incrementondel' => '0',
                    'tax1' => '19.00'
               ),
        )
);

        try {
                $invoice = $client->doCreate("Invoice", $values);
        } catch (Exception $exp) {
                var_dump($exp);
        }
        var_dump($invoice);```

See also example file - e.g. for SO.![Bildschirmfoto_vom_2018-03-01_12-02-37](http://code.vtiger.com/vtiger/vtigercrm/uploads/91328b3b89e0b5738b46479c3c401b46/Bildschirmfoto_vom_2018-03-01_12-02-37.png)
Edited by Prasad