dolibarr  9.0.0
commoninvoice.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
4  * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
27 
31 abstract class CommonInvoice extends CommonObject
32 {
36  const TYPE_STANDARD = 0;
37 
41  const TYPE_REPLACEMENT = 1;
42 
46  const TYPE_CREDIT_NOTE = 2;
47 
51  const TYPE_DEPOSIT = 3;
52 
57  const TYPE_PROFORMA = 4;
58 
62  const TYPE_SITUATION = 5;
63 
67  const STATUS_DRAFT = 0;
68 
72  const STATUS_VALIDATED = 1;
73 
81  const STATUS_CLOSED = 2;
82 
90  const STATUS_ABANDONED = 3;
91 
92 
100  function getRemainToPay($multicurrency=0)
101  {
102  $alreadypaid=0;
103  $alreadypaid+=$this->getSommePaiement($multicurrency);
104  $alreadypaid+=$this->getSumDepositsUsed($multicurrency);
105  $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency);
106  return $this->total_ttc - $alreadypaid;
107  }
108 
115  function getSommePaiement($multicurrency=0)
116  {
117  $table='paiement_facture';
118  $field='fk_facture';
119  if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
120  {
121  $table='paiementfourn_facturefourn';
122  $field='fk_facturefourn';
123  }
124 
125  $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount';
126  $sql.= ' FROM '.MAIN_DB_PREFIX.$table;
127  $sql.= ' WHERE '.$field.' = '.$this->id;
128 
129  dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
130  $resql=$this->db->query($sql);
131  if ($resql)
132  {
133  $obj = $this->db->fetch_object($resql);
134  $this->db->free($resql);
135  if ($multicurrency) return $obj->multicurrency_amount;
136  else return $obj->amount;
137  }
138  else
139  {
140  $this->error=$this->db->lasterror();
141  return -1;
142  }
143  }
144 
152  function getSumDepositsUsed($multicurrency=0)
153  {
154  if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
155  {
156  // TODO
157  return 0;
158  }
159 
160  require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
161 
162  $discountstatic=new DiscountAbsolute($this->db);
163  $result=$discountstatic->getSumDepositsUsed($this, $multicurrency);
164  if ($result >= 0)
165  {
166  return $result;
167  }
168  else
169  {
170  $this->error=$discountstatic->error;
171  return -1;
172  }
173  }
174 
181  function getSumCreditNotesUsed($multicurrency=0)
182  {
183  require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
184 
185  $discountstatic=new DiscountAbsolute($this->db);
186  $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency);
187  if ($result >= 0)
188  {
189  return $result;
190  }
191  else
192  {
193  $this->error=$discountstatic->error;
194  return -1;
195  }
196  }
197 
204  {
205  $idarray=array();
206 
207  $sql = 'SELECT rowid';
208  $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
209  $sql.= ' WHERE fk_facture_source = '.$this->id;
210  $sql.= ' AND type = 2';
211  $resql=$this->db->query($sql);
212  if ($resql)
213  {
214  $num = $this->db->num_rows($resql);
215  $i = 0;
216  while ($i < $num)
217  {
218  $row = $this->db->fetch_row($resql);
219  $idarray[]=$row[0];
220  $i++;
221  }
222  }
223  else
224  {
225  dol_print_error($this->db);
226  }
227  return $idarray;
228  }
229 
236  function getIdReplacingInvoice($option='')
237  {
238  $sql = 'SELECT rowid';
239  $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
240  $sql.= ' WHERE fk_facture_source = '.$this->id;
241  $sql.= ' AND type < 2';
242  if ($option == 'validated') $sql.= ' AND fk_statut = 1';
243  // PROTECTION BAD DATA
244  // Au cas ou base corrompue et qu'il y a une facture de remplacement validee
245  // et une autre non, on donne priorite a la validee.
246  // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes
247  // ont cree en meme temps une facture de remplacement pour la meme facture)
248  $sql.= ' ORDER BY fk_statut DESC';
249 
250  $resql=$this->db->query($sql);
251  if ($resql)
252  {
253  $obj = $this->db->fetch_object($resql);
254  if ($obj)
255  {
256  // Si il y en a
257  return $obj->rowid;
258  }
259  else
260  {
261  // Si aucune facture ne remplace
262  return 0;
263  }
264  }
265  else
266  {
267  return -1;
268  }
269  }
270 
277  function getListOfPayments($filtertype='')
278  {
279  $retarray=array();
280 
281  $table='paiement_facture';
282  $table2='paiement';
283  $field='fk_facture';
284  $field2='fk_paiement';
285  $sharedentity='facture';
286  if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
287  {
288  $table='paiementfourn_facturefourn';
289  $table2='paiementfourn';
290  $field='fk_facturefourn';
291  $field2='fk_paiementfourn';
292  $sharedentity='facture_fourn';
293  }
294 
295  $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code';
296  $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t';
297  $sql.= ' WHERE pf.'.$field.' = '.$this->id;
298  //$sql.= ' WHERE pf.'.$field.' = 1';
299  $sql.= ' AND pf.'.$field2.' = p.rowid';
300  $sql.= ' AND p.fk_paiement = t.id';
301  $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')';
302  if ($filtertype) $sql.=" AND t.code='PRE'";
303 
304  dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG);
305  $resql=$this->db->query($sql);
306  if ($resql)
307  {
308  $num = $this->db->num_rows($resql);
309  $i=0;
310  while ($i < $num)
311  {
312  $obj = $this->db->fetch_object($resql);
313  $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref);
314  $i++;
315  }
316  $this->db->free($resql);
317  return $retarray;
318  }
319  else
320  {
321  $this->error=$this->db->lasterror();
322  dol_print_error($this->db);
323  return array();
324  }
325  }
326 
327 
328  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
342  function is_erasable()
343  {
344  // phpcs:enable
345  global $conf;
346 
347  // We check if invoice is a temporary number (PROVxxxx)
348  $tmppart = substr($this->ref, 1, 4);
349 
350  if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined
351  {
352  return 1;
353  }
354 
355  if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0;
356 
357  // If not a draft invoice and not temporary invoice
358  if ($tmppart !== 'PROV')
359  {
360  $ventilExportCompta = $this->getVentilExportCompta();
361  if ($ventilExportCompta != 0) return -1;
362 
363  // Get last number of validated invoice
364  if ($this->element != 'invoice_supplier')
365  {
366  if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag).
367  $maxfacnumber = $this->getNextNumRef($this->thirdparty,'last');
368 
369  // If there is no invoice into the reset range and not already dispatched, we can delete
370  // If invoice to delete is last one and not already dispatched, we can delete
371  if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxfacnumber != '' && $maxfacnumber != $this->ref) return -2;
372 
373  // TODO If there is payment in bookkeeping, check payment is not dispatched in accounting
374  // ...
375 
376  if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle'))
377  {
378  $last = $this->is_last_in_cycle();
379  if (! $last) return -3;
380  }
381  }
382  }
383 
384  // Test if there is at least one payment. If yes, refuse to delete.
385  if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4;
386 
387  return 2;
388  }
389 
395  public function getVentilExportCompta()
396  {
397  $alreadydispatched = 0;
398 
399  $type = 'customer_invoice';
400  if ($this->element == 'invoice_supplier') $type = 'supplier_invoice';
401 
402  $sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id;
403  $resql = $this->db->query($sql);
404  if ($resql)
405  {
406  $obj = $this->db->fetch_object($resql);
407  if ($obj)
408  {
409  $alreadydispatched = $obj->nb;
410  }
411  }
412  else
413  {
414  $this->error = $this->db->lasterror();
415  return -1;
416  }
417 
418  if ($alreadydispatched)
419  {
420  return 1;
421  }
422  return 0;
423  }
424 
425 
431  function getLibType()
432  {
433  global $langs;
434  if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard");
435  elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement");
436  elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir");
437  elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit");
438  elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used.
439  elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation");
440  return $langs->trans("Unknown");
441  }
442 
450  function getLibStatut($mode=0, $alreadypaid=-1)
451  {
452  return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type);
453  }
454 
455  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
466  function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0)
467  {
468  // phpcs:enable
469  global $langs;
470  $langs->load('bills');
471 
472  //print "$paye,$status,$mode,$alreadypaid,$type";
473  if ($mode == 0)
474  {
475  $prefix='';
476  if (! $paye)
477  {
478  if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
479  elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid');
480  elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
481  elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
482  else return $langs->trans('Bill'.$prefix.'StatusStarted');
483  }
484  else
485  {
486  if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note
487  elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice
488  else return $langs->trans('Bill'.$prefix.'StatusPaid');
489  }
490  }
491  elseif ($mode == 1)
492  {
493  $prefix='Short';
494  if (! $paye)
495  {
496  if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
497  elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled');
498  elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
499  elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
500  else return $langs->trans('Bill'.$prefix.'StatusStarted');
501  }
502  else
503  {
504  if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
505  elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted');
506  else return $langs->trans('Bill'.$prefix.'StatusPaid');
507  }
508  }
509  elseif ($mode == 2)
510  {
511  $prefix='Short';
512  if (! $paye)
513  {
514  if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft');
515  elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
516  elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
517  elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid');
518  else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted');
519  }
520  else
521  {
522  if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
523  elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted');
524  else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid');
525  }
526  }
527  elseif ($mode == 3)
528  {
529  $prefix='Short';
530  if (! $paye)
531  {
532  if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0');
533  elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5');
534  elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9');
535  elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1');
536  else return img_picto($langs->trans('BillStatusStarted'),'statut3');
537  }
538  else
539  {
540  if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
541  elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6');
542  else return img_picto($langs->trans('BillStatusPaid'),'statut6');
543  }
544  }
545  elseif ($mode == 4)
546  {
547  $prefix='';
548  if (! $paye)
549  {
550  if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft');
551  elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
552  elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
553  elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid');
554  else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted');
555  }
556  else
557  {
558  if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted');
559  elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted');
560  else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid');
561  }
562  }
563  elseif ($mode == 5 || $mode == 6)
564  {
565  $prefix='';
566  if ($mode == 5) $prefix='Short';
567  if (! $paye)
568  {
569  if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0');
570  elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5');
571  elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9');
572  elseif ($alreadypaid <= 0)
573  {
574  if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1');
575  return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1');
576  }
577  else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3');
578  }
579  else
580  {
581  if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
582  elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6');
583  else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6');
584  }
585  }
586  }
587 
588  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
596  function calculate_date_lim_reglement($cond_reglement=0)
597  {
598  // phpcs:enable
599  if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code;
600  if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id;
601 
602  $cdr_nbjour=0;
603  $cdr_type=0;
604  $cdr_decalage=0;
605 
606  $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage';
607  $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c';
608  if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement;
609  else {
610  $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")";
611  $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'";
612  }
613 
614  dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG);
615  $resqltemp=$this->db->query($sqltemp);
616  if ($resqltemp)
617  {
618  if ($this->db->num_rows($resqltemp))
619  {
620  $obj = $this->db->fetch_object($resqltemp);
621  $cdr_nbjour = $obj->nbjour;
622  $cdr_type = $obj->type_cdr;
623  $cdr_decalage = $obj->decalage;
624  }
625  }
626  else
627  {
628  $this->error=$this->db->error();
629  return -1;
630  }
631  $this->db->free($resqltemp);
632 
633  /* Definition de la date limite */
634 
635  // 0 : ajout du nombre de jours
636  if ($cdr_type == 0)
637  {
638  $datelim = $this->date + ($cdr_nbjour * 3600 * 24);
639 
640  $datelim += ($cdr_decalage * 3600 * 24);
641  }
642  // 1 : application de la regle "fin de mois"
643  elseif ($cdr_type == 1)
644  {
645  $datelim = $this->date + ($cdr_nbjour * 3600 * 24);
646 
647  $mois=date('m', $datelim);
648  $annee=date('Y', $datelim);
649  if ($mois == 12)
650  {
651  $mois = 1;
652  $annee += 1;
653  }
654  else
655  {
656  $mois += 1;
657  }
658  // On se deplace au debut du mois suivant, et on retire un jour
659  $datelim=dol_mktime(12,0,0,$mois,1,$annee);
660  $datelim -= (3600 * 24);
661 
662  $datelim += ($cdr_decalage * 3600 * 24);
663  }
664  // 2 : application de la règle, le N du mois courant ou suivant
665  elseif ($cdr_type == 2 && !empty($cdr_decalage))
666  {
667  $datelim = $this->date + ($cdr_nbjour * 3600 * 24);
668 
669  $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes
670  $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes
671  $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month
672 
673  $diff = $date_piece - $date_lim_current;
674 
675  if ($diff < 0) $datelim = $date_lim_current;
676  else $datelim = $date_lim_next;
677  }
678  else return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement;
679 
680  return $datelim;
681  }
682 }
683 
684 
685 
686 require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
687 
691 abstract class CommonInvoiceLine extends CommonObjectLine
692 {
697  public $qty;
698 
703  public $subprice;
704 
709  public $product_type = 0;
710 
715  public $fk_product;
716 
721  public $vat_src_code;
722 
727  public $tva_tx;
728 
733  public $localtax1_tx;
734 
739  public $localtax2_tx;
740 
745  public $remise_percent;
746 
751  public $total_ht;
752 
757  public $total_tva;
758 
763  public $total_localtax1;
764 
769  public $total_localtax2;
770 
775  public $total_ttc;
776 
783  public $info_bits = 0;
784 
790  public function __construct(DoliDB $db)
791  {
792  $this->db = $db;
793  }
794 }
calculate_date_lim_reglement($cond_reglement=0)
Renvoi une date limite de reglement de facture en fonction des conditions de reglements de la facture...
const STATUS_CLOSED
Classified paid.
const TYPE_STANDARD
Standard invoice.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
is_erasable()
Return if an invoice can be deleted Rule is: If invoice is draft and has a temporary ref -> yes (1) I...
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage Dolibarr database access.
getListOfPayments($filtertype='')
Return list of payments.
getLibStatut($mode=0, $alreadypaid=-1)
Return label of object status.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty.
Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...)
LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0)
Return label of a status.
getListIdAvoirFromInvoice()
Renvoie tableau des ids de facture avoir issus de la facture.
const TYPE_PROFORMA
Proforma invoice.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
__construct(DoliDB $db)
Constructor.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
type
Definition: viewcat.php:284
getLibType()
Return label of type of invoice.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
const TYPE_REPLACEMENT
Replacement invoice.
getRemainToPay($multicurrency=0)
Return remain amount to pay.
getSommePaiement($multicurrency=0)
Return amount of payments already done.
getSumCreditNotesUsed($multicurrency=0)
Return amount (with tax) of all credit notes invoices + excess received used by invoice.
const STATUS_DRAFT
Draft status.
Superclass for invoices classes.
const STATUS_ABANDONED
Classified abandoned and no payment done.
getSumDepositsUsed($multicurrency=0)
Return amount (with tax) of all deposits invoices used by invoice.
const TYPE_SITUATION
Situation invoice.
getVentilExportCompta()
Return if an invoice was dispatched into bookkeeping.
getIdReplacingInvoice($option='')
Renvoie l&#39;id de la facture qui la remplace.
Class to manage absolute discounts.
const STATUS_VALIDATED
Validated (need to be paid)
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:116
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
const TYPE_DEPOSIT
Deposit invoice.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
const TYPE_CREDIT_NOTE
Credit note invoice.