Overview
Comment:Nom plus parlant du nouvel exercice
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA1: 2c234ac9ba979d7bdc4d3575866184d8671c4919
User & Date: bohwaz on 2019-12-01 19:29:59
Other Links: manifest | tags
Context
2019-12-01
20:04
Uniformisation de la position des actions à droite des tableaux, ajout d'une action pour voir les détails de l'écriture check-in: be5b3d5ef5 user: bohwaz tags: trunk
19:29
Nom plus parlant du nouvel exercice check-in: 2c234ac9ba user: bohwaz tags: trunk, stable
2019-11-17
19:46
Fix: stdClass, pas object check-in: 56bed8c330 user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Compta/Exercices.php from [7a15675417] to [3bc6667d2a].

102
103
104
105
106
107
108











109
110
111
112
113
114
115
116
117
118
119
120
121
        $new_end = Utils::modifyDate($new_begin, '+1 year -1 day');

        // 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->firstColumn('SELECT date FROM compta_journal WHERE id_exercice = ? AND date >= ? ORDER BY date DESC LIMIT 1;', $id, $new_end);
        $new_end = $last ?: $new_end;












        // Création du nouvel exercice
        $new_id = $this->add([
            '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->update('compta_journal', ['id_exercice' => $new_id], 'id_exercice = :id AND date >= :date', [
            'id'   => $id,
            'date' => $new_begin,







>
>
>
>
>
>
>
>
>
>
>





|







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
        $new_end = Utils::modifyDate($new_begin, '+1 year -1 day');

        // 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->firstColumn('SELECT date FROM compta_journal WHERE id_exercice = ? AND date >= ? ORDER BY date DESC LIMIT 1;', $id, $new_end);
        $new_end = $last ?: $new_end;

        $year_begin = substr($new_begin, 0, 4);
        $year_end = substr($new_end, 0, 4);

        // Nom du nouvel exercice
        if ($year_begin == $year_end) {
            $label = sprintf('Exercice %d', $year_begin);
        }
        else {
            $label = sprintf('Exercice %d-%d', $year_begin, $year_end);
        }

        // Création du nouvel exercice
        $new_id = $this->add([
            'debut'     =>  $new_begin,
            'fin'       =>  $new_end,
            'libelle'   =>  $label,
        ]);

        // Ré-attribution des opérations de l'exercice à clôturer qui ne sont pas dans son
        // intervale au nouvel exercice
        $db->update('compta_journal', ['id_exercice' => $new_id], 'id_exercice = :id AND date >= :date', [
            'id'   => $id,
            'date' => $new_begin,