VAT management must be internationnal
This commit is contained in:
parent
3e0608154f
commit
7a4325be73
@ -42,13 +42,9 @@
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="liste_articles">
|
<div class="liste_articles"><?php include ('liste_articles.php'); ?></div>
|
||||||
<?php include ('liste_articles.php'); ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="principal">
|
<div class="principal"><?php
|
||||||
|
|
||||||
<?php
|
|
||||||
if ( $_GET['menu'] ) {
|
if ( $_GET['menu'] ) {
|
||||||
|
|
||||||
include ($_GET['menu'].'.php');
|
include ($_GET['menu'].'.php');
|
||||||
@ -58,8 +54,7 @@
|
|||||||
include ('facturation.php');
|
include ('facturation.php');
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?></div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|||||||
@ -49,8 +49,6 @@
|
|||||||
*
|
*
|
||||||
* @var int $prix_total_ht => Prix total hors taxes
|
* @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 => 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
|
* @var int $prix_total_ttc => Prix total TTC
|
||||||
*/
|
*/
|
||||||
protected $num_facture;
|
protected $num_facture;
|
||||||
@ -61,8 +59,6 @@
|
|||||||
|
|
||||||
protected $prix_total_ht;
|
protected $prix_total_ht;
|
||||||
protected $montant_tva;
|
protected $montant_tva;
|
||||||
protected $montant_tva_19_6;
|
|
||||||
protected $montant_tva_5_5;
|
|
||||||
protected $prix_total_ttc;
|
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().';') );
|
$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
|
// Calcul du total ht sans remise
|
||||||
$total_ht = ( $this->qte * $this->prix() );
|
$total_ht = ( $this->qte * $this->prix() );
|
||||||
|
|
||||||
// Calcul du montant de la remise
|
// Calcul du montant de la remise
|
||||||
if ( $this->remise_percent() ) {
|
if ( $this->remise_percent() ) {
|
||||||
|
|
||||||
@ -98,13 +96,12 @@
|
|||||||
$remise_percent = 0;
|
$remise_percent = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$montant_remise = $total_ht * $remise_percent / 100;
|
$montant_remise = $total_ht * $remise_percent / 100;
|
||||||
$this->montant_remise ($montant_remise);
|
$this->montant_remise ($montant_remise);
|
||||||
|
|
||||||
// Calcul du total ttc
|
// Calcul du total ttc
|
||||||
$total_ttc = ($total_ht - $montant_remise) * (($tab_tva['taux'] / 100) + 1);
|
$total_ttc = ($total_ht - $montant_remise) * (($tab_tva['taux'] / 100) + 1);
|
||||||
|
|
||||||
|
|
||||||
$sql->query('
|
$sql->query('
|
||||||
INSERT INTO '.MAIN_DB_PREFIX.'tmp_caisse (
|
INSERT INTO '.MAIN_DB_PREFIX.'tmp_caisse (
|
||||||
fk_article,
|
fk_article,
|
||||||
@ -123,9 +120,6 @@
|
|||||||
'.price2num($total_ht).',
|
'.price2num($total_ht).',
|
||||||
'.price2num($total_ttc).')');
|
'.price2num($total_ttc).')');
|
||||||
|
|
||||||
// On modifie les totaux
|
|
||||||
$this->calculTotaux();
|
|
||||||
|
|
||||||
$this->raz();
|
$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 () {
|
public function calculTotaux () {
|
||||||
global $conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base;
|
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);
|
$sql = new Sql ($conf_db_host, $conf_db_user, $conf_db_pass, $conf_db_base);
|
||||||
|
|
||||||
// Incrémentation des compteurs
|
// 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
|
LEFT JOIN '.MAIN_DB_PREFIX.'c_tva as t ON c.fk_tva = t.rowid
|
||||||
ORDER BY id');
|
ORDER BY id');
|
||||||
|
|
||||||
$total_tva_19_6 = 0;
|
$total_ht=0;
|
||||||
$total_tva_5_5 = 0;
|
$total_ttc=0;
|
||||||
$total_tva_0 = 0;
|
|
||||||
if ( $sql->numRows($res) ) {
|
if ( $sql->numRows($res) ) {
|
||||||
|
|
||||||
$tab = $sql->fetchAll($res);
|
$tab = $sql->fetchAll($res);
|
||||||
@ -166,35 +160,15 @@
|
|||||||
|
|
||||||
// Total HT
|
// Total HT
|
||||||
$remise = $tab[$i]['remise'];
|
$remise = $tab[$i]['remise'];
|
||||||
$total = ($tab[$i]['total_ht'] - $remise);
|
$total_ht += ($tab[$i]['total_ht']);
|
||||||
|
$total_ttc += ($tab[$i]['total_ttc']);
|
||||||
// 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;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
$this->prix_total_ttc = $total_ttc;
|
||||||
|
$this->prix_total_ht = $total_ht;
|
||||||
$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->montant_tva = $total_ttc - $total_ht;
|
||||||
|
//print $this->prix_total_ttc.'eeee'; exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -228,8 +202,6 @@
|
|||||||
|
|
||||||
$this->prix_total_ht ('RESET');
|
$this->prix_total_ht ('RESET');
|
||||||
$this->montant_tva ('RESET');
|
$this->montant_tva ('RESET');
|
||||||
$this->montant_tva_19_6 ('RESET');
|
|
||||||
$this->montant_tva_5_5 ('RESET');
|
|
||||||
$this->prix_total_ttc ('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 ) {
|
public function prix_total_ttc ( $aTotalTtc=null ) {
|
||||||
|
|
||||||
if ( !$aTotalTtc ) {
|
if ( !$aTotalTtc ) {
|
||||||
|
|||||||
@ -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();
|
$total_ttc = $obj_facturation->prix_total_ttc();
|
||||||
echo ('<p class="cadre_prix_total">TOTAL : '.number_format ($total_ttc, 2, '.', '').' '.$conf->monnaie.'<br /></p>'."\n");
|
echo ('<p class="cadre_prix_total">TOTAL : '.number_format ($total_ttc, 2, '.', '').' '.$conf->monnaie.'<br /></p>'."\n");
|
||||||
|
|
||||||
|
|||||||
@ -146,23 +146,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||||||
|
|
||||||
<table class="totaux">
|
<table class="totaux">
|
||||||
<?php
|
<?php
|
||||||
echo '<tr><th>Total HT</th><td>'.number_format ($obj_facturation->prix_total_ht(),2, '.', '')." €</td></tr>\n";
|
echo '<tr><th>Total HT</th><td>'.price2num($obj_facturation->prix_total_ht())." ".$conf->monnaie."</td></tr>\n";
|
||||||
if ( $obj_facturation->montant_tva_19_6() ) {
|
if ( $obj_facturation->montant_tva() ) {
|
||||||
|
|
||||||
echo '<tr><th>TVA 19.6%</th><td>'.number_format ($obj_facturation->montant_tva_19_6(),2, '.', '')." €</td></tr>\n";
|
echo '<tr><th>TVA</th><td>'.price2num($obj_facturation->montant_tva())." ".$conf->monnaie."</td></tr>\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
if ( $obj_facturation->montant_tva_5_5() ) {
|
else {
|
||||||
|
|
||||||
echo '<tr><th>TVA 5.5%</th><td>'.number_format ($obj_facturation->montant_tva_5_5(),2, '.', '')." €</td></tr>\n";
|
|
||||||
|
|
||||||
}
|
|
||||||
if ( !$obj_facturation->montant_tva_19_6() && !$obj_facturation->montant_tva_5_5() ) {
|
|
||||||
|
|
||||||
echo '<tr><th></th><td>Pas de TVA</td><tr>'."\n";
|
echo '<tr><th></th><td>Pas de TVA</td><tr>'."\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
echo '<tr><th>Total TTC</th><td>'.number_format ($obj_facturation->prix_total_ttc(), 2, '.', '')." €</td></tr>\n";
|
echo '<tr><th>Total TTC</th><td>'.price2num($obj_facturation->prix_total_ttc())." ".$conf->monnaie."</td></tr>\n";
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@ -19,27 +19,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||||||
<table class="table_resume">
|
<table class="table_resume">
|
||||||
|
|
||||||
<tr><td class="resume_label">Facture N°</td><td><?php echo $obj_facturation->num_facture(); ?></td></tr>
|
<tr><td class="resume_label">Facture N°</td><td><?php echo $obj_facturation->num_facture(); ?></td></tr>
|
||||||
<tr><td class="resume_label">Prix HT :</td><td><?php echo number_format ($obj_facturation->prix_total_ht(), 2, '.', ''); ?> €</td></tr>
|
<tr><td class="resume_label">Prix HT :</td><td><?php echo price2num($obj_facturation->prix_total_ht()).' '.$conf->monnaie; ?></td></tr>
|
||||||
<?php
|
<?php
|
||||||
// Affichage de la tva par taux
|
// Affichage de la tva par taux
|
||||||
if ( $obj_facturation->montant_tva_19_6() ) {
|
if ( $obj_facturation->montant_tva() ) {
|
||||||
|
|
||||||
echo ('<tr><td class="resume_label">Montant TVA 19.6% :</td><td>'.number_format ($obj_facturation->montant_tva_19_6(), 2, '.', '').' €</td></tr>');
|
echo ('<tr><td class="resume_label">Montant TVA 19.6% :</td><td>'.price2num($obj_facturation->montant_tva()).' '.$conf->monnaie.'</td></tr>');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if ( $obj_facturation->montant_tva_5_5() ) {
|
{
|
||||||
|
|
||||||
echo ('<tr><td class="resume_label">Montant TVA 5.5% :</td><td>'.number_format ($obj_facturation->montant_tva_5_5(), 2, '.', '').' €</td></tr>');
|
|
||||||
|
|
||||||
}
|
|
||||||
if ( !$obj_facturation->montant_tva_19_6() && !$obj_facturation->montant_tva_5_5() ) {
|
|
||||||
|
|
||||||
echo ('<tr><td class="resume_label">Montant TVA :</td><td>Pas de TVA pour cette vente</td></tr>');
|
echo ('<tr><td class="resume_label">Montant TVA :</td><td>Pas de TVA pour cette vente</td></tr>');
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr><td class="resume_label">A payer :</td><td><?php echo number_format ($obj_facturation->prix_total_ttc(), 2, '.', ''); ?> €</td></tr>
|
<tr><td class="resume_label">A payer :</td><td><?php echo price2num($obj_facturation->prix_total_ttc()).' '.$conf->monnaie; ?></td></tr>
|
||||||
<tr><td class="resume_label">Mode de réglement :</td><td><?php echo $obj_facturation->mode_reglement(); ?></td></tr>
|
<tr><td class="resume_label">Mode de réglement :</td><td><?php echo $obj_facturation->mode_reglement(); ?></td></tr>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@ -51,14 +46,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
echo ('<tr><td class="resume_label">Encaissé :</td><td>'.number_format ($obj_facturation->montant_encaisse(), 2, '.', '').' €</td></tr>');
|
echo ('<tr><td class="resume_label">Encaissé :</td><td>'.price2num($obj_facturation->montant_encaisse()).' '.$conf->monnaie.'</td></tr>');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affichage du montant rendu (réglement en espèces)
|
// Affichage du montant rendu (réglement en espèces)
|
||||||
if ( $obj_facturation->montant_rendu() ) {
|
if ( $obj_facturation->montant_rendu() ) {
|
||||||
|
|
||||||
echo ('<tr><td class="resume_label">Rendu :</td><td>'.number_format ($obj_facturation->montant_rendu(), 2, '.', '').' €</td></tr>');
|
echo ('<tr><td class="resume_label">Rendu :</td><td>'.price2num($obj_facturation->montant_rendu()).' '.$conf->monnaie.'</td></tr>');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user