20 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
49 protected $remise_percent;
50 protected $montant_remise;
67 protected $mode_reglement;
68 protected $montant_encaisse;
69 protected $montant_rendu;
70 protected $paiement_le;
72 protected $prix_total_ht;
73 protected $montant_tva;
74 protected $prix_total_ttc;
97 global $conf, $db, $mysoc;
99 $thirdpartyid = $_SESSION[
'CASHDESK_ID_THIRDPARTY'];
102 $societe->fetch($thirdpartyid);
105 $product->fetch($this->
id);
108 $vatrowid = $this->
tva();
111 $txtva = $tmp[
'rate'].(empty($tmp[
'code']) ?
'' :
' ('.$tmp[
'code'].
')');
112 $vat_npr = $tmp[
'npr'];
119 if (preg_match(
'/\((.*)\)/', $txtva, $reg))
121 $vat_src_code = $reg[1];
122 $txtva = preg_replace(
'/\s*\(.*\)/',
'', $txtva);
126 $resultarray =
calcul_price_total($this->
qte, $this->
prix(), $this->
remisePercent(), $txtva, -1, -1, 0,
'HT', $vat_npr, $product->type, $mysoc, $localtaxarray);
129 $total_ht = $resultarray[0];
130 $total_vat = $resultarray[1];
131 $total_ttc = $resultarray[2];
132 $total_localtax1 = $resultarray[9];
133 $total_localtax2 = $resultarray[10];
142 $montant_remise_ht = ($resultarray[6] - $resultarray[0]);
145 $newcartarray = $_SESSION[
'poscart'];
148 if (!is_null($newcartarray) && !empty($newcartarray)) {
149 $i = count($newcartarray);
152 $newcartarray[$i][
'id'] = $i;
153 $newcartarray[$i][
'ref'] = $product->ref;
154 $newcartarray[$i][
'label'] = $product->label;
155 $newcartarray[$i][
'price'] = $product->price;
156 $newcartarray[$i][
'price_ttc'] = $product->price_ttc;
158 if (!empty($conf->global->PRODUIT_MULTIPRICES))
160 if (isset($product->multiprices[$societe->price_level]))
162 $newcartarray[$i][
'price'] = $product->multiprices[$societe->price_level];
163 $newcartarray[$i][
'price_ttc'] = $product->multiprices_ttc[$societe->price_level];
167 $newcartarray[$i][
'fk_article'] = $this->id;
168 $newcartarray[$i][
'qte'] = $this->
qte();
169 $newcartarray[$i][
'fk_tva'] = $this->
tva();
170 $newcartarray[$i][
'remise_percent'] = $remise_percent;
171 $newcartarray[$i][
'remise'] =
price2num($montant_remise_ht);
172 $newcartarray[$i][
'total_ht'] =
price2num($total_ht,
'MT');
173 $newcartarray[$i][
'total_ttc'] =
price2num($total_ttc,
'MT');
174 $newcartarray[$i][
'total_vat'] =
price2num($total_vat,
'MT');
175 $newcartarray[$i][
'total_localtax1'] =
price2num($total_localtax1,
'MT');
176 $newcartarray[$i][
'total_localtax2'] =
price2num($total_localtax2,
'MT');
177 $_SESSION[
'poscart'] = $newcartarray;
190 $poscart = $_SESSION[
'poscart'];
193 $newposcart = array();
194 foreach ($poscart as $key => $val)
196 if ($poscart[$key][
'id'] != $aArticle)
198 $newposcart[$j] = $poscart[$key];
199 $newposcart[$j][
'id'] = $j;
205 $_SESSION[
'poscart'] = $newposcart;
220 $total_localtax1 = 0;
221 $total_localtax2 = 0;
223 $tab = (!empty($_SESSION[
'poscart']) ? $_SESSION[
'poscart'] : array());
225 $tab_size = count($tab);
226 for ($i = 0; $i < $tab_size; $i++)
229 $remise = $tab[$i][
'remise'];
230 $total_ht += ($tab[$i][
'total_ht']);
231 $total_vat += ($tab[$i][
'total_vat']);
232 $total_ttc += ($tab[$i][
'total_ttc']);
233 $total_localtax1 += ($tab[$i][
'total_localtax1']);
234 $total_localtax2 += ($tab[$i][
'total_localtax2']);
237 $this->prix_total_ttc = $total_ttc;
238 $this->prix_total_ht = $total_ht;
239 $this->prix_total_vat = $total_vat;
240 $this->prix_total_localtax1 = $total_localtax1;
241 $this->prix_total_localtax2 = $total_localtax2;
243 $this->montant_tva = $total_ttc - $total_ht;
257 $this->
stock(
'RESET');
260 $this->
prix(
'RESET');
291 public function id($aId = null)
297 } elseif ($aId ==
'RESET')
311 public function ref($aRef = null)
317 } elseif ($aRef ==
'RESET')
331 public function qte($aQte = null)
336 } elseif ($aQte ==
'RESET')
350 public function stock($aStock = null)
353 if (is_null($aStock))
356 } elseif ($aStock ==
'RESET')
360 $this->
stock = $aStock;
373 if (is_null($aRemisePercent))
375 return $this->remise_percent;
376 } elseif ($aRemisePercent ==
'RESET')
378 $this->remise_percent = null;
380 $this->remise_percent = $aRemisePercent;
393 if (is_null($aMontantRemise)) {
394 return $this->montant_remise;
395 } elseif ($aMontantRemise ==
'RESET') {
396 $this->montant_remise = null;
398 $this->montant_remise = $aMontantRemise;
408 public function prix($aPrix = null)
411 if (is_null($aPrix)) {
413 } elseif ($aPrix ==
'RESET') {
416 $this->
prix = $aPrix;
426 public function tva($aTva = null)
428 if (is_null($aTva)) {
430 } elseif ($aTva ==
'RESET') {
445 if (is_null($aNumFacture)) {
447 } elseif ($aNumFacture ==
'RESET') {
448 $this->num_facture = null;
450 $this->num_facture = $aNumFacture;
463 if (is_null($aModeReglement)) {
464 return $this->mode_reglement;
465 } elseif ($aModeReglement ==
'RESET') {
466 $this->mode_reglement = null;
468 $this->mode_reglement = $aModeReglement;
481 if (is_null($aMontantEncaisse)) {
482 return $this->montant_encaisse;
483 } elseif ($aMontantEncaisse ==
'RESET') {
484 $this->montant_encaisse = null;
486 $this->montant_encaisse = $aMontantEncaisse;
499 if (is_null($aMontantRendu)) {
500 return $this->montant_rendu;
501 } elseif ($aMontantRendu ==
'RESET') {
502 $this->montant_rendu = null;
504 $this->montant_rendu = $aMontantRendu;
516 if (is_null($aPaiementLe)) {
517 return $this->paiement_le;
518 } elseif ($aPaiementLe ==
'RESET') {
519 $this->paiement_le = null;
521 $this->paiement_le = $aPaiementLe;
533 if (is_null($aTotalHt)) {
534 return $this->prix_total_ht;
535 } elseif ($aTotalHt ==
'RESET') {
536 $this->prix_total_ht = null;
538 $this->prix_total_ht = $aTotalHt;
550 if (is_null($aMontantTva)) {
551 return $this->montant_tva;
552 } elseif ($aMontantTva ==
'RESET') {
553 $this->montant_tva = null;
555 $this->montant_tva = $aMontantTva;
567 if (is_null($aTotalTtc))
569 return $this->prix_total_ttc;
570 } elseif ($aTotalTtc ==
'RESET')
572 $this->prix_total_ttc = null;
574 $this->prix_total_ttc = $aTotalTtc;
amountCollected($aMontantEncaisse=null)
Get amount.
ref($aRef=null)
Getter for ref.
tva($aTva=null)
Getter for tva.
__construct()
Constructor.
$num_facture
Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation) s...
getSetPaymentMode($aModeReglement=null)
Get payment mode.
razPers()
Resetting persistent attributes.
remisePercent($aRemisePercent=null)
Getter for remise_percent.
numInvoice($aNumFacture=null)
Get num invoice.
supprArticle($aArticle)
Remove a product from panel.
Class to manage products or services.
calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller= '', $localtaxes_array= '', $progress=100, $multicurrency_tx=1, $pu_devise=0, $multicurrency_code= '')
Calculate totals (net, vat, ...) of a line.
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
calculTotaux()
Calculation of total HT, total TTC and VAT amounts.
amountWithTax($aTotalTtc=null)
Get total TTC.
amountDiscount($aMontantRemise=null)
Getter for montant_remise.
paiementLe($aPaiementLe=null)
Get payment date.
qte($aQte=null)
Getter for qte.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage invoices for pos module (cashdesk)
id($aId=null)
Getter for id.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
ajoutArticle()
Add a product into cart.
stock($aStock=null)
Getter for stock.
amountWithoutTax($aTotalHt=null)
Get total HT.
prix($aPrix=null)
Getter for prix.
amountReturned($aMontantRendu=null)
Get amount.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
amountVat($aMontantTva=null)
Get amount vat.