dolibarr 23.0.3
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
152 public $description;
153
157 public $date_start;
158
162 public $date_end;
163
167 public $fk_code_ventilation;
168
172 public $skip_update_total; // Skip update price total for special lines
173
177 public $situation_percent;
178
182 public $fk_prev_id;
183
188 public $vat_src_code;
189
194 public $tva_tx;
195
200 public $localtax1_tx;
201
206 public $localtax2_tx;
207
212 public $qty;
213
218 public $remise_percent;
219
224 public $pa_ht;
225
230 public $total_ht;
231
236 public $total_ttc;
237
242 public $total_tva;
243
248 public $total_localtax1;
249
254 public $total_localtax2;
255
259 public $fk_product;
260
265 public $product_type;
266
271 public $product_label;
272
279 public $info_bits;
280
285 public $fk_remise_except;
286
290 public $fk_parent_line;
291
295 public $special_code;
296
300 public $rang;
301
306 public $localtax1_type;
307
312 public $localtax2_type;
313
314
320 public function __construct($db)
321 {
322 $this->db = $db;
323 }
324
331 public function fetch($rowid)
332 {
333 $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';
334 $sql .= ', f.localtax1_type, f.localtax2_type, f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2, f.fk_remise_except';
335 $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';
336 $sql .= ', p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc';
337 $sql .= ', f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, multicurrency_total_ttc';
338 $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
339 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
340 $sql .= ' WHERE f.rowid = '.((int) $rowid);
341 $sql .= ' ORDER BY f.rang, f.rowid';
342
343 $query = $this->db->query($sql);
344
345 if (!$query) {
346 $this->errors[] = $this->db->error();
347 return -1;
348 }
349
350 if (!$this->db->num_rows($query)) {
351 return 0;
352 }
353
354 $obj = $this->db->fetch_object($query);
355
356 $this->id = $obj->rowid;
357 $this->rowid = $obj->rowid;
358 $this->fk_facture_fourn = $obj->fk_facture_fourn;
359 $this->description = $obj->line_desc;
360 $this->desc = $obj->line_desc;
361 $this->date_start = $obj->date_start;
362 $this->date_end = $obj->date_end;
363 $this->product_ref = $obj->product_ref;
364 $this->ref_supplier = $obj->ref_supplier;
365 $this->product_desc = $obj->product_desc;
366
367 $this->subprice = $obj->pu_ht;
368 $this->pu_ht = $obj->pu_ht;
369 $this->subprice_ttc = $obj->pu_ttc;
370 $this->pu_ttc = $obj->pu_ttc;
371 $this->tva_tx = $obj->tva_tx;
372 $this->localtax1_tx = $obj->localtax1_tx;
373 $this->localtax2_tx = $obj->localtax2_tx;
374 $this->localtax1_type = $obj->localtax1_type;
375 $this->localtax2_type = $obj->localtax2_type;
376
377 $this->qty = $obj->qty;
378 $this->remise_percent = $obj->remise_percent;
379 $this->fk_remise_except = $obj->fk_remise_except;
380 //$this->tva = $obj->total_tva; // deprecated
381 $this->total_ht = $obj->total_ht;
382 $this->total_tva = $obj->total_tva;
383 $this->total_localtax1 = $obj->total_localtax1;
384 $this->total_localtax2 = $obj->total_localtax2;
385 $this->total_ttc = $obj->total_ttc;
386 $this->fk_product = $obj->fk_product;
387 $this->product_type = $obj->product_type;
388 $this->product_label = $obj->product_label;
389 $this->label = $obj->product_label;
390 $this->info_bits = $obj->info_bits;
391 $this->fk_parent_line = $obj->fk_parent_line;
392 $this->special_code = $obj->special_code;
393 $this->rang = $obj->rang;
394 $this->fk_unit = $obj->fk_unit;
395
396 $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array();
397
398 $this->multicurrency_subprice = $obj->multicurrency_subprice;
399 $this->multicurrency_total_ht = $obj->multicurrency_total_ht;
400 $this->multicurrency_total_tva = $obj->multicurrency_total_tva;
401 $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
402
403 $this->fetch_optionals();
404
405 return 1;
406 }
407
414 public function delete($notrigger = 0)
415 {
416 global $user;
417
418 dol_syslog(get_class($this)."::deleteline rowid=".((int) $this->id), LOG_DEBUG);
419
420 $error = 0;
421
422 $this->db->begin();
423
424 if (!$notrigger) {
425 if ($this->call_trigger('LINEBILL_SUPPLIER_DELETE', $user) < 0) {
426 $error++;
427 }
428 }
429
430 $this->deleteObjectLinked();
431
432 // Remove extrafields
433 if (!$error) {
434 $result = $this->deleteExtraFields();
435 if ($result < 0) {
436 $error++;
437 dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
438 }
439 }
440
441 if (!$error) {
442 // Supprime ligne
443 $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';
444 $sql .= " WHERE rowid = ".((int) $this->id);
445 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
446 $resql = $this->db->query($sql);
447 if (!$resql) {
448 $error++;
449 $this->error = $this->db->lasterror();
450 }
451 }
452
453 if (!$error) {
454 $this->db->commit();
455 return 1;
456 } else {
457 $this->db->rollback();
458 return -1;
459 }
460 }
461
468 public function update($notrigger = 0)
469 {
470 global $user;
471
472 $pu = price2num($this->subprice);
473 $qty = price2num($this->qty);
474
475 // Check parameters
476 if (empty($this->qty)) {
477 $this->qty = 0;
478 }
479
480 if ($this->product_type < 0) {
481 return -1;
482 }
483
484 // Clean parameters
485 if (empty($this->remise_percent)) {
486 $this->remise_percent = 0;
487 }
488 if (empty($this->tva_tx)) {
489 $this->tva_tx = 0;
490 }
491 if (empty($this->localtax1_tx)) {
492 $this->localtax1_tx = 0;
493 }
494 if (empty($this->localtax2_tx)) {
495 $this->localtax2_tx = 0;
496 }
497
498 if (empty($this->pa_ht)) {
499 $this->pa_ht = 0;
500 }
501 if (empty($this->multicurrency_subprice)) {
502 $this->multicurrency_subprice = 0;
503 }
504 if (empty($this->multicurrency_total_ht)) {
505 $this->multicurrency_total_ht = 0;
506 }
507 if (empty($this->multicurrency_total_tva)) {
508 $this->multicurrency_total_tva = 0;
509 }
510 if (empty($this->multicurrency_total_ttc)) {
511 $this->multicurrency_total_ttc = 0;
512 }
513
514 $fk_product = (int) $this->fk_product;
515 $fk_unit = (int) $this->fk_unit;
516
517 $this->db->begin();
518
519 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
520 $sql .= " description = '".$this->db->escape(empty($this->description) ? $this->desc : $this->description)."'";
521 $sql .= ", ref = '".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'";
522 $sql .= ", date_start = ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null");
523 $sql .= ", date_end = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null");
524 $sql .= ", pu_ht = ".price2num($this->subprice);
525 $sql .= ", pu_ttc = ".price2num($this->subprice_ttc);
526 $sql .= ", qty = ".price2num($this->qty);
527 $sql .= ", remise_percent = ".price2num($this->remise_percent);
528 if ($this->fk_remise_except > 0) {
529 $sql .= ", fk_remise_except=".((int) $this->fk_remise_except);
530 } else {
531 $sql .= ", fk_remise_except=null";
532 }
533 $sql .= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'";
534 $sql .= ", tva_tx = ".price2num($this->tva_tx);
535 $sql .= ", localtax1_tx = ".price2num($this->localtax1_tx);
536 $sql .= ", localtax2_tx = ".price2num($this->localtax2_tx);
537 $sql .= ", localtax1_type = '".$this->db->escape((string) $this->localtax1_type)."'";
538 $sql .= ", localtax2_type = '".$this->db->escape((string) $this->localtax2_type)."'";
539 $sql .= ", total_ht = ".price2num($this->total_ht);
540 $sql .= ", tva= ".price2num($this->total_tva);
541 $sql .= ", total_localtax1= ".price2num($this->total_localtax1);
542 $sql .= ", total_localtax2= ".price2num($this->total_localtax2);
543 $sql .= ", total_ttc = ".price2num($this->total_ttc);
544 $sql .= ", fk_product = ".($fk_product > 0 ? (int) $fk_product : 'null');
545 $sql .= ", product_type = ".((int) $this->product_type);
546 $sql .= ", info_bits = ".((int) $this->info_bits);
547 $sql .= ", fk_unit = ".($fk_unit > 0 ? (int) $fk_unit : 'null');
548
549 if (!empty($this->rang)) {
550 $sql .= ", rang=".((int) $this->rang);
551 }
552
553 // Multicurrency
554 $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice);
555 $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht);
556 $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva);
557 $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc);
558
559 $sql .= " WHERE rowid = ".((int) $this->id);
560
561 dol_syslog(get_class($this)."::update", LOG_DEBUG);
562 $resql = $this->db->query($sql);
563
564 if (!$resql) {
565 $this->db->rollback();
566 $this->error = $this->db->lasterror();
567 return -1;
568 }
569
570 $this->rowid = $this->id;
571 $error = 0;
572
573 if (!$error) {
574 $result = $this->insertExtraFields();
575 if ($result < 0) {
576 $error++;
577 }
578 }
579
580 if (!$error && !$notrigger) {
581 // Call trigger
582 if ($this->call_trigger('LINEBILL_SUPPLIER_MODIFY', $user) < 0) {
583 $this->db->rollback();
584 return -1;
585 }
586 // End call triggers
587 }
588
589 if ($error) {
590 $this->db->rollback();
591 return -1;
592 }
593
594 $this->db->commit();
595 return 1;
596 }
597
605 public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0)
606 {
607 global $user, $langs;
608
609 $error = 0;
610
611 dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG);
612
613 // Clean parameters
614 $this->desc = trim($this->desc);
615 if (empty($this->tva_tx)) {
616 $this->tva_tx = 0;
617 }
618 if (empty($this->localtax1_tx)) {
619 $this->localtax1_tx = 0;
620 }
621 if (empty($this->localtax2_tx)) {
622 $this->localtax2_tx = 0;
623 }
624 if (empty($this->localtax1_type)) {
625 $this->localtax1_type = 0.0;
626 }
627 if (empty($this->localtax2_type)) {
628 $this->localtax2_type = 0.0;
629 }
630 if (empty($this->total_tva)) {
631 $this->total_tva = 0;
632 }
633 if (empty($this->total_localtax1)) {
634 $this->total_localtax1 = 0;
635 }
636 if (empty($this->total_localtax2)) {
637 $this->total_localtax2 = 0;
638 }
639 if (empty($this->rang)) {
640 $this->rang = 0;
641 }
642 if (empty($this->remise_percent)) {
643 $this->remise_percent = 0;
644 }
645 if (empty($this->info_bits)) {
646 $this->info_bits = 0;
647 }
648 if (empty($this->subprice)) {
649 $this->subprice = 0;
650 }
651 if (empty($this->special_code)) {
652 $this->special_code = 0;
653 }
654 if (empty($this->fk_parent_line)) {
655 $this->fk_parent_line = 0;
656 }
657 if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') {
658 $this->situation_percent = 100;
659 }
660
661 if (empty($this->pa_ht)) {
662 $this->pa_ht = 0;
663 }
664 if (empty($this->multicurrency_subprice)) {
665 $this->multicurrency_subprice = 0;
666 }
667 if (empty($this->multicurrency_total_ht)) {
668 $this->multicurrency_total_ht = 0;
669 }
670 if (empty($this->multicurrency_total_tva)) {
671 $this->multicurrency_total_tva = 0;
672 }
673 if (empty($this->multicurrency_total_ttc)) {
674 $this->multicurrency_total_ttc = 0;
675 }
676
677
678 // Check parameters
679 if ($this->product_type < 0) {
680 $this->error = 'ErrorProductTypeMustBe0orMore';
681 return -1;
682 }
683 if (!empty($this->fk_product) && $this->fk_product > 0) {
684 // Check product exists
685 $result = Product::isExistingObject('product', $this->fk_product);
686 if ($result <= 0) {
687 $this->error = 'ErrorProductIdDoesNotExists';
688 return -1;
689 }
690 }
691
692 $this->db->begin();
693
694 // Insertion dans base de la ligne
695 $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
696 $sql .= ' (fk_facture_fourn, fk_parent_line, label, description, ref, qty,';
697 $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
698 $sql .= ' fk_product, product_type, remise_percent, fk_remise_except, pu_ht, pu_ttc,';
699 $sql .= ' date_start, date_end, fk_code_ventilation, rang, special_code,';
700 $sql .= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit';
701 $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
702 $sql .= ')';
703 $sql .= " VALUES (".$this->fk_facture_fourn.",";
704 $sql .= " ".($this->fk_parent_line > 0 ? "'".$this->db->escape((string) $this->fk_parent_line)."'" : "null").",";
705 $product_label
706 = !empty($this->product_label)
707 ? $this->product_label :
708 (!empty($this->label) ? $this->label : null);
709 $sql .= " ".(!empty($product_label) ? "'".$this->db->escape($product_label)."'" : "null").",";
710 $sql .= " '".$this->db->escape($this->desc ? $this->desc : $this->description)."',";
711 $sql .= " '".$this->db->escape($this->ref_supplier)."',";
712 $sql .= " ".price2num($this->qty).",";
713
714 $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").",";
715 $sql .= " ".price2num($this->tva_tx).",";
716 $sql .= " ".price2num($this->localtax1_tx).",";
717 $sql .= " ".price2num($this->localtax2_tx).",";
718 $sql .= " '".$this->db->escape((string) $this->localtax1_type)."',";
719 $sql .= " '".$this->db->escape((string) $this->localtax2_type)."',";
720 $sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").',';
721 $sql .= " ".((int) $this->product_type).",";
722 $sql .= " ".price2num($this->remise_percent).",";
723 $sql .= ' '.(!empty($this->fk_remise_except) ? ((int) $this->fk_remise_except) : "null").',';
724 $sql .= " ".price2num($this->subprice).",";
725 $sql .= " ".(!empty($this->qty) ? price2num($this->total_ttc / $this->qty) : price2num($this->total_ttc)).",";
726 $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").",";
727 $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").",";
728 $sql .= ' '.(!empty($this->fk_code_ventilation) ? $this->fk_code_ventilation : 0).',';
729 $sql .= ' '.((int) $this->rang).',';
730 $sql .= ' '.((int) $this->special_code).',';
731 $sql .= " ".((int) $this->info_bits).",";
732 $sql .= " ".price2num($this->total_ht).",";
733 $sql .= " ".price2num($this->total_tva).",";
734 $sql .= " ".price2num($this->total_ttc).",";
735 $sql .= " ".price2num($this->total_localtax1).",";
736 $sql .= " ".price2num($this->total_localtax2);
737 $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
738 $sql .= ", ".(int) $this->fk_multicurrency;
739 $sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
740 $sql .= ", ".price2num($this->multicurrency_subprice);
741 $sql .= ", ".price2num($this->multicurrency_total_ht);
742 $sql .= ", ".price2num($this->multicurrency_total_tva);
743 $sql .= ", ".price2num($this->multicurrency_total_ttc);
744 $sql .= ')';
745
746 $resql = $this->db->query($sql);
747 if ($resql) {
748 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
749 $this->rowid = $this->id; // backward compatibility
750
751 if (!$error) {
752 $result = $this->insertExtraFields();
753 if ($result < 0) {
754 $error++;
755 }
756 }
757
758 // Si fk_remise_except defini, on lie la remise a la facture
759 // ce qui la flague comme "consommee".
760 if ($this->fk_remise_except) {
761 $discount = new DiscountAbsolute($this->db);
762 $result = $discount->fetch($this->fk_remise_except);
763 if ($result >= 0) {
764 // Check if discount was found
765 if ($result > 0) {
766 // Check if discount not already affected to another invoice
767 if ($discount->fk_facture_line > 0) {
768 if (empty($noerrorifdiscountalreadylinked)) {
769 $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id);
770 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
771 $this->db->rollback();
772 return -3;
773 }
774 } else {
775 $result = $discount->link_to_invoice($this->id, 0);
776 if ($result < 0) {
777 $this->error = $discount->error;
778 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
779 $this->db->rollback();
780 return -3;
781 }
782 }
783 } else {
784 $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded");
785 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
786 $this->db->rollback();
787 return -3;
788 }
789 } else {
790 $this->error = $discount->error;
791 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
792 $this->db->rollback();
793 return -3;
794 }
795 }
796
797 if (!$error && !$notrigger) {
798 // Call trigger
799 $result = $this->call_trigger('LINEBILL_SUPPLIER_CREATE', $user);
800 if ($result < 0) {
801 $this->db->rollback();
802 return -2;
803 }
804 // End call triggers
805 }
806
807 if (!$error) {
808 $this->db->commit();
809 return $this->id;
810 }
811
812 foreach ($this->errors as $errmsg) {
813 dol_syslog(get_class($this)."::insert ".$errmsg, LOG_ERR);
814 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
815 }
816
817 $this->db->rollback();
818 return -3;
819 } else {
820 $this->error = $this->db->error();
821 $this->db->rollback();
822 return -2;
823 }
824 }
825
826 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
832 public function update_total()
833 {
834 // phpcs:enable
835 $this->db->begin();
836
837 // Mise a jour ligne en base
838 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
839 $sql .= " total_ht = ".price2num($this->total_ht);
840 $sql .= ", tva= ".price2num($this->total_tva);
841 $sql .= ", total_localtax1 = ".price2num($this->total_localtax1);
842 $sql .= ", total_localtax2 = ".price2num($this->total_localtax2);
843 $sql .= ", total_ttc = ".price2num($this->total_ttc);
844 $sql .= " WHERE rowid = ".((int) $this->id);
845
846 dol_syslog("FactureFournisseurLigne.class.php::update_total", LOG_DEBUG);
847
848 $resql = $this->db->query($sql);
849 if ($resql) {
850 $this->db->commit();
851 return 1;
852 } else {
853 $this->error = $this->db->error();
854 $this->db->rollback();
855 return -2;
856 }
857 }
858}
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.