From 0463fed0b28011095610c7a371e4f0d87532a94c Mon Sep 17 00:00:00 2001 From: Albin Date: Mon, 4 Dec 2023 21:52:34 +0100 Subject: [PATCH] Ajout TVA intracommunautaire #1348 --- .../20231204211600_tva_intra_facture.php | 15 ++++ htdocs/pages/administration/compta_devis.php | 6 +- .../pages/administration/compta_facture.php | 69 ++++++++++--------- sources/Afup/Comptabilite/Facture.php | 14 ++-- .../Admin/Tresorerie/DevisFactures.feature | 1 + 5 files changed, 65 insertions(+), 40 deletions(-) create mode 100644 db/migrations/20231204211600_tva_intra_facture.php diff --git a/db/migrations/20231204211600_tva_intra_facture.php b/db/migrations/20231204211600_tva_intra_facture.php new file mode 100644 index 000000000..c16517760 --- /dev/null +++ b/db/migrations/20231204211600_tva_intra_facture.php @@ -0,0 +1,15 @@ +execute($sql); + } +} diff --git a/htdocs/pages/administration/compta_devis.php b/htdocs/pages/administration/compta_devis.php index e2ac8b8cc..1cd4fa3f6 100644 --- a/htdocs/pages/administration/compta_devis.php +++ b/htdocs/pages/administration/compta_devis.php @@ -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']; @@ -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']) ) { @@ -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'], @@ -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'], diff --git a/htdocs/pages/administration/compta_facture.php b/htdocs/pages/administration/compta_facture.php index 356df64b1..2fc76bf2b 100644 --- a/htdocs/pages/administration/compta_facture.php +++ b/htdocs/pages/administration/compta_facture.php @@ -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']; @@ -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'] ) { @@ -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] + ); } diff --git a/sources/Afup/Comptabilite/Facture.php b/sources/Afup/Comptabilite/Facture.php index a3363960f..79cfa06f1 100644 --- a/sources/Afup/Comptabilite/Facture.php +++ b/sources/Afup/Comptabilite/Facture.php @@ -145,7 +145,7 @@ 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') { @@ -153,7 +153,7 @@ function ajouter($date_devis, $societe, $service, $adresse, $code_postal, $ville $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) . ','; @@ -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) . ','; @@ -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) { @@ -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) . ','; @@ -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); @@ -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); diff --git a/tests/behat/features/Admin/Tresorerie/DevisFactures.feature b/tests/behat/features/Admin/Tresorerie/DevisFactures.feature index 5e844fcb7..cf5a86494 100644 --- a/tests/behat/features/Admin/Tresorerie/DevisFactures.feature +++ b/tests/behat/features/Admin/Tresorerie/DevisFactures.feature @@ -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"