Skip to content

Commit

Permalink
fiscalisation : ajouter la TVA dans les entrées du journal
Browse files Browse the repository at this point in the history
fixes #1338

* Ajout de nouveaux champs dans la table du journal
* dans l'admin on permet de les ajouter/modifier
  • Loading branch information
agallou committed Nov 20, 2023
1 parent de58252 commit 24b5618
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
19 changes: 19 additions & 0 deletions db/migrations/20231120220609_tva_journal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Phinx\Migration\AbstractMigration;

class TvaJournal extends AbstractMigration
{
public function change()
{
$sql = <<<EOF
ALTER TABLE `compta`
ADD `montant_ht_soumis_tva_0` double(11,2) DEFAULT NULL AFTER `idcompte`,
ADD `montant_ht_soumis_tva_5_5` double(11,2) DEFAULT NULL AFTER `idcompte`,
ADD `montant_ht_soumis_tva_10` double(11,2) DEFAULT NULL AFTER `idcompte`,
ADD `montant_ht_soumis_tva_20` double(11,2) DEFAULT NULL AFTER `idcompte`
;
EOF;
$this->execute($sql);
}
}
28 changes: 25 additions & 3 deletions htdocs/pages/administration/compta_journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ function paybox_link($description)
$champs['obs_regl'] = $champsRecup['obs_regl'];
$champs['idevenement'] = $champsRecup['idevenement'];
$champs['comment'] = $champsRecup['comment'];
$champs['montant_ht_soumis_tva_0'] = $champsRecup['montant_ht_soumis_tva_0'];
$champs['montant_ht_soumis_tva_5_5'] = $champsRecup['montant_ht_soumis_tva_5_5'];
$champs['montant_ht_soumis_tva_10'] = $champsRecup['montant_ht_soumis_tva_10'];
$champs['montant_ht_soumis_tva_20'] = $champsRecup['montant_ht_soumis_tva_20'];



//$formulaire->setDefaults($champsRecup);
Expand Down Expand Up @@ -145,6 +150,13 @@ function paybox_link($description)
$formulaire->addElement('text', 'montant', 'Montant' , array('size' => 30, 'maxlength' => 40));
$formulaire->addElement('text', 'comment', 'Commentaire' , array('size' => 30, 'maxlength' => 255));

$formulaire->addElement('header' , '' , 'TVA');
$formulaire->addElement('text', 'montant_ht_soumis_tva_5_5', 'Montant HT soumis à TVA 5.5%' , array('size' => 30, 'maxlength' => 40));
$formulaire->addElement('text', 'montant_ht_soumis_tva_10', 'Montant HT soumis à TVA 10%' , array('size' => 30, 'maxlength' => 40));
$formulaire->addElement('text', 'montant_ht_soumis_tva_20', 'Montant HT soumis à TVA 20%' , array('size' => 30, 'maxlength' => 40));
$formulaire->addElement('text', 'montant_ht_soumis_tva_0', 'Montant HT non soumis à TVA' , array('size' => 30, 'maxlength' => 40));


//reglement
$formulaire->addElement('header' , '' , 'Réglement');
$formulaire->addElement('select' , 'idmode_regl', 'Réglement', $compta->obtenirListReglements());
Expand Down Expand Up @@ -207,7 +219,12 @@ function paybox_link($description)
$date_regl,
$valeur['obs_regl'],
$valeur['idevenement'],
$valeur['comment']
$valeur['comment'],
0,
$valeur['montant_ht_soumis_tva_0'],
$valeur['montant_ht_soumis_tva_5_5'],
$valeur['montant_ht_soumis_tva_10'],
$valeur['montant_ht_soumis_tva_20']
);
} else {
$ok = $compta->modifier(
Expand All @@ -224,10 +241,15 @@ function paybox_link($description)
$date_regl,
$valeur['obs_regl'],
$valeur['idevenement'],
$valeur['comment']
$valeur['comment'],
null,
0,
$valeur['montant_ht_soumis_tva_0'],
$valeur['montant_ht_soumis_tva_5_5'],
$valeur['montant_ht_soumis_tva_10'],
$valeur['montant_ht_soumis_tva_20']
);
}

if ($ok) {
if ($action == 'ajouter') {
Logs::log('Ajout une écriture ' . $formulaire->exportValue('titre'));
Expand Down
20 changes: 16 additions & 4 deletions sources/Afup/Comptabilite/Comptabilite.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,15 @@ public function obtenirListReglementsJournal()

function ajouter($idoperation, $idcompte, $idcategorie, $date_ecriture, $nom_frs, $montant, $description,
$numero, $idmode_regl, $date_regl, $obs_regl, $idevenement, $numero_operation = null,
$attachmentRequired = 0)
$attachmentRequired = 0, $montantHtSoumisTva0 = null, $montantHtSoumisTva55 = null, $montantHtSoumisTva10 = null, $montantHtSoumisTva20 = null)
{

$requete = 'INSERT INTO ';
$requete .= 'compta (';
$requete .= 'idoperation,idcategorie,date_ecriture,nom_frs,montant,description,';
$requete .= 'numero,idmode_regl,date_regl,obs_regl,idevenement, numero_operation,idcompte, attachment_required) ';
$requete .= 'numero,idmode_regl,date_regl,obs_regl,idevenement, numero_operation,idcompte, attachment_required,
montant_ht_soumis_tva_0, montant_ht_soumis_tva_5_5, montant_ht_soumis_tva_10, montant_ht_soumis_tva_20
) ';
$requete .= 'VALUES (';
$requete .= $this->_bdd->echapper($idoperation) . ',';
$requete .= $this->_bdd->echapper($idcategorie) . ',';
Expand All @@ -504,7 +506,11 @@ function ajouter($idoperation, $idcompte, $idcategorie, $date_ecriture, $nom_frs
$requete .= $this->_bdd->echapper($idevenement) . ',';
$requete .= $this->_bdd->echapper($numero_operation) . ',';
$requete .= $this->_bdd->echapper($idcompte) . ',';
$requete .= $this->_bdd->echapper($attachmentRequired) . '';
$requete .= $this->_bdd->echapper($attachmentRequired) . ',';
$requete .= (!$montantHtSoumisTva0 ? 'NULL' : $this->_bdd->echapper($montantHtSoumisTva0)) . ',';
$requete .= (!$montantHtSoumisTva55 ? 'NULL' : $this->_bdd->echapper($montantHtSoumisTva55)) . ',';
$requete .= (!$montantHtSoumisTva10 ? 'NULL' : $this->_bdd->echapper($montantHtSoumisTva10)) . ',';
$requete .= (!$montantHtSoumisTva20 ? 'NULL' : $this->_bdd->echapper($montantHtSoumisTva20)) . '';
$requete .= ');';

$resultat = $this->_bdd->executer($requete);
Expand All @@ -515,7 +521,9 @@ function ajouter($idoperation, $idcompte, $idcategorie, $date_ecriture, $nom_frs
}

function modifier($id, $idoperation, $idcompte, $idcategorie, $date_ecriture, $nom_frs, $montant, $description,
$numero, $idmode_regl, $date_regl, $obs_regl, $idevenement, $comment, $numero_operation = null, $attachmentRequired = 0)
$numero, $idmode_regl, $date_regl, $obs_regl, $idevenement, $comment, $numero_operation = null, $attachmentRequired = 0,
$montantHtSoumisTva0 = null, $montantHtSoumisTva55 = null, $montantHtSoumisTva10 = null, $montantHtSoumisTva20 = null
)
{

$requete = 'UPDATE ';
Expand All @@ -532,6 +540,10 @@ function modifier($id, $idoperation, $idcompte, $idcategorie, $date_ecriture, $n
$requete .= 'date_regl=' . $this->_bdd->echapper($date_regl) . ',';
$requete .= 'obs_regl=' . $this->_bdd->echapper($obs_regl) . ',';
$requete .= 'idcompte=' . $this->_bdd->echapper($idcompte) . ',';
$requete .= 'montant_ht_soumis_tva_0=' . (!$montantHtSoumisTva0 ? 'NULL' : $this->_bdd->echapper($montantHtSoumisTva0)) . ',';
$requete .= 'montant_ht_soumis_tva_5_5=' . (!$montantHtSoumisTva55 ? 'NULL' : $this->_bdd->echapper($montantHtSoumisTva55)) . ',';
$requete .= 'montant_ht_soumis_tva_10=' . (!$montantHtSoumisTva10 ? 'NULL' : $this->_bdd->echapper($montantHtSoumisTva10)) . ',';
$requete .= 'montant_ht_soumis_tva_20=' . (!$montantHtSoumisTva20 ? 'NULL' : $this->_bdd->echapper($montantHtSoumisTva20)) . ',';
$requete .= 'comment=' . (!$comment ? 'NULL' : $this->_bdd->echapper($comment)) . ',';
if ($numero_operation) {
$requete .= 'numero_operation=' . $this->_bdd->echapper($numero_operation) . ',';
Expand Down

0 comments on commit 24b5618

Please sign in to comment.