Overview
Comment: | Fix and improve reversed accounts in simple view |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
c1565ad1db426c037ae05aae8880f700 |
User & Date: | bohwaz on 2020-10-31 13:43:26 |
Other Links: | branch diff | manifest | tags |
Context
2020-10-31
| ||
13:52 | Rename p.alert style to .block.alert check-in: 949d222781 user: bohwaz tags: dev | |
13:43 | Fix and improve reversed accounts in simple view check-in: c1565ad1db user: bohwaz tags: dev | |
12:21 | Save the date of when a contribution has been paid check-in: 6f98e5f431 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Entities/Accounting/Account.php from [ed8b6884a2] to [7c238ab185].
︙ | ︙ | |||
114 115 116 117 118 119 120 | $this->assert(array_key_exists($this->type, self::TYPES_NAMES), 'Type invalide'); $this->assert(array_key_exists($this->position, self::POSITIONS_NAMES), 'Position invalide'); $this->assert($this->user === 0 || $this->user === 1); parent::selfCheck(); } | | > > > | > > > > > | 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 150 151 152 153 154 155 | $this->assert(array_key_exists($this->type, self::TYPES_NAMES), 'Type invalide'); $this->assert(array_key_exists($this->position, self::POSITIONS_NAMES), 'Position invalide'); $this->assert($this->user === 0 || $this->user === 1); parent::selfCheck(); } public function getJournal(int $year_id, bool $simple = false) { $db = DB::getInstance(); $sql = 'SELECT l.debit, l.credit, t.id, t.date, t.reference, l.reference AS line_reference, t.label, l.label AS line_label, l.reconciled FROM acc_transactions_lines l INNER JOIN acc_transactions t ON t.id = l.id_transaction WHERE l.id_account = ? AND t.id_year = ? ORDER BY t.date, t.id;'; $rows = $db->get($sql, $this->id(), $year_id); $sum = 0; $reverse = $simple && self::isReversed($this->type) ? -1 : 1; foreach ($rows as &$row) { $sum += ($row->credit - $row->debit); $row->change = ($row->credit - $row->debit) * $reverse; $row->running_sum = $sum * $reverse; $row->date = \DateTime::createFromFormat('Y-m-d', $row->date); } return $rows; } static public function isReversed(int $type): bool { return in_array($type, [self::TYPE_BANK, self::TYPE_CASH, self::TYPE_OUTSTANDING, self::TYPE_EXPENSE, self::TYPE_THIRD_PARTY]); } public function getReconcileJournal(int $year_id, DateTimeInterface $start_date, DateTimeInterface $end_date) { if ($end_date < $start_date) { throw new ValidationException('La date de début ne peut être avant la date de fin.'); } |
︙ | ︙ |
Added src/templates/acc/_simple_help.tpl version [c8d3648a08].
> > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <details> <summary class="help block"> Attention : dans cette vue simplifiée, {if $type == Entities\Accounting\Account::TYPE_THIRD_PARTY}les dettes du fournisseur/usager envers l'association apparaissent au crédit (positif) et les créances au débit (négatif) ! {elseif $type}les écritures apparaissent tels que sur le relevé de banque ou le journal de caisse ! {else}les comptes de banque, caisse, dépenses et tiers apparaissent de manière « simplifiée » ! {/if} C'est l'inverse de la {if $link}<a href="{$link}">{/if}la vue comptable{if $link}</a>{/if} en comptabilité en partie double.</summary> <div class="help block"> <p>L'extrait de compte fourni par la banque fonctionne « à l'envers », parce qu'il est établi du point de vue de la banque :</p> <ul> <li>les sommes versées sur votre compte (salaires etc.) constituent pour elle une ressource ( = crédit ; simultanément, cela augmente la dette de la banque à votre égard, ou réduit votre dette à son égard si vous êtes « débiteur »),</li> <li>les sommes retirées (paiement de chèques, carte bleue, etc.) constituent une utilisation ( = débit).</li> </ul> <p>Du point de vue du client de la banque, dans une comptabilité en partie double, ce que la banque appelle crédit (une entrée d'argent) est un débit (c'est une utilisation de l'argent), et inversement (un débit pour la banque est une ressource de son client, donc, pour lui, un crédit). (<a href="https://fr.wikipedia.org/wiki/Comptabilit%C3%A9_en_partie_double">Source Wikipedia</a>)</p> </div> </details> |
Modified src/templates/acc/accounts/index.tpl from [eb8e3427ba] to [ed2e64c0f1].
︙ | ︙ | |||
8 9 10 11 12 13 14 | <li><a href="{$admin_url}acc/search.php?year={$current_year.id}">Recherche</a></li> {if $session->canAccess('compta', Membres::DROIT_ADMIN)} <li><a href="{$admin_url}acc/charts/accounts/?id={$chart_id}">Gestion des comptes</a></li> {/if} </ul> </nav> | | < < | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <li><a href="{$admin_url}acc/search.php?year={$current_year.id}">Recherche</a></li> {if $session->canAccess('compta', Membres::DROIT_ADMIN)} <li><a href="{$admin_url}acc/charts/accounts/?id={$chart_id}">Gestion des comptes</a></li> {/if} </ul> </nav> {include file="acc/_simple_help.tpl" link=null type=null} <table class="list"> <thead> <tr> <td>Numéro</td> <th>Compte</th> <td class="money">Solde</td> |
︙ | ︙ |
Modified src/templates/acc/accounts/journal.tpl from [bc9fa2aafa] to [5ee0908607].
︙ | ︙ | |||
8 9 10 11 12 13 14 | <h3>{$year.label} — {$year.start_date|date_fr:'d/m/Y'} au {$year.end_date|date_fr:'d/m/Y'}</h3> </nav> {/if} {if $account.type} | > > > > | > > > > | < > > | > > > > > | > > > > > > > > > > > > > > > | | | | | | | | 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 42 43 44 45 46 47 48 49 50 51 52 53 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 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 | <h3>{$year.label} — {$year.start_date|date_fr:'d/m/Y'} au {$year.end_date|date_fr:'d/m/Y'}</h3> </nav> {/if} {if $account.type} {if $simple && $account::isReversed($account.type)} {include file="acc/_simple_help.tpl" link="?id=%d&simple=0&year=%d"|args:$account.id,$year.id type=$account.type} {/if} {if $simple} {if $account.type == $account::TYPE_THIRD_PARTY} {if $sum < 0} <p class="alert block">Vous devez <strong>{$sum|abs|raw|html_money} {$config.monnaie}</strong> à ce tiers.</p> {elseif $sum > 0} <p class="alert block">Ce tiers vous doit <strong>{$sum|raw|html_money} {$config.monnaie}</strong>.</p> {else} <p class="confirm block">Vous ne devez pas d'argent à ce tiers, et il ne vous en doit pas non plus.</p> {/if} {elseif $account.type == $account::TYPE_BANK} {if $sum < 0} <p class="error block">Ce compte est à découvert de <strong>{$sum|abs|raw|html_money} {$config.monnaie}</strong> à la banque.</p> {elseif $sum >= 0} <p class="confirm block">Ce compte est créditeur de <strong>{$sum|raw|html_money} {$config.monnaie}</strong> à la banque.</p> {/if} {elseif $account.type == $account::TYPE_CASH} {if $sum < 0} <p class="error block">Cette caisse est débiteur de <strong>{$sum|abs|raw|html_money} {$config.monnaie}</strong>. Est-ce normal ? Une vérification est peut-être nécessaire ?</p> {elseif $sum >= 0} <p class="confirm block">Cette caisse est créditrice de <strong>{$sum|raw|html_money} {$config.monnaie}</strong>.</p> {/if} {elseif $account.type == $account::TYPE_OUTSTANDING} {if $sum < 0} <p class="error block">Ce compte est débiteur <strong>{$sum|abs|raw|html_money} {$config.monnaie}</strong>. Est-ce normal ? Une vérification est peut-être nécessaire ?</p> {elseif $sum >= 0} <p class="confirm block">Ce compte d'attente est créditeur de <strong>{$sum|raw|html_money} {$config.monnaie}</strong>. {if $sum > 200}Un dépôt à la banque serait peut-être une bonne idée ?{/if}</p> {/if} {/if} {/if} <nav class="tabs"> <ul> <li{if $simple} class="current"{/if}><a href="?id={$account.id}&simple=1&year={$year.id}">Vue simplifiée</a></li> <li{if !$simple} class="current"{/if}><a href="?id={$account.id}&simple=0&year={$year.id}">Vue comptable</a></li> </ul> </nav> {/if} <table class="list"> <colgroup> <col width="3%" /> <col width="12%" /> <col width="10%" /> {if !$simple}<col width="10%" />{/if} <col width="12%" /> <col /> <col width="6%" /> </colgroup> <thead> <tr> <td>Réf.</td> <td>Date</td> {if $simple} <td>Mouvement</td> {else} <td class="money">Débit</td> <td class="money">Crédit</td> {/if} <td class="money">Solde cumulé</td> <th>Libellé</th> <td></td> </tr> </thead> <tbody> {foreach from=$journal item="line"} <tr> <td class="num"><a href="{$admin_url}acc/transactions/details.php?id={$line.id}">{if $line.line_reference}{$line.line_reference}{elseif $line.reference}{$line.reference}{else}#{$line.id}{/if}</a></td> <td>{$line.date|date_fr:'d/m/Y'}</td> {if $simple} <td class="money">{if $line.change > 0}+{else}-{/if}{$line.change|abs|raw|html_money}</td> {else} <td class="money">{$line.debit|raw|html_money}</td> <td class="money">{$line.credit|raw|html_money}</td> {/if} <td class="money">{$line.running_sum|raw|html_money:false}</td> <th>{$line.label}</th> <td class="actions"> {linkbutton href="acc/transactions/details.php?id=%d"|args:$line.id label="Détails" shape="search"} </td> </tr> {/foreach} </tbody> <tfoot> <tr> <td colspan="{if $simple}3{else}4{/if}">Solde</td> <td class="money">{$sum|raw|html_money:false}</td> <td colspan="2"></td> </tr> </tfoot> </table> {include file="admin/_foot.tpl"} |
Modified src/www/admin/acc/accounts/journal.php from [460f15984d] to [9d77473616].
︙ | ︙ | |||
23 24 25 26 27 28 29 | if (!$year) { throw new UserException("L'exercice demandé n'existe pas."); } $tpl->assign('year', $year); } | < < < < < < < | > | > > > | | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | if (!$year) { throw new UserException("L'exercice demandé n'existe pas."); } $tpl->assign('year', $year); } $simple = qg('simple'); // Use simplified view for favourite accounts if (null === $simple) { $simple = (bool) $account->type; } $journal = $account->getJournal($year_id, $simple); $sum = 0; if (count($journal)) { $sum = end($journal)->running_sum; } $tpl->assign(compact('simple', 'year', 'account', 'journal', 'sum')); $tpl->display('acc/accounts/journal.tpl'); |
Modified src/www/admin/static/admin.css from [f7cdff05c5] to [fa2c2e334b].
︙ | ︙ | |||
196 197 198 199 200 201 202 | color: #990; } .alert p, .error p, .confirm p { margin-bottom: .8em; } | | > > > > > | | | | | | | | | > > > > > > > > > > > | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | color: #990; } .alert p, .error p, .confirm p { margin-bottom: .8em; } .alert.block, .error.block, .confirm.block, .help.block { border: 1px solid #ccc; padding: .5em; margin-bottom: 1em; border-radius: .3em; padding-left: 3em; position: relative; } .alert.block { border-color: #cc0; background-color: #ffc; } .error.block { border-color: #c00; background-color: #fcc; } .confirm.block { border-color: #0c0; background-color: #cfc; } .help.block { border-color: #999; background-color: #eee; } .confirm.block::before, .alert.block::before, .error.block::before, .help.block::before { font-family: "gicon"; left: .5em; top: .2em; position: absolute; font-size: 1.5em; text-shadow: 2px 2px 5px #666; } .confirm.block::before { content: "☑"; color: green; } .alert.block::before { content: "⚠"; color: yellow; } .error.block::before { content: "⚠"; color: red; } .help.block::before { content: "❓"; color: #666; } .help { color: #666; } p.help { margin: 1em; } .help ul li { list-style-type: disc; margin: .5em; margin-left: 2em; } dd em.help { margin-left: 1em; } dd.help li { list-style-type: disc; |
︙ | ︙ | |||
951 952 953 954 955 956 957 | h2.ruler:after { left: 0.5em; margin-right: -50%; } .icn-btn { | > > | | < < < < < | < > | 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 | h2.ruler:after { left: 0.5em; margin-right: -50%; } .icn-btn { display: inline-block; color: rgb(var(--gMainColor)); border: 1px solid rgba(var(--gSecondColor), 0.5); background-color: rgba(var(--gSecondColor), 0.1); font-size: inherit; border-radius: .2em; padding: .2em .4em; margin: .2em .5em; white-space: pre; text-decoration: underline; transition: color .3s, background-color .3s; } .icn-btn[data-icon]:before, summary::after { display: inline-block; font-family: "gicon", sans-serif; text-shadow: 1px 1px 1px #999; padding-right: .5em; font-size: 1.2em; line-height: .8em; vertical-align: middle; content: attr(data-icon); } |
︙ | ︙ | |||
1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 | background: #fff; } details summary { list-style: none; padding: 0.2em 0.5em; transition: background-color .2s; } details summary:hover { cursor: pointer; background-color: rgba(var(--gMainColor), 0.1); } details summary::-webkit-details-marker { display: none; } | > | > > > > > > > > | < < < < < > | | > > > > > > > > > > > > > > | 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 | background: #fff; } details summary { list-style: none; padding: 0.2em 0.5em; transition: background-color .2s; position: relative; } details summary:hover { cursor: pointer; background-color: rgba(var(--gMainColor), 0.1); } details summary::-webkit-details-marker { display: none; } details summary::after { content: "↓"; position: absolute; left: 0; top: 0; /* From .icn-btn */ display: inline-block; color: rgb(var(--gMainColor)); border: 1px solid rgba(var(--gSecondColor), 0.5); background: #fff; font-size: 1.5em; border-radius: .2em; padding: .2em .4em; margin: .2em .5em; transition: color .3s, background-color .3s; font-family: "gicon", sans-serif; text-shadow: 1px 1px 1px #999; } details[open] summary::after { content: "↑"; } details summary:hover::after { background-color: rgb(var(--gMainColor)); color: #fff; } details summary.block { padding-right: 4em; } details summary.block::after { right: 0; left: inherit; } |