I'm using invoice.add event to add lines to the created invoice. And when running the query, the first addition of the first two lines always don't add tax. If I run it again, all subsequent entries have tax added, and are working properly. Any help or hints where to find this issue?
 
$invoicelines[] = array(  
   "service_id" => '1',                 
   "description" =>' description ',
   "tax" => '1',
   "qty" => '1',                                   
    "amount" => 2
);
$invoicelines[] = array(  
   "service_id" => '2',                 
   "description" =>' description ',
   "tax" => '1',
   "qty" => '1',                              
   "amount" => 2
);
$vars = [
         'delivery' => ['email'],
         'lines' => $invoicelines
       ];
 $this->Invoices->edit($invoice_id, $vars);