Overview
Comment: | Change the creation of a new account to make it simpler, also add ability to add an opening balance when creating an account |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
469e2911f394f325f5bf81ecb3482a98 |
User & Date: | bohwaz on 2022-03-07 04:07:18 |
Other Links: | manifest | tags |
Context
2022-03-07
| ||
04:07 | Sync file with schema.sql check-in: ef2546d83f user: bohwaz tags: trunk | |
04:07 | Change the creation of a new account to make it simpler, also add ability to add an opening balance when creating an account check-in: 469e2911f3 user: bohwaz tags: trunk | |
02:15 | Add page to show balance of all accounts check-in: bbd12328fb user: bohwaz tags: trunk | |
Changes
Modified src/templates/acc/charts/accounts/_account_form.tpl from [67f92e389c] to [34b75a09e9].
1 | <dl> | > | | | > > > > | < < < < < < < < < < < | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < | > | 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 | <dl> {if !$account.type} {input type="select" label="Type de compte favori" name="type" source=$account required=true options=$types} <dd class="help">Le statut de compte favori est utilisé pour les écritures <em>« simplifiées »</em> (recettes, dépenses, dettes, créances, virements), pour la liste des comptes, et également pour proposer certaines fonctionnalités (rapprochement pour les comptes bancaires, règlement rapide de dette et créance, dépôt de chèques).</dd> <dd class="help">Un compte qui n'a pas de type favori ne pourra être utilisé que dans une saisie avancée, et ne sera visible que dans les rapports de l'exercice.</dd> {else} <dt>Type de compte</dt> <dd><?php $t = $types[$account->type]; ?> {$t}</dd> {/if} {if !$account.type} <dt><label for="f_position_0">Position au bilan ou résultat</label>{if !$edit_disabled} <b>(obligatoire)</b>{/if}</dt> <dd class="help">La position permet d'indiquer dans quelle partie du bilan ou du résultat doit figurer le compte.</dd> <dd class="help">Les comptes inscrits en actif ou passif figureront dans le bilan, alors que ceux inscrits en produit ou charge figureront au compte de résultat.</dd> {input type="radio" label="Ne pas utiliser ce compte au bilan ni au résultat" name="position" value=0 source=$account disabled=$edit_disabled} {input type="radio" label="Bilan : actif" name="position" value=Entities\Accounting\Account::ASSET source=$account help="ce que possède l'association : stocks, locaux, soldes bancaires, etc." disabled=$edit_disabled} {input type="radio" label="Bilan : passif" name="position" value=Entities\Accounting\Account::LIABILITY source=$account help="ce que l'association doit : dettes, provisions, réserves, etc." disabled=$edit_disabled} {input type="radio" label="Bilan : actif ou passif" name="position" value=Entities\Accounting\Account::ASSET_OR_LIABILITY source=$account help="le compte sera placé à l'actif si son solde est débiteur, ou au passif s'il est créditeur" disabled=$edit_disabled} {input type="radio" label="Résultat : charge" name="position" value=Entities\Accounting\Account::EXPENSE source=$account help="dépenses" disabled=$edit_disabled} {input type="radio" label="Résultat : produit" name="position" value=Entities\Accounting\Account::REVENUE source=$account help="recettes" disabled=$edit_disabled} {/if} {input type="text" label="Code" maxlength="10" name="code" source=$account required=true help="Le code du compte sert à trier le compte dans le plan comptable, attention à choisir un code qui correspond au plan comptable." disabled=$edit_disabled} {input type="text" label="Libellé" name="label" source=$account required=true disabled=$edit_disabled} {input type="textarea" label="Description" name="description" source=$account} {if $create && in_array($account.type, [$account::TYPE_BANK, $account::TYPE_CASH, $account::TYPE_OUTSTANDING, $account::TYPE_THIRD_PARTY]) && !empty($current_year)} {input type="money" name="opening_amount" label="Solde d'ouverture" help="Si renseigné, ce solde sera inscrit dans l'exercice « %s »."|args:$current_year.label} {/if} </dl> |
Modified src/templates/acc/charts/accounts/edit.tpl from [0283435372] to [e354d8006c].
︙ | ︙ | |||
9 10 11 12 13 14 15 | Il n'est pas possible de modifier le libellé, le code ou la position de ce compte car il {if $account.user}est utilisé par des écritures liées à des exercices clôturés{else}fait partie du plan comptable officiel{/if}.<br /> Pour pouvoir modifier ce compte pour l'exercice courant, il est conseillé de <a href="{$admin_url}acc/charts/?from={$account.id_chart}">créer un nouveau plan comptable</a> en y recopiant l'ancien plan comptable. </p> {/if} <fieldset> <legend>Modifier un compte</legend> | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | Il n'est pas possible de modifier le libellé, le code ou la position de ce compte car il {if $account.user}est utilisé par des écritures liées à des exercices clôturés{else}fait partie du plan comptable officiel{/if}.<br /> Pour pouvoir modifier ce compte pour l'exercice courant, il est conseillé de <a href="{$admin_url}acc/charts/?from={$account.id_chart}">créer un nouveau plan comptable</a> en y recopiant l'ancien plan comptable. </p> {/if} <fieldset> <legend>Modifier un compte</legend> {include file="acc/charts/accounts/_account_form.tpl" create=false} </fieldset> <p class="submit"> {csrf_field key="acc_accounts_edit_%s"|args:$account.id} {button type="submit" name="edit" label="Enregistrer" shape="right" class="main"} </p> </form> {include file="admin/_foot.tpl"} |
Modified src/templates/acc/charts/accounts/new.tpl from [4b1c300015] to [da7b7cc99e].
1 2 3 4 5 6 7 8 9 10 | {include file="admin/_head.tpl" title="Nouveau compte" current="acc/charts"} {include file="acc/charts/accounts/_nav.tpl" current="new"} {form_errors} <form method="post" action="{$self_url}" data-focus="1"> <fieldset> <legend>Créer un nouveau compte</legend> | > > > > > > > > > > > > > > > > > > | > > | 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 | {include file="admin/_head.tpl" title="Nouveau compte" current="acc/charts"} {include file="acc/charts/accounts/_nav.tpl" current="new"} {form_errors} {if null === $type} <form method="get" action="{$self_url}" data-focus="1"> <fieldset> <legend>Créer un nouveau compte</legend> <dl><label for="f_type">Type de compte</label></dl> {foreach from=$types_create item="t" key="v"} {input type="radio-btn" name="type" value=$v label=$t.label help=$t.help} {/foreach} </fieldset> <p class="submit"> <input type="hidden" name="id" value="{$chart.id}" /> {button type="submit" label="Continuer" shape="right" class="main"} </p> </form> {else} <form method="post" action="{$self_url}" data-focus="1"> <fieldset> <legend>Créer un nouveau compte</legend> {include file="acc/charts/accounts/_account_form.tpl" edit_disabled=false create=true} </fieldset> <p class="submit"> {csrf_field key="acc_accounts_new"} {button type="submit" name="save" label="Créer" shape="right" class="main"} </p> </form> {/if} {include file="admin/_foot.tpl"} |
Modified src/www/admin/acc/charts/accounts/new.php from [317fd65486] to [1d828d1672].
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 | <?php namespace Garradin; use Garradin\Entities\Accounting\Account; use Garradin\Accounting\Accounts; use Garradin\Accounting\Charts; require_once __DIR__ . '/../../_inc.php'; $session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN); $chart = Charts::get((int)qg('id')); if (!$chart) { throw new UserException('Ce plan comptable n\'existe pas'); } if ($chart->archived) { throw new UserException("Il n'est pas possible de modifier un plan comptable archivé."); } $account = new Account; $account->position = Account::ASSET_OR_LIABILITY; $types = $account::TYPES_NAMES; $types[0] = '-- Pas un compte favori'; | > > > > > < < < < < < < < < | | | < | < | < < | < < | < < > | | | | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | 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 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 | <?php namespace Garradin; use Garradin\Entities\Accounting\Account; use Garradin\Entities\Accounting\Transaction; use Garradin\Entities\Accounting\Line; use Garradin\Accounting\Accounts; use Garradin\Accounting\Charts; use Garradin\Membres\Session; require_once __DIR__ . '/../../_inc.php'; $session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN); $chart = Charts::get((int)qg('id')); if (!$chart) { throw new UserException('Ce plan comptable n\'existe pas'); } if ($chart->archived) { throw new UserException("Il n'est pas possible de modifier un plan comptable archivé."); } $accounts = $chart->accounts(); $account = new Account; $account->position = Account::ASSET_OR_LIABILITY; $types = $account::TYPES_NAMES; $types[0] = '-- Pas un compte favori'; // Simple creation with pre-determined account type if (qg('type') !== null) { $account->type = (int)qg('type'); $account->position = Accounts::getPositionFromType($account->type); $account->code = $accounts->getNextCodeForType($account->type); } $form->runIf('save', function () use ($account, $accounts, $chart, $current_year) { $db = DB::getInstance(); $db->begin(); $account->importForm(); $account->id_chart = $chart->id(); $account->user = 1; $account->save(); if (!empty(f('opening_amount')) && $current_year) { $t = new Transaction; $t->label = 'Solde d\'ouverture du compte'; $t->id_creator = Session::getInstance()->getUser()->id; $t->date = clone $current_year->start_date; $t->type = $t::TYPE_ADVANCED; $t->notes = 'Créé automatiquement à l\'ajout du compte'; $t->id_year = $current_year->id; $opening_account = $accounts->getOpeningAccountId(); $amount = Utils::moneyToInteger(f('opening_amount')); $a = $amount > 0 ? 0 : abs($amount); $b = $amount < 0 ? 0 : abs($amount); $t->addLine(Line::create($account->id, $a, $b)); $t->addLine(Line::create($opening_account, $b, $a)); $t->save(); } $db->commit(); $page = ''; if (!$account->type) { $page = 'all.php'; } Utils::redirect(sprintf('%sacc/charts/accounts/%s?id=%d', ADMIN_URL, $page, $account->id_chart)); }, 'acc_accounts_new'); $types_create = [ Account::TYPE_BANK => [ 'label' => Account::TYPES_NAMES[Account::TYPE_BANK], 'help' => 'Compte bancaire, livret, ou intermédiaire financier (type HelloAsso, Paypal, Stripe, SumUp, etc.)', ], Account::TYPE_CASH => [ 'label' => Account::TYPES_NAMES[Account::TYPE_CASH], 'help' => 'Caisse qui sert aux espèces, par exemple la caisse de l\'atelier ou de la boutique.', ], Account::TYPE_OUTSTANDING => [ 'label' => Account::TYPES_NAMES[Account::TYPE_OUTSTANDING], 'help' => 'Paiements qui ont été reçus mais qui ne sont pas encore déposés sur un compte bancaire (typiquement les chèques reçus, qui seront déposés en banque plus tard).', ], Account::TYPE_THIRD_PARTY => [ 'label' => Account::TYPES_NAMES[Account::TYPE_THIRD_PARTY], 'help' => 'Fournisseur, membres de l\'association, collectivités ou services de l\'État par exemple.', ], Account::TYPE_EXPENSE => [ 'label' => Account::TYPES_NAMES[Account::TYPE_EXPENSE], 'help' => 'Compte destiné à recevoir les dépenses (charges)', ], Account::TYPE_REVENUE => [ 'label' => Account::TYPES_NAMES[Account::TYPE_REVENUE], 'help' => 'Compte destiné à recevoir les recettes (produits)', ], Account::TYPE_ANALYTICAL => [ 'label' => Account::TYPES_NAMES[Account::TYPE_ANALYTICAL], 'help' => 'Permet de suivre un budget spécifique, un projet, par exemple : bourse aux vélos, séjour au ski, etc.', ], Account::TYPE_VOLUNTEERING => [ 'label' => Account::TYPES_NAMES[Account::TYPE_VOLUNTEERING], 'help' => 'Pour valoriser le temps de bénévolat, les dons en nature, etc.', ], Account::TYPE_NONE => [ 'label' => 'Autre type de compte', ], ]; $type = $account->type; $tpl->assign(compact('types', 'types_create', 'account', 'chart', 'type')); $tpl->display('acc/charts/accounts/new.tpl'); |