Skip to content

Commit

Permalink
Ajout TVA intracommunautaire
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Dec 5, 2023
1 parent 91d12b7 commit 0463fed
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 40 deletions.
15 changes: 15 additions & 0 deletions db/migrations/20231204211600_tva_intra_facture.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Phinx\Migration\AbstractMigration;

class TvaIntraFacture extends AbstractMigration
{
public function change()
{
$sql = <<<EOF
ALTER TABLE `afup_compta_facture`
ADD `tva_intra` VARCHAR(20) AFTER `email`;
EOF;
$this->execute($sql);
}
}
6 changes: 4 additions & 2 deletions htdocs/pages/administration/compta_devis.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ function prepareDefaultsFromComptaFacId(Facture $comptaFact, $id) {
$champs['date_devis'] = $champsRecup['date_devis'];
$champs['date_facture'] = $champsRecup['date_facture'];
$champs['societe'] = $champsRecup['societe'];
$champs['numero_devis'] = $champsRecup['numero_devis'];
$champs['societe'] = $champsRecup['societe'];
$champs['service'] = $champsRecup['service'];
$champs['adresse'] = $champsRecup['adresse'];
$champs['code_postal'] = $champsRecup['code_postal'];
$champs['ville'] = $champsRecup['ville'];
$champs['id_pays'] = $champsRecup['id_pays'];
$champs['email'] = $champsRecup['email'];
$champs['tva_intra'] = $champsRecup['tva_intra'];
$champs['observation'] = $champsRecup['observation'];
$champs['ref_clt1'] = $champsRecup['ref_clt1'];
$champs['ref_clt2'] = $champsRecup['ref_clt2'];
Expand Down Expand Up @@ -149,6 +148,7 @@ function prepareDefaultsFromComptaFacId(Facture $comptaFact, $id) {
$formulaire->addElement('text' , 'prenom' , 'Prénom' , array('size' => 30, 'maxlength' => 40));
$formulaire->addElement('text' , 'tel' , 'tel' , array('size' => 30, 'maxlength' => 40));
$formulaire->addElement('text' , 'email' , 'Email (facture)', array('size' => 30, 'maxlength' => 100));
$formulaire->addElement('text' , 'tva_intra' , 'TVA intercommunautaire (facture)', array('size' => 30, 'maxlength' => 100));

if (isset($champs['numero_devis']) || isset($champs['numero_facture']) )
{
Expand Down Expand Up @@ -224,6 +224,7 @@ function prepareDefaultsFromComptaFacId(Facture $comptaFact, $id) {
$valeur['prenom'],
$valeur['tel'],
$valeur['email'],
$valeur['tva_intra'],
$valeur['observation'],
$valeur['ref_clt1'],
$valeur['ref_clt2'],
Expand Down Expand Up @@ -257,6 +258,7 @@ function prepareDefaultsFromComptaFacId(Facture $comptaFact, $id) {
$valeur['prenom'],
$valeur['tel'],
$valeur['email'],
$valeur['tva_intra'],
$valeur['observation'],
$valeur['ref_clt1'],
$valeur['ref_clt2'],
Expand Down
69 changes: 36 additions & 33 deletions htdocs/pages/administration/compta_facture.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
$champs['ville'] = $champsRecup['ville'];
$champs['id_pays'] = $champsRecup['id_pays'];
$champs['email'] = $champsRecup['email'];
$champs['tva_intra'] = $champsRecup['tva_intra'];
$champs['observation'] = $champsRecup['observation'];
$champs['ref_clt1'] = $champsRecup['ref_clt1'];
$champs['ref_clt2'] = $champsRecup['ref_clt2'];
Expand Down Expand Up @@ -137,6 +138,7 @@
$formulaire->addElement('text' , 'prenom' , 'Prénom' , array('size' => 30, 'maxlength' => 40));
$formulaire->addElement('text' , 'tel' , 'Numero de tél' , array('size' => 30, 'maxlength' => 40));
$formulaire->addElement('text' , 'email' , 'Email (facture)', array('size' => 30, 'maxlength' => 100));
$formulaire->addElement('text' , 'tva_intra' , 'TVA intercommunautaire (facture)', array('size' => 30, 'maxlength' => 100));

if ($champs['numero_devis'] || $champs['numero_facture'] )
{
Expand Down Expand Up @@ -212,42 +214,43 @@

$date_ecriture= $valeur['date_facture']['Y']."-".$valeur['date_facture']['F']."-".$valeur['date_facture']['d'] ;
$date_paiement= $valeur['date_paiement']['Y']."-".$valeur['date_paiement']['F']."-".$valeur['date_paiement']['d'] ;

if ($action == 'ajouter') {
// il faut passser obligatoirement par un devis
// il faut passser obligatoirement par un devis
} else {
$ok = $comptaFact->modifier(
$_GET['id'],
$date_ecriture,
$valeur['societe'],
$valeur['service'],
$valeur['adresse'],
$valeur['code_postal'],
$valeur['ville'],
$valeur['id_pays'],
$valeur['nom'],
$valeur['prenom'],
$valeur['tel'],
$valeur['email'],
$valeur['observation'],
$valeur['ref_clt1'],
$valeur['ref_clt2'],
$valeur['ref_clt3'],
$valeur['numero_devis'],
$valeur['numero_facture'],
$valeur['etat_paiement'],
$date_paiement,
$valeur['devise_facture']
);
for ($i=1;$i<6;$i++)
{
$ok = $comptaFact->modifier_details(
$valeur['id'.$i],
$valeur['ref'.$i],
$valeur['designation'.$i],
$valeur['quantite'.$i],
$valeur['pu'.$i]
);
$_GET['id'],
$date_ecriture,
$valeur['societe'],
$valeur['service'],
$valeur['adresse'],
$valeur['code_postal'],
$valeur['ville'],
$valeur['id_pays'],
$valeur['nom'],
$valeur['prenom'],
$valeur['tel'],
$valeur['email'],
$valeur['tva_intra'],
$valeur['observation'],
$valeur['ref_clt1'],
$valeur['ref_clt2'],
$valeur['ref_clt3'],
$valeur['numero_devis'],
$valeur['numero_facture'],
$valeur['etat_paiement'],
$date_paiement,
$valeur['devise_facture']
);

for ($i=1;$i<6;$i++) {
$ok = $comptaFact->modifier_details(
$valeur['id'.$i],
$valeur['ref'.$i],
$valeur['designation'.$i],
$valeur['quantite'.$i],
$valeur['pu'.$i],
$valeur['tva'.$i]
);
}


Expand Down
14 changes: 9 additions & 5 deletions sources/Afup/Comptabilite/Facture.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ function obtenir_details($id)
}

function ajouter($date_devis, $societe, $service, $adresse, $code_postal, $ville, $id_pays,
$nom, $prenom, $tel, $email, $observation, $ref_clt1, $ref_clt2, $ref_clt3,
$nom, $prenom, $tel, $email, $tva_intra, $observation, $ref_clt1, $ref_clt2, $ref_clt3,
$etat_paiement = 0, $date_paiement = null, $devise = 'EUR')
{

$requete = 'INSERT INTO ';
$requete .= 'afup_compta_facture (';
$requete .= 'date_devis,societe,service,adresse,code_postal,ville,id_pays,';
$requete .= 'nom,prenom,tel,';
$requete .= 'email,observation,ref_clt1,ref_clt2,ref_clt3,etat_paiement,date_paiement,numero_devis,devise_facture) ';
$requete .= 'email,tva_intra,observation,ref_clt1,ref_clt2,ref_clt3,etat_paiement,date_paiement,numero_devis,devise_facture) ';
$requete .= 'VALUES (';
$requete .= $this->_bdd->echapper($date_devis) . ',';
$requete .= $this->_bdd->echapper($societe) . ',';
Expand All @@ -166,6 +166,7 @@ function ajouter($date_devis, $societe, $service, $adresse, $code_postal, $ville
$requete .= $this->_bdd->echapper($prenom) . ',';
$requete .= $this->_bdd->echapper($tel) . ',';
$requete .= $this->_bdd->echapper($email) . ',';
$requete .= $this->_bdd->echapper($tva_intra) . ',';
$requete .= $this->_bdd->echapper($observation) . ',';
$requete .= $this->_bdd->echapper($ref_clt1) . ',';
$requete .= $this->_bdd->echapper($ref_clt2) . ',';
Expand Down Expand Up @@ -198,7 +199,7 @@ function ajouter_details($ref, $designation, $quantite, $pu, $tva = 0)
}

function modifier($id, $date_devis, $societe, $service, $adresse, $code_postal, $ville, $id_pays,
$nom, $prenom, $tel, $email, $observation, $ref_clt1, $ref_clt2, $ref_clt3,
$nom, $prenom, $tel, $email, $tva_intra, $observation, $ref_clt1, $ref_clt2, $ref_clt3,
$numero_devis, $numero_facture, $etat_paiement, $date_paiement, $devise)
{

Expand All @@ -216,6 +217,7 @@ function modifier($id, $date_devis, $societe, $service, $adresse, $code_postal,
$requete .= 'prenom=' . $this->_bdd->echapper($prenom) . ',';
$requete .= 'tel=' . $this->_bdd->echapper($tel) . ',';
$requete .= 'email=' . $this->_bdd->echapper($email) . ',';
$requete .= 'tva_intra=' . $this->_bdd->echapper($tva_intra) . ',';
$requete .= 'observation=' . $this->_bdd->echapper($observation) . ', ';
$requete .= 'ref_clt1=' . $this->_bdd->echapper($ref_clt1) . ',';
$requete .= 'ref_clt2=' . $this->_bdd->echapper($ref_clt2) . ',';
Expand Down Expand Up @@ -467,7 +469,7 @@ function genererFacture($reference, $chemin = null)
$pdf->Ln();


// A l'attention du client [adresse]
// À l'attention du client [adresse]
$pdf->SetFont('Arial', '', 10);
$pdf->Ln(10);
$pdf->setx(120);
Expand All @@ -476,7 +478,9 @@ function genererFacture($reference, $chemin = null)
utf8_decode($coordonnees['adresse']) . "\n" .
utf8_decode($coordonnees['code_postal']) . "\n" .
utf8_decode($coordonnees['ville']) . "\n" .
utf8_decode($pays->obtenirNom($coordonnees['id_pays'])));
utf8_decode($pays->obtenirNom($coordonnees['id_pays'])) .
$coordonnees['tva_intra'] ? ("\nTVA : ".utf8_decode($coordonnees['tva_intra'])) : null
);

$pdf->Ln(10);
$pdf->SetFont('Arial', 'BU', 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Feature: Administration - Trésorerie - Devis/Facture
And I fill in "quantite2" with "1"
And I fill in "pu2" with "12000"
When I press "Ajouter"
And print last response
Then I should see "L'écriture a été ajoutée"
And I should see "ESN dev en folie"
And I should see "Paris"
Expand Down

0 comments on commit 0463fed

Please sign in to comment.