From d28188d19ddaf57290a854518f829f53e0be5bad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Oct 2017 14:27:10 +0200 Subject: [PATCH 1/3] FIX Generation of invoice from bulk action "Bill Orders" Conflicts: htdocs/fourn/class/fournisseur.facture.class.php --- htdocs/commande/list.php | 248 +++++++++--------- htdocs/compta/facture/class/facture.class.php | 7 +- htdocs/core/actions_builddoc.inc.php | 9 +- .../fourn/class/fournisseur.facture.class.php | 6 +- htdocs/fourn/commande/list.php | 238 ++++++++--------- 5 files changed, 257 insertions(+), 251 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 8810a1be986..1efd428159a 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -208,7 +208,7 @@ if (empty($reshook)) // TODO Move this into mass action include if ($massaction == 'confirm_createbills') { - $orders = GETPOST('toselect'); + $orders = GETPOST('toselect','array'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); $validate_invoices = GETPOST('valdate_invoices', 'int'); @@ -219,13 +219,13 @@ if (empty($reshook)) $db->begin(); - foreach($orders as $id_order) { - + foreach($orders as $id_order) + { $cmd = new Commande($db); - if($cmd->fetch($id_order) <= 0) continue; + if ($cmd->fetch($id_order) <= 0) continue; $object = new Facture($db); - if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. + if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. else { $object->socid = $cmd->socid; @@ -247,12 +247,10 @@ if (empty($reshook)) $res = $object->create($user); if($res > 0) $nb_bills_created++; - } - if($object->id > 0) { - - $db->begin(); + if ($object->id > 0) + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql.= "fk_source"; $sql.= ", sourcetype"; @@ -265,115 +263,113 @@ if (empty($reshook)) $sql.= ", '".$object->element."'"; $sql.= ")"; - if ($db->query($sql)) + if (! $db->query($sql)) { - $db->commit(); - } - else - { - $db->rollback(); + $error++; } - $lines = $cmd->lines; - if (empty($lines) && method_exists($cmd, 'fetch_lines')) + if (! $error) { - $cmd->fetch_lines(); - $lines = $cmd->lines; + $lines = $cmd->lines; + if (empty($lines) && method_exists($cmd, 'fetch_lines')) + { + $cmd->fetch_lines(); + $lines = $cmd->lines; + } + + $fk_parent_line=0; + $num=count($lines); + + for ($i=0;$i<$num;$i++) + { + $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + if ($lines[$i]->subprice < 0) + { + // Negative line, we create a discount line + $discount = new DiscountAbsolute($db); + $discount->fk_soc=$object->socid; + $discount->amount_ht=abs($lines[$i]->total_ht); + $discount->amount_tva=abs($lines[$i]->total_tva); + $discount->amount_ttc=abs($lines[$i]->total_ttc); + $discount->tva_tx=$lines[$i]->tva_tx; + $discount->fk_user=$user->id; + $discount->description=$desc; + $discountid=$discount->create($user); + if ($discountid > 0) + { + $result=$object->insert_discount($discountid); + //$result=$discount->link_to_invoice($lineid,$id); + } + else + { + setEventMessages($discount->error, $discount->errors, 'errors'); + $error++; + break; + } + } + else + { + // Positive line + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + // Date start + $date_start=false; + if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + //Date end + $date_end=false; + if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) + { + $fk_parent_line = 0; + } + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + $lines[$i]->fk_remise_except, + 'HT', + 0, + $product_type, + $ii, + $lines[$i]->special_code, + $object->origin, + $lines[$i]->rowid, + $fk_parent_line, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht, + $lines[$i]->label + ); + if ($result > 0) + { + $lineid=$result; + } + else + { + $lineid=0; + $error++; + break; + } + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) + { + $fk_parent_line = $result; + } + } + } } - - $fk_parent_line=0; - $num=count($lines); - - for ($i=0;$i<$num;$i++) - { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - if ($lines[$i]->subprice < 0) - { - // Negative line, we create a discount line - $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); - if ($discountid > 0) - { - $result=$object->insert_discount($discountid); - //$result=$discount->link_to_invoice($lineid,$id); - } - else - { - setEventMessages($discount->error, $discount->errors, 'errors'); - $error++; - break; - } - } - else - { - // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); - // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) - { - $fk_parent_line = 0; - } - $result = $object->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $product_type, - $ii, - $lines[$i]->special_code, - $object->origin, - $lines[$i]->rowid, - $fk_parent_line, - $lines[$i]->fk_fournprice, - $lines[$i]->pa_ht, - $lines[$i]->label - ); - if ($result > 0) - { - $lineid=$result; - } - else - { - $lineid=0; - $error++; - break; - } - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) - { - $fk_parent_line = $result; - } - } - } - } //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. @@ -386,27 +382,29 @@ if (empty($reshook)) $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if(!empty($validate_invoices)) { - + if (! $error && $validate_invoices) + { $massaction = $action = 'builddoc'; + foreach($TAllFact as &$object) + { + $result = $object->validate($user); + if ($result <= 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + break; + } - foreach($TAllFact as &$object) { - $object->validate($user); - $toselect[] = $object->id; // For builddoc action + $id = $object->id; // For builddoc action // Fac builddoc + $donotredirect = 1; $upload_dir = $conf->facture->dir_output; $permissioncreate=$user->rights->facture->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } - $objectclass='Facture'; - $objectlabel='Invoice'; - $permtoread = $user->rights->facture->lire; - $permtodelete = $user->rights->facture->supprimer; - $uploaddir = $conf->facture->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - + $massaction = $action = 'confirm_createbills'; } if (! $error) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c3b58117dd7..fc019d92eea 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2051,6 +2051,10 @@ class Facture extends CommonInvoice $error=0; dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse); + // Force to have object complete for checks + $this->fetch_thirdparty(); + $this->fetch_lines(); + // Check parameters if (! $this->brouillon) { @@ -2068,9 +2072,6 @@ class Facture extends CommonInvoice $this->db->begin(); - $this->fetch_thirdparty(); - $this->fetch_lines(); - // Check parameters if ($this->type == self::TYPE_REPLACEMENT) // si facture de remplacement { diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 076a7a6a035..70876d4bf9a 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -91,10 +91,13 @@ if ($action == 'builddoc' && $permissioncreate) } else { - setEventMessages($langs->trans("FileGenerated"), null); + if (empty($donotredirect)) // This is se when include is done by bulk action "Bill Orders" + { + setEventMessages($langs->trans("FileGenerated"), null); - header('Location: '.$_SERVER['REQUEST_URI'].'#builddoc'); - exit; + header('Location: '.$_SERVER['REQUEST_URI'].'#builddoc'); + exit; + } } } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8b573679f82..143d2cd5f36 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1086,7 +1086,11 @@ class FactureFournisseur extends CommonInvoice $error=0; - // Protection + // Force to have object complete for checks + $this->fetch_thirdparty(); + $this->fetch_lines(); + + // Check parameters if ($this->statut > self::STATUS_DRAFT) // This is to avoid to validate twice (avoid errors on logs and stock management) { dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index ac67d256824..706e7e22024 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -239,7 +239,7 @@ if (empty($reshook)) // TODO Move this into mass action include if ($massaction == 'confirm_createbills') { - $orders = GETPOST('toselect'); + $orders = GETPOST('toselect','array'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); $validate_invoices = GETPOST('valdate_invoices', 'int'); @@ -281,9 +281,8 @@ if (empty($reshook)) } - if($object->id > 0) { - - $db->begin(); + if ($object->id > 0) + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; $sql.= "fk_source"; $sql.= ", sourcetype"; @@ -296,118 +295,116 @@ if (empty($reshook)) $sql.= ", '".$object->element."'"; $sql.= ")"; - if ($db->query($sql)) + if (! $db->query($sql)) { - $db->commit(); - } - else - { - $db->rollback(); + $erorr++; } - $lines = $cmd->lines; - if (empty($lines) && method_exists($cmd, 'fetch_lines')) + if (! $error) { - $cmd->fetch_lines(); - $lines = $cmd->lines; + $lines = $cmd->lines; + if (empty($lines) && method_exists($cmd, 'fetch_lines')) + { + $cmd->fetch_lines(); + $lines = $cmd->lines; + } + + $fk_parent_line=0; + $num=count($lines); + + for ($i=0;$i<$num;$i++) + { + $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + if ($lines[$i]->subprice < 0) + { + // Negative line, we create a discount line + $discount = new DiscountAbsolute($db); + $discount->fk_soc=$object->socid; + $discount->amount_ht=abs($lines[$i]->total_ht); + $discount->amount_tva=abs($lines[$i]->total_tva); + $discount->amount_ttc=abs($lines[$i]->total_ttc); + $discount->tva_tx=$lines[$i]->tva_tx; + $discount->fk_user=$user->id; + $discount->description=$desc; + $discountid=$discount->create($user); + if ($discountid > 0) + { + $result=$object->insert_discount($discountid); + //$result=$discount->link_to_invoice($lineid,$id); + } + else + { + setEventMessages($discount->error, $discount->errors, 'errors'); + $error++; + break; + } + } + else + { + // Positive line + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + // Date start + $date_start=false; + if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + //Date end + $date_end=false; + if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) + { + $fk_parent_line = 0; + } + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + $lines[$i]->fk_remise_except, + 'HT', + 0, + $product_type, + $ii, + $lines[$i]->special_code, + $object->origin, + $lines[$i]->rowid, + $fk_parent_line, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht, + $lines[$i]->label + ); + if ($result > 0) + { + $lineid=$result; + } + else + { + $lineid=0; + $error++; + break; + } + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) + { + $fk_parent_line = $result; + } + } + } } - - $fk_parent_line=0; - $num=count($lines); - - for ($i=0;$i<$num;$i++) - { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - if ($lines[$i]->subprice < 0) - { - // Negative line, we create a discount line - $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); - if ($discountid > 0) - { - $result=$object->insert_discount($discountid); - //$result=$discount->link_to_invoice($lineid,$id); - } - else - { - setEventMessages($discount->error, $discount->errors, 'errors'); - $error++; - break; - } - } - else - { - // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); - // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) - { - $fk_parent_line = 0; - } - $result = $object->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $product_type, - $ii, - $lines[$i]->special_code, - $object->origin, - $lines[$i]->rowid, - $fk_parent_line, - $lines[$i]->fk_fournprice, - $lines[$i]->pa_ht, - $lines[$i]->label - ); - if ($result > 0) - { - $lineid=$result; - } - else - { - $lineid=0; - $error++; - break; - } - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) - { - $fk_parent_line = $result; - } - } - } - } - $cmd->classifyBilled($user); + $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; else $TFact[$object->id] = $object; @@ -417,27 +414,30 @@ if (empty($reshook)) $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if(!empty($validate_invoices)) { + if (! $error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach($TAllFact as &$object) { + foreach($TAllFact as &$object) + { $object->validate($user); - $toselect[] = $object->id; // For builddoc action + if ($result <= 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + break; + } + + $id = $object->id; // For builddoc action // Fac builddoc + $donotredirect = 1; $upload_dir = $conf->facture->dir_output; $permissioncreate=$user->rights->facture->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } - $objectclass='Facture'; - $objectlabel='Invoice'; - $permtoread = $user->rights->facture->lire; - $permtodelete = $user->rights->facture->supprimer; - $uploaddir = $conf->facture->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - + $massaction = $action = 'confirm_createbills'; } if (! $error) From 13cb8064363635aec034646fa8a16ce5b9fe0539 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Oct 2017 15:17:20 +0200 Subject: [PATCH 2/3] FIX #7531 #7537 --- htdocs/core/class/commonobject.class.php | 8 ++++++-- htdocs/core/class/extrafields.class.php | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f1002d86f80..a97b553aed4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4559,12 +4559,16 @@ abstract class CommonObject { $out .= ''; } - // Convert date into timestamp format + // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) { $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->db->jdate($this->array_options['options_'.$key]); } - + // Convert float submited string into real php numeric (value in memory must be a php numeric) + if (in_array($extrafields->attribute_type[$key],array('price','double'))) + { + $value = isset($_POST["options_".$key])?price2num($_POST["options_".$key]):$this->array_options['options_'.$key]; + } if($extrafields->attribute_required[$key]) $label = ''.$label.''; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index b539a02654f..f6f0006a6d6 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -738,7 +738,7 @@ class ExtraFields * Return HTML string to put an input field into a page * * @param string $key Key of attribute - * @param string $value Preselected value to show (for date type it must be in timestamp format) + * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) * @param string $moreparam To add more parametes on html input tag * @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names) @@ -861,11 +861,14 @@ class ExtraFields } elseif ($type == 'price') { - $out=' '.$langs->getCurrencySymbol($conf->currency); + if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. + $value=price($value); + } + $out.=' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { - if (!empty($value)) { + if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } $out=' '; From 69c47aa7d9f44ccca40b09973621271ce69ffdbe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Oct 2017 15:22:55 +0200 Subject: [PATCH 3/3] Fix sql error --- htdocs/fourn/class/fournisseur.facture.class.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 143d2cd5f36..d4edc4a01cd 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2531,15 +2531,10 @@ class SupplierInvoiceLine extends CommonObjectLine } // Clean parameters - if (empty($this->tva_tx)) { - $this->tva_tx = 0; - } - if (empty($this->localtax1_tx)) { - $this->localtax1_tx = 0; - } - if (empty($this->localtax2_tx)) { - $this->localtax2_tx = 0; - } + if (empty($this->remise_percent)) $this->remise_percent = 0; + if (empty($this->tva_tx)) $this->tva_tx = 0; + if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; + if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; $this->db->begin();