Overview
Comment: |
|
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
18c69e30511a1eed1f9fd4186ed5bab4 |
User & Date: | bohwaz on 2013-05-15 10:39:26 |
Other Links: | manifest | tags |
Context
2013-05-16
| ||
05:21 | Merge correction 0.5.3 check-in: 79c68368a6 user: bohwaz tags: trunk | |
2013-05-15
| ||
10:39 |
| |
2013-04-12
| ||
13:57 | Enregistrement du type de rappel effectué check-in: a0711ba1ef user: bohwaz tags: trunk | |
Changes
Modified include/class.compta_exercices.php from [cee018764e] to [561ecf8911].
︙ | ︙ | |||
63 64 65 66 67 68 69 | 'debut' => $data['debut'], 'fin' => $data['fin'], ), 'id = \''.(int)$id.'\''); return true; } | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 99 100 101 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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | 'debut' => $data['debut'], 'fin' => $data['fin'], ), 'id = \''.(int)$id.'\''); return true; } public function close($id, $end) { $db = DB::getInstance(); if (!utils::checkDate($end)) { throw new UserException('Date de fin vide ou invalide.'); } $db->exec('BEGIN;'); $db->simpleUpdate('compta_exercices', array( 'cloture' => 1, 'fin' => $end, ), 'id = \''.(int)$id.'\''); $new_begin = utils::modifyDate($end, '+1 day'); $last = $db->simpleQuerySingle('SELECT date FROM compta_journal WHERE id_exercice = ? AND date >= ? ORDER BY date DESC LIMIT 1;', false, $id, $new_begin); $new_end = $last ?: utils::modifyDate($new_begin, '+1 year'); $new_id = $this->add(array( 'debut' => $new_begin, 'fin' => $new_end, 'libelle' => 'Nouvel exercice' ) ); if ($last) { $db->simpleExec('UPDATE compta_journal SET id_exercice = ? WHERE id_exercice = ? AND date >= ?;', $new_id, $id, $new_begin); } $db->exec('END;'); return $new_id; } /** * Créer les reports à nouveau issus de l'exercice $old_id dans le nouvel exercice courant * @param integer $old_id ID de l'ancien exercice * @param string $date Date Y-m-d donnée aux opérations créées * @return boolean true si succès */ public function doReports($old_id, $date) { $db = DB::getInstance(); $report_crediteur = 110; $report_debiteur = 119; // Récupérer chacun des comptes de bilan et leurs soldes $statement = $db->simpleStatement('SELECT id, COALESCE((SELECT SUM(montant) FROM compta_journal WHERE compte_debit = compte AND id_exercice = :id), 0) AS debit, COALESCE((SELECT SUM(montant) FROM compta_journal WHERE compte_credit = compte AND id_exercice = :id), 0) AS credit, CASE WHEN position & ' . Compta_Comptes::ACTIF . ' THEN debit - credit ELSE credit - debit END AS solde FROM compta_comptes LEFT JOIN compta_journal ON compta_comptes.id = compta_journal.compte_debit OR compta_comptes.id = compta_journal.compte_credit WHERE solde != 0 AND id NOT LIKE \'6%\' AND id NOT LIKE \'7%\';', array('id' => $old_id)); while ($row = $statement->fetchArray(SQLITE3_ASSOC)) { // Chaque solde de compte est reporté dans le nouvel exercice $journal->add(array( 'libelle' => 'Report à nouveau', 'date' => $date, 'montant' => abs($solde), 'compte_debit' => ($solde < 0 ? $report_crediteur : $row['compte']), // FIXME 'compte_credit' => ($solde > 0 ? $report_debiteur : $row['compte']), // FIXME 'remarques' => 'Report à nouveau créé automatiquement à la clôture de l\'exercice précédent', )); } return true; } public function delete($id) { $db = DB::getInstance(); |
︙ | ︙ |
Modified include/data/0.6.0.sql from [fee8118654] to [ee5ee4434f].
1 2 3 4 5 6 7 | CREATE TABLE transactions -- Paiements possibles ( id INTEGER PRIMARY KEY, id_categorie_compta INTEGER NULL, -- NULL si le type n'est pas associé automatiquement à la compta intitule TEXT NOT NULL, | > > > | 1 2 3 4 5 6 7 8 9 10 | -- nouveau moyen de paiement --INSERT INTO compta_moyens_paiement (code, nom) VALUES ('AU', 'Autre'); CREATE TABLE transactions -- Paiements possibles ( id INTEGER PRIMARY KEY, id_categorie_compta INTEGER NULL, -- NULL si le type n'est pas associé automatiquement à la compta intitule TEXT NOT NULL, |
︙ | ︙ |
Modified include/data/schema.sql from [80ed003645] to [efb5c9c9f6].
︙ | ︙ | |||
285 286 287 288 289 290 291 292 293 294 295 296 297 298 | CREATE TABLE compta_moyens_paiement -- Moyens de paiement ( code TEXT PRIMARY KEY, nom TEXT ); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('CB', 'Carte bleue'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('CH', 'Chèque'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('ES', 'Espèces'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('PR', 'Prélèvement'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('TI', 'TIP'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('VI', 'Virement'); | > | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | CREATE TABLE compta_moyens_paiement -- Moyens de paiement ( code TEXT PRIMARY KEY, nom TEXT ); --INSERT INTO compta_moyens_paiement (code, nom) VALUES ('AU', 'Autre'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('CB', 'Carte bleue'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('CH', 'Chèque'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('ES', 'Espèces'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('PR', 'Prélèvement'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('TI', 'TIP'); INSERT INTO compta_moyens_paiement (code, nom) VALUES ('VI', 'Virement'); |
︙ | ︙ |
Modified include/lib.utils.php from [c24a99ba2c] to [ac227a55ca].
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 51 52 53 54 55 | return $date; } static public function makeTimestampFromForm($d) { return mktime($d['h'], $d['min'], 0, $d['m'], $d['d'], $d['y']); } static public function checkDate($str) { if (!preg_match('!^(\d{4})-(\d{2})-(\d{2})$!', $str, $match)) return false; if (!checkdate($match[2], $match[3], $match[1])) | > > > > > > > | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | return $date; } static public function makeTimestampFromForm($d) { return mktime($d['h'], $d['min'], 0, $d['m'], $d['d'], $d['y']); } static public function modifyDate($str, $change) { $date = \DateTime::createFromFormat('Y-m-d', $str); $date->modify($change); return $date->format('Y-m-d'); } static public function checkDate($str) { if (!preg_match('!^(\d{4})-(\d{2})-(\d{2})$!', $str, $match)) return false; if (!checkdate($match[2], $match[3], $match[1])) |
︙ | ︙ |
Modified templates/admin/compta/exercices/cloturer.tpl from [2d201cbf65] to [7b2c62b146].
1 2 3 4 5 6 7 8 9 10 11 12 13 | {include file="admin/_head.tpl" title="Clôturer un exercice" current="compta/exercices"} {if $error} <p class="error"> {$error|escape} </p> {/if} <form method="post" action="{$self_url|escape}"> <fieldset> <legend>Clôturer un exercice</legend> <h3 class="warning"> | | < | > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | {include file="admin/_head.tpl" title="Clôturer un exercice" current="compta/exercices"} {if $error} <p class="error"> {$error|escape} </p> {/if} <form method="post" action="{$self_url|escape}"> <fieldset> <legend>Clôturer un exercice</legend> <h3 class="warning"> Êtes-vous sûr de vouloir clôturer l'exercice « {$exercice.libelle|escape} » ? </h3> <p class="help"> Attention, une fois clôturé, les opérations de cet exercice ne pourront plus être supprimées ou modifiées. </p> <dl> <dt>Début de l'exercice</dt> <dd>{$exercice.debut|date_fr:'d/m/Y'}</dd> <dt><label for="f_fin">Fin de l'exercice</label></dt> <dd class="help">Si des opérations existent après cette date, elles seront automatiquement attribuées à un nouvel exercice.</dd> <dd><input type="date" name="fin" id="f_fin" value="{form_field name=fin default=$exercice.fin|date_fr:'Y-m-d'}" size="10" /></dd> <dt> <input type="checkbox" name="reports" {form_field name=reports default="1" checked=true} id="f_reports" /> <label for="f_reports">Exécuter automatiquement les reports à nouveau</label> </dt> <dd class="help">Les soldes créditeurs et débiteurs de chaque compte seront reportés automatiquement dans le nouvel exercice. Si vous ne cochez pas la case, vous devrez faire les reports à nouveau vous-même.</dd> </h3> </fieldset> <p class="submit"> {csrf_field key="compta_cloturer_exercice_`$exercice.id`"} <input type="submit" name="close" value="Clôturer →" /> </p> </form> {include file="admin/_foot.tpl"} |
Modified www/admin/compta/exercices/cloturer.php from [8a9abb1f9f] to [7f46902ef6].
︙ | ︙ | |||
25 26 27 28 29 30 31 | { $error = 'Une erreur est survenue, merci de renvoyer le formulaire.'; } else { try { | | > > > > > > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | { $error = 'Une erreur est survenue, merci de renvoyer le formulaire.'; } else { try { $id = $e->close($exercice['id'], utils::post('fin')); if ($id && utils::post('reports')) { $e->doReports($exercice['id'], utils::modifyDate(utils::post('fin'), '+1 day')); } utils::redirect('/admin/compta/exercices/'); } catch (UserException $e) { $error = $e->getMessage(); } } } $tpl->assign('error', $error); $tpl->assign('exercice', $exercice); $tpl->assign('custom_js', array('datepickr.js')); $tpl->display('admin/compta/exercices/cloturer.tpl'); ?> |