Overview
Comment: | Add alert message if there is nothing to deposit |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
1e30d5d4530c62451f718d556b45e617 |
User & Date: | bohwaz on 2021-01-14 14:55:40 |
Other Links: | branch diff | manifest | tags |
Context
2021-01-15
| ||
18:59 | Add more debug options, progress on skeletons check-in: 3f8be2329a user: bohwaz tags: dev | |
2021-01-14
| ||
14:57 | Backport: Add alert message if there is nothing to deposit check-in: 0a1806f465 user: bohwaz tags: trunk | |
14:55 | Add alert message if there is nothing to deposit check-in: 1e30d5d453 user: bohwaz tags: dev | |
14:49 | A better error message when nothing is checked check-in: 6dad4a9dda user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Entities/Accounting/Account.php from [bfec22341c] to [055e1ef171].
︙ | ︙ | |||
385 386 387 388 389 390 391 392 393 394 395 396 397 398 | $row->date = \DateTime::createFromFormat('Y-m-d', $row->date); $sum += ($row->credit - $row->debit); $row->running_sum = $sum; $row->checked = array_key_exists($row->id, $checked); yield $row; } } public function getSum(int $year_id, bool $simple = false): int { $sum = (int) DB::getInstance()->firstColumn('SELECT SUM(l.credit) - SUM(l.debit) FROM acc_transactions_lines l INNER JOIN acc_transactions t ON t.id = l.id_transaction wHERE l.id_account = ? AND t.id_year = ?;', $this->id(), $year_id); | > > > > > > > > > > | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | $row->date = \DateTime::createFromFormat('Y-m-d', $row->date); $sum += ($row->credit - $row->debit); $row->running_sum = $sum; $row->checked = array_key_exists($row->id, $checked); yield $row; } } public function countDepositJournal(int $year_id): int { return DB::getInstance()->firstColumn('SELECT COUNT(*) FROM acc_transactions_lines l INNER JOIN acc_transactions t ON t.id = l.id_transaction WHERE t.id_year = ? AND l.id_account = ? AND l.credit = 0 AND NOT (t.status & ?) ORDER BY t.date, t.id;', $year_id, $this->id(), Transaction::STATUS_DEPOSIT); } public function getSum(int $year_id, bool $simple = false): int { $sum = (int) DB::getInstance()->firstColumn('SELECT SUM(l.credit) - SUM(l.debit) FROM acc_transactions_lines l INNER JOIN acc_transactions t ON t.id = l.id_transaction wHERE l.id_account = ? AND t.id_year = ?;', $this->id(), $year_id); |
︙ | ︙ |
Modified src/templates/acc/accounts/deposit.tpl from [f0e1448813] to [1de1606a11].
1 2 | {include file="admin/_head.tpl" title="Dépôt en banque : %s — %s"|args:$account.code,$account.label current="acc/accounts"} | < < < < > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 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 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 | {include file="admin/_head.tpl" title="Dépôt en banque : %s — %s"|args:$account.code,$account.label current="acc/accounts"} {form_errors} {if !$journal_count} <p class="alert block">Il n'y a aucune écriture qui nécessite un dépôt.<br /> {linkbutton href="!acc/transactions/new.php" shape="plus" label="Saisir un virement"} </p> {else} <p class="help"> Cocher les cases correspondant aux montants à déposer, une nouvelle écriture sera générée. </p> <form method="post" action="{$self_url}" data-focus="1"> <table class="list"> <thead> <tr> <td class="check"><input type="checkbox" title="Tout cocher / décocher" id="f_all" /><label for="f_all"></label></td> <td></td> <td>Date</td> <td>Réf. écriture</td> <td>Réf. ligne</td> <th>Libellé</th> <td class="money">Montant</td> <td class="money">Solde cumulé</td> </tr> </thead> <tbody> {foreach from=$journal item="line"} {if isset($line.sum)} <tr> <td colspan="5"></td> <td class="money">{if $line.sum > 0}-{/if}{$line.sum|abs|raw|html_money:false}</td> <th>Solde au {$line.date|date_short}</th> <td colspan="2"></td> </tr> {else} <tr> <td class="check"> {input type="checkbox" name="deposit[%d]"|args:$line.id value="1" data-debit=$line.debit|abs data-credit=$line.credit default=$line.checked} </td> <td class="num"><a href="{$admin_url}acc/transactions/details.php?id={$line.id}">#{$line.id}</a></td> <td>{$line.date|date_short}</td> <td>{$line.reference}</td> <td>{$line.line_reference}</td> <th>{$line.label}</th> <td class="money">{$line.debit|raw|html_money}</td> <td class="money">{if $line.running_sum > 0}-{/if}{$line.running_sum|abs|raw|html_money:false}</td> </tr> {/if} {/foreach} </tbody> </table> <fieldset> <legend>Détails de l'écriture de dépôt</legend> <dl> {input type="text" name="label" label="Libellé" required=1 default="Dépôt en banque"} {input type="date" name="date" default=$date label="Date" required=1} {input type="money" name="amount" label="Montant" required=1} {input type="list" target="acc/charts/accounts/selector.php?chart=%d&targets=%d"|args:$account.id_chart,$target name="account_transfer" label="Compte de dépôt" required=1} {input type="text" name="reference" label="Numéro de pièce comptable"} {input type="textarea" name="notes" label="Remarques" rows=4 cols=30} </dl> </fieldset> <p class="submit"> {csrf_field key="acc_deposit_%s"|args:$account.id} {button type="submit" name="save" label="Enregistrer" class="main" shape="check"} </p> </form> {literal} <script type="text/javascript"> var total = 0; $('tbody input[type=checkbox]').forEach((e) => { e.addEventListener('change', () => { var v = e.getAttribute('data-debit') || e.getAttribute('data-credit'); v = parseInt(v, 10); total += e.checked ? v : -v; if (total < 0) { total = 0; } $('#f_amount').value = g.formatMoney(total); }); }); $('#f_all').addEventListener('change', (e) => { $('#f_amount').value = ''; total = 0; }); </script> {/literal} {/if} {include file="admin/_foot.tpl"} |
Modified src/www/admin/acc/accounts/deposit.php from [73f47982d1] to [ceabbe5204].
︙ | ︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | $transaction->importFromDepositForm(); Transactions::saveDeposit($transaction, $journal, $checked); Utils::redirect(ADMIN_URL . 'acc/transactions/details.php?id=' . $transaction->id()); }, 'acc_deposit_' . $account->id()); if ($form->hasErrors()) { $journal = $account->getDepositJournal(CURRENT_YEAR_ID); } $date = new \DateTime; if ($date > $current_year->end_date) { $date = $current_year->end_date; } $target = $account::TYPE_BANK; $tpl->assign(compact( 'account', 'journal', 'date', 'target', | > > > | > | 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 | $transaction->importFromDepositForm(); Transactions::saveDeposit($transaction, $journal, $checked); Utils::redirect(ADMIN_URL . 'acc/transactions/details.php?id=' . $transaction->id()); }, 'acc_deposit_' . $account->id()); // Uncheck everything if there was an error if ($form->hasErrors()) { $journal = $account->getDepositJournal(CURRENT_YEAR_ID); } $date = new \DateTime; if ($date > $current_year->end_date) { $date = $current_year->end_date; } $target = $account::TYPE_BANK; $journal_count = $account->countDepositJournal(CURRENT_YEAR_ID); $tpl->assign(compact( 'account', 'journal', 'date', 'target', 'checked', 'journal_count' )); $tpl->display('acc/accounts/deposit.tpl'); |