Overview
Comment: | Progression sur le report à nouveau, et suppression du doublon de la méthode doReports |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
b65094375d3dd926179bffd22d5e5c1f |
User & Date: | bohwaz on 2013-06-08 07:54:56 |
Other Links: | manifest | tags |
Context
2013-06-08
| ||
08:03 | Correction bug [edda38ee74] check-in: b8157e5819 user: bohwaz tags: trunk | |
07:54 | Progression sur le report à nouveau, et suppression du doublon de la méthode doReports check-in: b65094375d user: bohwaz tags: trunk | |
2013-05-24
| ||
10:02 | Merge corrections branche stable check-in: ff7d019472 user: bohwaz tags: trunk | |
Changes
Modified include/class.compta_exercices.php from [33ec667eb6] to [c15898ea4d].
︙ | ︙ | |||
87 88 89 90 91 92 93 94 | // Clôture de l'exercice $db->simpleUpdate('compta_exercices', array( 'cloture' => 1, 'fin' => $end, ), 'id = \''.(int)$id.'\''); $new_begin = utils::modifyDate($end, '+1 day'); | > > > > > > > > | | > | < > | | < | 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 | // Clôture de l'exercice $db->simpleUpdate('compta_exercices', array( 'cloture' => 1, 'fin' => $end, ), 'id = \''.(int)$id.'\''); // Date de début du nouvel exercice : lendemain de la clôture du précédent exercice $new_begin = utils::modifyDate($end, '+1 day'); // Date de fin du nouvel exercice : un an après l'ouverture $new_end = utils::modifyDate($new_begin, '+1 year'); // Enfin sauf s'il existe déjà des opérations après cette date, auquel cas la date de fin // est fixée à la date de la dernière opération, ceci pour ne pas avoir d'opération // orpheline d'exercice $last = $db->simpleQuerySingle('SELECT date FROM compta_journal WHERE id_exercice = ? AND date >= ? ORDER BY date DESC LIMIT 1;', false, $id, $new_end); $new_end = $last ?: $new_end; // Création du nouvel exercice $new_id = $this->add(array( 'debut' => $new_begin, 'fin' => $new_end, 'libelle' => 'Nouvel exercice' ) ); // Ré-attribution des opérations de l'exercice à clôturer qui ne sont pas dans son // intervale au nouvel exercice $db->simpleExec('UPDATE compta_journal SET id_exercice = ? WHERE id_exercice = ? AND date >= ?;', $new_id, $id, $new_begin); $db->exec('END;'); return $new_id; } /** |
︙ | ︙ | |||
130 131 132 133 134 135 136 | $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 | | > | | < < < < < < < < < < < < < < < < < < < < < < < < < | | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | $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 id_exercice = :id AND solde != 0 AND substr(id, 0, 1) <= 5;', 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), // FIXME : de quel compte viens l'argent?! 'compte_debit' => ($solde < 0 ? $report_crediteur : $row['compte']), 'compte_credit' => ($solde > 0 ? $report_debiteur : $row['compte']), 'remarques' => 'Report à nouveau créé automatiquement à la clôture de l\'exercice précédent', )); } // Solder tous les comptes de charges et de produits (production du résultat) $this->solderResultat($id); $db->exec('END;'); return $new_id; } /** * Solder les comptes de charge et de produits puis les inscrire au résultat du n * @param integer $exercice ID de l'exercice à solder * @return boolean true en cas de succès */ public function solderResultat($exercice) { $db = DB::getInstance(); |
︙ | ︙ | |||
227 228 229 230 231 232 233 | { continue; } // Enregistrement du résultat $journal = new Compta_Journal; $journal->add(array( | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | { continue; } // Enregistrement du résultat $journal = new Compta_Journal; $journal->add(array( 'libelle' => 'Résultat de l\'exercice', 'date' => $end, 'montant' => abs($solde), 'compte_debit' => $debit, 'compte_credit' => $credit, )); } $res->finalize(); } public function delete($id) { $db = DB::getInstance(); // Ne pas supprimer un compte qui est utilisé ! if ($db->simpleQuerySingle('SELECT 1 FROM compta_journal WHERE id_exercice = ? LIMIT 1;', false, $id)) { |
︙ | ︙ |