226 public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0)
229 if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source) {
230 $this->error =
'ErrorBadParameters';
234 $sql =
"SELECT sr.rowid, sr.fk_soc, sr.discount_type,";
235 $sql .=
" sr.fk_user,";
236 $sql .=
" sr.amount_ht, sr.amount_tva, sr.amount_localtax1, sr.amount_localtax2, sr.amount_ttc, sr.tva_tx, sr.localtax1_tx, sr.localtax1_type, sr.localtax2_tx, sr.localtax2_type, sr.vat_src_code,";
237 $sql .=
" sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,";
238 $sql .=
" sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,";
239 $sql .=
" sr.datec,";
240 $sql .=
" f.ref as ref_facture_source, f.type as type_facture_source,";
241 $sql .=
" fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source";
242 $sql .=
" FROM ".$this->db->prefix().
"societe_remise_except as sr";
243 $sql .=
" LEFT JOIN ".$this->db->prefix().
"facture as f ON sr.fk_facture_source = f.rowid";
244 $sql .=
" LEFT JOIN ".$this->db->prefix().
"facture_fourn as fsup ON sr.fk_invoice_supplier_source = fsup.rowid";
245 $sql .=
" WHERE sr.entity IN (".getEntity(
'invoice').
")";
247 $sql .=
" AND sr.rowid = ".((int) $rowid);
249 if ($fk_facture_source) {
250 $sql .=
" AND sr.fk_facture_source = ".((int) $fk_facture_source);
252 if ($fk_invoice_supplier_source) {
253 $sql .=
" AND sr.fk_invoice_supplier_source = ".((int) $fk_invoice_supplier_source);
256 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
257 $resql = $this->db->query($sql);
259 if ($this->db->num_rows($resql)) {
260 $obj = $this->db->fetch_object($resql);
262 $this->
id = $obj->rowid;
263 $this->fk_soc = $obj->fk_soc;
264 $this->socid = $obj->fk_soc;
265 $this->discount_type = $obj->discount_type;
267 $this->total_ht = $obj->amount_ht;
268 $this->total_tva = $obj->amount_tva;
269 $this->total_localtax1 = $obj->amount_localtax1;
270 $this->total_localtax2 = $obj->amount_localtax2;
271 $this->total_ttc = $obj->amount_ttc;
273 $this->amount_ht = $this->total_ht;
274 $this->amount_tva = $this->total_tva;
275 $this->amount_ttc = $this->total_ttc;
277 $this->multicurrency_total_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht;
278 $this->multicurrency_total_tva = $obj->multicurrency_amount_tva;
279 $this->multicurrency_total_ttc = $obj->multicurrency_amount_ttc;
281 $this->multicurrency_amount_ht = $this->multicurrency_total_ht;
282 $this->multicurrency_amount_tva = $this->multicurrency_total_tva;
283 $this->multicurrency_amount_ttc = $this->multicurrency_total_ttc;
285 $this->tva_tx = $obj->tva_tx;
286 $this->localtax1_tx = $obj->localtax1_tx;
287 $this->localtax1_type = $obj->localtax1_type;
288 $this->localtax2_tx = $obj->localtax2_tx;
289 $this->localtax2_type = $obj->localtax2_type;
290 $this->vat_src_code = $obj->vat_src_code;
292 $this->fk_user = $obj->fk_user;
293 $this->fk_facture_line = $obj->fk_facture_line;
294 $this->fk_facture = $obj->fk_facture;
295 $this->fk_facture_source = $obj->fk_facture_source;
296 $this->ref_facture_source = $obj->ref_facture_source;
297 $this->type_facture_source = $obj->type_facture_source;
298 $this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line;
299 $this->fk_invoice_supplier = $obj->fk_invoice_supplier;
300 $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source;
301 $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source;
302 $this->type_invoice_supplier_source = $obj->type_invoice_supplier_source;
304 $this->datec = $this->db->jdate($obj->datec);
306 $this->db->free($resql);
309 $this->db->free($resql);
313 $this->error = $this->db->error();
330 $this->amount_ht =
price2num($this->amount_ht);
331 $this->amount_tva =
price2num($this->amount_tva);
332 $this->amount_ttc =
price2num($this->amount_ttc);
334 $this->tva_tx =
price2num($this->tva_tx);
335 $this->localtax1_tx =
price2num($this->localtax1_tx);
336 $this->localtax1_type =
price2num($this->localtax1_type);
337 $this->localtax2_tx =
price2num($this->localtax2_tx);
338 $this->localtax2_type =
price2num($this->localtax2_type);
340 $this->multicurrency_amount_ht =
price2num($this->multicurrency_amount_ht);
341 $this->multicurrency_amount_tva =
price2num($this->multicurrency_amount_tva);
342 $this->multicurrency_amount_ttc =
price2num($this->multicurrency_amount_ttc);
344 if (empty($this->multicurrency_amount_ht)) {
345 $this->multicurrency_amount_ht = 0;
347 if (empty($this->multicurrency_amount_tva)) {
348 $this->multicurrency_amount_tva = 0;
350 if (empty($this->multicurrency_amount_ttc)) {
351 $this->multicurrency_amount_ttc = 0;
353 if (empty($this->tva_tx)) {
356 if (empty($this->localtax1_tx)) {
357 $this->localtax1_tx = 0;
358 $this->localtax1_type = 0;
360 if (empty($this->localtax2_tx)) {
361 $this->localtax2_tx = 0;
362 $this->localtax2_type = 0;
367 $this->error =
'BadValueForPropertyDescriptionOfDiscount';
368 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
373 if (!($userid > 0)) {
374 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
375 $tmpinvoice =
new Facture($this->db);
376 $tmpinvoice->fetch($this->fk_facture_source);
377 $userid = $tmpinvoice->user_creation_id;
381 $sql =
"INSERT INTO ".$this->db->prefix().
"societe_remise_except";
382 $sql .=
" (entity, datec, fk_soc, discount_type, fk_user, description,";
383 $sql .=
" amount_ht, amount_tva, amount_localtax1, amount_localtax2, amount_ttc, tva_tx, localtax1_tx, localtax1_type, localtax2_tx, localtax2_type, vat_src_code,";
384 $sql .=
" multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,";
385 $sql .=
" fk_facture_source, fk_invoice_supplier_source, multicurrency_code, multicurrency_tx";
387 $sql .=
" VALUES (".((int)
$conf->entity).
", '".$this->db->idate($this->datec !=
'' ? $this->datec :
dol_now()).
"', ".((
int) $this->socid).
", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).
", ".((
int) $userid).
", '".$this->db->escape($this->description).
"',";
388 $sql .=
" ".price2num($this->amount_ht).
", ".
price2num($this->amount_tva).
", ";
389 $sql .=
" ".($this->total_localtax1 ?
price2num($this->total_localtax1) : 0).
", ".($this->total_localtax2 ?
price2num($this->total_localtax2) : 0).
", ".
price2num($this->amount_ttc).
", ".
price2num($this->tva_tx).
",";
390 $sql .=
" ".($this->localtax1_tx ?
price2num($this->localtax1_tx) : 0).
", ".($this->localtax1_type ?
price2num($this->localtax1_type) : 0).
", ";
391 $sql .=
" ".($this->localtax2_tx ?
price2num($this->localtax2_tx) : 0).
", ".($this->localtax2_type ?
price2num($this->localtax2_type) : 0).
", '".$this->db->escape($this->vat_src_code).
"',";
392 $sql .=
" ".price2num($this->multicurrency_amount_ht).
", ".
price2num($this->multicurrency_amount_tva).
", ";
393 $sql .=
" ".price2num($this->multicurrency_amount_ttc).
", ";
394 $sql .=
" ".($this->fk_facture_source ? ((int) $this->fk_facture_source) :
"null").
",";
395 $sql .=
" ".($this->fk_invoice_supplier_source ? ((int) $this->fk_invoice_supplier_source) :
"null").
",";
396 $sql .=
" ".($this->multicurrency_code ?
"'".$this->db->escape($this->multicurrency_code).
"'" :
"null").
",";
397 $sql .=
" ".($this->multicurrency_tx ?
price2num($this->multicurrency_tx) :
"null");
400 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
401 $resql = $this->db->query($sql);
403 $this->
id = $this->db->last_insert_id($this->db->prefix().
"societe_remise_except");
406 $result = $this->call_trigger(
'DISCOUNTABSOLUTE_CREATE', $user);
414 $this->error = $this->db->lasterror().
' - sql='.$sql;
426 public function delete($user)
429 if ($this->fk_facture_source) {
430 $sql =
"SELECT COUNT(rowid) as nb";
431 $sql .=
" FROM ".$this->db->prefix().
"societe_remise_except";
432 $sql .=
" WHERE (fk_facture_line IS NOT NULL";
433 $sql .=
" OR fk_facture IS NOT NULL)";
434 $sql .=
" AND fk_facture_source = ".((int) $this->fk_facture_source);
437 dol_syslog(get_class($this).
"::delete Check if we can remove discount", LOG_DEBUG);
438 $resql = $this->db->query($sql);
440 $obj = $this->db->fetch_object($resql);
442 $this->error =
'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved';
446 dol_print_error($this->db);
452 if ($this->fk_invoice_supplier_source) {
453 $sql =
"SELECT COUNT(rowid) as nb";
454 $sql .=
" FROM ".$this->db->prefix().
"societe_remise_except";
455 $sql .=
" WHERE (fk_invoice_supplier_line IS NOT NULL";
456 $sql .=
" OR fk_invoice_supplier IS NOT NULL)";
457 $sql .=
" AND fk_invoice_supplier_source = ".((int) $this->fk_invoice_supplier_source);
460 dol_syslog(get_class($this).
"::delete Check if we can remove discount", LOG_DEBUG);
461 $resql = $this->db->query($sql);
463 $obj = $this->db->fetch_object($resql);
465 $this->error =
'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved';
469 dol_print_error($this->db);
477 $sql =
"DELETE FROM ".$this->db->prefix().
"societe_remise_except ";
478 if ($this->fk_facture_source) {
479 $sql .=
" WHERE fk_facture_source = ".((int) $this->fk_facture_source);
480 } elseif ($this->fk_invoice_supplier_source) {
481 $sql .=
" WHERE fk_invoice_supplier_source = ".((int) $this->fk_invoice_supplier_source);
483 $sql .=
" WHERE rowid = ".((int) $this->
id);
485 $sql .=
" AND (fk_facture_line IS NULL";
486 $sql .=
" AND fk_facture IS NULL)";
487 $sql .=
" AND (fk_invoice_supplier_line IS NULL";
488 $sql .=
" AND fk_invoice_supplier IS NULL)";
490 dol_syslog(get_class($this).
"::delete Delete discount", LOG_DEBUG);
492 require_once DOL_DOCUMENT_ROOT.
'/core/class/commoninvoice.class.php';
493 $result = $this->db->query($sql);
496 if ($this->fk_facture_source) {
497 $sql =
"UPDATE ".$this->db->prefix().
"facture";
498 $sql .=
" set paye=0, fk_statut=1";
501 dol_syslog(get_class($this).
"::delete Update credit note or deposit invoice statut", LOG_DEBUG);
502 $result = $this->db->query($sql);
507 $this->error = $this->db->lasterror();
508 $this->db->rollback();
511 } elseif ($this->fk_invoice_supplier_source) {
512 $sql =
"UPDATE ".$this->db->prefix().
"facture_fourn";
513 $sql .=
" set paye=0, fk_statut=1";
516 dol_syslog(get_class($this).
"::delete Update credit note or deposit invoice statut", LOG_DEBUG);
517 $result = $this->db->query($sql);
522 $this->error = $this->db->lasterror();
523 $this->db->rollback();
531 $this->error = $this->db->lasterror();
532 $this->db->rollback();
556 if (!$rowidline && !$rowidinvoice) {
557 $this->error =
'ErrorBadParameters';
560 if ($rowidline && $rowidinvoice) {
561 $this->error =
'ErrorBadParameters';
565 $sql =
"UPDATE ".$this->db->prefix().
"societe_remise_except";
566 if (!empty($this->discount_type)) {
568 $sql .=
" SET fk_invoice_supplier_line = ".((int) $rowidline);
571 $sql .=
" SET fk_invoice_supplier = ".((int) $rowidinvoice);
575 $sql .=
" SET fk_facture_line = ".((int) $rowidline);
578 $sql .=
" SET fk_facture = ".((int) $rowidinvoice);
581 $sql .=
" WHERE rowid = ".((int) $this->
id);
583 dol_syslog(get_class($this).
"::link_to_invoice", LOG_DEBUG);
584 $resql = $this->db->query($sql);
586 if (!empty($this->discount_type)) {
587 $this->fk_invoice_supplier_line = $rowidline;
588 $this->fk_invoice_supplier = $rowidinvoice;
590 $this->fk_facture_line = $rowidline;
591 $this->fk_facture = $rowidinvoice;
599 $sourceinvoiceid = 0;
601 if (!empty($this->discount_type)) {
602 $sourcetype =
'invoice_supplier';
603 $targettype =
'invoice_supplier';
604 $sourceinvoiceid = (int) $this->fk_invoice_supplier_source;
606 $sourcetype =
'facture';
607 $targettype =
'facture';
608 $sourceinvoiceid = (int) $this->fk_facture_source;
611 if ($sourceinvoiceid > 0 && $sourceinvoiceid !== (
int) $rowidinvoice) {
612 $sqlcheck =
"SELECT 1";
613 $sqlcheck .=
" FROM ".$this->db->prefix().
"element_element";
614 $sqlcheck .=
" WHERE fk_source = ".((int) $sourceinvoiceid);
615 $sqlcheck .=
" AND sourcetype = '".$this->db->escape($sourcetype).
"'";
616 $sqlcheck .=
" AND fk_target = ".((int) $rowidinvoice);
617 $sqlcheck .=
" AND targettype = '".$this->db->escape($targettype).
"'";
618 $sqlcheck .= $this->db->plimit(1);
620 $rescheck = $this->db->query($sqlcheck);
621 if ($rescheck && $this->db->num_rows($rescheck) === 0) {
622 $sqladd =
"INSERT INTO ".$this->db->prefix().
"element_element (fk_source, sourcetype, fk_target, targettype)";
623 $sqladd .=
" VALUES (".((int) $sourceinvoiceid).
", '".$this->db->escape($sourcetype).
"', ".((int) $rowidinvoice).
", '".$this->db->escape($targettype).
"')";
624 $this->db->query($sqladd);
631 $result = $this->call_trigger(
'DISCOUNT_MODIFY', $user);
639 $this->error = $this->db->error();
955 public function generateFromAmount($amount, $amount_type, $tva_tx, $localtax1_tx, $localtax2_tx, $localtax1_type = 1, $localtax2_type = 1)
957 $tva_tx_pct = (float) ($tva_tx / 100);
958 $localtax1_tx_pct = (float) ($localtax1_tx / 100);
959 $localtax2_tx_pct = (float) ($localtax2_tx / 100);
966 $localtax1_type2 = ((int) $localtax1_type > 0 && (
int) $localtax1_type % 2 == 0 ? 1 : 0);
967 $localtax2_type2 = ((int) $localtax2_type > 0 && (
int) $localtax2_type % 2 == 0 ? 1 : 0);
969 if ($amount_type == 1) {
971 $this->total_ttc = (float)
price2num($amount,
'MT');
973 $ttc = (float) $this->total_ttc;
979 $tx_before_vat_without1 = 0;
980 $tx_before_vat_without2 = 0;
982 $tx_after_vat_without1 = 0;
983 $tx_after_vat_without2 = 0;
984 if ($localtax1_type2 && $localtax1_tx_pct > 0) {
985 $tx_after_vat += $localtax1_tx_pct;
986 $tx_after_vat_without2 += $localtax1_tx_pct;
988 $tx_before_vat += $localtax1_tx_pct;
989 $tx_before_vat_without2 += $localtax1_tx_pct;
991 if ($localtax2_type2 && $localtax2_tx_pct > 0) {
992 $tx_after_vat += $localtax2_tx_pct;
993 $tx_after_vat_without1 += $localtax2_tx_pct;
995 $tx_before_vat += $localtax2_tx_pct;
996 $tx_before_vat_without1 += $localtax2_tx_pct;
998 $tx_before_vat += $tva_tx_pct;
999 $tx_before_vat_without1 += $tva_tx_pct;
1000 $tx_before_vat_without2 += $tva_tx_pct;
1001 if ($localtax1_type2 && $localtax1_tx_pct > 0) {
1002 $lt1 = (float)
price2num($ttc - $ttc / (1 + $tx_after_vat) * (1 + $tx_after_vat_without1),
'MT');
1004 if ($localtax2_type2 && $localtax2_tx_pct > 0) {
1005 $lt2 = (float)
price2num($ttc - $ttc / (1 + $tx_after_vat) * (1 + $tx_after_vat_without2),
'MT');
1011 $htplusbeforevat = $ttc - $lt1 - $lt2;
1013 if (!$localtax1_type2 && $localtax1_tx_pct > 0) {
1014 $lt1 = (float)
price2num($htplusbeforevat - $htplusbeforevat / (1 + $tx_before_vat) * (1 + $tx_before_vat_without1),
'MT');
1016 if (!$localtax2_type2 && $localtax2_tx_pct > 0) {
1017 $lt2 = (float)
price2num($htplusbeforevat - $htplusbeforevat / (1 + $tx_before_vat) * (1 + $tx_before_vat_without2),
'MT');
1023 $tva = ($ttc - $lt2 - $lt1) - ($ttc - $lt2 - $lt1) / (1 + $tva_tx_pct);
1024 $this->total_tva = (float)
price2num($tva,
'MT');
1025 $this->total_localtax1 = $lt1;
1026 $this->total_localtax2 = $lt2;
1027 $this->total_ht = (float)
price2num($this->total_ttc - $this->total_localtax1 - $this->total_localtax2 - $this->total_tva,
'MT');
1030 $this->multicurrency_total_ttc = (float)
price2num($amount * (
float) $this->multicurrency_tx,
'MT');
1031 $this->multicurrency_total_ht = (float)
price2num((
float) $amount / (1 + $tva_tx_pct) * (
float) $this->multicurrency_tx,
'MT');
1032 $this->multicurrency_total_tva = (float)
price2num($this->multicurrency_total_ttc - $this->multicurrency_total_ht,
'MT');
1033 } elseif ($amount_type == 0) {
1035 $this->total_ht = (float)
price2num($amount,
'MT');
1036 $this->total_tva = (float)
price2num((
float) $this->total_ht * $tva_tx_pct,
'MT');
1039 $this->multicurrency_total_ht = (float)
price2num($amount * (
float) $this->multicurrency_tx,
'MT');
1040 $this->multicurrency_total_tva = (float)
price2num(((
float) $amount * $tva_tx_pct) * (
float) $this->multicurrency_tx,
'MT');
1043 if ($localtax1_type2 == 0) {
1044 $this->total_localtax1 = (float)
price2num((
float) $this->total_ht * $localtax1_tx_pct,
'MT');
1045 } elseif ($localtax1_type2 == 1) {
1046 $this->total_localtax1 = (float)
price2num(((
float) $this->total_ht + (
float) $this->total_tva) * $localtax1_tx_pct,
'MT');
1049 if ($localtax2_type2 == 0) {
1050 $this->total_localtax2 = (float)
price2num((
float) $this->total_ht * $localtax2_tx_pct,
'MT');
1051 } elseif ($localtax2_type2 == 1) {
1052 $this->total_localtax2 = (float)
price2num(((
float) $this->total_ht + (
float) $this->total_tva) * $localtax2_tx_pct,
'MT');
1057 $this->amount_ht = $this->total_ht;
1058 $this->amount_tva = $this->total_tva;
1059 $this->amount_ttc = $this->total_ttc;
1060 $this->multicurrency_amount_ht = $this->multicurrency_total_ht;
1061 $this->multicurrency_amount_tva = $this->multicurrency_total_tva;
1062 $this->multicurrency_amount_ttc = $this->multicurrency_total_ttc;
1064 $this->tva_tx = $tva_tx;
1065 $this->localtax1_tx = $localtax1_tx;
1066 $this->localtax1_type = $localtax1_type;
1067 $this->localtax2_tx = $localtax2_tx;
1068 $this->localtax2_type = $localtax2_type;
1073 if (empty($this->total_ttc)) {
1076 $this->total_ttc = (float)
price2num((
float) $this->total_ht + (float) $this->total_tva + $this->total_localtax1 + $this->total_localtax2,
'MT');
1077 $this->multicurrency_total_ttc = (float)
price2num(((
float) $this->total_ht + (float) $this->total_tva + $this->total_localtax1 + $this->total_localtax2) * (float) $this->multicurrency_tx,
'MT');
1080 $this->amount_ttc = $this->total_ttc;
1081 $this->multicurrency_amount_ttc = $this->multicurrency_total_ttc;
1101 $newdiscount1->fk_facture_source = $this->fk_facture_source;
1102 $newdiscount2->fk_facture_source = $this->fk_facture_source;
1103 $newdiscount1->fk_facture = $this->fk_facture;
1104 $newdiscount2->fk_facture = $this->fk_facture;
1105 $newdiscount1->fk_facture_line = $this->fk_facture_line;
1106 $newdiscount2->fk_facture_line = $this->fk_facture_line;
1107 $newdiscount1->fk_invoice_supplier_source = $this->fk_invoice_supplier_source;
1108 $newdiscount2->fk_invoice_supplier_source = $this->fk_invoice_supplier_source;
1109 $newdiscount1->fk_invoice_supplier = $this->fk_invoice_supplier;
1110 $newdiscount2->fk_invoice_supplier = $this->fk_invoice_supplier;
1111 $newdiscount1->fk_invoice_supplier_line = $this->fk_invoice_supplier_line;
1112 $newdiscount2->fk_invoice_supplier_line = $this->fk_invoice_supplier_line;
1114 $newdiscount1->description = $this->description;
1115 $newdiscount2->description = $this->description;
1117 $newdiscount1->description = $this->
description.
' (1)';
1118 $newdiscount2->description = $this->
description.
' (2)';
1120 $newdiscount1->fk_user = $this->fk_user;
1121 $newdiscount2->fk_user = $this->fk_user;
1122 $newdiscount1->fk_soc = $this->fk_soc;
1123 $newdiscount1->socid = $this->socid;
1124 $newdiscount2->fk_soc = $this->fk_soc;
1125 $newdiscount2->socid = $this->socid;
1126 $newdiscount1->discount_type = $this->discount_type;
1127 $newdiscount2->discount_type = $this->discount_type;
1128 $newdiscount1->datec = $this->datec;
1129 $newdiscount2->datec = $this->datec;
1130 $newdiscount1->tva_tx = $this->tva_tx;
1131 $newdiscount2->tva_tx = $this->tva_tx;
1132 $newdiscount1->localtax1_tx = $this->localtax1_tx;
1133 $newdiscount2->localtax1_tx = $this->localtax1_tx;
1134 $newdiscount1->localtax2_tx = $this->localtax2_tx;
1135 $newdiscount2->localtax2_tx = $this->localtax2_tx;
1136 $newdiscount1->vat_src_code = $this->vat_src_code;
1137 $newdiscount2->vat_src_code = $this->vat_src_code;
1139 $newdiscount1->generateFromAmount($amount_ttc1, 1, $newdiscount1->tva_tx, $newdiscount1->localtax1_tx, $newdiscount1->localtax2_tx, $this->localtax1_type, $this->localtax2_type);
1140 $newdiscount2->generateFromAmount($amount_ttc2, 1, $newdiscount2->tva_tx, $newdiscount2->localtax1_tx, $newdiscount2->localtax2_tx, $this->localtax1_type, $this->localtax2_type);
1142 return array($newdiscount1, $newdiscount2);