Overview
Comment: | Fix PHP 8.1 errors |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
38ca4038815dbf1bd5c9c6de9062f735 |
User & Date: | bohwaz on 2022-02-05 00:25:09 |
Other Links: | manifest | tags |
Context
2022-02-07
| ||
22:54 | Add ability to link a fee to a project, fix [fde0ebd9e938a3496720c1974dcd2d0f47275c5f] check-in: 900e9cdb36 user: bohwaz tags: trunk | |
2022-02-05
| ||
00:25 | Fix PHP 8.1 errors check-in: 38ca403881 user: bohwaz tags: trunk | |
2022-02-04
| ||
23:33 | Fix input of money amounts < 1 check-in: b9dde10b95 user: bohwaz tags: trunk, stable | |
Changes
Modified src/include/lib/Garradin/Entities/Accounting/Transaction.php from [7221fdb55d] to [7501d22f68].
︙ | ︙ | |||
518 519 520 521 522 523 524 | throw new UserException('Montant non précisé'); } $this->type = self::TYPE_ADVANCED; $amount = $source['amount']; $key = 'account_transfer'; | > > > > > | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | throw new UserException('Montant non précisé'); } $this->type = self::TYPE_ADVANCED; $amount = $source['amount']; $key = 'account_transfer'; if (empty($source[$key]) || !count($source[$key])) { throw new ValidationException('Aucun compte de dépôt n\'a été sélectionné'); } $account = key($source[$key]); $line = new Line; $line->importForm([ 'debit' => $amount, 'credit' => 0, 'id_account' => $account, ]); |
︙ | ︙ | |||
554 555 556 557 558 559 560 | if (!isset($source['lines']) || !is_array($source['lines'])) { throw new ValidationException('Aucune ligne dans la saisie'); } $lines = Utils::array_transpose($source['lines']); foreach ($lines as $i => $line) { | | > | < < | > | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 | if (!isset($source['lines']) || !is_array($source['lines'])) { throw new ValidationException('Aucune ligne dans la saisie'); } $lines = Utils::array_transpose($source['lines']); foreach ($lines as $i => $line) { if (empty($line['account']) || !count($line['account'])) { throw new ValidationException(sprintf('Ligne %d : aucun compte n\'a été sélectionné', $i + 1)); } $line['id_account'] = key($line['account']); $line = (new Line)->import($line); $this->addLine($line); } } else { $details = self::getTypesDetails(); |
︙ | ︙ | |||
588 589 590 591 592 593 594 595 | $amount = $source['amount']; // Fill lines using a pre-defined setup obtained from getTypesDetails foreach ($details[$type]->accounts as $k => $account) { $credit = $account->position == 'credit' ? $amount : 0; $debit = $account->position == 'debit' ? $amount : 0; $key = sprintf('account_%d_%d', $type, $k); | > > > > > > | | 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | $amount = $source['amount']; // Fill lines using a pre-defined setup obtained from getTypesDetails foreach ($details[$type]->accounts as $k => $account) { $credit = $account->position == 'credit' ? $amount : 0; $debit = $account->position == 'debit' ? $amount : 0; $key = sprintf('account_%d_%d', $type, $k); if (empty($source[$key]) || !count($source[$key])) { throw new ValidationException(sprintf('Ligne %d : aucun compte n\'a été sélectionné', $k+1)); } $account = key($source[$key]); $line = new Line; $line->importForm([ 'reference' => !empty($source['payment_reference']) ? $source['payment_reference'] : null, 'credit' => $credit, 'debit' => $debit, 'id_account' => $account, |
︙ | ︙ | |||
643 644 645 646 647 648 649 | catch (\LogicException $e) { throw new ValidationException('Aucun compte sélectionné pour certaines lignes.'); } $debit = $credit = 0; foreach ($lines as $k => $line) { | > > > > | | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | catch (\LogicException $e) { throw new ValidationException('Aucun compte sélectionné pour certaines lignes.'); } $debit = $credit = 0; foreach ($lines as $k => $line) { if (empty($line['account']) || !count($line['account'])) { throw new ValidationException(sprintf('Ligne %d : aucun compte n\'a été sélectionné', $k+1)); } $line['id_account'] = key($line['account']); try { $line = (new Line)->importForm($line); $this->addLine($line); } catch (ValidationException $e) { throw new ValidationException(sprintf('Ligne %d : %s', $k+1, $e->getMessage()), 0, $e); |
︙ | ︙ |
Modified src/include/lib/Garradin/Utils.php from [17a190ee95] to [7cb0b53f79].
︙ | ︙ | |||
159 160 161 162 163 164 165 | return 0; } if (!preg_match('/^-?(\d+)(?:[,.](\d{1,2}))?$/', $value, $match)) { throw new UserException(sprintf('Le montant est invalide : %s. Exemple de format accepté : 142,02', $value)); } | | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | return 0; } if (!preg_match('/^-?(\d+)(?:[,.](\d{1,2}))?$/', $value, $match)) { throw new UserException(sprintf('Le montant est invalide : %s. Exemple de format accepté : 142,02', $value)); } $value = $match[1] . str_pad($match[2] ?? '', 2, '0', STR_PAD_RIGHT); $value = (int) $value; return $value; } static public function money_format($number, string $dec_point = ',', string $thousands_sep = ' ', $zero_if_empty = true): string { if ($number == 0) { return $zero_if_empty ? '0' : '0,00'; |
︙ | ︙ |
Modified src/templates/acc/transactions/details.tpl from [2150b256f3] to [ae5c4aad19].
︙ | ︙ | |||
47 48 49 50 51 52 53 | {$transaction->getTypeName()} </dd> <dt>Libellé</dt> <dd><h2>{$transaction.label}</h2></dd> <dt>Date</dt> <dd>{$transaction.date|date:'l j F Y (d/m/Y)'}</dd> <dt>Numéro pièce comptable</dt> | | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | {$transaction->getTypeName()} </dd> <dt>Libellé</dt> <dd><h2>{$transaction.label}</h2></dd> <dt>Date</dt> <dd>{$transaction.date|date:'l j F Y (d/m/Y)'}</dd> <dt>Numéro pièce comptable</dt> <dd>{if $transaction.reference}{$transaction.reference}{else}-{/if}</dd> <dt>Exercice</dt> <dd> <a href="{$admin_url}acc/reports/ledger.php?year={$transaction.id_year}">{$tr_year.label}</a> | Du {$tr_year.start_date|date_short} au {$tr_year.end_date|date_short} | <strong>{if $tr_year.closed}Clôturé{else}En cours{/if}</strong> </dd> |
︙ | ︙ | |||
82 83 84 85 86 87 88 | <a href="{$admin_url}membres/fiche.php?id={$u.id}">{$u.identity}</a> {if $u.id_service_user}— en règlement d'une <a href="{$admin_url}services/user/?id={$u.id}&only={$u.id_service_user}">activité</a>{/if} </dd> {/foreach} {/if} <dt>Remarques</dt> | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | <a href="{$admin_url}membres/fiche.php?id={$u.id}">{$u.identity}</a> {if $u.id_service_user}— en règlement d'une <a href="{$admin_url}services/user/?id={$u.id}&only={$u.id_service_user}">activité</a>{/if} </dd> {/foreach} {/if} <dt>Remarques</dt> <dd>{if $transaction.notes}{$transaction.notes|escape|nl2br}{else}-{/if}</dd> </dl> <table class="list"> <thead> <tr> <td class="num">N° compte</td> <th>Compte</th> |
︙ | ︙ |