Overview
Comment: | Implement simple tracking of revenue/expense/others |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
a7bb0c41f46441172152adb61c5ff6b9 |
User & Date: | bohwaz on 2020-11-09 22:24:29 |
Other Links: | branch diff | manifest | tags |
Context
2020-11-09
| ||
22:40 | Fix issue with single cents check-in: 447fa418e5 user: bohwaz tags: dev | |
22:24 | Implement simple tracking of revenue/expense/others check-in: a7bb0c41f4 user: bohwaz tags: dev | |
20:36 | Use dynamic list for account journals check-in: 89f465c9b1 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Accounting/Accounts.php from [00a304dd25] to [29792bec41].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?php namespace Garradin\Accounting; use Garradin\Entities\Accounting\Account; use Garradin\CSV; use Garradin\DB; use Garradin\Utils; use KD2\DB\EntityManager; class Accounts { protected $chart_id; protected $em; | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?php namespace Garradin\Accounting; use Garradin\Entities\Accounting\Account; use Garradin\CSV; use Garradin\DB; use Garradin\DynamicList; use Garradin\Utils; use KD2\DB\EntityManager; class Accounts { protected $chart_id; protected $em; |
︙ | ︙ | |||
189 190 191 192 193 194 195 | $db->commit(); } catch (\Exception $e) { $db->rollback(); throw $e; } } | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | $db->commit(); } catch (\Exception $e) { $db->rollback(); throw $e; } } static public function listByType(int $year_id, ?int $type) { $reverse = Account::isReversed((int) $type) ? -1 : 1; $columns = Account::LIST_COLUMNS; unset($columns['sum'], $columns['credit'], $columns['debit'], $columns['line_label']); $columns['line_reference']['label'] = 'Réf. paiement'; $columns['change']['select'] = sprintf($columns['change']['select'], $reverse); $acc_columns = [ 'account' => ['label' => 'Compte', 'select' => 'a.code'], 'account_label' => ['label' => 'Nom du compte', 'select' => 'a.label'], 'id_account' => [], ]; $columns = array_merge($acc_columns, $columns); if (null === $type) { $other_types = implode(',', [0, Account::TYPE_OPENING, Account::TYPE_CLOSING]); } $tables = 'acc_transactions_lines l INNER JOIN acc_transactions t ON t.id = l.id_transaction INNER JOIN acc_accounts a ON a.id = l.id_account'; $conditions = sprintf('a.type IN (%s) AND t.id_year = %d', $type ?: $other_types, $year_id); $sum = 0; $list = new DynamicList($columns, $tables, $conditions); $list->orderBy('date', true); $list->setCount('COUNT(*)'); return $list; } } |
Modified src/include/lib/Garradin/Entities/Accounting/Account.php from [430c69b132] to [11c31ecee5].
︙ | ︙ | |||
67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 'Dépenses', 'Recettes', 'Analytique', 'Bénévolat', 'Ouverture', 'Clôture', ]; protected $id; protected $id_chart; protected $code; protected $label; protected $description; protected $position; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 122 123 124 125 126 127 | 'Dépenses', 'Recettes', 'Analytique', 'Bénévolat', 'Ouverture', 'Clôture', ]; 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', 'label' => 'Débit', ], 'credit' => [ 'select' => 'l.credit', 'label' => 'Crédit', ], 'change' => [ 'select' => '(l.credit - l.debit) * %d', 'label' => 'Mouvement', ], 'sum' => [ 'select' => NULL, 'label' => 'Solde cumulé', ], 'reference' => [ 'label' => 'Pièce comptable', 'select' => 't.reference', ], 'type' => [ 'select' => 't.type', ], 'label' => [ 'select' => 't.label', 'label' => 'Libellé', ], 'line_label' => [ 'select' => 'l.label', 'label' => 'Libellé ligne' ], 'line_reference' => [ 'label' => 'Réf. ligne', 'select' => 'l.reference', ], ]; protected $id; protected $id_chart; protected $code; protected $label; protected $description; protected $position; |
︙ | ︙ | |||
118 119 120 121 122 123 124 | $this->assert($this->user === 0 || $this->user === 1); parent::selfCheck(); } public function listJournal(int $year_id, bool $simple = false) { | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < > > > > < | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | $this->assert($this->user === 0 || $this->user === 1); parent::selfCheck(); } public function listJournal(int $year_id, bool $simple = false) { $columns = self::LIST_COLUMNS; $tables = 'acc_transactions_lines l INNER JOIN acc_transactions t ON t.id = l.id_transaction'; $conditions = sprintf('l.id_account = %d AND t.id_year = %d', $this->id(), $year_id); $sum = 0; $reverse = $simple && self::isReversed($this->type) ? -1 : 1; if ($simple) { unset($columns['debit']['label'], $columns['credit']['label'], $columns['line_label']); $columns['line_reference']['label'] = 'Réf. paiement'; $columns['change']['select'] = sprintf($columns['change']['select'], $reverse); } else { unset($columns['change']); } $list = new DynamicList($columns, $tables, $conditions); $list->orderBy('date', true); $list->setCount('COUNT(*)'); $list->setPageSize(null); $list->setModifier(function ($row) use (&$sum, $reverse) { $sum += ($row->credit - $row->debit); $row->running_sum = $sum * $reverse; $row->date = \DateTime::createFromFormat('Y-m-d', $row->date); return $row; }); return $list; } |
︙ | ︙ | |||
249 250 251 252 253 254 255 | $row->running_sum = $sum; yield $row; } } public function getSum(int $year_id): int { | | > > > > > > | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | $row->running_sum = $sum; yield $row; } } public function getSum(int $year_id): 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); if (self::isReversed($this->type)) { $sum *= -1; } return $sum; } public function getSumAtDate(int $year_id, DateTimeInterface $date): int { return (int) DB::getInstance()->firstColumn('SELECT SUM(l.credit) - SUM(l.debit) FROM acc_transactions_lines l |
︙ | ︙ |
Modified src/templates/acc/accounts/journal.tpl from [bf6da0acf0] to [e142c54a05].
︙ | ︙ | |||
21 22 23 24 25 26 27 | <p class="alert block">Vous devez <strong>{$sum|abs|raw|money_currency}</strong> à ce tiers.</p> {elseif $sum > 0} <p class="alert block">Ce tiers vous doit <strong>{$sum|abs|raw|money_currency}</strong>.</p> {else} <p class="confirm block">Vous ne devez pas d'argent à ce tiers, et il ne vous en doit pas non plus.</p> {/if} {elseif $account.type == $account::TYPE_BANK} | | | | | | | | 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 | <p class="alert block">Vous devez <strong>{$sum|abs|raw|money_currency}</strong> à ce tiers.</p> {elseif $sum > 0} <p class="alert block">Ce tiers vous doit <strong>{$sum|abs|raw|money_currency}</strong>.</p> {else} <p class="confirm block">Vous ne devez pas d'argent à ce tiers, et il ne vous en doit pas non plus.</p> {/if} {elseif $account.type == $account::TYPE_BANK} {if $sum < 0} <p class="error block">Ce compte est à découvert de <strong>{$sum|abs|raw|money_currency}</strong> à la banque.</p> {elseif $sum >= 0} <p class="confirm block">Ce compte est créditeur de <strong>{$sum|abs|raw|money_currency}</strong> à la banque.</p> {/if} {elseif $account.type == $account::TYPE_CASH} {if $sum < 0} <p class="error block">Cette caisse est débiteur de <strong>{$sum|abs|raw|money_currency}</strong>. Est-ce normal ? Une vérification est peut-être nécessaire ?</p> {elseif $sum >= 0} <p class="confirm block">Cette caisse est créditrice de <strong>{$sum|abs|raw|money_currency}</strong>.</p> {/if} {elseif $account.type == $account::TYPE_OUTSTANDING} {if $sum < 0} <p class="error block">Ce compte est débiteur <strong>{$sum|abs|raw|money_currency}</strong>. Est-ce normal ? Une vérification est peut-être nécessaire ?</p> {elseif $sum >= 0} <p class="confirm block">Ce compte d'attente est créditeur de <strong>{$sum|abs|raw|money_currency}</strong>. {if $sum > 200}Un dépôt à la banque serait peut-être une bonne idée ?{/if}</p> {/if} {/if} {/if} <nav class="tabs"> |
︙ | ︙ |
Added src/templates/acc/accounts/simple.tpl version [9dcd6e5c52].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | {include file="admin/_head.tpl" title="Suivi : %s"|args:$types[$type] current="acc/simple"} {include file="acc/_year_select.tpl"} {if Entities\Accounting\Account::isReversed($type)} {include file="acc/_simple_help.tpl" link=null type=$type} {/if} <nav class="tabs"> <aside> {if $session->canAccess('compta', Membres::DROIT_ADMIN)} {linkbutton href="%s&export=csv"|args:$self_url label="Export CSV" shape="export"} {linkbutton href="%s&export=ods"|args:$self_url label="Export tableur" shape="export"} {/if} </aside> <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> {include file="common/dynamic_list_head.tpl"} {foreach from=$list->iterate() item="line"} <tr> <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_fr:'d/m/Y'}</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> </table> {pagination url=$list->paginationURL() page=$list.page bypage=$list.per_page total=$list->count()} {include file="admin/_foot.tpl"} |
Modified src/templates/admin/_head.tpl from [4f253a1d75] to [37ba7d9629].
︙ | ︙ | |||
71 72 73 74 75 76 77 | <li class="{if $current == 'membres/services'} current{/if}"><a href="{$admin_url}services/">Activités & cotisations</a></li> <li class="member message{if $current == 'membres/message'} current{/if}"><a href="{$admin_url}membres/message_collectif.php">Message collectif</a></li> </ul> {/if} </li> {/if} {if $session->canAccess('compta', Membres::DROIT_ACCES)} | | | | > | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | <li class="{if $current == 'membres/services'} current{/if}"><a href="{$admin_url}services/">Activités & cotisations</a></li> <li class="member message{if $current == 'membres/message'} current{/if}"><a href="{$admin_url}membres/message_collectif.php">Message collectif</a></li> </ul> {/if} </li> {/if} {if $session->canAccess('compta', Membres::DROIT_ACCES)} <li class="{if $current == 'acc'} current{elseif $current_parent == 'acc'} current_parent{/if}"><a href="{$admin_url}acc/"><b>€</b><i> Comptabilité</i></a> <ul> {if $session->canAccess('compta', Membres::DROIT_ECRITURE)} <li class="{if $current == 'acc/new'} current{/if}"><a href="{$admin_url}acc/transactions/new.php">Saisie</a></li> {/if} <li class="{if $current == 'acc/accounts'} current{/if}"><a href="{$admin_url}acc/accounts/">Comptes</a></li> <li class="{if $current == 'acc/journals'} current{/if}"><a href="{$admin_url}acc/accounts/simple.php">Suivi des écritures</a></li> <li class="{if $current == 'acc/years'} current{/if}"><a href="{$admin_url}acc/years/">Exercices & rapports</a></li> {if $session->canAccess('compta', Membres::DROIT_ECRITURE)} <li class="{if $current == 'acc/charts'} current{/if}"><a href="{$admin_url}acc/charts/">Plans comptables</a></li> {/if} </ul> </li> {/if} {if $session->canAccess('wiki', Membres::DROIT_ACCES)} <li class="wiki{if $current == 'wiki'} current{elseif $current_parent == 'wiki'} current_parent{/if}"><a href="{$admin_url}wiki/"><b class="icn">✎</b><i> Wiki</i></a> <ul> |
︙ | ︙ |
Added src/www/admin/acc/accounts/simple.php version [d8d17ba662].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | <?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', Account::TYPE_THIRD_PARTY => 'Dettes et créances', 0 => 'Autres', ]; $type = qg('type'); if (null == $type || !array_key_exists($type, $types)) { $type = key($types); } $list = Accounts::listByType(CURRENT_YEAR_ID, $type ?: null); $list->setTitle(sprintf('Suivi - %s', $types[$type])); $list->loadFromQueryString(); $tpl->assign(compact('type', 'list', 'types')); $tpl->display('acc/accounts/simple.tpl'); |
Modified src/www/admin/static/admin.css from [d4366dd476] to [7683289c5f].
︙ | ︙ | |||
1109 1110 1111 1112 1113 1114 1115 | padding-right: .4em; } a.icn[title]:hover:after { display: inline-block; } | | | | 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 | padding-right: .4em; } a.icn[title]:hover:after { display: inline-block; } .num a, a.num { text-decoration: none; border-radius: .5rem; display: inline-block; text-align: center; padding: 0 .3rem; background: rgba(var(--gMainColor), 0.7); color: #fff; white-space: pre; } .actions .icn:hover, .num a:hover, .icn.action:hover, .icn-btn:hover, .radio-btn:hover div, a.num:hover { color: darkred; background: #ff9; z-index: 300; } .droits b { border: 2px solid #999; |
︙ | ︙ |