dolibarr 22.0.5
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-2024 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
124 public $pu_ttc;
125
126
131 public $fk_facture_fourn;
132
138 public $label;
139
145 public $description;
146
150 public $date_start;
154 public $date_end;
155
159 public $fk_code_ventilation;
160
164 public $skip_update_total; // Skip update price total for special lines
165
169 public $situation_percent;
170
174 public $fk_prev_id;
175
180 public $vat_src_code;
181
186 public $tva_tx;
187
192 public $localtax1_tx;
193
198 public $localtax2_tx;
199
204 public $qty;
205
210 public $remise_percent;
211
216 public $pa_ht;
217
222 public $total_ht;
223
228 public $total_ttc;
229
234 public $total_tva;
235
240 public $total_localtax1;
241
246 public $total_localtax2;
247
251 public $fk_product;
252
257 public $product_type;
258
263 public $product_label;
264
271 public $info_bits;
272
277 public $fk_remise_except;
278
282 public $fk_parent_line;
283
287 public $special_code;
288
292 public $rang;
293
298 public $localtax1_type;
299
304 public $localtax2_type;
305
306
312 public function __construct($db)
313 {
314 $this->db = $db;
315 }
316
323 public function fetch($rowid)
324 {
325 $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';
326 $sql .= ', f.localtax1_type, f.localtax2_type, f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2, f.fk_remise_except';
327 $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';
328 $sql .= ', p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc';
329 $sql .= ', f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, multicurrency_total_ttc';
330 $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
331 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
332 $sql .= ' WHERE f.rowid = '.((int) $rowid);
333 $sql .= ' ORDER BY f.rang, f.rowid';
334
335 $query = $this->db->query($sql);
336
337 if (!$query) {
338 $this->errors[] = $this->db->error();
339 return -1;
340 }
341
342 if (!$this->db->num_rows($query)) {
343 return 0;
344 }
345
346 $obj = $this->db->fetch_object($query);
347
348 $this->id = $obj->rowid;
349 $this->rowid = $obj->rowid;
350 $this->fk_facture_fourn = $obj->fk_facture_fourn;
351 $this->description = $obj->line_desc;
352 $this->desc = $obj->line_desc;
353 $this->date_start = $obj->date_start;
354 $this->date_end = $obj->date_end;
355 $this->product_ref = $obj->product_ref;
356 $this->ref_supplier = $obj->ref_supplier;
357 $this->product_desc = $obj->product_desc;
358
359 $this->subprice = $obj->pu_ht;
360 $this->pu_ht = $this->subprice;
361 $this->pu_ttc = $obj->pu_ttc;
362 $this->tva_tx = $obj->tva_tx;
363 $this->localtax1_tx = $obj->localtax1_tx;
364 $this->localtax2_tx = $obj->localtax2_tx;
365 $this->localtax1_type = $obj->localtax1_type;
366 $this->localtax2_type = $obj->localtax2_type;
367
368 $this->qty = $obj->qty;
369 $this->remise_percent = $obj->remise_percent;
370 $this->fk_remise_except = $obj->fk_remise_except;
371 //$this->tva = $obj->total_tva; // deprecated
372 $this->total_ht = $obj->total_ht;
373 $this->total_tva = $obj->total_tva;
374 $this->total_localtax1 = $obj->total_localtax1;
375 $this->total_localtax2 = $obj->total_localtax2;
376 $this->total_ttc = $obj->total_ttc;
377 $this->fk_product = $obj->fk_product;
378 $this->product_type = $obj->product_type;
379 $this->product_label = $obj->product_label;
380 $this->label = $obj->product_label;
381 $this->info_bits = $obj->info_bits;
382 $this->fk_parent_line = $obj->fk_parent_line;
383 $this->special_code = $obj->special_code;
384 $this->rang = $obj->rang;
385 $this->fk_unit = $obj->fk_unit;
386
387 $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array();
388
389 $this->multicurrency_subprice = $obj->multicurrency_subprice;
390 $this->multicurrency_total_ht = $obj->multicurrency_total_ht;
391 $this->multicurrency_total_tva = $obj->multicurrency_total_tva;
392 $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
393
394 $this->fetch_optionals();
395
396 return 1;
397 }
398
405 public function delete($notrigger = 0)
406 {
407 global $user;
408
409 dol_syslog(get_class($this)."::deleteline rowid=".((int) $this->id), LOG_DEBUG);
410
411 $error = 0;
412
413 $this->db->begin();
414
415 if (!$notrigger) {
416 if ($this->call_trigger('LINEBILL_SUPPLIER_DELETE', $user) < 0) {
417 $error++;
418 }
419 }
420
421 $this->deleteObjectLinked();
422
423 // Remove extrafields
424 if (!$error) {
425 $result = $this->deleteExtraFields();
426 if ($result < 0) {
427 $error++;
428 dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
429 }
430 }
431
432 if (!$error) {
433 // Supprime ligne
434 $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';
435 $sql .= " WHERE rowid = ".((int) $this->id);
436 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
437 $resql = $this->db->query($sql);
438 if (!$resql) {
439 $error++;
440 $this->error = $this->db->lasterror();
441 }
442 }
443
444 if (!$error) {
445 $this->db->commit();
446 return 1;
447 } else {
448 $this->db->rollback();
449 return -1;
450 }
451 }
452
459 public function update($notrigger = 0)
460 {
461 global $user;
462
463 $pu = price2num($this->subprice);
464 $qty = price2num($this->qty);
465
466 // Check parameters
467 if (empty($this->qty)) {
468 $this->qty = 0;
469 }
470
471 if ($this->product_type < 0) {
472 return -1;
473 }
474
475 // Clean parameters
476 if (empty($this->remise_percent)) {
477 $this->remise_percent = 0;
478 }
479 if (empty($this->tva_tx)) {
480 $this->tva_tx = 0;
481 }
482 if (empty($this->localtax1_tx)) {
483 $this->localtax1_tx = 0;
484 }
485 if (empty($this->localtax2_tx)) {
486 $this->localtax2_tx = 0;
487 }
488
489 if (empty($this->pa_ht)) {
490 $this->pa_ht = 0;
491 }
492 if (empty($this->multicurrency_subprice)) {
493 $this->multicurrency_subprice = 0;
494 }
495 if (empty($this->multicurrency_total_ht)) {
496 $this->multicurrency_total_ht = 0;
497 }
498 if (empty($this->multicurrency_total_tva)) {
499 $this->multicurrency_total_tva = 0;
500 }
501 if (empty($this->multicurrency_total_ttc)) {
502 $this->multicurrency_total_ttc = 0;
503 }
504
505 $fk_product = (int) $this->fk_product;
506 $fk_unit = (int) $this->fk_unit;
507
508 $this->db->begin();
509
510 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
511 $sql .= " description = '".$this->db->escape(empty($this->description) ? $this->desc : $this->description)."'";
512 $sql .= ", ref = '".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'";
513 $sql .= ", date_start = ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null");
514 $sql .= ", date_end = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null");
515 $sql .= ", pu_ht = ".price2num($this->subprice);
516 $sql .= ", pu_ttc = ".price2num($this->pu_ttc);
517 $sql .= ", qty = ".price2num($this->qty);
518 $sql .= ", remise_percent = ".price2num($this->remise_percent);
519 if ($this->fk_remise_except > 0) {
520 $sql .= ", fk_remise_except=".((int) $this->fk_remise_except);
521 } else {
522 $sql .= ", fk_remise_except=null";
523 }
524 $sql .= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'";
525 $sql .= ", tva_tx = ".price2num($this->tva_tx);
526 $sql .= ", localtax1_tx = ".price2num($this->localtax1_tx);
527 $sql .= ", localtax2_tx = ".price2num($this->localtax2_tx);
528 $sql .= ", localtax1_type = '".$this->db->escape((string) $this->localtax1_type)."'";
529 $sql .= ", localtax2_type = '".$this->db->escape((string) $this->localtax2_type)."'";
530 $sql .= ", total_ht = ".price2num($this->total_ht);
531 $sql .= ", tva= ".price2num($this->total_tva);
532 $sql .= ", total_localtax1= ".price2num($this->total_localtax1);
533 $sql .= ", total_localtax2= ".price2num($this->total_localtax2);
534 $sql .= ", total_ttc = ".price2num($this->total_ttc);
535 $sql .= ", fk_product = ".($fk_product > 0 ? (int) $fk_product : 'null');
536 $sql .= ", product_type = ".((int) $this->product_type);
537 $sql .= ", info_bits = ".((int) $this->info_bits);
538 $sql .= ", fk_unit = ".($fk_unit > 0 ? (int) $fk_unit : 'null');
539
540 if (!empty($this->rang)) {
541 $sql .= ", rang=".((int) $this->rang);
542 }
543
544 // Multicurrency
545 $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice);
546 $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht);
547 $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva);
548 $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc);
549
550 $sql .= " WHERE rowid = ".((int) $this->id);
551
552 dol_syslog(get_class($this)."::update", LOG_DEBUG);
553 $resql = $this->db->query($sql);
554
555 if (!$resql) {
556 $this->db->rollback();
557 $this->error = $this->db->lasterror();
558 return -1;
559 }
560
561 $this->rowid = $this->id;
562 $error = 0;
563
564 if (!$error) {
565 $result = $this->insertExtraFields();
566 if ($result < 0) {
567 $error++;
568 }
569 }
570
571 if (!$error && !$notrigger) {
572 // Call trigger
573 if ($this->call_trigger('LINEBILL_SUPPLIER_MODIFY', $user) < 0) {
574 $this->db->rollback();
575 return -1;
576 }
577 // End call triggers
578 }
579
580 if ($error) {
581 $this->db->rollback();
582 return -1;
583 }
584
585 $this->db->commit();
586 return 1;
587 }
588
596 public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0)
597 {
598 global $user, $langs;
599
600 $error = 0;
601
602 dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG);
603
604 // Clean parameters
605 $this->desc = trim($this->desc);
606 if (empty($this->tva_tx)) {
607 $this->tva_tx = 0;
608 }
609 if (empty($this->localtax1_tx)) {
610 $this->localtax1_tx = 0;
611 }
612 if (empty($this->localtax2_tx)) {
613 $this->localtax2_tx = 0;
614 }
615 if (empty($this->localtax1_type)) {
616 $this->localtax1_type = 0.0;
617 }
618 if (empty($this->localtax2_type)) {
619 $this->localtax2_type = 0.0;
620 }
621 if (empty($this->total_tva)) {
622 $this->total_tva = 0;
623 }
624 if (empty($this->total_localtax1)) {
625 $this->total_localtax1 = 0;
626 }
627 if (empty($this->total_localtax2)) {
628 $this->total_localtax2 = 0;
629 }
630 if (empty($this->rang)) {
631 $this->rang = 0;
632 }
633 if (empty($this->remise_percent)) {
634 $this->remise_percent = 0;
635 }
636 if (empty($this->info_bits)) {
637 $this->info_bits = 0;
638 }
639 if (empty($this->subprice)) {
640 $this->subprice = 0;
641 }
642 if (empty($this->special_code)) {
643 $this->special_code = 0;
644 }
645 if (empty($this->fk_parent_line)) {
646 $this->fk_parent_line = 0;
647 }
648 if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') {
649 $this->situation_percent = 100;
650 }
651
652 if (empty($this->pa_ht)) {
653 $this->pa_ht = 0;
654 }
655 if (empty($this->multicurrency_subprice)) {
656 $this->multicurrency_subprice = 0;
657 }
658 if (empty($this->multicurrency_total_ht)) {
659 $this->multicurrency_total_ht = 0;
660 }
661 if (empty($this->multicurrency_total_tva)) {
662 $this->multicurrency_total_tva = 0;
663 }
664 if (empty($this->multicurrency_total_ttc)) {
665 $this->multicurrency_total_ttc = 0;
666 }
667
668
669 // Check parameters
670 if ($this->product_type < 0) {
671 $this->error = 'ErrorProductTypeMustBe0orMore';
672 return -1;
673 }
674 if (!empty($this->fk_product) && $this->fk_product > 0) {
675 // Check product exists
676 $result = Product::isExistingObject('product', $this->fk_product);
677 if ($result <= 0) {
678 $this->error = 'ErrorProductIdDoesNotExists';
679 return -1;
680 }
681 }
682
683 $this->db->begin();
684
685 // Insertion dans base de la ligne
686 $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
687 $sql .= ' (fk_facture_fourn, fk_parent_line, label, description, ref, qty,';
688 $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
689 $sql .= ' fk_product, product_type, remise_percent, fk_remise_except, pu_ht, pu_ttc,';
690 $sql .= ' date_start, date_end, fk_code_ventilation, rang, special_code,';
691 $sql .= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit';
692 $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
693 $sql .= ')';
694 $sql .= " VALUES (".$this->fk_facture_fourn.",";
695 $sql .= " ".($this->fk_parent_line > 0 ? "'".$this->db->escape((string) $this->fk_parent_line)."'" : "null").",";
696 $product_label
697 = !empty($this->product_label)
698 ? $this->product_label :
699 (!empty($this->label) ? $this->label : null);
700 $sql .= " ".(!empty($product_label) ? "'".$this->db->escape($product_label)."'" : "null").",";
701 $sql .= " '".$this->db->escape($this->desc ? $this->desc : $this->description)."',";
702 $sql .= " '".$this->db->escape($this->ref_supplier)."',";
703 $sql .= " ".price2num($this->qty).",";
704
705 $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").",";
706 $sql .= " ".price2num($this->tva_tx).",";
707 $sql .= " ".price2num($this->localtax1_tx).",";
708 $sql .= " ".price2num($this->localtax2_tx).",";
709 $sql .= " '".$this->db->escape((string) $this->localtax1_type)."',";
710 $sql .= " '".$this->db->escape((string) $this->localtax2_type)."',";
711 $sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").',';
712 $sql .= " ".((int) $this->product_type).",";
713 $sql .= " ".price2num($this->remise_percent).",";
714 $sql .= ' '.(!empty($this->fk_remise_except) ? ((int) $this->fk_remise_except) : "null").',';
715 $sql .= " ".price2num($this->subprice).",";
716 $sql .= " ".(!empty($this->qty) ? price2num($this->total_ttc / $this->qty) : price2num($this->total_ttc)).",";
717 $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").",";
718 $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").",";
719 $sql .= ' '.(!empty($this->fk_code_ventilation) ? $this->fk_code_ventilation : 0).',';
720 $sql .= ' '.((int) $this->rang).',';
721 $sql .= ' '.((int) $this->special_code).',';
722 $sql .= " ".((int) $this->info_bits).",";
723 $sql .= " ".price2num($this->total_ht).",";
724 $sql .= " ".price2num($this->total_tva).",";
725 $sql .= " ".price2num($this->total_ttc).",";
726 $sql .= " ".price2num($this->total_localtax1).",";
727 $sql .= " ".price2num($this->total_localtax2);
728 $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
729 $sql .= ", ".(int) $this->fk_multicurrency;
730 $sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
731 $sql .= ", ".price2num($this->multicurrency_subprice);
732 $sql .= ", ".price2num($this->multicurrency_total_ht);
733 $sql .= ", ".price2num($this->multicurrency_total_tva);
734 $sql .= ", ".price2num($this->multicurrency_total_ttc);
735 $sql .= ')';
736
737 $resql = $this->db->query($sql);
738 if ($resql) {
739 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
740 $this->rowid = $this->id; // backward compatibility
741
742 if (!$error) {
743 $result = $this->insertExtraFields();
744 if ($result < 0) {
745 $error++;
746 }
747 }
748
749 // Si fk_remise_except defini, on lie la remise a la facture
750 // ce qui la flague comme "consommee".
751 if ($this->fk_remise_except) {
752 $discount = new DiscountAbsolute($this->db);
753 $result = $discount->fetch($this->fk_remise_except);
754 if ($result >= 0) {
755 // Check if discount was found
756 if ($result > 0) {
757 // Check if discount not already affected to another invoice
758 if ($discount->fk_facture_line > 0) {
759 if (empty($noerrorifdiscountalreadylinked)) {
760 $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id);
761 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
762 $this->db->rollback();
763 return -3;
764 }
765 } else {
766 $result = $discount->link_to_invoice($this->id, 0);
767 if ($result < 0) {
768 $this->error = $discount->error;
769 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
770 $this->db->rollback();
771 return -3;
772 }
773 }
774 } else {
775 $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded");
776 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
777 $this->db->rollback();
778 return -3;
779 }
780 } else {
781 $this->error = $discount->error;
782 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
783 $this->db->rollback();
784 return -3;
785 }
786 }
787
788 if (!$error && !$notrigger) {
789 // Call trigger
790 $result = $this->call_trigger('LINEBILL_SUPPLIER_CREATE', $user);
791 if ($result < 0) {
792 $this->db->rollback();
793 return -2;
794 }
795 // End call triggers
796 }
797
798 if (!$error) {
799 $this->db->commit();
800 return $this->id;
801 }
802
803 foreach ($this->errors as $errmsg) {
804 dol_syslog(get_class($this)."::insert ".$errmsg, LOG_ERR);
805 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
806 }
807
808 $this->db->rollback();
809 return -3;
810 } else {
811 $this->error = $this->db->error();
812 $this->db->rollback();
813 return -2;
814 }
815 }
816
817 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
823 public function update_total()
824 {
825 // phpcs:enable
826 $this->db->begin();
827
828 // Mise a jour ligne en base
829 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
830 $sql .= " total_ht = ".price2num($this->total_ht);
831 $sql .= ", tva= ".price2num($this->total_tva);
832 $sql .= ", total_localtax1 = ".price2num($this->total_localtax1);
833 $sql .= ", total_localtax2 = ".price2num($this->total_localtax2);
834 $sql .= ", total_ttc = ".price2num($this->total_ttc);
835 $sql .= " WHERE rowid = ".((int) $this->id);
836
837 dol_syslog("FactureFournisseurLigne.class.php::update_total", LOG_DEBUG);
838
839 $resql = $this->db->query($sql);
840 if ($resql) {
841 $this->db->commit();
842 return 1;
843 } else {
844 $this->error = $this->db->error();
845 $this->db->rollback();
846 return -2;
847 }
848 }
849}
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.
call_trigger($triggerName, $user)
Call trigger based on this instance.
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 '.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.