dolibarr  7.0.0-beta
commoninvoice.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.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  if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
184  {
185  // TODO
186  return 0;
187  }
188 
189  require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
190 
191  $discountstatic=new DiscountAbsolute($this->db);
192  $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency);
193  if ($result >= 0)
194  {
195  return $result;
196  }
197  else
198  {
199  $this->error=$discountstatic->error;
200  return -1;
201  }
202  }
203 
210  {
211  $idarray=array();
212 
213  $sql = 'SELECT rowid';
214  $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
215  $sql.= ' WHERE fk_facture_source = '.$this->id;
216  $sql.= ' AND type = 2';
217  $resql=$this->db->query($sql);
218  if ($resql)
219  {
220  $num = $this->db->num_rows($resql);
221  $i = 0;
222  while ($i < $num)
223  {
224  $row = $this->db->fetch_row($resql);
225  $idarray[]=$row[0];
226  $i++;
227  }
228  }
229  else
230  {
231  dol_print_error($this->db);
232  }
233  return $idarray;
234  }
235 
242  function getIdReplacingInvoice($option='')
243  {
244  $sql = 'SELECT rowid';
245  $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
246  $sql.= ' WHERE fk_facture_source = '.$this->id;
247  $sql.= ' AND type < 2';
248  if ($option == 'validated') $sql.= ' AND fk_statut = 1';
249  // PROTECTION BAD DATA
250  // Au cas ou base corrompue et qu'il y a une facture de remplacement validee
251  // et une autre non, on donne priorite a la validee.
252  // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes
253  // ont cree en meme temps une facture de remplacement pour la meme facture)
254  $sql.= ' ORDER BY fk_statut DESC';
255 
256  $resql=$this->db->query($sql);
257  if ($resql)
258  {
259  $obj = $this->db->fetch_object($resql);
260  if ($obj)
261  {
262  // Si il y en a
263  return $obj->rowid;
264  }
265  else
266  {
267  // Si aucune facture ne remplace
268  return 0;
269  }
270  }
271  else
272  {
273  return -1;
274  }
275  }
276 
289  function is_erasable()
290  {
291  global $conf;
292 
293  // We check if invoice is a temporary number (PROVxxxx)
294  $tmppart = substr($this->ref, 1, 4);
295 
296  if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined
297  {
298  return 1;
299  }
300 
301  if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0;
302 
303  // If not a draft invoice and not temporary invoice
304  if ($tmppart !== 'PROV')
305  {
306  $ventilExportCompta = $this->getVentilExportCompta();
307  if ($ventilExportCompta != 0) return -1;
308 
309  // Get last number of validated invoice
310  if ($this->element != 'invoice_supplier')
311  {
312  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).
313  $maxfacnumber = $this->getNextNumRef($this->thirdparty,'last');
314 
315  // If there is no invoice into the reset range and not already dispatched, we can delete
316  // If invoice to delete is last one and not already dispatched, we can delete
317  if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxfacnumber != '' && $maxfacnumber != $this->ref) return -2;
318 
319  // TODO If there is payment in bookkeeping, check payment is not dispatched in accounting
320  // ...
321 
322  if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle'))
323  {
324  $last = $this->is_last_in_cycle();
325  if (! $last) return -3;
326  }
327  }
328  }
329 
330  // Test if there is at least one payment. If yes, refuse to delete.
331  if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4;
332 
333  return 1;
334  }
335 
342  {
343  $alreadydispatched = 0;
344 
345  $type = 'customer_invoice';
346  if ($this->element == 'invoice_supplier') $type = 'supplier_invoice';
347 
348  $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;
349  $resql = $this->db->query($sql);
350  if ($resql)
351  {
352  $obj = $this->db->fetch_object($resql);
353  if ($obj)
354  {
355  $alreadydispatched = $obj->nb;
356  }
357  }
358  else
359  {
360  $this->error = $this->db->lasterror();
361  return -1;
362  }
363 
364  if ($alreadydispatched)
365  {
366  return 1;
367  }
368  return 0;
369  }
370 
371 
377  function getLibType()
378  {
379  global $langs;
380  if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard");
381  if ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement");
382  if ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir");
383  if ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit");
384  if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used.
385  if ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation");
386  return $langs->trans("Unknown");
387  }
388 
396  function getLibStatut($mode=0, $alreadypaid=-1)
397  {
398  return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type);
399  }
400 
411  function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0)
412  {
413  global $langs;
414  $langs->load('bills');
415 
416  //print "$paye,$status,$mode,$alreadypaid,$type";
417  if ($mode == 0)
418  {
419  $prefix='';
420  if (! $paye)
421  {
422  if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
423  if (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid');
424  if (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
425  if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
426  return $langs->trans('Bill'.$prefix.'StatusStarted');
427  }
428  else
429  {
430  if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note
431  elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice
432  else return $langs->trans('Bill'.$prefix.'StatusPaid');
433  }
434  }
435  if ($mode == 1)
436  {
437  $prefix='Short';
438  if (! $paye)
439  {
440  if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
441  if (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled');
442  if (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
443  if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
444  return $langs->trans('Bill'.$prefix.'StatusStarted');
445  }
446  else
447  {
448  if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
449  elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted');
450  else return $langs->trans('Bill'.$prefix.'StatusPaid');
451  }
452  }
453  if ($mode == 2)
454  {
455  $prefix='Short';
456  if (! $paye)
457  {
458  if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft');
459  if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
460  if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
461  if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid');
462  return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted');
463  }
464  else
465  {
466  if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
467  elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted');
468  else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid');
469  }
470  }
471  if ($mode == 3)
472  {
473  $prefix='Short';
474  if (! $paye)
475  {
476  if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0');
477  if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5');
478  if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
479  if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1');
480  return img_picto($langs->trans('BillStatusStarted'),'statut3');
481  }
482  else
483  {
484  if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
485  elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6');
486  else return img_picto($langs->trans('BillStatusPaid'),'statut6');
487  }
488  }
489  if ($mode == 4)
490  {
491  $prefix='';
492  if (! $paye)
493  {
494  if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft');
495  if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
496  if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
497  if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid');
498  return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted');
499  }
500  else
501  {
502  if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted');
503  elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted');
504  else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid');
505  }
506  }
507  if ($mode == 5 || $mode == 6)
508  {
509  $prefix='';
510  if ($mode == 5) $prefix='Short';
511  if (! $paye)
512  {
513  if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0');
514  if (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5');
515  if (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
516  if ($alreadypaid <= 0)
517  {
518  if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1');
519  return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1');
520  }
521  return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3');
522  }
523  else
524  {
525  if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
526  elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6');
527  else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6');
528  }
529  }
530  }
531 
539  function calculate_date_lim_reglement($cond_reglement=0)
540  {
541  if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code;
542  if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id;
543 
544  $cdr_nbjour=0; $cdr_type=0; $cdr_decalage=0;
545 
546  $sqltemp = 'SELECT c.type_cdr,c.nbjour,c.decalage';
547  $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c';
548  $sqltemp.= " WHERE c.entity IN (" . getEntity('c_payment_term').")";
549  if (is_numeric($cond_reglement)) $sqltemp.= " AND c.rowid=".$cond_reglement;
550  else $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'";
551 
552  dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG);
553  $resqltemp=$this->db->query($sqltemp);
554  if ($resqltemp)
555  {
556  if ($this->db->num_rows($resqltemp))
557  {
558  $obj = $this->db->fetch_object($resqltemp);
559  $cdr_nbjour = $obj->nbjour;
560  $cdr_type = $obj->type_cdr;
561  $cdr_decalage = $obj->decalage;
562  }
563  }
564  else
565  {
566  $this->error=$this->db->error();
567  return -1;
568  }
569  $this->db->free($resqltemp);
570 
571  /* Definition de la date limite */
572 
573  // 1 : ajout du nombre de jours
574  $datelim = $this->date + ($cdr_nbjour * 3600 * 24);
575 
576  // 2 : application de la regle "fin de mois"
577  if ($cdr_type == 1)
578  {
579  $mois=date('m', $datelim);
580  $annee=date('Y', $datelim);
581  if ($mois == 12)
582  {
583  $mois = 1;
584  $annee += 1;
585  }
586  else
587  {
588  $mois += 1;
589  }
590  // On se deplace au debut du mois suivant, et on retire un jour
591  $datelim=dol_mktime(12,0,0,$mois,1,$annee);
592  $datelim -= (3600 * 24);
593  }
594  elseif($cdr_type == 2 && !empty($cdr_nbjour)) // Application de la règle, le N du mois courant ou suivant
595  {
596 
597  $date_piece = dol_mktime(0,0,0,date('m', $this->date),date('d', $this->date),date('Y', $this->date)); // Sans les heures minutes et secondes
598  $date_lim_current = dol_mktime(0,0,0,date('m', $this->date),$cdr_nbjour,date('Y', $this->date)); // Sans les heures minutes et secondes
599  $date_lim_next = strtotime(date('Y-m-d', $date_lim_current).' +1month');
600 
601  $diff = $date_piece - $date_lim_current;
602 
603  if($diff < 0) $datelim = $date_lim_current;
604  else $datelim = $date_lim_next;
605 
606  }
607 
608  // 3 : application du decalage
609  $datelim += ($cdr_decalage * 3600 * 24);
610 
611  return $datelim;
612  }
613 }
614 
615 
616 
617 require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
618 
622 abstract class CommonInvoiceLine extends CommonObjectLine
623 {
628  public $qty;
629 
634  public $subprice;
635 
640  public $product_type = 0;
641 
646  public $fk_product;
647 
652  public $vat_src_code;
653 
658  public $tva_tx;
659 
664  public $localtax1_tx;
665 
670  public $localtax2_tx;
671 
676  public $remise_percent;
677 
682  public $total_ht;
683 
688  public $total_tva;
689 
694  public $total_localtax1;
695 
700  public $total_localtax2;
701 
706  public $total_ttc;
707 
714  public $info_bits = 0;
715 
721  public function __construct(DoliDB $db)
722  {
723  $this->db = $db;
724  }
725 }
726 
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.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
const TYPE_STANDARD
Standard invoice.
is_erasable()
Return if an invoice can be deleted Rule is: If invoice is draft and has a temporary ref -> yes If hi...
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.
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.
getLibType()
Return label of type of invoice.
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 and deposits invoices used by invoice.
const STATUS_DRAFT
Draft.
getEntity($element, $shared=1, $forceentity=null)
Get list of entity id to use.
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'id de la facture qui la remplace.
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:1013
Class to manage absolute discounts.
const STATUS_VALIDATED
Validated (need to be paid)
type
Definition: viewcat.php:283
const TYPE_DEPOSIT
Deposit invoice.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
const TYPE_CREDIT_NOTE
Credit note invoice.