diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php
index b4f90372b00..8e5928e24b0 100644
--- a/htdocs/cashdesk/affContenu.php
+++ b/htdocs/cashdesk/affContenu.php
@@ -16,54 +16,49 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
- require ('classes/Facturation.class.php');
+require ('classes/Facturation.class.php');
- // Si nouvelle vente, réinitialisation des données (destruction de l'objet et vidage de la table contenant la liste des articles)
- if ( $_GET['id'] == 'NOUV' ) {
+// Si nouvelle vente, réinitialisation des données (destruction de l'objet et vidage de la table contenant la liste des articles)
+if ( $_GET['id'] == 'NOUV' ) {
- unset ($_SESSION['serObjFacturation']);
+ unset ($_SESSION['serObjFacturation']);
- $sql->query ('DELETE FROM '.MAIN_DB_PREFIX.'tmp_caisse');
+ $sql->query ('DELETE FROM '.MAIN_DB_PREFIX.'tmp_caisse');
- }
+}
- // Récupération, s'il existe, de l'objet contenant les infos de la vente en cours ...
- if ( isset ($_SESSION['serObjFacturation']) ) {
+// Récupération, s'il existe, de l'objet contenant les infos de la vente en cours ...
+if ( isset ($_SESSION['serObjFacturation']) ) {
- $obj_facturation = unserialize ($_SESSION['serObjFacturation']);
- unset ($_SESSION['serObjFacturation']);
+ $obj_facturation = unserialize ($_SESSION['serObjFacturation']);
+ unset ($_SESSION['serObjFacturation']);
// ... sinon, c'est une nouvelle vente
- } else {
+} else {
- $obj_facturation = new Facturation;
+ $obj_facturation = new Facturation;
- }
+}
?>
-
-
-
+
-
diff --git a/htdocs/cashdesk/classes/Facturation.class.php b/htdocs/cashdesk/classes/Facturation.class.php
index a56390ef833..5b9ff5b566e 100644
--- a/htdocs/cashdesk/classes/Facturation.class.php
+++ b/htdocs/cashdesk/classes/Facturation.class.php
@@ -49,8 +49,6 @@
*
* @var int $prix_total_ht => Prix total hors taxes
* @var int $montant_tva => Montant total de la TVA, tous taux confondus
- * @var int $montant_tva_19_6 => Montant de la TVA à 19.6%
- * @var int $montant_tva_5_5 => Montant de la TVA à 5.5%
* @var int $prix_total_ttc => Prix total TTC
*/
protected $num_facture;
@@ -61,8 +59,6 @@
protected $prix_total_ht;
protected $montant_tva;
- protected $montant_tva_19_6;
- protected $montant_tva_5_5;
protected $prix_total_ttc;
@@ -85,9 +81,11 @@
$tab_tva = $sql->fetchFirst ( $sql->query ('SELECT taux FROM '.MAIN_DB_PREFIX.'c_tva WHERE rowid = '.$this->tva().';') );
+
+ // TODO Mettre methode de calcul arrondi TVA de Dolibarr
+
// Calcul du total ht sans remise
$total_ht = ( $this->qte * $this->prix() );
-
// Calcul du montant de la remise
if ( $this->remise_percent() ) {
@@ -98,13 +96,12 @@
$remise_percent = 0;
}
-
$montant_remise = $total_ht * $remise_percent / 100;
$this->montant_remise ($montant_remise);
-
// Calcul du total ttc
$total_ttc = ($total_ht - $montant_remise) * (($tab_tva['taux'] / 100) + 1);
+
$sql->query('
INSERT INTO '.MAIN_DB_PREFIX.'tmp_caisse (
fk_article,
@@ -123,9 +120,6 @@
'.price2num($total_ht).',
'.price2num($total_ttc).')');
- // On modifie les totaux
- $this->calculTotaux();
-
$this->raz();
}
@@ -143,7 +137,7 @@
}
/**
- * Calcul du total HT, total TTC et montants TVA par types
+ * Calcul du total HT, total TTC et montants TVA
*/
public function calculTotaux () {
global $conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base;
@@ -151,13 +145,13 @@
$sql = new Sql ($conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base);
// Incrémentation des compteurs
- $res = $sql->query ('SELECT remise, total_ht, taux FROM '.MAIN_DB_PREFIX.'tmp_caisse as c
+ $res = $sql->query ('SELECT remise, total_ht, total_ttc, taux FROM '.MAIN_DB_PREFIX.'tmp_caisse as c
LEFT JOIN '.MAIN_DB_PREFIX.'c_tva as t ON c.fk_tva = t.rowid
ORDER BY id');
- $total_tva_19_6 = 0;
- $total_tva_5_5 = 0;
- $total_tva_0 = 0;
+ $total_ht=0;
+ $total_ttc=0;
+
if ( $sql->numRows($res) ) {
$tab = $sql->fetchAll($res);
@@ -166,35 +160,15 @@
// Total HT
$remise = $tab[$i]['remise'];
- $total = ($tab[$i]['total_ht'] - $remise);
-
- // Calcul des totaux HT par taux de tva
- if ( $tab[$i]['taux'] == '19.6' ) {
-
- $total_tva_19_6 += $total;
-
- } elseif ( $tab[$i]['taux'] == '5.5' ) {
-
- $total_tva_5_5 += $total;
-
- } else {
-
- $total_tva_0 += $total;
-
- }
-
+ $total_ht += ($tab[$i]['total_ht']);
+ $total_ttc += ($tab[$i]['total_ttc']);
}
- $this->prix_total_ht = $total_tva_0 + $total_tva_19_6 + $total_tva_5_5;
-
- $total_ttc_19_6 = round ( ($total_tva_19_6 * 1.196), 2 );
- $total_ttc_5_5 = round ( ($total_tva_5_5 * 1.055), 2 );
- $this->prix_total_ttc = $total_ttc_19_6 + $total_ttc_5_5 + $total_tva_0;
-
- $this->montant_tva_19_6 = ($total_ttc_19_6 - $total_tva_19_6);
- $this->montant_tva_5_5 = ($total_ttc_5_5 - $total_tva_5_5);
- $this->montant_tva = ($this->montant_tva_19_6 + $this->montant_tva_5_5);
-
+ $this->prix_total_ttc = $total_ttc;
+ $this->prix_total_ht = $total_ht;
+
+ $this->montant_tva = $total_ttc - $total_ht;
+ //print $this->prix_total_ttc.'eeee'; exit;
}
}
@@ -228,8 +202,6 @@
$this->prix_total_ht ('RESET');
$this->montant_tva ('RESET');
- $this->montant_tva_19_6 ('RESET');
- $this->montant_tva_5_5 ('RESET');
$this->prix_total_ttc ('RESET');
}
@@ -505,42 +477,6 @@
}
- public function montant_tva_19_6 ( $aMontantTva=null ) {
-
- if ( !$aMontantTva ) {
-
- return $this->montant_tva_19_6;
-
- } else if ( $aMontantTva == 'RESET' ) {
-
- $this->montant_tva_19_6 = NULL;
-
- } else {
-
- $this->montant_tva_19_6 = $aMontantTva;
-
- }
-
- }
-
- public function montant_tva_5_5 ( $aMontantTva=null ) {
-
- if ( !$aMontantTva ) {
-
- return $this->montant_tva_5_5;
-
- } else if ( $aMontantTva == 'RESET' ) {
-
- $this->montant_tva_5_5 = NULL;
-
- } else {
-
- $this->montant_tva_5_5 = $aMontantTva;
-
- }
-
- }
-
public function prix_total_ttc ( $aTotalTtc=null ) {
if ( !$aTotalTtc ) {
diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php
index 1a134be5e58..0a5ea276a54 100644
--- a/htdocs/cashdesk/facturation.php
+++ b/htdocs/cashdesk/facturation.php
@@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
- // Récupération de la liste des articles
- if ( $_GET['filtre'] ) {
+// Récupération de la liste des articles
+if ( $_GET['filtre'] ) {
- // Avec filtre
- $tab_designations = $sql->fetchAll ( $sql->query (
+ // Avec filtre
+ $tab_designations = $sql->fetchAll ( $sql->query (
'SELECT '.MAIN_DB_PREFIX.'product.rowid, ref, label, tva_tx
FROM '.MAIN_DB_PREFIX.'product
LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product
@@ -32,10 +32,10 @@
ORDER BY label
;'));
- } else {
+} else {
- // Sans filtre
- $tab_designations = $sql->fetchAll ( $sql->query ('
+ // Sans filtre
+ $tab_designations = $sql->fetchAll ( $sql->query ('
SELECT '.MAIN_DB_PREFIX.'product.rowid, ref, label, tva_tx
FROM '.MAIN_DB_PREFIX.'product
LEFT JOIN '.MAIN_DB_PREFIX.'product_stock ON '.MAIN_DB_PREFIX.'product.rowid = '.MAIN_DB_PREFIX.'product_stock.fk_product
@@ -45,50 +45,50 @@
ORDER BY label
;'));
- }
+}
- $nbr_enreg = count ($tab_designations);
+$nbr_enreg = count ($tab_designations);
- if ( $nbr_enreg > 1 ) {
+if ( $nbr_enreg > 1 ) {
- if ( $nbr_enreg > $conf_taille_listes ) {
+ if ( $nbr_enreg > $conf_taille_listes ) {
- $top_liste_produits = '----- '.$conf_taille_listes.' produits affichés sur un total de '.$nbr_enreg.' -----';
-
- } else {
-
- $top_liste_produits = '----- '.$nbr_enreg.' produits affichés sur un total de '.$nbr_enreg.' -----';
-
- }
-
- } else if ( $nbr_enreg == 1 ) {
-
- $top_liste_produits = '----- 1 article trouvé -----';
+ $top_liste_produits = '----- '.$conf_taille_listes.' produits affichés sur un total de '.$nbr_enreg.' -----';
} else {
- $top_liste_produits = '----- Aucun article trouvé -----';
+ $top_liste_produits = '----- '.$nbr_enreg.' produits affichés sur un total de '.$nbr_enreg.' -----';
}
+} else if ( $nbr_enreg == 1 ) {
- // Récupération des taux de tva
- global $mysoc;
- $request="SELECT t.rowid, t.taux
+ $top_liste_produits = '----- 1 article trouvé -----';
+
+} else {
+
+ $top_liste_produits = '----- Aucun article trouvé -----';
+
+}
+
+
+// Récupération des taux de tva
+global $mysoc;
+$request="SELECT t.rowid, t.taux
FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p
WHERE t.fk_pays = p.rowid AND t.active = 1 AND p.code = '".$mysoc->pays_code."'";
- //print $request;
- $tab_tva = $sql->fetchAll ($sql->query ($request));
+//print $request;
+$tab_tva = $sql->fetchAll ($sql->query ($request));
- // Réinitialisation du mode de paiement, en cas de retour aux achats après validation
- $obj_facturation->mode_reglement ('RESET');
- $obj_facturation->montant_encaisse ('RESET');
- $obj_facturation->montant_rendu ('RESET');
- $obj_facturation->paiement_le ('RESET');
+// Réinitialisation du mode de paiement, en cas de retour aux achats après validation
+$obj_facturation->mode_reglement ('RESET');
+$obj_facturation->montant_encaisse ('RESET');
+$obj_facturation->montant_rendu ('RESET');
+$obj_facturation->paiement_le ('RESET');
- // Affichage des templates
- require ('templates/facturation1.tpl.php');
+// Affichage des templates
+require ('templates/facturation1.tpl.php');
?>
diff --git a/htdocs/cashdesk/templates/liste_articles.tpl.php b/htdocs/cashdesk/templates/liste_articles.tpl.php
index c4661131695..3bd74964ecd 100644
--- a/htdocs/cashdesk/templates/liste_articles.tpl.php
+++ b/htdocs/cashdesk/templates/liste_articles.tpl.php
@@ -53,6 +53,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
+ $obj_facturation->calculTotaux();
$total_ttc = $obj_facturation->prix_total_ttc();
echo ('TOTAL : '.number_format ($total_ttc, 2, '.', '').' '.$conf->monnaie.'
'."\n");
diff --git a/htdocs/cashdesk/templates/ticket.tpl.php b/htdocs/cashdesk/templates/ticket.tpl.php
index bf1b6af2a5e..1cc2423b603 100644
--- a/htdocs/cashdesk/templates/ticket.tpl.php
+++ b/htdocs/cashdesk/templates/ticket.tpl.php
@@ -146,23 +146,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
| Total HT | '.number_format ($obj_facturation->prix_total_ht(),2, '.', '')." € | \n";
- if ( $obj_facturation->montant_tva_19_6() ) {
+ echo '| Total HT | '.price2num($obj_facturation->prix_total_ht())." ".$conf->monnaie." |
\n";
+ if ( $obj_facturation->montant_tva() ) {
- echo '| TVA 19.6% | '.number_format ($obj_facturation->montant_tva_19_6(),2, '.', '')." € |
\n";
+ echo '| TVA | '.price2num($obj_facturation->montant_tva())." ".$conf->monnaie." |
\n";
}
- if ( $obj_facturation->montant_tva_5_5() ) {
-
- echo '| TVA 5.5% | '.number_format ($obj_facturation->montant_tva_5_5(),2, '.', '')." € |
\n";
-
- }
- if ( !$obj_facturation->montant_tva_19_6() && !$obj_facturation->montant_tva_5_5() ) {
+ else {
echo ' | Pas de TVA |
|---|
'."\n";
}
- echo '
| Total TTC | '.number_format ($obj_facturation->prix_total_ttc(), 2, '.', '')." € |
\n";
+ echo '| Total TTC | '.price2num($obj_facturation->prix_total_ttc())." ".$conf->monnaie." |
\n";
?>
diff --git a/htdocs/cashdesk/templates/validation1.tpl.php b/htdocs/cashdesk/templates/validation1.tpl.php
index e238c7f0335..22d4dca209d 100644
--- a/htdocs/cashdesk/templates/validation1.tpl.php
+++ b/htdocs/cashdesk/templates/validation1.tpl.php
@@ -19,27 +19,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
| Facture N° | num_facture(); ?> |
- | Prix HT : | prix_total_ht(), 2, '.', ''); ?> € |
+ | Prix HT : | prix_total_ht()).' '.$conf->monnaie; ?> |
montant_tva_19_6() ) {
+ if ( $obj_facturation->montant_tva() ) {
- echo ('| Montant TVA 19.6% : | '.number_format ($obj_facturation->montant_tva_19_6(), 2, '.', '').' € |
');
+ echo ('| Montant TVA 19.6% : | '.price2num($obj_facturation->montant_tva()).' '.$conf->monnaie.' |
');
}
-
- if ( $obj_facturation->montant_tva_5_5() ) {
-
- echo ('| Montant TVA 5.5% : | '.number_format ($obj_facturation->montant_tva_5_5(), 2, '.', '').' € |
');
-
- }
- if ( !$obj_facturation->montant_tva_19_6() && !$obj_facturation->montant_tva_5_5() ) {
+ else
+ {
echo ('| Montant TVA : | Pas de TVA pour cette vente |
');
}
?>
- | A payer : | prix_total_ttc(), 2, '.', ''); ?> € |
+ | A payer : | prix_total_ttc()).' '.$conf->monnaie; ?> |
| Mode de réglement : | mode_reglement(); ?> |
Encaissé : | '.number_format ($obj_facturation->montant_encaisse(), 2, '.', '').' € | ');
+ echo ('| Encaissé : | '.price2num($obj_facturation->montant_encaisse()).' '.$conf->monnaie.' |
');
}
// Affichage du montant rendu (réglement en espèces)
if ( $obj_facturation->montant_rendu() ) {
- echo ('| Rendu : | '.number_format ($obj_facturation->montant_rendu(), 2, '.', '').' € |
');
+ echo ('| Rendu : | '.price2num($obj_facturation->montant_rendu()).' '.$conf->monnaie.' |
');
}