Comment: | Change analytical account action (patch from @zou) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
f7516d9adb71bc3d578ad91899cc3008 |
User & Date: | bohwaz on 2020-11-25 19:23:24 |
Other Links: | branch diff | manifest | tags |
2020-11-25
| ||
19:31 | Add column with project code, patch by @zou check-in: f9f9d935a7 user: bohwaz tags: dev, 1.0.0-beta8 | |
19:23 | Change analytical account action (patch from @zou) check-in: f7516d9adb user: bohwaz tags: dev | |
18:46 | Fix issues with checkboxes check-in: c7949d172e user: bohwaz tags: dev | |
Modified src/include/lib/Garradin/Accounting/Transactions.php from [c4c7222539] to [f37ddc1d1c].
1 2 3 4 5 6 7 8 9 10 11 | <?php namespace Garradin\Accounting; use Garradin\Entities\Accounting\Line; use Garradin\Entities\Accounting\Transaction; use Garradin\Entities\Accounting\Year; use KD2\DB\EntityManager; use Garradin\CSV; use Garradin\CSV_Custom; use Garradin\DB; | > | 1 2 3 4 5 6 7 8 9 10 11 12 | <?php namespace Garradin\Accounting; use Garradin\Entities\Accounting\Account; use Garradin\Entities\Accounting\Line; use Garradin\Entities\Accounting\Transaction; use Garradin\Entities\Accounting\Year; use KD2\DB\EntityManager; use Garradin\CSV; use Garradin\CSV_Custom; use Garradin\DB; |
︙ | ︙ | |||
342 343 344 345 346 347 348 | catch (UserException $e) { $db->rollback(); throw new UserException(sprintf('Erreur sur la ligne %d : %s', $l, $e->getMessage())); } $db->commit(); } | | > > > > > > > > > > > > > > > | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | catch (UserException $e) { $db->rollback(); throw new UserException(sprintf('Erreur sur la ligne %d : %s', $l, $e->getMessage())); } $db->commit(); } static public function setAnalytical(?int $id_analytical, array $lines) { $db = DB::getInstance(); if (null !== $id_analytical && !$db->test(Account::TABLE, 'type = 7 AND id = ?', $id_analytical)) { throw new \InvalidArgumentException('Chosen account ID is not analytical'); } $lines = array_map('intval', $lines); return $db->exec(sprintf('UPDATE acc_transactions_lines SET id_analytical = %s WHERE id IN (%s);', (int)$id_analytical ?: 'NULL', implode(', ', $lines))); } } |
Modified src/include/lib/Garradin/Entities/Accounting/Account.php from [1d8cfae373] to [fe2c4f18cc].
︙ | ︙ | |||
80 81 82 83 84 85 86 87 88 89 90 91 92 93 | ]; const LIST_COLUMNS = [ 'id' => [ 'select' => 't.id', 'label' => 'N°', ], 'date' => [ 'label' => 'Date', 'select' => 't.date', 'order' => 'date %s, id %1$s', ], 'debit' => [ 'select' => 'l.debit', | > > > | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | ]; const LIST_COLUMNS = [ 'id' => [ 'select' => 't.id', 'label' => 'N°', ], 'id_line' => [ 'select' => 'l.id', ], 'date' => [ 'label' => 'Date', 'select' => 't.date', 'order' => 'date %s, id %1$s', ], 'debit' => [ 'select' => 'l.debit', |
︙ | ︙ |
Modified src/templates/acc/accounts/index.tpl from [3215914970] to [d00593bab9].
︙ | ︙ | |||
11 12 13 14 15 16 17 | <li><a href="{$admin_url}acc/charts/accounts/all.php?id={$chart_id}">Plan comptable</a></li> {/if} </ul> </nav> {include file="acc/_simple_help.tpl" link="../reports/trial_balance.php?year=%d"|args:$current_year.id type=null} | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < < < | | > | 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 | <li><a href="{$admin_url}acc/charts/accounts/all.php?id={$chart_id}">Plan comptable</a></li> {/if} </ul> </nav> {include file="acc/_simple_help.tpl" link="../reports/trial_balance.php?year=%d"|args:$current_year.id type=null} {if !empty($grouped_accounts)} <table class="list"> <thead> <tr> <td class="num">Numéro</td> <th>Compte</th> <td class="money">Solde</td> <td></td> <td></td> </tr> </thead> {foreach from=$grouped_accounts item="group"} <tbody> <tr> <td colspan="5"><h2 class="ruler">{$group.label}</h2></td> </tr> {foreach from=$group.accounts item="account"} <tr> <td class="num"><a href="{$admin_url}acc/accounts/journal.php?id={$account.id}&year={$current_year.id}">{$account.code}</a></td> <th><a href="{$admin_url}acc/accounts/journal.php?id={$account.id}&year={$current_year.id}">{$account.label}</a></th> <td class="money"> {if $account.sum < 0}<strong class="error">{/if} {$account.sum|raw|money_currency:false} {if $account.sum < 0}</strong>{/if} </td> <td> {if $account.type == Entities\Accounting\Account::TYPE_THIRD_PARTY} <em class="alert"> {if $account.sum < 0}(Dette) {elseif $account.sum > 0}(Créance) {/if} </em> {/if} </td> <td class="actions"> {linkbutton label="Journal" shape="menu" href="journal.php?id=%d&year=%d"|args:$account.id,$current_year.id} {if $session->canAccess('compta', Membres::DROIT_ADMIN)} {if $account.type == Entities\Accounting\Account::TYPE_BANK} {linkbutton label="Rapprochement" shape="check" href="reconcile.php?id=%d"|args:$account.id} {elseif $account.type == Entities\Accounting\Account::TYPE_OUTSTANDING} {linkbutton label="Dépôt en banque" shape="check" href="deposit.php?id=%d"|args:$account.id} {/if} {/if} </td> </tr> {/foreach} </tbody> {/foreach} </table> {/if} <p class="help"> Note : n'apparaissent ici que les comptes favoris. Pour voir le solde de tous les comptes, se référer à la <a href="{$admin_url}acc/reports/trial_balance.php?year={$current_year.id}">balance générale de l'exercice</a>. </p> {include file="admin/_foot.tpl"} |
Modified src/templates/acc/accounts/journal.tpl from [09331b1b0f] to [d802a84d1e].
︙ | ︙ | |||
61 62 63 64 65 66 67 | <li{if !$simple} class="current"{/if}><a href="?id={$account.id}&simple=0&year={$year.id}">Vue comptable</a></li> </ul> </nav> {/if} <form method="post" action="{$admin_url}acc/transactions/actions.php"> | | | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | <li{if !$simple} class="current"{/if}><a href="?id={$account.id}&simple=0&year={$year.id}">Vue comptable</a></li> </ul> </nav> {/if} <form method="post" action="{$admin_url}acc/transactions/actions.php"> {include file="common/dynamic_list_head.tpl" check=$can_edit} {foreach from=$list->iterate() item="line"} <tr> {if $can_edit} <td class="check"> {input type="checkbox" name="check[%s]"|args:$line.id_line value=$line.id default=0} </td> {/if} <td class="num"><a href="{$admin_url}acc/transactions/details.php?id={$line.id}">#{$line.id}</a></td> <td>{$line.date|date_short}</td> {if $simple} <td class="money">{if $line.change > 0}+{else}-{/if}{$line.change|abs|raw|html_money}</td> {else} |
︙ | ︙ | |||
101 102 103 104 105 106 107 | {linkbutton href="!acc/transactions/details.php?id=%d"|args:$line.id label="Détails" shape="search"} </td> </tr> {/foreach} </tbody> <tfoot> <tr> | | | > | > > > > > | > > > > | 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 127 128 129 130 131 132 133 134 135 136 137 | {linkbutton href="!acc/transactions/details.php?id=%d"|args:$line.id label="Détails" shape="search"} </td> </tr> {/foreach} </tbody> <tfoot> <tr> {if $can_edit} <td class="check"><input type="checkbox" value="Tout cocher / décocher" id="f_all2" /><label for="f_all2"></label></td> {/if} {if !$simple}<td></td>{/if} <td colspan="3">Solde</td> <td class="money">{$sum|raw|html_money:false}</td> {if !$simple}<td></td>{/if} <td class="actions" colspan="4"> {if $can_edit} <em>Pour les écritures cochées :</em> <input type="hidden" name="from" value="{$self_url}" /> <input type="hidden" name="year" value="{$year.id}" /> {csrf_field key="projects_action"} <select name="action"> <option value="">— Choisir une action à effectuer —</option> <option value="change_analytical">Ajouter/enlever d'un projet</option> <option value="delete">Supprimer les écritures</option> </select> <noscript> {button type="submit" value="OK" shape="right" label="Valider"} </noscript> {/if} </td> </tr> </tfoot> </table> </form> {include file="admin/_foot.tpl"} |
Modified src/templates/acc/accounts/simple.tpl from [d31f0ca0e1] to [ed79ad4ba1].
|
| | | 1 2 3 4 5 6 7 8 | {include file="admin/_head.tpl" title="Suivi : %s"|args:$types[$type] current="acc/simple" js=1} {if empty($year)} {include file="acc/_year_select.tpl"} {else} <nav class="acc-year"> <h4>Exercice sélectionné :</h4> <h3>{$year.label} — {$year.start_date|date_short} au {$year.end_date|date_short}</h3> |
︙ | ︙ | |||
23 24 25 26 27 28 29 | <ul> {foreach from=$types key="key" item="label"} <li{if $type == $key} class="current"{/if}><a href="?type={$key}">{$label}</a></li> {/foreach} </ul> </nav> | > > > > > > > | | | < < < < | < < < | < | < < > > > > > > > > > > > > > > > | | | | | > > > > > > > > > > > > > > > > > > > > > | > > | > | 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 | <ul> {foreach from=$types key="key" item="label"} <li{if $type == $key} class="current"{/if}><a href="?type={$key}">{$label}</a></li> {/foreach} </ul> </nav> {if !$list->count()} <p class="alert block"> Aucune écriture à afficher. </p> {else} <form method="post" action="{$admin_url}acc/transactions/actions.php"> {include file="common/dynamic_list_head.tpl" check=$can_edit} {foreach from=$list->iterate() item="line"} <tr> {if $can_edit} <td class="check"> {input type="checkbox" name="check[%s]"|args:$line.id_line value=$line.id default=0} </td> {/if} <td class="num"><a href="journal.php?id={$line.id_account}">{$line.account}</a></td> <td>{$line.account_label}</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 class="money">{if $line.change > 0}+{else}-{/if}{$line.change|abs|raw|html_money}</td> <td>{$line.reference}</td> <th>{$line.label}</th> <td>{$line.line_reference}</td> <td class="actions"> {if $line.type == Entities\Accounting\Transaction::TYPE_DEBT} {linkbutton shape="check" label="Régler cette dette" href="!acc/transactions/new.php?payoff_for=%d"|args:$line.id} {elseif $line.type == Entities\Accounting\Transaction::TYPE_CREDIT} {linkbutton shape="export" label="Régler cette créance" href="!acc/transactions/new.php?payoff_for=%d"|args:$line.id} {/if} {linkbutton href="!acc/transactions/details.php?id=%d"|args:$line.id label="Détails" shape="search"} </td> </tr> {/foreach} </tbody> {if $can_edit} <tfoot> <tr> <td class="check"><input type="checkbox" value="Tout cocher / décocher" id="f_all2" /><label for="f_all2"></label></td> <td class="actions" colspan="9"> <em>Pour les écritures cochées :</em> <input type="hidden" name="from" value="{$self_url}" /> <input type="hidden" name="year" value="{$year.id}" /> {csrf_field key="projects_action"} <select name="action"> <option value="">— Choisir une action à effectuer —</option> <option value="change_analytical">Ajouter/enlever d'un projet</option> <option value="delete">Supprimer les écritures</option> </select> <noscript> {button type="submit" value="OK" shape="right" label="Valider"} </noscript> </td> </tr> </tfoot> {/if} </table> </form> {pagination url=$list->paginationURL() page=$list.page bypage=$list.per_page total=$list->count()} {/if} {include file="admin/_foot.tpl"} |
Added src/templates/acc/transactions/actions_analytical.tpl version [f3e59030a3].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | {include file="admin/_head.tpl" title="Ajouter/supprimer des écritures à un projet" current="acc/accounts"} {form_errors} <form method="post" action="{$self_url}"> <fieldset> <legend>Affecter {$count} écritures sélectionnées à un projet</legend> <dl> <dd> {input type="select" name="id_analytical" options=$analytical_accounts required="" label="Projet à utiliser" help="Pour retirer les écritures de leur projet actuellement affecté, sélectionner simplement « Aucun projet »."} </dd> </dl> </fieldset> <p class="submit"> {csrf_field key="acc_actions"} <input type="hidden" name="action" value="add" /> {button type="submit" name="change_analytical" label="Modifier les écritures" shape="right" class="main"} {if isset($extra)} {foreach from=$extra key="key" item="value"} {if is_array($value)} {foreach from=$value key="subkey" item="subvalue"} <input type="hidden" name="{$key}[{$subkey}]" value="{$subvalue}" /> {/foreach} {else} <input type="hidden" name="{$key}" value="{$value}" /> {/if} {/foreach} {/if} </p> </form> {include file="admin/_foot.tpl"} |
Modified src/www/admin/acc/accounts/journal.php from [cd05a99b41] to [73088600e8].
︙ | ︙ | |||
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 | if (!$year) { throw new UserException("L'exercice demandé n'existe pas."); } $tpl->assign('year', $year); } $can_edit = $session->canAccess('compta', Membres::DROIT_ADMIN) && !$year->closed; $simple = qg('simple'); // Use simplified view for favourite accounts if (null === $simple) { $simple = (bool) $account->type; } $list = $account->listJournal($year_id, $simple); $list->setTitle(sprintf('Journal - %s - %s', $account->code, $account->label)); $list->loadFromQueryString(); $sum = $account->getSum($year_id, $simple); $tpl->assign(compact('simple', 'year', 'account', 'list', 'sum', 'can_edit')); $tpl->display('acc/accounts/journal.tpl'); |
Modified src/www/admin/acc/accounts/simple.php from [d8d17ba662] to [ab194fa77a].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php namespace Garradin; use Garradin\Accounting\Accounts; use Garradin\Entities\Accounting\Account; require_once __DIR__ . '/../_inc.php'; if (!CURRENT_YEAR_ID) { Utils::redirect(ADMIN_URL . 'acc/years/?msg=OPEN'); } $types = [ Account::TYPE_REVENUE => 'Recettes', Account::TYPE_EXPENSE => 'Dépenses', Account::TYPE_BANK => 'Banques', Account::TYPE_CASH => 'Caisses', Account::TYPE_OUTSTANDING => 'En attente', | > > > > > > > > > > > > > > > | 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 | <?php namespace Garradin; use Garradin\Accounting\Accounts; use Garradin\Entities\Accounting\Account; require_once __DIR__ . '/../_inc.php'; if (!CURRENT_YEAR_ID) { Utils::redirect(ADMIN_URL . 'acc/years/?msg=OPEN'); } $year_id = (int) qg('year') ?: CURRENT_YEAR_ID; if ($year_id === CURRENT_YEAR_ID) { $year = $current_year; } else { $year = Years::get($year_id); if (!$year) { throw new UserException("L'exercice demandé n'existe pas."); } $tpl->assign('year', $year); } $types = [ Account::TYPE_REVENUE => 'Recettes', Account::TYPE_EXPENSE => 'Dépenses', Account::TYPE_BANK => 'Banques', Account::TYPE_CASH => 'Caisses', Account::TYPE_OUTSTANDING => 'En attente', |
︙ | ︙ | |||
26 27 28 29 30 31 32 | $type = key($types); } $list = Accounts::listByType(CURRENT_YEAR_ID, $type ?: null); $list->setTitle(sprintf('Suivi - %s', $types[$type])); $list->loadFromQueryString(); | > > | | 41 42 43 44 45 46 47 48 49 50 51 52 | $type = key($types); } $list = Accounts::listByType(CURRENT_YEAR_ID, $type ?: null); $list->setTitle(sprintf('Suivi - %s', $types[$type])); $list->loadFromQueryString(); $can_edit = $session->canAccess('compta', Membres::DROIT_ADMIN) && !$year->closed; $tpl->assign(compact('type', 'list', 'types', 'can_edit', 'year')); $tpl->display('acc/accounts/simple.tpl'); |
Modified src/www/admin/acc/transactions/actions.php from [93957c5a93] to [0ea83417c0].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php namespace Garradin; use Garradin\Accounting\Transactions; require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ADMIN); $check = f('check'); if (!$check || !is_array($check)) { throw new UserException('Aucune écriture n\'a été sélectionnée.'); } $csrf_key = 'acc_actions'; | > > > > > | | > > > > > > > > > > > > > > > > | > > > | > > | > | 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 | <?php namespace Garradin; use Garradin\Accounting\Transactions; use Garradin\Accounting\Years; require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ADMIN); $check = f('check'); if (!$check || !is_array($check)) { throw new UserException('Aucune écriture n\'a été sélectionnée.'); } $transactions = array_unique(array_values($check)); $lines = array_keys($check); $csrf_key = 'acc_actions'; // Delete transactions $form->runIf('delete', function () use ($transactions) { foreach ($transactions as $id) { $transaction = Transactions::get((int) $id); if (!$transaction) { throw new UserException('Cette écriture n\'existe pas'); } $transaction->delete(); } }, $csrf_key, f('from') ?: ADMIN_URL); // Add/remove lines to analytical $form->runIf('change_analytical', function () use ($lines) { $id = f('id_analytical') ?: null; Transactions::setAnalytical($id, $lines); }, $csrf_key, f('from') ?: ADMIN_URL); $from = f('from'); $count = count($check); $extra = compact('check', 'from'); $tpl->assign(compact('csrf_key', 'check', 'count', 'extra')); if (f('action') == 'delete') { $tpl->display('acc/transactions/actions_delete.tpl'); } else { // Get year to get analytical accounts $year = Years::get((int) f('year')); if (!$year) { throw new UserException("Aucun exercice sélectionné."); } $analytical = $year->chart()->accounts()->listAnalytical(); $tpl->assign('analytical_accounts', ['' => '-- Aucun projet'] + $analytical); $tpl->display('acc/transactions/actions_analytical.tpl'); } |