Overview
Comment: | Fix opening balance: don't forget everything that was entered when an error happens |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | stable |
Files: | files | file ages | folders |
SHA1: |
8c704892c04009df4a0b6d807e078f34 |
User & Date: | bohwaz on 2020-12-21 21:26:29 |
Other Links: | manifest | tags |
Context
2020-12-21
| ||
21:49 | Fix 486/487 account for 2018 chart check-in: 4e9a6a5bb5 user: bohwaz tags: trunk | |
21:26 | Fix opening balance: don't forget everything that was entered when an error happens check-in: 8c704892c0 user: bohwaz tags: trunk, stable | |
2020-12-20
| ||
16:56 | Fix import of transactions check-in: 026dee2dda user: bohwaz tags: trunk, stable | |
Changes
Modified src/templates/acc/years/balance.tpl from [23bad15873] to [7e2d7fd2b5].
︙ | ︙ | |||
10 11 12 13 14 15 16 | {/if} <form method="post" action="{$self_url}"> <fieldset> <legend>Exercice : « {$year.label} » du {$year.start_date|date_short} au {$year.end_date|date_short}</legend> | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | {/if} <form method="post" action="{$self_url}"> <fieldset> <legend>Exercice : « {$year.label} » du {$year.start_date|date_short} au {$year.end_date|date_short}</legend> {if !$year_selected} <dl> <dt><label for="f_from_year">Reprendre les soldes de fermeture d'un exercice clôturé</label></dt> <dd> <select id="f_from_year" name="from_year"> <option value="">-- Aucun</option> {foreach from=$years item="year"} <option value="{$year.id}">{$year.label} — {$year.start_date|date_short} au {$year.end_date|date_short}</option> |
︙ | ︙ | |||
43 44 45 46 47 48 49 | <td>Crédit</td> <td></td> </tr> </thead> <tbody> {foreach from=$lines key="k" item="line"} <tr> | | > | > > > | < < < | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | <td>Crédit</td> <td></td> </tr> </thead> <tbody> {foreach from=$lines key="k" item="line"} <tr> {if $chart_change || isset($line->code, $line->label)} <td> {$line.code} — {$line.label} <input type="hidden" name="lines[code][]" value="{$line.code}" /> <input type="hidden" name="lines[label][]" value="{$line.label}" /> </td> {/if} <th> {input type="list" target="acc/charts/accounts/selector.php?chart=%d"|args:$year.id_chart name="lines[account][]" default=$line.account} </th> <td>{input type="money" name="lines[debit][]" default=$line.debit size=5}</td> <td>{input type="money" name="lines[credit][]" default=$line.credit size=5}</td> <td>{button label="Enlever la ligne" shape="minus" min="1" name="remove_line"}</td> </tr> {/foreach} </tbody> |
︙ | ︙ | |||
81 82 83 84 85 86 87 | {if null === $previous_year} {button type="submit" name="next" label="Continuer" shape="right" class="main"} - ou - {linkbutton shape="reset" href="!acc/years/" label="Passer cet étape"} <i class="help">(Il sera toujours possible de reprendre la balance d'ouverture plus tard.)</i> {else} {csrf_field key="acc_years_balance_%s"|args:$year.id} {if $previous_year} | | > > | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | {if null === $previous_year} {button type="submit" name="next" label="Continuer" shape="right" class="main"} - ou - {linkbutton shape="reset" href="!acc/years/" label="Passer cet étape"} <i class="help">(Il sera toujours possible de reprendre la balance d'ouverture plus tard.)</i> {else} {csrf_field key="acc_years_balance_%s"|args:$year.id} {if $previous_year} <input type="hidden" name="from_year" value="{$previous_year.id}" /> {else} <input type="hidden" name="from_year" value="" /> {/if} {button type="submit" name="save" label="Enregistrer" shape="right" class="main"} {literal} <script type="text/javascript" defer="defer" async="async"> g.script('scripts/accounting.js', () => { initTransactionForm(); }); </script> |
︙ | ︙ |
Modified src/www/admin/acc/years/balance.php from [f0580c2891] to [05200c3b37].
︙ | ︙ | |||
32 33 34 35 36 37 38 39 40 | catch (UserException $e) { $form->addError($e->getMessage()); } } $previous_year = null; $chart_change = false; $lines = [[]]; | > < < | 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 | catch (UserException $e) { $form->addError($e->getMessage()); } } $previous_year = null; $year_selected = f('from_year') !== null; $chart_change = false; $lines = [[]]; $years = Years::listClosed(); // Empty balance if (!count($years) || f('from_year') === '') { $previous_year = 0; } elseif (null !== f('from_year')) { $previous_year = (int)f('from_year'); $previous_year = Years::get($previous_year); if (!$previous_year) { throw new UserException('Année précédente invalide'); } } if ($previous_year) { $lines = Reports::getClosingSumsWithAccounts(['year' => $previous_year->id(), 'exclude_position' => [Account::EXPENSE, Account::REVENUE]]); if ($previous_year->id_chart != $year->id_chart) { $chart_change = true; $codes = []; |
︙ | ︙ | |||
88 89 90 91 92 93 94 | } $lines[] = (object) [ 'sum' => $result, 'id' => $account->id, 'code' => $account->code, 'label' => $account->label, | < < | | | < > > > > > > > > > > > | | 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 | } $lines[] = (object) [ 'sum' => $result, 'id' => $account->id, 'code' => $account->code, 'label' => $account->label, ]; foreach ($lines as $k => &$line) { $line->credit = $line->sum > 0 ? $line->sum : 0; $line->debit = $line->sum < 0 ? abs($line->sum) : 0; if ($chart_change) { if (array_key_exists($line->code, $matching_accounts)) { $acc = $matching_accounts[$line->code]; $line->account = [$acc->id => sprintf('%s — %s', $acc->code, $acc->label)]; } } $line->account = [$line->id => sprintf('%s — %s', $line->code, $line->label)]; $line = (array) $line; } unset($line); } if (!empty($_POST['lines']) && is_array($_POST['lines'])) { $lines = Utils::array_transpose($_POST['lines']); foreach ($lines as &$line) { $line['credit'] = Utils::moneyToInteger($line['credit']); $line['debit'] = Utils::moneyToInteger($line['debit']); } } $tpl->assign(compact('lines', 'years', 'chart_change', 'previous_year', 'year_selected', 'year')); $tpl->display('acc/years/balance.tpl'); |