Overview
Comment: | Associer les opérations comptables aux cotisations membres |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
45c128dbf04d46bc12f98e1f709e1fb9 |
User & Date: | bohwaz on 2014-03-31 16:34:26 |
Other Links: | manifest | tags |
Context
2014-03-31
| ||
21:13 | Envoi automatisé des rappels check-in: 12e7f0652b user: bohwaz tags: trunk | |
16:34 | Associer les opérations comptables aux cotisations membres check-in: 45c128dbf0 user: bohwaz tags: trunk | |
15:02 | Les fichiers index.html sont fournis par défaut dans l'archive de Garradin, pas besoin de ce code check-in: 2a85567682 user: bohwaz tags: trunk | |
Changes
Modified src/config.dist.php from [1f97e4c178] to [2bb62bda6d].
whitespace changes only
Modified src/include/class.cotisations_membres.php from [9f020b3272] to [a8c69469ae].
︙ | ︙ | |||
54 55 56 57 58 59 60 | 'date' => $data['date'], 'id_cotisation' => $data['id_cotisation'], 'id_membre' => $data['id_membre'], ]); $id = $db->lastInsertRowId(); | | | | | | | | < < > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 'date' => $data['date'], 'id_cotisation' => $data['id_cotisation'], 'id_membre' => $data['id_membre'], ]); $id = $db->lastInsertRowId(); $co = $db->simpleQuerySingle('SELECT * FROM cotisations WHERE id = ?;', true, (int)$data['id_cotisation']); if ($co['id_categorie_compta']) { try { $id_operation = $this->addOperationCompta($id, [ 'id_categorie' => $co['id_categorie_compta'], 'libelle' => 'Cotisation (automatique)', 'montant' => $co['montant'], 'date' => $data['date'], 'moyen_paiement'=> $data['moyen_paiement'], 'numero_cheque' => $data['numero_cheque'], 'id_auteur' => $data['id_auteur'], 'banque' => $data['banque'], 'id_membre' => $data['id_membre'], ]); } catch (\Exception $e) { $db->exec('ROLLBACK;'); throw $e; } |
︙ | ︙ | |||
103 104 105 106 107 108 109 | public function get($id) { $db = DB::getInstance(); return $db->simpleQuerySingle('SELECT * FROM cotisations_membres WHERE id = ?;', true, (int)$id); } /** | | | < | | < | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | public function get($id) { $db = DB::getInstance(); return $db->simpleQuerySingle('SELECT * FROM cotisations_membres WHERE id = ?;', true, (int)$id); } /** * Renvoie une liste des écritures comptables liées à une cotisation * @param int $id Numéro de la cotisation membre * @return array Liste des écritures */ public function listOperationsCompta($id) { $db = DB::getInstance(); return $db->simpleStatementFetch('SELECT * FROM compta_journal WHERE id IN (SELECT id_operation FROM membres_operations WHERE id_cotisation = ?);', \SQLITE3_ASSOC, (int)$id); } /** * Ajouter une écriture comptable pour un paiemement membre * @param int $id Numéro de la cotisation membre * @param array $data Données */ public function addOperationCompta($id, $data) { $journal = new Compta_Journal; $db = DB::getInstance(); if (!isset($data['libelle']) || trim($data['libelle']) == '') { throw new UserException('Le libellé ne peut rester vide.'); } |
︙ | ︙ | |||
186 187 188 189 190 191 192 | 'numero_cheque' => isset($data['numero_cheque']) ? $data['numero_cheque'] : null, 'compte_debit' => $debit, 'compte_credit' => $credit, 'id_categorie' => (int)$data['id_categorie'], 'id_auteur' => (int)$data['id_auteur'], ]); | | | > | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | 'numero_cheque' => isset($data['numero_cheque']) ? $data['numero_cheque'] : null, 'compte_debit' => $debit, 'compte_credit' => $credit, 'id_categorie' => (int)$data['id_categorie'], 'id_auteur' => (int)$data['id_auteur'], ]); $db->simpleInsert('membres_operations', [ 'id_operation' => $id_operation, 'id_membre' => $data['id_membre'], 'id_cotisation' => (int)$id, ]); return $id_operation; } /** * Nombre de membres pour une cotisation |
︙ | ︙ | |||
239 240 241 242 243 244 245 | * Liste des événements d'un membre * @param integer $id Numéro de membre * @return array Liste des événements de cotisation fait par ce membre */ public function listForMember($id) { $db = DB::getInstance(); | | > | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | * Liste des événements d'un membre * @param integer $id Numéro de membre * @return array Liste des événements de cotisation fait par ce membre */ public function listForMember($id) { $db = DB::getInstance(); return $db->simpleStatementFetch('SELECT cm.*, c.intitule, c.duree, c.debut, c.fin, c.montant, (SELECT COUNT(*) FROM membres_operations WHERE id_cotisation = cm.id) AS nb_operations FROM cotisations_membres AS cm LEFT JOIN cotisations AS c ON c.id = cm.id_cotisation WHERE cm.id_membre = ? ORDER BY cm.date DESC;', \SQLITE3_ASSOC, (int)$id); } /** * Liste des cotisations / activités en cours pour ce membre |
︙ | ︙ |
Modified src/include/data/0.6.0.sql from [4df7c58a86] to [188660d97f].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | CREATE UNIQUE INDEX cm_unique ON cotisations_membres (id_membre, id_cotisation, date); CREATE TABLE membres_operations -- Liaision des enregistrement des paiements en compta ( id_membre INTEGER NOT NULL REFERENCES membres (id), id_operation INTEGER NOT NULL REFERENCES compta_journal (id), PRIMARY KEY (id_membre, id_operation) ); CREATE TABLE rappels -- Rappels de devoir renouveller une cotisation ( id INTEGER PRIMARY KEY, | > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | CREATE UNIQUE INDEX cm_unique ON cotisations_membres (id_membre, id_cotisation, date); CREATE TABLE membres_operations -- Liaision des enregistrement des paiements en compta ( id_membre INTEGER NOT NULL REFERENCES membres (id), id_operation INTEGER NOT NULL REFERENCES compta_journal (id), id_cotisation INTEGER NULL REFERENCES cotisations_membres (id), PRIMARY KEY (id_membre, id_operation) ); CREATE TABLE rappels -- Rappels de devoir renouveller une cotisation ( id INTEGER PRIMARY KEY, |
︙ | ︙ |
Modified src/include/data/schema.sql from [4c09ae0edc] to [f901a8e68f].
︙ | ︙ | |||
60 61 62 63 64 65 66 67 68 69 70 71 72 73 | CREATE UNIQUE INDEX cm_unique ON cotisations_membres (id_membre, id_cotisation, date); CREATE TABLE membres_operations -- Liaision des enregistrement des paiements en compta ( id_membre INTEGER NOT NULL REFERENCES membres (id), id_operation INTEGER NOT NULL REFERENCES compta_journal (id), PRIMARY KEY (id_membre, id_operation) ); CREATE TABLE rappels -- Rappels de devoir renouveller une cotisation ( id INTEGER PRIMARY KEY, | > > | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | CREATE UNIQUE INDEX cm_unique ON cotisations_membres (id_membre, id_cotisation, date); CREATE TABLE membres_operations -- Liaision des enregistrement des paiements en compta ( id_membre INTEGER NOT NULL REFERENCES membres (id), id_operation INTEGER NOT NULL REFERENCES compta_journal (id), id_cotisation INTEGER NULL REFERENCES cotisations_membres (id), PRIMARY KEY (id_membre, id_operation) ); CREATE TABLE rappels -- Rappels de devoir renouveller une cotisation ( id INTEGER PRIMARY KEY, |
︙ | ︙ |
Modified src/templates/admin/membres/cotisations.tpl from [30903a1317] to [bc85f86c2a].
︙ | ︙ | |||
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | </dl> {if !empty($cotisations)} <table class="list"> <thead> <th>Date</th> <td>Cotisation</td> <td class="actions"></td> </thead> <tbody> {foreach from=$cotisations item="c"} <tr> <td>{$c.date|format_sqlite_date_to_french}</td> <td> {$c.intitule|escape} — {if $c.duree} {$c.duree|escape} jours {elseif $c.debut} du {$c.debut|format_sqlite_date_to_french} au {$c.fin|format_sqlite_date_to_french} {else} ponctuelle {/if} — {$c.montant|html_money} {$config.monnaie|escape} </td> <td class="actions"> | > > > > > > | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | </dl> {if !empty($cotisations)} <table class="list"> <thead> <th>Date</th> <td>Cotisation</td> <td></td> <td class="actions"></td> </thead> <tbody> {foreach from=$cotisations item="c"} <tr> <td>{$c.date|format_sqlite_date_to_french}</td> <td> {$c.intitule|escape} — {if $c.duree} {$c.duree|escape} jours {elseif $c.debut} du {$c.debut|format_sqlite_date_to_french} au {$c.fin|format_sqlite_date_to_french} {else} ponctuelle {/if} — {$c.montant|html_money} {$config.monnaie|escape} </td> <td> {if $user.droits.compta >= Garradin\Membres::DROIT_ECRITURE && !empty($c.nb_operations)} {$c.nb_operations} écritures {/if} </td> <td class="actions"> <a href="{$admin_url}membres/cotisations/voir.php?id={$c.id_cotisation|escape}">Autres cotisants</a> | <a class="icn" href="{$admin_url}membres/cotisations/supprimer.php?id={$c.id|escape}">✘</a> </td> </tr> {/foreach} </tbody> </table> {/if} {include file="admin/_foot.tpl"} |
Modified src/templates/admin/membres/cotisations/ajout.tpl from [2e38a73b19] to [406c2a793b].
︙ | ︙ | |||
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | {csrf_field key="add_cotisation"} {if $membre}<input type="hidden" name="id_membre" value="{$membre.id|escape}" />{/if} <input type="submit" name="add" value="Enregistrer →" /> </p> </form> <script type="text/javascript"> {literal} (function () { window.changeMoyenPaiement = function() { var elm = $('#f_moyen_paiement'); toggleElementVisibility('.f_cheque', elm.value == 'CH'); toggleElementVisibility('.f_banque', elm.value != 'ES'); }; changeMoyenPaiement(); toggleElementVisibility('.f_compta', false); $('#f_moyen_paiement').onchange = changeMoyenPaiement; $('#f_id_cotisation').onchange = function () { if (this.options[this.selectedIndex].getAttribute('data-compta')) { toggleElementVisibility('.f_compta', true); | > > > > > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | {csrf_field key="add_cotisation"} {if $membre}<input type="hidden" name="id_membre" value="{$membre.id|escape}" />{/if} <input type="submit" name="add" value="Enregistrer →" /> </p> </form> <script type="text/javascript"> var show_compta = {if $default_compta}true{else}false{/if}; {literal} (function () { window.changeMoyenPaiement = function() { var elm = $('#f_moyen_paiement'); toggleElementVisibility('.f_cheque', elm.value == 'CH'); toggleElementVisibility('.f_banque', elm.value != 'ES'); }; changeMoyenPaiement(); if (!show_compta) { toggleElementVisibility('.f_compta', false); } $('#f_moyen_paiement').onchange = changeMoyenPaiement; $('#f_id_cotisation').onchange = function () { if (this.options[this.selectedIndex].getAttribute('data-compta')) { toggleElementVisibility('.f_compta', true); |
︙ | ︙ |
Modified src/templates/admin/membres/cotisations/voir.tpl from [09c2e0218f] to [9f7b26684d].
︙ | ︙ | |||
37 38 39 40 41 42 43 | {foreach from=$liste item="co"} <tr> <td class="num"><a class="icn" href="{$admin_url}membres/fiche.php?id={$co.id_membre|escape}">{$co.id_membre|escape}</a></td> <th>{$co.nom|escape}</th> <td>{if $co.a_jour}<b class="confirm">À jour</b>{else}<b class="error">En retard</b>{/if}</td> <td>{$co.date|format_sqlite_date_to_french}</td> <td class="actions"> | | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | {foreach from=$liste item="co"} <tr> <td class="num"><a class="icn" href="{$admin_url}membres/fiche.php?id={$co.id_membre|escape}">{$co.id_membre|escape}</a></td> <th>{$co.nom|escape}</th> <td>{if $co.a_jour}<b class="confirm">À jour</b>{else}<b class="error">En retard</b>{/if}</td> <td>{$co.date|format_sqlite_date_to_french}</td> <td class="actions"> <a href="{$admin_url}membres/cotisations/ajout.php?id={$co.id_membre|escape}&cotisation={$cotisation.id|escape}">Saisir</a> | <a href="{$admin_url}membres/cotisations.php?id={$co.id_membre|escape}">Cotisations de ce membre</a> </td> </tr> {/foreach} </tbody> </table> {pagination url=$pagination_url page=$page bypage=$bypage total=$total} {/if} {include file="admin/_foot.tpl"} |
Modified src/www/admin/membres/cotisations/ajout.php from [d89a6b0de5] to [47528a9ba2].
︙ | ︙ | |||
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | $tpl->assign('membre', $membre); $tpl->assign('cotisations', $cotisations->listCurrent()); $tpl->assign('default_co', null); $tpl->assign('default_amount', 0.00); $tpl->assign('default_date', date('Y-m-d')); $tpl->assign('moyens_paiement', $cats->listMoyensPaiement()); $tpl->assign('moyen_paiement', utils::post('moyen_paiement') ?: 'ES'); $tpl->assign('comptes_bancaires', $banques->getList()); $tpl->assign('banque', utils::post('banque')); if (utils::get('cotisation')) { $co = $cotisations->get(utils::get('cotisation')); if (!$co) { throw new UserException("La cotisation indiquée en paramètre n'existe pas."); } $tpl->assign('default_co', $co['id']); $tpl->assign('default_amount', $co['montant']); } elseif ($membre) { if (!empty($categorie['id_cotisation_obligatoire'])) { $co = $cotisations->get($categorie['id_cotisation_obligatoire']); | > > | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | $tpl->assign('membre', $membre); $tpl->assign('cotisations', $cotisations->listCurrent()); $tpl->assign('default_co', null); $tpl->assign('default_amount', 0.00); $tpl->assign('default_date', date('Y-m-d')); $tpl->assign('default_compta', null); $tpl->assign('moyens_paiement', $cats->listMoyensPaiement()); $tpl->assign('moyen_paiement', utils::post('moyen_paiement') ?: 'ES'); $tpl->assign('comptes_bancaires', $banques->getList()); $tpl->assign('banque', utils::post('banque')); if (utils::get('cotisation')) { $co = $cotisations->get(utils::get('cotisation')); if (!$co) { throw new UserException("La cotisation indiquée en paramètre n'existe pas."); } $tpl->assign('default_co', $co['id']); $tpl->assign('default_compta', $co['id_categorie_compta']); $tpl->assign('default_amount', $co['montant']); } elseif ($membre) { if (!empty($categorie['id_cotisation_obligatoire'])) { $co = $cotisations->get($categorie['id_cotisation_obligatoire']); |
︙ | ︙ |