Overview
Comment: | Liste des comptes, objets pour les plans comptables et exercices |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
6987513f8d724225303fe1f8324fa036 |
User & Date: | bohwaz on 2020-09-08 19:03:20 |
Other Links: | branch diff | manifest | tags |
Context
2020-09-08
| ||
19:03 | Suppression du style .catList, ajout d'un style générique dl.list check-in: ed2734a9a7 user: bohwaz tags: dev | |
19:03 | Liste des comptes, objets pour les plans comptables et exercices check-in: 6987513f8d user: bohwaz tags: dev | |
2020-09-04
| ||
22:23 | Autoriser les widgets input à ne pas avoir de label etc., ajouter un widget de type bouton avec icône check-in: 3af48380f7 user: bohwaz tags: dev | |
Changes
Added src/include/lib/Garradin/Accounting/Charts.php version [ad61920bc2].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | <?php namespace Garradin\Accounting; use Garradin\Entities\Accounting\Chart; use Garradin\Utils; use Garradin\DB; use KD2\DB\EntityManager; class Charts { public function get(int $id) { return EntityManager::findOneById(Chart::class, $id); } public function list() { $em = EntityManager::getInstance(Chart::class); return $em->all('SELECT * FROM @TABLE ORDER BY country, label;'); } public function listByCountry() { $sql = sprintf('SELECT id, country, label FROM %s ORDER BY country, label;', Chart::TABLE); $list = DB::getInstance()->getGrouped($sql); $out = []; foreach ($list as $row) { $country = Utils::getCountryName($row->country); if (!array_key_exists($country, $out)) { $out[$country] = []; } $out[$country][$row->id] = $row->label; } return $out; } } |
Added src/include/lib/Garradin/Accounting/Years.php version [72badb3526].
> > > > > > > > > > > > > > > > > > > > > > > > > > > | 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\Accounting; use Garradin\Entities\Accounting\Year; use Garradin\Utils; use Garradin\DB; use KD2\DB\EntityManager; class Years { static public function get(int $year_id) { return EntityManager::findOneById(Year::class, $year_id); } static public function getCurrentOpenYearIfSingle() { return EntityManager::findOne(Year::class, 'SELECT * FROM @TABLE WHERE closed = 0 GROUP BY closed HAVING COUNT(*) = 1;'); } static public function listOpen() { $em = EntityManager::getInstance(Year::class); return $em->all('SELECT * FROM @TABLE WHERE closed = 0 ORDER BY end_date;'); } } |
Modified src/include/lib/Garradin/Entities/Accounting/Chart.php from [2ddf8263f9] to [0d7b6f937a].
1 2 3 4 5 6 7 8 9 10 11 12 | <?php namespace Garradin\Entities\Accounting; use Garradin\Entity; class Chart extends Entity { const TABLE = 'acc_charts'; protected $id; protected $label; | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php namespace Garradin\Entities\Accounting; use Garradin\Entity; use Garradin\Accounting\Accounts; class Chart extends Entity { const TABLE = 'acc_charts'; protected $id; protected $label; |
︙ | ︙ | |||
30 31 32 33 34 35 36 | ]; public function selfCheck(): void { parent::selfCheck(); $this->assert(Utils::getCountryName($this->country), 'Le code pays doit être un code ISO valide'); } | | > > > > > | 31 32 33 34 35 36 37 38 39 40 41 42 43 | ]; public function selfCheck(): void { parent::selfCheck(); $this->assert(Utils::getCountryName($this->country), 'Le code pays doit être un code ISO valide'); } public function accounts() { return new Accounts($this->id()); } } |
Modified src/include/lib/Garradin/Entities/Accounting/Year.php from [2715ee53bc] to [b1de5f2457].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?php namespace Garradin\Entities\Accounting; use Garradin\Entity; use Garradin\DB; use Garradin\UserException; class Year extends Entity { const TABLE = 'acc_years'; protected $id; protected $label; protected $start_date; protected $end_date; protected $closed = 0; protected $_types = [ 'id' => 'integer', 'label' => 'string', | > > | | > > | 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 | <?php namespace Garradin\Entities\Accounting; use KD2\DB\EntityManager; use Garradin\Entity; use Garradin\DB; use Garradin\UserException; class Year extends Entity { const TABLE = 'acc_years'; protected $id; protected $label; protected $start_date; protected $end_date; protected $closed = 0; protected $id_chart; protected $_types = [ 'id' => 'integer', 'label' => 'string', 'start_date' => 'DateTime', 'end_date' => 'DateTime', 'closed' => 'integer', 'id_chart' => 'integer', ]; protected $_validation_rules = [ 'label' => 'required|string|max:200', 'start_date' => 'required|date|before:end_date', 'end_date' => 'required|date|after:start_date', 'closed' => 'int|min:0|max:1', 'id_chart' => 'required|integer', ]; public function selfCheck(): void { parent::selfCheck(); $this->assert($this->start_date < $this->end_date, 'La date de fin doit être postérieure à la date de début'); $this->assert($this->closed == 1 || !isset($this->_modified['closed']), 'Il est interdit de réouvrir un exercice clôturé'); |
︙ | ︙ | |||
83 84 85 86 87 88 89 | if ($db->test(Transaction::TABLE, $db->where('id_year', $this->id()))) { throw new UserException('Cet exercice ne peut être supprimé car des mouvements y sont liés.'); } return parent::delete(); } | | > > > > > | 87 88 89 90 91 92 93 94 95 96 97 98 99 | if ($db->test(Transaction::TABLE, $db->where('id_year', $this->id()))) { throw new UserException('Cet exercice ne peut être supprimé car des mouvements y sont liés.'); } return parent::delete(); } public function chart() { return EntityManager::findOneById(Chart::class, $this->id_chart); } } |
Modified src/templates/acc/accounts/index.tpl from [57b9ce51f4] to [e3f5de676f].
|
| | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | {include file="admin/_head.tpl" title="%s - Comptes utilisés couramment"|args:$chart.label current="acc/charts"} <ul class="actions"> <li class="current"><a href="{$admin_url}acc/accounts/">Comptes utilisés couramment</a></li> <li><a href="{$admin_url}acc/charts/">Gestion des plans comptables</a></li> <li><a href="{$admin_url}acc/charts/import.php">Importer un plan comptable</a></li> </ul> <form method="post" action="{$self_url_no_qs}"> <fieldset> <legend>Ajouter un compte</legend> <dl> {input type="select" name="group" label="Type de compte" options=$accounts_types} |
︙ | ︙ |
Modified src/templates/acc/charts/index.tpl from [c2019af16c] to [7eae295b0f].
1 2 3 | {include file="admin/_head.tpl" title="Gestion des plans comptables" current="acc/charts"} <ul class="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 | {include file="admin/_head.tpl" title="Gestion des plans comptables" current="acc/charts"} <ul class="actions"> <li><a href="{$admin_url}acc/accounts/">Comptes utilisés couramment</a></li> <li class="current"><a href="{$admin_url}acc/charts/">Gestion des plans comptables</a></li> <li><a href="{$admin_url}acc/charts/import.php">Importer un plan comptable</a></li> </ul> {if count($list)} <table class="list"> <thead> <td>Pays</td> <th>Libellé</th> <td></td> </thead> <tbody> {foreach from=$list item="item"} <tr> <td>{$item.country|get_country_name}</td> <th><a href="{$admin_url}acc/accounts/?id={$item.id}">{$item.label}</a> <em>{if $item.code}(officiel){else}(copie){/if}</em></th> <td class="actions"> {icon shape="menu" label="Gérer les comptes" href="acc/accounts/all.php?id=%d"|args:$item.id} {icon shape="edit" label="Renommer" href="acc/charts/edit.php?id=%d"|args:$item.id} {icon shape="export" label="Exporter en CSV" href="acc/charts/export.php?id=%d"|args:$item.id} {if empty($item.code)} {icon shape="upload" label="Importer" href="acc/charts/import.php?id=%d"|args:$item.id} {icon shape="delete" label="Supprimer" href="acc/charts/delete.php?id=%d"|args:$item.id} {else} {icon shape="reset" label="Remettre à zéro" href="acc/charts/reset.php?id=%d"|args:$item.id} |
︙ | ︙ |
Modified src/www/admin/acc/accounts/index.php from [b1639557bf] to [f3196c4f82].
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 | require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ADMIN); $chart = $year->chart(); $accounts = $chart->accounts(); $tpl->assign('accounts_grouped', $accounts->listCommonGrouped()); $types = array_filter(Account::TYPES_NAMES, function ($v) { return $v !== ''; }); $tpl->assign('accounts_types', $types); $tpl->display('acc/accounts/index.tpl'); | > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ADMIN); $chart = $year->chart(); $accounts = $chart->accounts(); $tpl->assign('chart', $chart); $tpl->assign('accounts_grouped', $accounts->listCommonGrouped()); $types = array_filter(Account::TYPES_NAMES, function ($v) { return $v !== ''; }); $tpl->assign('accounts_types', $types); $tpl->display('acc/accounts/index.tpl'); |
Modified src/www/admin/acc/charts/index.php from [b524fa30f8] to [a56aa48374].
︙ | ︙ | |||
9 10 11 12 13 14 15 | $charts = new Charts; $tpl->assign('list', $charts->list()); $tpl->assign('charts_groupped', $charts->listByCountry()); $tpl->assign('country_list', Utils::getCountryList()); | | | 9 10 11 12 13 14 15 16 | $charts = new Charts; $tpl->assign('list', $charts->list()); $tpl->assign('charts_groupped', $charts->listByCountry()); $tpl->assign('country_list', Utils::getCountryList()); $tpl->display('acc/charts/index.tpl'); |