1111
1212use Afup \Site \Forum \Forum ;
1313use Afup \Site \Utils \Base_De_Donnees ;
14- use AppBundle \Compta \Importer \AutoQualifier ;
15- use AppBundle \Compta \Importer \Importer ;
1614
1715class Comptabilite
1816{
@@ -27,128 +25,6 @@ class Comptabilite
2725 public function __construct (protected Base_De_Donnees $ _bdd ) {}
2826
2927
30- /* affiche le journal de :
31- * courant = Compte courant
32- * Livret A
33- * Espece
34- * Paypal
35- *
36- */
37- public function obtenirJournalBanque ($ compte = 1 ,
38- $ periode_debut = '' ,
39- $ periode_fin = '' ,
40- ) {
41- $ periode_debut = $ this ->periodeDebutFin ($ debutFin = 'debut ' , $ periode_debut );
42- $ periode_fin = $ this ->periodeDebutFin ($ debutFin = 'fin ' , $ periode_fin );
43- $ requete = 'SELECT ' ;
44- $ requete .= 'compta.date_regl, compta.description, compta.montant, compta.idoperation, ' ;
45- $ requete .= 'MONTH(compta.date_regl) as mois, compta.id as idtmp, compta.comment, ' ;
46- $ requete .= 'compta_reglement.reglement, ' ;
47- $ requete .= 'compta_evenement.evenement, compta.idevenement, ' ;
48- $ requete .= 'compta_categorie.categorie, compta.idcategorie, ' ;
49- $ requete .= 'compta.attachment_required, compta.attachment_filename, ' ;
50- $ requete .= 'compta_compte.nom_compte as compta_compte_nom_compte ' ;
51- $ requete .= 'FROM ' ;
52- $ requete .= 'compta ' ;
53- $ requete .= 'LEFT JOIN ' ;
54- $ requete .= 'compta_categorie on compta_categorie.id=compta.idcategorie ' ;
55- $ requete .= 'LEFT JOIN ' ;
56- $ requete .= 'compta_reglement on compta_reglement.id=compta.idmode_regl ' ;
57- $ requete .= 'LEFT JOIN ' ;
58- $ requete .= 'compta_evenement on compta_evenement.id=compta.idevenement ' ;
59- $ requete .= 'LEFT JOIN ' ;
60- $ requete .= 'compta_compte on compta_compte.id=compta.idcompte ' ;
61- $ requete .= 'WHERE ' ;
62- $ requete .= 'compta.date_regl >= \'' . $ periode_debut . '\' ' ;
63- $ requete .= 'AND compta.date_regl <= \'' . $ periode_fin . '\' ' ;
64- $ requete .= 'AND compta.montant != \'0.00 \' ' ;
65- $ requete .= 'AND compta.idmode_regl = compta_reglement.id ' ;
66- $ requete .= 'AND idcompte = ' . (int ) $ compte . ' ' ;
67- $ requete .= 'ORDER BY ' ;
68- $ requete .= 'compta.date_regl ' ;
69- return $ this ->_bdd ->obtenirTous ($ requete );
70- }
71-
72-
73- public function obtenirSousTotalJournalBanque ($ periode_debut , $ periode_fin , $ compte = 1 )
74- {
75- $ data = $ this ->obtenirJournalBanque ($ compte , $ periode_debut , $ periode_fin );
76-
77- for ($ i = 1 ; $ i <= 12 ; $ i ++) {
78- $ credit [$ i ] = 0 ;
79- $ debit [$ i ] = 0 ;
80- $ nligne [$ i ] = 0 ;
81- }
82- foreach ($ data as $ row ) {
83- if ($ row ['idoperation ' ] == "1 " ) {
84- $ debit [$ row ['mois ' ]] += $ row ['montant ' ];
85- }
86- if ($ row ['idoperation ' ] == "2 " ) {
87- $ credit [$ row ['mois ' ]] += $ row ['montant ' ];
88- }
89- if ($ row ['idoperation ' ] == "1 " || $ row ['idoperation ' ] == "2 " ) {
90- $ nligne [$ row ['mois ' ]]++;
91- }
92- }
93-
94- $ dif_old = 0 ;
95- for ($ i = 1 ; $ i <= 12 ; $ i ++) {
96- $ dif = $ dif_old + $ credit [$ i ] - $ debit [$ i ];
97- $ tableau [$ i ] = ["mois " => $ i ,
98- "debit " => $ debit [$ i ],
99- "credit " => $ credit [$ i ],
100- "dif " => $ dif ,
101- "nligne " => $ nligne [$ i ],
102- ];
103- $ dif_old = $ dif ;
104- }
105-
106- return $ tableau ;
107- }
108-
109- public function obtenirTotalJournalBanque ($ periode_debut , $ periode_fin , $ compte = 1 ): array
110- {
111- $ data = $ this ->obtenirJournalBanque ($ compte , $ periode_debut , $ periode_fin );
112- /* echo "<pre>";
113- print_r($data);
114- echo "</pre>";*/
115- $ credit = 0 ;
116- $ debit = 0 ;
117-
118- foreach ($ data as $ row ) {
119- if ($ row ['idoperation ' ] == "1 " ) {
120- $ debit += $ row ['montant ' ];
121- }
122- if ($ row ['idoperation ' ] == "2 " ) {
123- $ credit += $ row ['montant ' ];
124- }
125- }
126- //print_r($credit);
127- //$dif_old=0;
128- //for ($i=1;$i<=12;$i++)
129- //{
130- // $dif=$dif_old+$credit[$i]-$debit[$i];
131- $ tableau = [
132- "debit " => $ debit ,
133- "credit " => $ credit ,
134- "dif " => $ credit - $ debit ,
135- ];
136- // $dif_old=$dif;
137- //}
138-
139- return $ tableau ;
140- /* $total=0;
141- foreach ($data as $id=>$row)
142- {
143-
144- if ($idoperation==$row['idoperation'])
145- $total += $row['montant'];
146- }
147-
148- return $total;
149- */
150- }
151-
15228 /* Journal des opération
15329 *
15430 */
@@ -689,76 +565,6 @@ public function obtenirEvenementParIdForum($id)
689565 return $ this ->_bdd ->obtenirUn ($ requete );
690566 }
691567
692- public function extraireComptaDepuisCSVBanque (Importer $ importer ): bool
693- {
694- if (!$ importer ->validate ()) {
695- return false ;
696- }
697-
698- $ qualifier = new AutoQualifier ($ this ->obtenirListRegles (true ));
699-
700- foreach ($ importer ->extract () as $ operation ) {
701- $ numero_operation = $ operation ->numeroOperation ;
702- // On vérife si l'enregistrement existe déjà
703- $ enregistrement = $ this ->obtenirParNumeroOperation ($ numero_operation );
704-
705- $ operationQualified = $ qualifier ->qualify ($ operation );
706- if (!is_array ($ enregistrement )) {
707- $ this ->ajouter (
708- $ operationQualified ['idoperation ' ],
709- $ importer ->getCompteId (),
710- $ operationQualified ['categorie ' ],
711- $ operationQualified ['date_ecriture ' ],
712- '' ,
713- '' ,
714- $ operationQualified ['montant ' ],
715- $ operationQualified ['description ' ],
716- '' ,
717- $ operationQualified ['idModeReglement ' ],
718- $ operationQualified ['date_ecriture ' ],
719- '' ,
720- $ operationQualified ['evenement ' ],
721- $ operationQualified ['numero_operation ' ] ?? null ,
722- $ operationQualified ['attachmentRequired ' ],
723- $ operationQualified ['montant_ht_soumis_tva_0 ' ],
724- $ operationQualified ['montant_ht_soumis_tva_5_5 ' ],
725- $ operationQualified ['montant_ht_soumis_tva_10 ' ],
726- $ operationQualified ['montant_ht_soumis_tva_20 ' ],
727- );
728- } else {
729- $ modifier = false ;
730- if ($ enregistrement ['idcategorie ' ] == AutoQualifier::DEFAULT_CATEGORIE && $ operationQualified ['categorie ' ] != AutoQualifier::DEFAULT_CATEGORIE ) {
731- $ enregistrement ['idcategorie ' ] = $ operationQualified ['categorie ' ];
732- $ modifier = true ;
733- }
734- if ($ enregistrement ['idevenement ' ] == AutoQualifier::DEFAULT_EVENEMENT && $ operationQualified ['evenement ' ] != AutoQualifier::DEFAULT_EVENEMENT ) {
735- $ enregistrement ['idevenement ' ] = $ operationQualified ['evenement ' ];
736- $ modifier = true ;
737- }
738- if ($ modifier ) {
739- $ this ->modifier ($ enregistrement ['id ' ],
740- $ enregistrement ['idoperation ' ],
741- $ importer ->getCompteId (),
742- $ enregistrement ['idcategorie ' ],
743- $ enregistrement ['date_ecriture ' ],
744- $ enregistrement ['nom_frs ' ],
745- $ enregistrement ['tva_intra ' ],
746- $ enregistrement ['montant ' ],
747- $ enregistrement ['description ' ],
748- $ enregistrement ['numero ' ],
749- $ enregistrement ['idmode_regl ' ],
750- $ enregistrement ['date_regl ' ],
751- $ enregistrement ['obs_regl ' ],
752- $ enregistrement ['idevenement ' ],
753- $ enregistrement ['numero_operation ' ],
754- $ operationQualified ['attachmentRequired ' ],
755- );
756- }
757- }
758- }
759- return true ;
760- }
761-
762568 /**
763569 * Search in whole database
764570 * <p>We do multiple queries.</p>
0 commit comments