dolibarr 23.0.4
fournisseur.facture.ligne.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
5 * Copyright (C) 2005 Marc Barilley <marc@ocebo.com>
6 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2013-2019 Philippe Grand <philippe.grand@atoo-net.com>
9 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
10 * Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
11 * Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
12 * Copyright (C) 2015-2022 Ferran Marcet <fmarcet@2byte.es>
13 * Copyright (C) 2016-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
14 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
15 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
16 * Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
17 * Copyright (C) 2023 Nick Fragoulis
18 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
19 * Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
20 *
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 3 of the License, or
24 * (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <https://www.gnu.org/licenses/>.
33 */
34
41require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
42require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
43require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
44
45if (isModEnabled('accounting')) {
46 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
47 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
48}
49
54{
58 public $element = 'facture_fourn_det';
59
63 public $table_element = 'facture_fourn_det';
64
68 public $parent_element = 'facture_fourn';
69
73 public $fk_parent_attribute = 'fk_facture_fourn';
74
78 public $oldline;
79
85 public $ref;
86
91 public $product_ref;
92
98 public $ref_supplier;
99
104 public $product_desc;
105
112 public $pu_ht;
113
118 public $subprice;
119
126 public $pu_ttc;
127
132 public $subprice_ttc;
133
138 public $fk_facture_fourn;
139
145 public $label;
146
151 public $libelle;
152
158 public $description;
159
163 public $date_start;
164
168 public $date_end;
169
173 public $fk_code_ventilation;
174
178 public $skip_update_total; // Skip update price total for special lines
179
183 public $situation_percent;
184
188 public $fk_prev_id;
189
194 public $vat_src_code;
195
200 public $tva_tx;
201
206 public $localtax1_tx;
207
212 public $localtax2_tx;
213
218 public $qty;
219
224 public $remise_percent;
225
230 public $pa_ht;
231
236 public $total_ht;
237
242 public $total_ttc;
243
248 public $total_tva;
249
254 public $total_localtax1;
255
260 public $total_localtax2;
261
265 public $fk_product;
266
271 public $product_type;
272
277 public $product_label;
278
285 public $info_bits;
286
291 public $fk_remise_except;
292
296 public $fk_parent_line;
297
301 public $special_code;
302
306 public $rang;
307
312 public $localtax1_type;
313
318 public $localtax2_type;
319
320
326 public function __construct($db)
327 {
328 $this->db = $db;
329 }
330
337 public function fetch($rowid)
338 {
339 $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description as line_desc, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx';
340 $sql .= ', f.localtax1_type, f.localtax2_type, f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2, f.fk_remise_except';
341 $sql .= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_facture_fourn, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit, f.extraparams';
342 $sql .= ', p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc';
343 $sql .= ', f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, multicurrency_total_ttc';
344 $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
345 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
346 $sql .= ' WHERE f.rowid = '.((int) $rowid);
347 $sql .= ' ORDER BY f.rang, f.rowid';
348
349 $query = $this->db->query($sql);
350
351 if (!$query) {
352 $this->errors[] = $this->db->error();
353 return -1;
354 }
355
356 if (!$this->db->num_rows($query)) {
357 return 0;
358 }
359
360 $obj = $this->db->fetch_object($query);
361
362 $this->id = $obj->rowid;
363 $this->rowid = $obj->rowid;
364 $this->fk_facture_fourn = $obj->fk_facture_fourn;
365 $this->description = $obj->line_desc;
366 $this->desc = $obj->line_desc;
367 $this->date_start = $obj->date_start;
368 $this->date_end = $obj->date_end;
369 $this->product_ref = $obj->product_ref;
370 $this->ref_supplier = $obj->ref_supplier;
371 $this->product_desc = $obj->product_desc;
372
373 $this->subprice = $obj->pu_ht;
374 $this->pu_ht = $obj->pu_ht;
375 $this->subprice_ttc = $obj->pu_ttc;
376 $this->pu_ttc = $obj->pu_ttc;
377 $this->tva_tx = $obj->tva_tx;
378 $this->localtax1_tx = $obj->localtax1_tx;
379 $this->localtax2_tx = $obj->localtax2_tx;
380 $this->localtax1_type = $obj->localtax1_type;
381 $this->localtax2_type = $obj->localtax2_type;
382
383 $this->qty = $obj->qty;
384 $this->remise_percent = $obj->remise_percent;
385 $this->fk_remise_except = $obj->fk_remise_except;
386 //$this->tva = $obj->total_tva; // deprecated
387 $this->total_ht = $obj->total_ht;
388 $this->total_tva = $obj->total_tva;
389 $this->total_localtax1 = $obj->total_localtax1;
390 $this->total_localtax2 = $obj->total_localtax2;
391 $this->total_ttc = $obj->total_ttc;
392 $this->fk_product = $obj->fk_product;
393 $this->product_type = $obj->product_type;
394 $this->product_label = $obj->product_label;
395 $this->label = $obj->product_label;
396 $this->info_bits = $obj->info_bits;
397 $this->fk_parent_line = $obj->fk_parent_line;
398 $this->special_code = $obj->special_code;
399 $this->rang = $obj->rang;
400 $this->fk_unit = $obj->fk_unit;
401
402 $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array();
403
404 $this->multicurrency_subprice = $obj->multicurrency_subprice;
405 $this->multicurrency_total_ht = $obj->multicurrency_total_ht;
406 $this->multicurrency_total_tva = $obj->multicurrency_total_tva;
407 $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
408
409 $this->fetch_optionals();
410
411 return 1;
412 }
413
420 public function delete($notrigger = 0)
421 {
422 global $user;
423
424 dol_syslog(get_class($this)."::deleteline rowid=".((int) $this->id), LOG_DEBUG);
425
426 $error = 0;
427
428 $this->db->begin();
429
430 if (!$notrigger) {
431 if ($this->call_trigger('LINEBILL_SUPPLIER_DELETE', $user) < 0) {
432 $error++;
433 }
434 }
435
436 $this->deleteObjectLinked();
437
438 // Remove extrafields
439 if (!$error) {
440 $result = $this->deleteExtraFields();
441 if ($result < 0) {
442 $error++;
443 dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
444 }
445 }
446
447 if (!$error) {
448 // Supprime ligne
449 $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';
450 $sql .= " WHERE rowid = ".((int) $this->id);
451 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
452 $resql = $this->db->query($sql);
453 if (!$resql) {
454 $error++;
455 $this->error = $this->db->lasterror();
456 }
457 }
458
459 if (!$error) {
460 $this->db->commit();
461 return 1;
462 } else {
463 $this->db->rollback();
464 return -1;
465 }
466 }
467
474 public function update($notrigger = 0)
475 {
476 global $user;
477
478 $pu = price2num($this->subprice);
479 $qty = price2num($this->qty);
480
481 // Check parameters
482 if (empty($this->qty)) {
483 $this->qty = 0;
484 }
485
486 if ($this->product_type < 0) {
487 return -1;
488 }
489
490 // Clean parameters
491 if (empty($this->remise_percent)) {
492 $this->remise_percent = 0;
493 }
494 if (empty($this->tva_tx)) {
495 $this->tva_tx = 0;
496 }
497 if (empty($this->localtax1_tx)) {
498 $this->localtax1_tx = 0;
499 }
500 if (empty($this->localtax2_tx)) {
501 $this->localtax2_tx = 0;
502 }
503
504 if (empty($this->pa_ht)) {
505 $this->pa_ht = 0;
506 }
507 if (empty($this->multicurrency_subprice)) {
508 $this->multicurrency_subprice = 0;
509 }
510 if (empty($this->multicurrency_total_ht)) {
511 $this->multicurrency_total_ht = 0;
512 }
513 if (empty($this->multicurrency_total_tva)) {
514 $this->multicurrency_total_tva = 0;
515 }
516 if (empty($this->multicurrency_total_ttc)) {
517 $this->multicurrency_total_ttc = 0;
518 }
519
520 $fk_product = (int) $this->fk_product;
521 $fk_unit = (int) $this->fk_unit;
522
523 $this->db->begin();
524
525 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
526 $sql .= " description = '".$this->db->escape(empty($this->description) ? $this->desc : $this->description)."'";
527 $sql .= ", ref = '".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'";
528 $sql .= ", date_start = ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null");
529 $sql .= ", date_end = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null");
530 $sql .= ", pu_ht = ".price2num($this->subprice);
531 $sql .= ", pu_ttc = ".price2num($this->subprice_ttc);
532 $sql .= ", qty = ".price2num($this->qty);
533 $sql .= ", remise_percent = ".price2num($this->remise_percent);
534 if ($this->fk_remise_except > 0) {
535 $sql .= ", fk_remise_except=".((int) $this->fk_remise_except);
536 } else {
537 $sql .= ", fk_remise_except=null";
538 }
539 $sql .= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'";
540 $sql .= ", tva_tx = ".price2num($this->tva_tx);
541 $sql .= ", localtax1_tx = ".price2num($this->localtax1_tx);
542 $sql .= ", localtax2_tx = ".price2num($this->localtax2_tx);
543 $sql .= ", localtax1_type = '".$this->db->escape((string) $this->localtax1_type)."'";
544 $sql .= ", localtax2_type = '".$this->db->escape((string) $this->localtax2_type)."'";
545 $sql .= ", total_ht = ".price2num($this->total_ht);
546 $sql .= ", tva= ".price2num($this->total_tva);
547 $sql .= ", total_localtax1= ".price2num($this->total_localtax1);
548 $sql .= ", total_localtax2= ".price2num($this->total_localtax2);
549 $sql .= ", total_ttc = ".price2num($this->total_ttc);
550 $sql .= ", fk_product = ".($fk_product > 0 ? (int) $fk_product : 'null');
551 $sql .= ", product_type = ".((int) $this->product_type);
552 $sql .= ", info_bits = ".((int) $this->info_bits);
553 $sql .= ", fk_unit = ".($fk_unit > 0 ? (int) $fk_unit : 'null');
554
555 if (!empty($this->rang)) {
556 $sql .= ", rang=".((int) $this->rang);
557 }
558
559 // Multicurrency
560 $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice);
561 $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht);
562 $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva);
563 $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc);
564
565 $sql .= " WHERE rowid = ".((int) $this->id);
566
567 dol_syslog(get_class($this)."::update", LOG_DEBUG);
568 $resql = $this->db->query($sql);
569
570 if (!$resql) {
571 $this->db->rollback();
572 $this->error = $this->db->lasterror();
573 return -1;
574 }
575
576 $this->rowid = $this->id;
577 $error = 0;
578
579 if (!$error) {
580 $result = $this->insertExtraFields();
581 if ($result < 0) {
582 $error++;
583 }
584 }
585
586 if (!$error && !$notrigger) {
587 // Call trigger
588 if ($this->call_trigger('LINEBILL_SUPPLIER_MODIFY', $user) < 0) {
589 $this->db->rollback();
590 return -1;
591 }
592 // End call triggers
593 }
594
595 if ($error) {
596 $this->db->rollback();
597 return -1;
598 }
599
600 $this->db->commit();
601 return 1;
602 }
603
611 public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0)
612 {
613 global $user, $langs;
614
615 $error = 0;
616
617 dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG);
618
619 // Clean parameters
620 $this->desc = trim($this->desc);
621 if (empty($this->tva_tx)) {
622 $this->tva_tx = 0;
623 }
624 if (empty($this->localtax1_tx)) {
625 $this->localtax1_tx = 0;
626 }
627 if (empty($this->localtax2_tx)) {
628 $this->localtax2_tx = 0;
629 }
630 if (empty($this->localtax1_type)) {
631 $this->localtax1_type = 0.0;
632 }
633 if (empty($this->localtax2_type)) {
634 $this->localtax2_type = 0.0;
635 }
636 if (empty($this->total_tva)) {
637 $this->total_tva = 0;
638 }
639 if (empty($this->total_localtax1)) {
640 $this->total_localtax1 = 0;
641 }
642 if (empty($this->total_localtax2)) {
643 $this->total_localtax2 = 0;
644 }
645 if (empty($this->rang)) {
646 $this->rang = 0;
647 }
648 if (empty($this->remise_percent)) {
649 $this->remise_percent = 0;
650 }
651 if (empty($this->info_bits)) {
652 $this->info_bits = 0;
653 }
654 if (empty($this->subprice)) {
655 $this->subprice = 0;
656 }
657 if (empty($this->special_code)) {
658 $this->special_code = 0;
659 }
660 if (empty($this->fk_parent_line)) {
661 $this->fk_parent_line = 0;
662 }
663 if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') {
664 $this->situation_percent = 100;
665 }
666
667 if (empty($this->pa_ht)) {
668 $this->pa_ht = 0;
669 }
670 if (empty($this->multicurrency_subprice)) {
671 $this->multicurrency_subprice = 0;
672 }
673 if (empty($this->multicurrency_total_ht)) {
674 $this->multicurrency_total_ht = 0;
675 }
676 if (empty($this->multicurrency_total_tva)) {
677 $this->multicurrency_total_tva = 0;
678 }
679 if (empty($this->multicurrency_total_ttc)) {
680 $this->multicurrency_total_ttc = 0;
681 }
682
683
684 // Check parameters
685 if ($this->product_type < 0) {
686 $this->error = 'ErrorProductTypeMustBe0orMore';
687 return -1;
688 }
689 if (!empty($this->fk_product) && $this->fk_product > 0) {
690 // Check product exists
691 $result = Product::isExistingObject('product', $this->fk_product);
692 if ($result <= 0) {
693 $this->error = 'ErrorProductIdDoesNotExists';
694 return -1;
695 }
696 }
697
698 $this->db->begin();
699
700 // Insertion dans base de la ligne
701 $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
702 $sql .= ' (fk_facture_fourn, fk_parent_line, label, description, ref, qty,';
703 $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
704 $sql .= ' fk_product, product_type, remise_percent, fk_remise_except, pu_ht, pu_ttc,';
705 $sql .= ' date_start, date_end, fk_code_ventilation, rang, special_code,';
706 $sql .= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit';
707 $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
708 $sql .= ')';
709 $sql .= " VALUES (".$this->fk_facture_fourn.",";
710 $sql .= " ".($this->fk_parent_line > 0 ? "'".$this->db->escape((string) $this->fk_parent_line)."'" : "null").",";
711 $product_label
712 = !empty($this->product_label)
713 ? $this->product_label :
714 (!empty($this->label) ? $this->label : null);
715 $sql .= " ".(!empty($product_label) ? "'".$this->db->escape($product_label)."'" : "null").",";
716 $sql .= " '".$this->db->escape($this->desc ? $this->desc : $this->description)."',";
717 $sql .= " '".$this->db->escape($this->ref_supplier)."',";
718 $sql .= " ".price2num($this->qty).",";
719
720 $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").",";
721 $sql .= " ".price2num($this->tva_tx).",";
722 $sql .= " ".price2num($this->localtax1_tx).",";
723 $sql .= " ".price2num($this->localtax2_tx).",";
724 $sql .= " '".$this->db->escape((string) $this->localtax1_type)."',";
725 $sql .= " '".$this->db->escape((string) $this->localtax2_type)."',";
726 $sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").',';
727 $sql .= " ".((int) $this->product_type).",";
728 $sql .= " ".price2num($this->remise_percent).",";
729 $sql .= ' '.(!empty($this->fk_remise_except) ? ((int) $this->fk_remise_except) : "null").',';
730 $sql .= " ".price2num($this->subprice).",";
731 $sql .= " ".(!empty($this->qty) ? price2num($this->total_ttc / $this->qty) : price2num($this->total_ttc)).",";
732 $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").",";
733 $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").",";
734 $sql .= ' '.(!empty($this->fk_code_ventilation) ? $this->fk_code_ventilation : 0).',';
735 $sql .= ' '.((int) $this->rang).',';
736 $sql .= ' '.((int) $this->special_code).',';
737 $sql .= " ".((int) $this->info_bits).",";
738 $sql .= " ".price2num($this->total_ht).",";
739 $sql .= " ".price2num($this->total_tva).",";
740 $sql .= " ".price2num($this->total_ttc).",";
741 $sql .= " ".price2num($this->total_localtax1).",";
742 $sql .= " ".price2num($this->total_localtax2);
743 $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
744 $sql .= ", ".(int) $this->fk_multicurrency;
745 $sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
746 $sql .= ", ".price2num($this->multicurrency_subprice);
747 $sql .= ", ".price2num($this->multicurrency_total_ht);
748 $sql .= ", ".price2num($this->multicurrency_total_tva);
749 $sql .= ", ".price2num($this->multicurrency_total_ttc);
750 $sql .= ')';
751
752 $resql = $this->db->query($sql);
753 if ($resql) {
754 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
755 $this->rowid = $this->id; // backward compatibility
756
757 if (!$error) {
758 $result = $this->insertExtraFields();
759 if ($result < 0) {
760 $error++;
761 }
762 }
763
764 // Si fk_remise_except defini, on lie la remise a la facture
765 // ce qui la flague comme "consommee".
766 if ($this->fk_remise_except) {
767 $discount = new DiscountAbsolute($this->db);
768 $result = $discount->fetch($this->fk_remise_except);
769 if ($result >= 0) {
770 // Check if discount was found
771 if ($result > 0) {
772 // Check if discount not already affected to another invoice
773 if ($discount->fk_facture_line > 0) {
774 if (empty($noerrorifdiscountalreadylinked)) {
775 $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id);
776 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
777 $this->db->rollback();
778 return -3;
779 }
780 } else {
781 $result = $discount->link_to_invoice($this->id, 0);
782 if ($result < 0) {
783 $this->error = $discount->error;
784 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
785 $this->db->rollback();
786 return -3;
787 }
788 }
789 } else {
790 $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded");
791 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
792 $this->db->rollback();
793 return -3;
794 }
795 } else {
796 $this->error = $discount->error;
797 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
798 $this->db->rollback();
799 return -3;
800 }
801 }
802
803 if (!$error && !$notrigger) {
804 // Call trigger
805 $result = $this->call_trigger('LINEBILL_SUPPLIER_CREATE', $user);
806 if ($result < 0) {
807 $this->db->rollback();
808 return -2;
809 }
810 // End call triggers
811 }
812
813 if (!$error) {
814 $this->db->commit();
815 return $this->id;
816 }
817
818 foreach ($this->errors as $errmsg) {
819 dol_syslog(get_class($this)."::insert ".$errmsg, LOG_ERR);
820 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
821 }
822
823 $this->db->rollback();
824 return -3;
825 } else {
826 $this->error = $this->db->error();
827 $this->db->rollback();
828 return -2;
829 }
830 }
831
832 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
838 public function update_total()
839 {
840 // phpcs:enable
841 $this->db->begin();
842
843 // Mise a jour ligne en base
844 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
845 $sql .= " total_ht = ".price2num($this->total_ht);
846 $sql .= ", tva= ".price2num($this->total_tva);
847 $sql .= ", total_localtax1 = ".price2num($this->total_localtax1);
848 $sql .= ", total_localtax2 = ".price2num($this->total_localtax2);
849 $sql .= ", total_ttc = ".price2num($this->total_ttc);
850 $sql .= " WHERE rowid = ".((int) $this->id);
851
852 dol_syslog("FactureFournisseurLigne.class.php::update_total", LOG_DEBUG);
853
854 $resql = $this->db->query($sql);
855 if ($resql) {
856 $this->db->commit();
857 return 1;
858 } else {
859 $this->error = $this->db->error();
860 $this->db->rollback();
861 return -2;
862 }
863 }
864}
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteObjectLinked($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $rowid=0, $f_user=null, $notrigger=0)
Delete all links between an object $this.
static isExistingObject($element, $id, $ref='', $ref_ext='')
Check if an object id or ref exists If you don't need or want to instantiate the object and just need...
deleteExtraFields()
Delete all extra fields values for the current object.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage absolute discounts.
Class to manage line invoices.
fetch($rowid)
Retrieves a supplier invoice line.
update($notrigger=0)
Update a supplier invoice line.
insert($notrigger=0, $noerrorifdiscountalreadylinked=0)
Insert line into database.
update_total()
Mise a jour de l'objet ligne de commande en base.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.