dolibarr 21.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-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 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';
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->multicurrency_subprice = $obj->multicurrency_subprice;
388 $this->multicurrency_total_ht = $obj->multicurrency_total_ht;
389 $this->multicurrency_total_tva = $obj->multicurrency_total_tva;
390 $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
391
392 $this->fetch_optionals();
393
394 return 1;
395 }
396
403 public function delete($notrigger = 0)
404 {
405 global $user;
406
407 dol_syslog(get_class($this)."::deleteline rowid=".((int) $this->id), LOG_DEBUG);
408
409 $error = 0;
410
411 $this->db->begin();
412
413 if (!$notrigger) {
414 if ($this->call_trigger('LINEBILL_SUPPLIER_DELETE', $user) < 0) {
415 $error++;
416 }
417 }
418
419 $this->deleteObjectLinked();
420
421 // Remove extrafields
422 if (!$error) {
423 $result = $this->deleteExtraFields();
424 if ($result < 0) {
425 $error++;
426 dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
427 }
428 }
429
430 if (!$error) {
431 // Supprime ligne
432 $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det ';
433 $sql .= " WHERE rowid = ".((int) $this->id);
434 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
435 $resql = $this->db->query($sql);
436 if (!$resql) {
437 $error++;
438 $this->error = $this->db->lasterror();
439 }
440 }
441
442 if (!$error) {
443 $this->db->commit();
444 return 1;
445 } else {
446 $this->db->rollback();
447 return -1;
448 }
449 }
450
457 public function update($notrigger = 0)
458 {
459 global $user;
460
461 $pu = price2num($this->subprice);
462 $qty = price2num($this->qty);
463
464 // Check parameters
465 if (empty($this->qty)) {
466 $this->qty = 0;
467 }
468
469 if ($this->product_type < 0) {
470 return -1;
471 }
472
473 // Clean parameters
474 if (empty($this->remise_percent)) {
475 $this->remise_percent = 0;
476 }
477 if (empty($this->tva_tx)) {
478 $this->tva_tx = 0;
479 }
480 if (empty($this->localtax1_tx)) {
481 $this->localtax1_tx = 0;
482 }
483 if (empty($this->localtax2_tx)) {
484 $this->localtax2_tx = 0;
485 }
486
487 if (empty($this->pa_ht)) {
488 $this->pa_ht = 0;
489 }
490 if (empty($this->multicurrency_subprice)) {
491 $this->multicurrency_subprice = 0;
492 }
493 if (empty($this->multicurrency_total_ht)) {
494 $this->multicurrency_total_ht = 0;
495 }
496 if (empty($this->multicurrency_total_tva)) {
497 $this->multicurrency_total_tva = 0;
498 }
499 if (empty($this->multicurrency_total_ttc)) {
500 $this->multicurrency_total_ttc = 0;
501 }
502
503 $fk_product = (int) $this->fk_product;
504 $fk_unit = (int) $this->fk_unit;
505
506 $this->db->begin();
507
508 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
509 $sql .= " description = '".$this->db->escape(empty($this->description) ? $this->desc : $this->description)."'";
510 $sql .= ", ref = '".$this->db->escape($this->ref_supplier ? $this->ref_supplier : $this->ref)."'";
511 $sql .= ", date_start = ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null");
512 $sql .= ", date_end = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null");
513 $sql .= ", pu_ht = ".price2num($this->subprice);
514 $sql .= ", pu_ttc = ".price2num($this->pu_ttc);
515 $sql .= ", qty = ".price2num($this->qty);
516 $sql .= ", remise_percent = ".price2num($this->remise_percent);
517 if ($this->fk_remise_except > 0) {
518 $sql .= ", fk_remise_except=".((int) $this->fk_remise_except);
519 } else {
520 $sql .= ", fk_remise_except=null";
521 }
522 $sql .= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'";
523 $sql .= ", tva_tx = ".price2num($this->tva_tx);
524 $sql .= ", localtax1_tx = ".price2num($this->localtax1_tx);
525 $sql .= ", localtax2_tx = ".price2num($this->localtax2_tx);
526 $sql .= ", localtax1_type = '".$this->db->escape($this->localtax1_type)."'";
527 $sql .= ", localtax2_type = '".$this->db->escape($this->localtax2_type)."'";
528 $sql .= ", total_ht = ".price2num($this->total_ht);
529 $sql .= ", tva= ".price2num($this->total_tva);
530 $sql .= ", total_localtax1= ".price2num($this->total_localtax1);
531 $sql .= ", total_localtax2= ".price2num($this->total_localtax2);
532 $sql .= ", total_ttc = ".price2num($this->total_ttc);
533 $sql .= ", fk_product = ".($fk_product > 0 ? (int) $fk_product : 'null');
534 $sql .= ", product_type = ".((int) $this->product_type);
535 $sql .= ", info_bits = ".((int) $this->info_bits);
536 $sql .= ", fk_unit = ".($fk_unit > 0 ? (int) $fk_unit : 'null');
537
538 if (!empty($this->rang)) {
539 $sql .= ", rang=".((int) $this->rang);
540 }
541
542 // Multicurrency
543 $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice);
544 $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht);
545 $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva);
546 $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc);
547
548 $sql .= " WHERE rowid = ".((int) $this->id);
549
550 dol_syslog(get_class($this)."::update", LOG_DEBUG);
551 $resql = $this->db->query($sql);
552
553 if (!$resql) {
554 $this->db->rollback();
555 $this->error = $this->db->lasterror();
556 return -1;
557 }
558
559 $this->rowid = $this->id;
560 $error = 0;
561
562 if (!$error) {
563 $result = $this->insertExtraFields();
564 if ($result < 0) {
565 $error++;
566 }
567 }
568
569 if (!$error && !$notrigger) {
570 // Call trigger
571 if ($this->call_trigger('LINEBILL_SUPPLIER_MODIFY', $user) < 0) {
572 $this->db->rollback();
573 return -1;
574 }
575 // End call triggers
576 }
577
578 if ($error) {
579 $this->db->rollback();
580 return -1;
581 }
582
583 $this->db->commit();
584 return 1;
585 }
586
594 public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0)
595 {
596 global $user, $langs;
597
598 $error = 0;
599
600 dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG);
601
602 // Clean parameters
603 $this->desc = trim($this->desc);
604 if (empty($this->tva_tx)) {
605 $this->tva_tx = 0;
606 }
607 if (empty($this->localtax1_tx)) {
608 $this->localtax1_tx = 0;
609 }
610 if (empty($this->localtax2_tx)) {
611 $this->localtax2_tx = 0;
612 }
613 if (empty($this->localtax1_type)) {
614 $this->localtax1_type = 0.0;
615 }
616 if (empty($this->localtax2_type)) {
617 $this->localtax2_type = 0.0;
618 }
619 if (empty($this->total_tva)) {
620 $this->total_tva = 0;
621 }
622 if (empty($this->total_localtax1)) {
623 $this->total_localtax1 = 0;
624 }
625 if (empty($this->total_localtax2)) {
626 $this->total_localtax2 = 0;
627 }
628 if (empty($this->rang)) {
629 $this->rang = 0;
630 }
631 if (empty($this->remise_percent)) {
632 $this->remise_percent = 0;
633 }
634 if (empty($this->info_bits)) {
635 $this->info_bits = 0;
636 }
637 if (empty($this->subprice)) {
638 $this->subprice = 0;
639 }
640 if (empty($this->special_code)) {
641 $this->special_code = 0;
642 }
643 if (empty($this->fk_parent_line)) {
644 $this->fk_parent_line = 0;
645 }
646 if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') {
647 $this->situation_percent = 100;
648 }
649
650 if (empty($this->pa_ht)) {
651 $this->pa_ht = 0;
652 }
653 if (empty($this->multicurrency_subprice)) {
654 $this->multicurrency_subprice = 0;
655 }
656 if (empty($this->multicurrency_total_ht)) {
657 $this->multicurrency_total_ht = 0;
658 }
659 if (empty($this->multicurrency_total_tva)) {
660 $this->multicurrency_total_tva = 0;
661 }
662 if (empty($this->multicurrency_total_ttc)) {
663 $this->multicurrency_total_ttc = 0;
664 }
665
666
667 // Check parameters
668 if ($this->product_type < 0) {
669 $this->error = 'ErrorProductTypeMustBe0orMore';
670 return -1;
671 }
672 if (!empty($this->fk_product) && $this->fk_product > 0) {
673 // Check product exists
674 $result = Product::isExistingObject('product', $this->fk_product);
675 if ($result <= 0) {
676 $this->error = 'ErrorProductIdDoesNotExists';
677 return -1;
678 }
679 }
680
681 $this->db->begin();
682
683 // Insertion dans base de la ligne
684 $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
685 $sql .= ' (fk_facture_fourn, fk_parent_line, label, description, ref, qty,';
686 $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
687 $sql .= ' fk_product, product_type, remise_percent, fk_remise_except, pu_ht, pu_ttc,';
688 $sql .= ' date_start, date_end, fk_code_ventilation, rang, special_code,';
689 $sql .= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit';
690 $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
691 $sql .= ')';
692 $sql .= " VALUES (".$this->fk_facture_fourn.",";
693 $sql .= " ".($this->fk_parent_line > 0 ? "'".$this->db->escape($this->fk_parent_line)."'" : "null").",";
694 $product_label
695 = !empty($this->product_label)
696 ? $this->product_label :
697 (!empty($this->label) ? $this->label : null);
698 $sql .= " ".(!empty($product_label) ? "'".$this->db->escape($product_label)."'" : "null").",";
699 $sql .= " '".$this->db->escape($this->desc ? $this->desc : $this->description)."',";
700 $sql .= " '".$this->db->escape($this->ref_supplier)."',";
701 $sql .= " ".price2num($this->qty).",";
702
703 $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").",";
704 $sql .= " ".price2num($this->tva_tx).",";
705 $sql .= " ".price2num($this->localtax1_tx).",";
706 $sql .= " ".price2num($this->localtax2_tx).",";
707 $sql .= " '".$this->db->escape($this->localtax1_type)."',";
708 $sql .= " '".$this->db->escape($this->localtax2_type)."',";
709 $sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").',';
710 $sql .= " ".((int) $this->product_type).",";
711 $sql .= " ".price2num($this->remise_percent).",";
712 $sql .= ' '.(!empty($this->fk_remise_except) ? ((int) $this->fk_remise_except) : "null").',';
713 $sql .= " ".price2num($this->subprice).",";
714 $sql .= " ".(!empty($this->qty) ? price2num($this->total_ttc / $this->qty) : price2num($this->total_ttc)).",";
715 $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").",";
716 $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").",";
717 $sql .= ' '.(!empty($this->fk_code_ventilation) ? $this->fk_code_ventilation : 0).',';
718 $sql .= ' '.((int) $this->rang).',';
719 $sql .= ' '.((int) $this->special_code).',';
720 $sql .= " ".((int) $this->info_bits).",";
721 $sql .= " ".price2num($this->total_ht).",";
722 $sql .= " ".price2num($this->total_tva).",";
723 $sql .= " ".price2num($this->total_ttc).",";
724 $sql .= " ".price2num($this->total_localtax1).",";
725 $sql .= " ".price2num($this->total_localtax2);
726 $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
727 $sql .= ", ".(int) $this->fk_multicurrency;
728 $sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
729 $sql .= ", ".price2num($this->multicurrency_subprice);
730 $sql .= ", ".price2num($this->multicurrency_total_ht);
731 $sql .= ", ".price2num($this->multicurrency_total_tva);
732 $sql .= ", ".price2num($this->multicurrency_total_ttc);
733 $sql .= ')';
734
735 $resql = $this->db->query($sql);
736 if ($resql) {
737 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
738 $this->rowid = $this->id; // backward compatibility
739
740 if (!$error) {
741 $result = $this->insertExtraFields();
742 if ($result < 0) {
743 $error++;
744 }
745 }
746
747 // Si fk_remise_except defini, on lie la remise a la facture
748 // ce qui la flague comme "consommee".
749 if ($this->fk_remise_except) {
750 $discount = new DiscountAbsolute($this->db);
751 $result = $discount->fetch($this->fk_remise_except);
752 if ($result >= 0) {
753 // Check if discount was found
754 if ($result > 0) {
755 // Check if discount not already affected to another invoice
756 if ($discount->fk_facture_line > 0) {
757 if (empty($noerrorifdiscountalreadylinked)) {
758 $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id);
759 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
760 $this->db->rollback();
761 return -3;
762 }
763 } else {
764 $result = $discount->link_to_invoice($this->id, 0);
765 if ($result < 0) {
766 $this->error = $discount->error;
767 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
768 $this->db->rollback();
769 return -3;
770 }
771 }
772 } else {
773 $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded");
774 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
775 $this->db->rollback();
776 return -3;
777 }
778 } else {
779 $this->error = $discount->error;
780 dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
781 $this->db->rollback();
782 return -3;
783 }
784 }
785
786 if (!$error && !$notrigger) {
787 // Call trigger
788 $result = $this->call_trigger('LINEBILL_SUPPLIER_CREATE', $user);
789 if ($result < 0) {
790 $this->db->rollback();
791 return -2;
792 }
793 // End call triggers
794 }
795
796 if (!$error) {
797 $this->db->commit();
798 return $this->id;
799 }
800
801 foreach ($this->errors as $errmsg) {
802 dol_syslog(get_class($this)."::insert ".$errmsg, LOG_ERR);
803 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
804 }
805
806 $this->db->rollback();
807 return -3;
808 } else {
809 $this->error = $this->db->error();
810 $this->db->rollback();
811 return -2;
812 }
813 }
814
815 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
821 public function update_total()
822 {
823 // phpcs:enable
824 $this->db->begin();
825
826 // Mise a jour ligne en base
827 $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
828 $sql .= " total_ht = ".price2num($this->total_ht);
829 $sql .= ", tva= ".price2num($this->total_tva);
830 $sql .= ", total_localtax1 = ".price2num($this->total_localtax1);
831 $sql .= ", total_localtax2 = ".price2num($this->total_localtax2);
832 $sql .= ", total_ttc = ".price2num($this->total_ttc);
833 $sql .= " WHERE rowid = ".((int) $this->id);
834
835 dol_syslog("FactureFournisseurLigne.class.php::update_total", LOG_DEBUG);
836
837 $resql = $this->db->query($sql);
838 if ($resql) {
839 $this->db->commit();
840 return 1;
841 } else {
842 $this->error = $this->db->error();
843 $this->db->rollback();
844 return -2;
845 }
846 }
847}
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.