Salut, je fais partie vente en ligne du site web amis je trouve une probléme au cours de calcul tva et totalHt

voici probléme :

Nom : Capture5387.PNG
Affichages : 5355
Taille : 14,6 Ko

partie du code commande (code facture):

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
public function facture()
****{
*********$em = $this->getDoctrine()->getManager();
********$generator = $this->container->get('security.secure_random');
********$session = $this->getRequest()->getSession();
********$adresse = $session->get('adresse');
********$panier = $session->get('panier');
********$commande = array();
********$totalHT = 0;
********$totalTVA = 0;
*********
********$facturation = $em->getRepository('ventenligneBundle:UtilisateursAdresses')->find($adresse['facturation']);
********$livraison = $em->getRepository('ventenligneBundle:UtilisateursAdresses')->find($adresse['livraison']);
********$produits = $em->getRepository('ventenligneBundle:Produit')->findArray(array_keys($session->get('panier')));
*********
**********
********foreach($produits as $produit)
********{
************$prixHT = ($produit->getPrix() * $panier[$produit->getId()]);
************$prixTTC =** ($produit->getPrix() * $panier[$produit->getId()] / $produit->getTva()->getMultiplicate());
************$totalHT += $prixHT;
*************
************if (!isset($commande['tva']['%'.$produit->getTva()->getValeur()]))
****************$commande['tva']['%'.$produit->getTva()->getValeur()] = round($prixTTC - $prixHT,2);
************else
****************$commande['tva']['%'.$produit->getTva()->getValeur()] += round($prixTTC - $prixHT,2);
*************
************$totalTVA += round($prixTTC - $prixHT,2);
*************
************$commande['produit'][$produit->getId()] = array('reference' => $produit->getNom(),
************************************************************'quantite' => $panier[$produit->getId()],
************************************************************'prixHT' => round($produit->getPrix(),2),
*************************'prixTTC' => round($produit->getPrix() / $produit->getTva()->getMultiplicate(),2));
********}**
*********
********$commande['livraison'] = array('prenom' => $livraison->getPrenom(),
************************************'nom' => $livraison->getNom(),
************************************'telephone' => $livraison->getTelephone(),
************************************'adresse' => $livraison->getAdresse(),
************************************'cp' => $livraison->getCp(),
************************************'ville' => $livraison->getVille());
********$commande['facturation'] = array('prenom' => $facturation->getPrenom(),
************************************'nom' => $facturation->getNom(),
************************************'telephone' => $facturation->getTelephone(),
************************************'adresse' => $facturation->getAdresse(),
************************************'cp' => $facturation->getCp(),
************************************'ville' => $facturation->getVille());
********$commande['prixHT'] = round($totalHT,2);
********$commande['prixTTC'] = round($totalHT + $totalTVA,2);
********$commande['token'] = bin2hex($generator->nextBytes(20));
********return $commande;
****}
*****
****public function prepareCommandeAction()
****{
*********$session = $this->getRequest()->getSession();
********$em = $this->getDoctrine()->getManager();
*********
********if (!$session->has('commande'))
************$commande = new Commandes();
********else
************$commande = $em->getRepository('ventenligneBundle:Commandes')->find($session->get('commande'));
*********
********$commande->setDate(new \DateTime());
********$commande->setUtilisateur($this->container->get('security.context')->getToken()->getUser());
********$commande->setValider(0);
********$commande->setReference(0);
********$commande->setCommande($this->facture());
*********
********if (!$session->has('commande')) {
************$em->persist($commande);
************$session->set('commande',$commande);
********}
*********
********$em->flush();
*********
********return new Response($commande->getId());
****}
code panier.html.twig :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<link rel="stylesheet" href="{{ asset ('bundles/crud/css/bootstrap.css') }}" />
<link rel="stylesheet" href="{{ asset ('bundles/crud/css/bootstrap-responsive.css') }}" />
<link rel="stylesheet" href="{{ asset ('bundles/crud/css/style.css') }}" />
<link rel="stylesheet" href=" {{ asset ('bundles/crud/css/font-awesome.css') }}" />
*
{% set totalHT = 0 %}
{% set totalTTC = 0%}
{% set refTva = {} %}
{% set remise = 0 %}***
*{% for produit in produits %}
*****{% set refTva = refTva|merge({ (produit.tva.valeur ~ '%' ) : 0 }) %}
**{% endfor %}
*******
<div class="container">
****<div class="row">
********<div class="span3">
****************{% include '::ModulesUsed/navigation.html.twig' %}
************</div>*
*
************<div class="span8">
******************{% for flashMessage in app.session.flashbag.get('success') %}
********************<div class="alert alert-success">
************************{{ flashMessage }}
********************</div>
****************{% endfor %}***
************<h2>Votre parnier</h2>**
*************
****************<table class="table table-striped table-hover">
********************<thead>
************************<tr>
****************************<th>Références</th>
****************************<th>Quantité</th>
****************************<th>Prix unitaire</th>
****************************<th>Total HT</th>
************************</tr>
********************</thead>
********************<tbody>
************************{% if produits|length == 0 %}
****************************<tr>
********************************<td class="text-center" colspan="4">Aucun article dans votre panier</td>
****************************</tr>**
************************{% endif %}***
*************************
************************{% for produit in produits %}
*****************************
********************{% set totalHT = totalHT + (produit.prix * panier[produit.id]) %}
********************{% set totalTTC = totalTTC + (produit.prix * panier[produit.id])|tva(produit.tva.multiplicate) %}
********************{% set refTva = refTva|merge({ ( produit.tva.valeur ~ '%' ) : refTva[produit.tva.valeur ~ '%'] + ( produit.prix * panier[produit.id])|montantTva(produit.tva.multiplicate) }) %}
********************{% set remise = ((totalHT * 10) /100) %}
***********************
************************<tr>
***************************<form action="{{ path('ajouter', { 'id' : produit.id }) }}" method="get">
*
****************************<td>{{ produit.nom }}</td>
****************************<td>
********************************<select name="qte" class="span1" onChange="this.form.submit()">
************************************{% for i in 1..10 %}
****************************************<option value="{{ i }}" {% if i == panier[produit.id] %} selected="selected" {% endif %}>{{ i }}</option>
************************************{% endfor %}
********************************</select>&nbsp;
**********************************
********************************<a href="{{ path('supprimer', { 'id' : produit.id }) }}"><i class="icon-trash"></i></a>
****************************</td>
****************************<td>{{ produit.prix }} €</td>
*****************************
**********************************{% if is_granted('ROLE_ADHERANT') %}
****************************<td>{{ produit.prix * panier[produit.id] - remise }}* €</td>
****************************{% else %}
********************************<td>{{ produit.prix * panier[produit.id] }}* €</td>
****************************{% endif %}
***************************</form>
************************</tr>
*********************
************************{% endfor %}
********************</tbody>
****************</table>
************</form>
*
************<dl class="dl-horizontal pull-right">
******************{% if is_granted('ROLE_ADHERANT') %}
********************<dt>Total HT:</dt> <dd>{{ totalHT - remise }} €</dd>
********************{% else %}
****************<dt>Total HT :</dt> <dd>{{ totalHT }} €</dd>
***************{% endif %}
****************{% for key, tva in refTva %}
****************<dt>TVA {{ key }} :</dt> <dd>{{ tva }} €</dd>
****************{% endfor %}
***********************************
****************<dt>Total TTC:</dt> <dd>{{ totalTTC }} €</dd>
******************
************</dl>
************<div class="clearfix"></div>
************<a href="{{ path('livraison') }}" class="btn btn-success pull-right">Valider mon panier</a>
************<a href="{{ path('produit') }}" class="btn btn-primary">Continuer mes achats</a>
********</div>
*
****</div>
</div>
*
<script src="{{ asset ('bundles/crud/js/bootstrap.js') }}"></script>
<script src="{{ asset ('bundles/crud/js/jquery.min.js') }}"></script>***
code du facturePDF:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
****<head>
********<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
********<title>Facture</title>
********<link rel="stylesheet" href="{{ asset ('bundles/crud/css/bootstrap.css') }}" />
********<link rel="stylesheet" href="{{ asset ('bundles/crud/css/bootstrap-responsive.css') }}" />
********<link rel="stylesheet" href="{{ asset ('bundles/crud/css/style.css') }}" />
********<link rel="stylesheet" href=" {{ asset ('bundles/crud/css/font-awesome.css') }}" />
********<link href=" {{ asset ('bundles/crud/css/facture.css') }}" rel="stylesheet" />
****</head>
****<body style="background-color:#444;">
*
****
************
********<h1>DevAndClick</h1>
********<table id="enTete">
************<tr>
****************<td colspan="1"></td>
****************<td colspan="1"><h1>Facture</h1></td>
****************<td colspan="1"></td>
************</tr>
**************
************<tr>
****************<td width="80">Page</td>
****************<td width="100">Date</td>
****************<td width="120">Ref</td>
************</tr>
************<tr>
****************<td class="color">[[page_nb]]</td>
****************<td class="color">{{ facture.date|date('d-m-Y') }}</td>
****************<td class="color">{{ facture.reference }}</td>
************</tr>
********</table>
********<ul id="coordonnes">
************<li>{{ facture.commande.facturation.nom }} {{ facture.commande.facturation.prenom }}</li>
************<li>{{ facture.commande.facturation.adresse}}</li>
************<li>{{ facture.commande.facturation.cp }} {{ facture.commande.facturation.ville }}</li>
********</ul>
********<table id="entity">
************<tr>
****************<td width="280">DESIGNATION</td>
****************<td width="105">QUANTITE</td>
****************<td width="100">P.U - HT</td>
****************<td width="105">MONTANT HT</td>
****************<td width="105">MONTANT TTC</td>
************</tr>
****************{% for produit in facture.commande.produit %}
****************<tr>
********************<td class="color">{{ produit.reference }}</td>
********************<td class="color">{{ produit.quantite }}</td>
********************<td class="color">{{ produit.prixHT }} €</td>
********************<td class="color">{{ produit.prixHT * produit.quantite }} €</td>
********************<td class="color">{{ produit.prixTTC * produit.quantite }} €</td>
****************</tr>
****************{% endfor %}
********</table>
********<table id="total">
************<tr>
****************<td width="110">TOTAL HT :</td>
****************<td width="100" class="color">{{ facture.commande.prixHT }} €</td>
************</tr>
************{% for key, tva in facture.commande.tva %}
************<tr>
****************<td width="110">TVA <span class="color min">{{ key }}</span> :</td>
****************<td width="100" class="color">{{ tva }} €</td>
************</tr>
************{% endfor %}
************<tr>
****************<td width="110">TOTAL TTC :</td>
****************<td width="100" class="color">{{ facture.commande.prixTTC }} €</td>
************</tr>
********</table>
********<div id="footer">
*************
********</div>
*********
****</body>
</html>
*
***
ou ést la probléme et merci d'avance