Overview
Comment: | Import compta : utilisation de la ligne d'entête comme intitulé des colonnes, import fonctionnel du projet depuis CSV, ne pas exiger d'avoir toutes les colonnes présentes dans le CSV |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | stable |
Files: | files | file ages | folders |
SHA1: |
cc3a83e9d2a7a980898f7c4e7962414f |
User & Date: | bohwaz on 2019-12-09 17:52:54 |
Other Links: | manifest | tags |
Context
2019-12-09
| ||
18:10 | Clarification de la valeur de retour de Plugin::fireSignal, qui doit renvoyer TRUE si un plugin a arrêté l'exécution, FALSE si des plugins ont été appelés mais aucun n'a interrompu l'exécution, et NULL si aucun plugin n'a été exécuté check-in: 126edcf10c user: bohwaz tags: trunk | |
17:52 | Import compta : utilisation de la ligne d'entête comme intitulé des colonnes, import fonctionnel du projet depuis CSV, ne pas exiger d'avoir toutes les colonnes présentes dans le CSV check-in: cc3a83e9d2 user: bohwaz tags: trunk, stable | |
2019-12-04
| ||
17:01 | Dépendances check-in: ddb1679140 user: bohwaz tags: trunk | |
Changes
Modified src/include/lib/Garradin/Compta/Import.php from [b55af76dc7] to [f263dfbb6d].
︙ | ︙ | |||
86 87 88 89 90 91 92 | } $db = DB::getInstance(); $db->begin(); $cats = new Categories; $journal = new Journal; | < > > > | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | } $db = DB::getInstance(); $db->begin(); $cats = new Categories; $journal = new Journal; $liste_cats = $db->getAssoc('SELECT intitule, id FROM compta_categories;'); // Liste des moyens sous la forme nom -> code $liste_moyens = array_flip($cats->listMoyensPaiement(true)); // Liste associative des projets $liste_projets = $db->getAssoc('SELECT libelle, id FROM compta_projets;'); $col = function($column) use (&$row, &$columns) { if (!isset($columns[$column])) return null; if (!isset($row[$columns[$column]])) return null; |
︙ | ︙ | |||
122 123 124 125 126 127 128 129 130 131 132 133 134 135 | if ($line === 1) { if (trim($row[0]) != 'Numéro mouvement') { throw new UserException('Erreur sur la ligne ' . $line . ' : l\'entête des colonnes est absent ou incorrect.'); } continue; } if (count($row) != count($columns)) { $db->rollback(); | > > | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | if ($line === 1) { if (trim($row[0]) != 'Numéro mouvement') { throw new UserException('Erreur sur la ligne ' . $line . ' : l\'entête des colonnes est absent ou incorrect.'); } $columns = array_flip($row); continue; } if (count($row) != count($columns)) { $db->rollback(); |
︙ | ︙ | |||
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | $cat = false; } if ($cat && !array_key_exists($cat, $liste_cats)) { $cat = $moyen = false; } $data = [ 'libelle' => $col('Libellé'), 'montant' => (float) $col('Montant'), 'date' => $date, 'compte_credit' => $credit, 'compte_debit' => $debit, 'numero_piece' => $col('Numéro de pièce'), 'remarques' => $col('Remarques'), ]; if ($cat) { $data['moyen_paiement'] = $moyen; $data['numero_cheque'] = $col('Numéro de chèque'); $data['id_categorie'] = $liste_cats[$cat]; | > > > > > > > > > > > | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | $cat = false; } if ($cat && !array_key_exists($cat, $liste_cats)) { $cat = $moyen = false; } $id_projet = null; if (!empty($col('Projet'))) { if (!array_key_exists($col('Projet'), $liste_projets)) { throw new UserException(sprintf('Erreur sur la ligne %d : le projet "%s" est inconnu', $line, $col('Projet'))); } $id_projet = $liste_projets[$col('Projet')]; } $data = [ 'libelle' => $col('Libellé'), 'montant' => (float) $col('Montant'), 'date' => $date, 'compte_credit' => $credit, 'compte_debit' => $debit, 'numero_piece' => $col('Numéro de pièce'), 'remarques' => $col('Remarques'), 'id_projet' => $id_projet, ]; if ($cat) { $data['moyen_paiement'] = $moyen; $data['numero_cheque'] = $col('Numéro de chèque'); $data['id_categorie'] = $liste_cats[$cat]; |
︙ | ︙ |