Completed
Branch develop (d076ff)
by
unknown
28:37
created

CommonInvoice::getSumCreditNotesUsed()   B

Complexity

Conditions 4
Paths 3

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nc 3
nop 1
dl 0
loc 22
rs 8.9197
c 0
b 0
f 0
1
<?php
2
/* Copyright (C) 2012       Regis Houssin       <[email protected]>
3
 * Copyright (C) 2012       Cédric Salvador     <[email protected]>
4
 * Copyright (C) 2012-2014  Raphaël Doursenaud  <[email protected]>
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
20
/**
21
 *       \file       htdocs/core/class/commoninvoice.class.php
22
 *       \ingroup    core
23
 *       \brief      File of the superclass of invoices classes (customer and supplier)
24
 */
25
26
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
27
28
/**
29
 * 	Superclass for invoices classes
30
 */
31
abstract class CommonInvoice extends CommonObject
32
{
33
    /**
34
     * Standard invoice
35
     */
36
    const TYPE_STANDARD = 0;
37
38
    /**
39
     * Replacement invoice
40
     */
41
    const TYPE_REPLACEMENT = 1;
42
43
    /**
44
     * Credit note invoice
45
     */
46
    const TYPE_CREDIT_NOTE = 2;
47
48
    /**
49
     * Deposit invoice
50
     */
51
    const TYPE_DEPOSIT = 3;
52
53
    /**
54
     * Proforma invoice
55
     */
56
    const TYPE_PROFORMA = 4;
57
58
    /**
59
     * Situation invoice
60
     */
61
    const TYPE_SITUATION = 5;
62
63
	/**
64
	 * Draft
65
	 */
66
	const STATUS_DRAFT = 0;
67
68
	/**
69
	 * Validated (need to be paid)
70
	 */
71
	const STATUS_VALIDATED = 1;
72
73
	/**
74
	 * Classified paid.
75
	 * If paid partially, $this->close_code can be:
76
	 * - CLOSECODE_DISCOUNTVAT
77
	 * - CLOSECODE_BADDEBT
78
	 * If paid completelly, this->close_code will be null
79
	 */
80
	const STATUS_CLOSED = 2;
81
82
	/**
83
	 * Classified abandoned and no payment done.
84
	 * $this->close_code can be:
85
	 * - CLOSECODE_BADDEBT
86
	 * - CLOSECODE_ABANDONED
87
	 * - CLOSECODE_REPLACED
88
	 */
89
	const STATUS_ABANDONED = 3;
90
91
	
92
	/**
93
	 * 	Return amount of payments already done
94
	 *
95
	 *  @param 		int 	$multicurrency 	Return multicurrency_amount instead of amount
96
	 *	@return		int						Amount of payment already done, <0 if KO
97
	 */
98
	function getSommePaiement($multicurrency=0)
99
	{
100
		$table='paiement_facture';
101
		$field='fk_facture';
102
		if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
103
		{
104
			$table='paiementfourn_facturefourn';
105
			$field='fk_facturefourn';
106
		}
107
108
		$sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount';
109
		$sql.= ' FROM '.MAIN_DB_PREFIX.$table;
110
		$sql.= ' WHERE '.$field.' = '.$this->id;
111
112
		dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
113
		$resql=$this->db->query($sql);
114
		if ($resql)
115
		{
116
			$obj = $this->db->fetch_object($resql);
117
			$this->db->free($resql);
118
			if ($multicurrency) return $obj->multicurrency_amount;
119
			else return $obj->amount;
120
		}
121
		else
122
		{
123
			$this->error=$this->db->lasterror();
124
			return -1;
125
		}
126
	}
127
128
	/**
129
	 *    	Return amount (with tax) of all credit notes and deposits invoices used by invoice
130
	 *
131
	 * 		@param 		int 	$multicurrency 	Return multicurrency_amount instead of amount
132
	 *		@return		int						<0 if KO, Sum of credit notes and deposits amount otherwise
133
	 */
134
	function getSumCreditNotesUsed($multicurrency=0)
135
	{
136
	    if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
137
	    {
138
	        // TODO
139
	       return 0;     
140
	    }
141
	    
142
	    require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
143
	
144
	    $discountstatic=new DiscountAbsolute($this->db);
145
	    $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency);
0 ignored issues
show
Compatibility introduced by
$this of type object<CommonInvoice> is not a sub-type of object<Facture>. It seems like you assume a child class of the class CommonInvoice to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
146
	    if ($result >= 0)
147
	    {
148
	        return $result;
149
	    }
150
	    else
151
	    {
152
	        $this->error=$discountstatic->error;
153
	        return -1;
154
	    }
155
	}
156
	
157
	/**
158
	 *    	Return amount (with tax) of all deposits invoices used by invoice
159
	 *
160
	 * 		@param 		int 	$multicurrency 	Return multicurrency_amount instead of amount
161
	 *		@return		int						<0 if KO, Sum of deposits amount otherwise
162
	 */
163
	function getSumDepositsUsed($multicurrency=0)
164
	{
165
		if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
166
	    {
167
	        // TODO
168
	       return 0;     
169
	    }
170
	    
171
	    require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
172
	
173
	    $discountstatic=new DiscountAbsolute($this->db);
174
	    $result=$discountstatic->getSumDepositsUsed($this, $multicurrency);
0 ignored issues
show
Compatibility introduced by
$this of type object<CommonInvoice> is not a sub-type of object<Facture>. It seems like you assume a child class of the class CommonInvoice to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
175
	    if ($result >= 0)
176
	    {
177
	        return $result;
178
	    }
179
	    else
180
	    {
181
	        $this->error=$discountstatic->error;
182
	        return -1;
183
	    }
184
	}
185
	
186
	
187
	/**
188
	 *	Renvoie tableau des ids de facture avoir issus de la facture
189
	 *
190
	 *	@return		array		Tableau d'id de factures avoirs
191
	 */
192
	function getListIdAvoirFromInvoice()
193
	{
194
		$idarray=array();
195
196
		$sql = 'SELECT rowid';
197
		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
198
		$sql.= ' WHERE fk_facture_source = '.$this->id;
199
		$sql.= ' AND type = 2';
200
		$resql=$this->db->query($sql);
201
		if ($resql)
202
		{
203
			$num = $this->db->num_rows($resql);
204
			$i = 0;
205
			while ($i < $num)
206
			{
207
				$row = $this->db->fetch_row($resql);
208
				$idarray[]=$row[0];
209
				$i++;
210
			}
211
		}
212
		else
213
		{
214
			dol_print_error($this->db);
215
		}
216
		return $idarray;
217
	}
218
219
	/**
220
	 *	Renvoie l'id de la facture qui la remplace
221
	 *
222
	 *	@param		string	$option		filtre sur statut ('', 'validated', ...)
223
	 *	@return		int					<0 si KO, 0 si aucune facture ne remplace, id facture sinon
224
	 */
225
	function getIdReplacingInvoice($option='')
226
	{
227
		$sql = 'SELECT rowid';
228
		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
229
		$sql.= ' WHERE fk_facture_source = '.$this->id;
230
		$sql.= ' AND type < 2';
231
		if ($option == 'validated') $sql.= ' AND fk_statut = 1';
232
		// PROTECTION BAD DATA
233
		// Au cas ou base corrompue et qu'il y a une facture de remplacement validee
234
		// et une autre non, on donne priorite a la validee.
235
		// Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes
236
		// ont cree en meme temps une facture de remplacement pour la meme facture)
237
		$sql.= ' ORDER BY fk_statut DESC';
238
239
		$resql=$this->db->query($sql);
240
		if ($resql)
241
		{
242
			$obj = $this->db->fetch_object($resql);
243
			if ($obj)
244
			{
245
				// Si il y en a
246
				return $obj->rowid;
247
			}
248
			else
249
			{
250
				// Si aucune facture ne remplace
251
				return 0;
252
			}
253
		}
254
		else
255
		{
256
			return -1;
257
		}
258
	}
259
260
	/**
261
	 *	Return label of type of invoice
262
	 *
263
	 *	@return     string        Label of type of invoice
264
	 */
265
	function getLibType()
266
	{
267
		global $langs;
268
        if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard");
269
        if ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement");
270
        if ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir");
271
        if ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit");
272
        if ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma");           // Not used.
273
        if ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation");
274
		return $langs->trans("Unknown");
275
	}
276
277
	/**
278
	 *  Return label of object status
279
	 *
280
	 *  @param      int		$mode			0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto
281
	 *  @param      integer	$alreadypaid    0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise)
282
	 *  @return     string			        Label
283
	 */
284
	function getLibStatut($mode=0,$alreadypaid=-1)
285
	{
286
		return $this->LibStatut($this->paye,$this->statut,$mode,$alreadypaid,$this->type);
287
	}
288
289
	/**
290
	 *	Renvoi le libelle d'un statut donne
291
	 *
292
	 *	@param    	int  	$paye          	Status field paye
293
	 *	@param      int		$status        	Id status
294
	 *	@param      int		$mode          	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto
295
	 *	@param		integer	$alreadypaid	0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise)
296
	 *	@param		int		$type			Type invoice
297
	 *	@return     string        			Libelle du statut
298
	 */
299
	function LibStatut($paye,$status,$mode=0,$alreadypaid=-1,$type=0)
300
	{
301
		global $langs;
302
		$langs->load('bills');
303
304
		//print "$paye,$status,$mode,$alreadypaid,$type";
305
		if ($mode == 0)
306
		{
307
			$prefix='';
308
			if (! $paye)
309
			{
310
				if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
311
				if (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid');
312
				if (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
313
				if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
314
				return $langs->trans('Bill'.$prefix.'StatusStarted');
315
			}
316
			else
317
			{
318
				if ($type == 2) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');       // credit note
319
				elseif ($type == 3) return $langs->trans('Bill'.$prefix.'StatusConverted');             // deposit invoice
320
				else return $langs->trans('Bill'.$prefix.'StatusPaid');
321
			}
322
		}
323
		if ($mode == 1)
324
		{
325
			$prefix='Short';
326
			if (! $paye)
327
			{
328
				if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
329
				if (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled');
330
				if (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
331
				if ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
332
				return $langs->trans('Bill'.$prefix.'StatusStarted');
333
			}
334
			else
335
			{
336
				if ($type == 2) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
337
				elseif ($type == 3) return $langs->trans('Bill'.$prefix.'StatusConverted');
338
				else return $langs->trans('Bill'.$prefix.'StatusPaid');
339
			}
340
		}
341
		if ($mode == 2)
342
		{
343
			$prefix='Short';
344
			if (! $paye)
345
			{
346
				if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft');
347
				if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
348
				if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
349
				if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid');
350
				return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted');
351
			}
352
			else
353
			{
354
				if ($type == 2) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
355
				elseif ($type == 3) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted');
356
				else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid');
357
			}
358
		}
359
		if ($mode == 3)
360
		{
361
			$prefix='Short';
362
			if (! $paye)
363
			{
364
				if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0');
365
				if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5');
366
				if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
367
				if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1');
368
				return img_picto($langs->trans('BillStatusStarted'),'statut3');
369
			}
370
			else
371
			{
372
				if ($type == 2) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
373
				elseif ($type == 3) return img_picto($langs->trans('BillStatusConverted'),'statut6');
374
				else return img_picto($langs->trans('BillStatusPaid'),'statut6');
375
			}
376
		}
377
		if ($mode == 4)
378
		{
379
			$prefix='';
380
			if (! $paye)
381
			{
382
				if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft');
383
				if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
384
				if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
385
				if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid');
386
				return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted');
387
			}
388
			else
389
			{
390
				if ($type == 2) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted');
391
				elseif ($type == 3) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted');
392
				else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid');
393
			}
394
		}
395
		if ($mode == 5)
396
		{
397
			$prefix='Short';
398
			if (! $paye)
399
			{
400
				if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0');
401
				if (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5');
402
				if (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7');
403
				if ($alreadypaid <= 0) 
404
				{
405
				    if ($type == 2) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1');
406
				    return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1');
407
				}
408
				return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3');
409
			}
410
			else
411
			{
412
				if ($type == 2) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
413
				elseif ($type == 3) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6');
414
				else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6');
415
			}
416
		}
417
	}
418
419
	/**
420
	 *	Renvoi une date limite de reglement de facture en fonction des
421
	 *	conditions de reglements de la facture et date de facturation
422
	 *
423
	 *	@param      integer	$cond_reglement   	Condition of payment (code or id) to use. If 0, we use current condition.
424
	 *	@return     date     			       	Date limite de reglement si ok, <0 si ko
425
	 */
426
	function calculate_date_lim_reglement($cond_reglement=0)
427
	{
428
		if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code;
429
		if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id;
430
431
		$cdr_nbjour=0; $cdr_type=0; $cdr_decalage=0;
432
433
		$sqltemp = 'SELECT c.type_cdr,c.nbjour,c.decalage';
434
		$sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c';
435
		if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement;
436
		else $sqltemp.= " WHERE c.code='".$this->db->escape($cond_reglement)."'";
437
438
		dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG);
439
		$resqltemp=$this->db->query($sqltemp);
440
		if ($resqltemp)
441
		{
442
			if ($this->db->num_rows($resqltemp))
443
			{
444
				$obj = $this->db->fetch_object($resqltemp);
445
				$cdr_nbjour = $obj->nbjour;
446
				$cdr_type = $obj->type_cdr;
447
				$cdr_decalage = $obj->decalage;
448
			}
449
		}
450
		else
451
		{
452
			$this->error=$this->db->error();
453
			return -1;
454
		}
455
		$this->db->free($resqltemp);
456
457
		/* Definition de la date limite */
458
459
		// 1 : ajout du nombre de jours
460
		$datelim = $this->date + ($cdr_nbjour * 3600 * 24);
461
462
		// 2 : application de la regle "fin de mois"
463
		if ($cdr_type == 1)
464
		{
465
			$mois=date('m', $datelim);
466
			$annee=date('Y', $datelim);
467
			if ($mois == 12)
468
			{
469
				$mois = 1;
470
				$annee += 1;
471
			}
472
			else
473
			{
474
				$mois += 1;
475
			}
476
			// On se deplace au debut du mois suivant, et on retire un jour
477
			$datelim=dol_mktime(12,0,0,$mois,1,$annee);
478
			$datelim -= (3600 * 24);
479
		}
480
		elseif($cdr_type == 2 && !empty($cdr_nbjour)) // Application de la règle, le N du mois courant ou suivant
481
		{
482
			
483
			$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
484
			$date_lim_current = dol_mktime(0,0,0,date('m', $this->date),$cdr_nbjour,date('Y', $this->date)); // Sans les heures minutes et secondes
485
			$date_lim_next = strtotime(date('Y-m-d', $date_lim_current).' +1month');
486
			
487
			$diff = $date_piece - $date_lim_current;
488
			
489
			if($diff < 0) $datelim = $date_lim_current;
490
			else $datelim = $date_lim_next;
491
492
		}
493
494
		// 3 : application du decalage
495
		$datelim += ($cdr_decalage * 3600 * 24);
496
497
		return $datelim;
498
	}
499
}
500
501
502
503
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
504
505
/**
506
 *	Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...)
507
 */
508
abstract class CommonInvoiceLine extends CommonObjectLine
509
{
510
	/**
511
	 * Quantity
512
	 * @var int
513
	 */
514
	public $qty;
515
516
	/**
517
	 * Unit price before taxes
518
	 * @var float
519
	 */
520
	public $subprice;
521
522
	/**
523
	 * Type of the product. 0 for product 1 for service
524
	 * @var int
525
	 */
526
	public $product_type = 0;
527
528
	/**
529
	 * Id of corresponding product
530
	 * @var int
531
	 */
532
	public $fk_product;
533
534
	/**
535
	 * VAT %
536
	 * @var float
537
	 */
538
	public $tva_tx;
539
540
	/**
541
	 * Local tax 1 %
542
	 * @var float
543
	 */
544
	public $localtax1_tx;
545
546
	/**
547
	 * Local tax 2 %
548
	 * @var float
549
	 */
550
	public $localtax2_tx;
551
552
	/**
553
	 * Percent of discount
554
	 * @var float
555
	 */
556
	public $remise_percent;
557
558
	/**
559
	 * Total amount before taxes
560
	 * @var float
561
	 */
562
	public $total_ht;
563
564
	/**
565
	 * Total VAT amount
566
	 * @var float
567
	 */
568
	public $total_tva;
569
570
	/**
571
	 * Total local tax 1 amount
572
	 * @var float
573
	 */
574
	public $total_localtax1;
575
576
	/**
577
	 * Total local tax 2 amount
578
	 * @var float
579
	 */
580
	public $total_localtax2;
581
582
	/**
583
	 * Total amount with taxes
584
	 * @var float
585
	 */
586
	public $total_ttc;
587
588
	/**
589
	 * Liste d'options cumulables:
590
	 * Bit 0:	0 si TVA normal - 1 si TVA NPR
591
	 * Bit 1:	0 si ligne normal - 1 si bit discount (link to line into llx_remise_except)
592
	 * @var int
593
	 */
594
	public $info_bits = 0;
595
596
	/**
597
	 *  Constructor
598
	 *
599
	 *  @param	DoliDB		$db		Database handler
600
	 */
601
	public function __construct(DoliDB $db)
602
	{
603
		$this->db = $db;
604
	}
605
}
606
607