Overview
Comment: | Move lines number verification to selfcheck |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ac656bd72e59ca46d5caad3747aadbf4 |
User & Date: | bohwaz on 2022-07-27 19:49:57 |
Other Links: | manifest | tags |
Context
2022-07-27
| ||
19:54 |
Year import: Remove line_id from import and export as it may lead to strange stuff, much easier to remove all lines and add them back.
Fix mandatory columns display. check-in: 26fd5b826f user: bohwaz tags: trunk, stable | |
19:49 | Move lines number verification to selfcheck check-in: ac656bd72e user: bohwaz tags: trunk | |
03:07 | Implement FEC export/import Add preview to import process check-in: 882618edde user: bohwaz tags: trunk | |
Changes
Modified src/include/lib/Garradin/Entities/Accounting/Transaction.php from [dcb33fd3f0] to [ad24a3c1f3].
︙ | ︙ | |||
426 427 428 429 430 431 432 | public function save(): bool { if ($this->validated && !(isset($this->_modified['validated']) && $this->_modified['validated'] === 0)) { throw new ValidationException('Il n\'est pas possible de modifier une écriture qui a été validée'); } | < < < < | < < < < < < < < < < < | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | public function save(): bool { if ($this->validated && !(isset($this->_modified['validated']) && $this->_modified['validated'] === 0)) { throw new ValidationException('Il n\'est pas possible de modifier une écriture qui a été validée'); } $db = DB::getInstance(); if ($db->test(Year::TABLE, 'id = ? AND closed = 1', $this->id_year)) { throw new ValidationException('Il n\'est pas possible de créer ou modifier une écriture dans un exercice clôturé'); } // echo '<pre>'; var_dump($this->asDetailsArray(), count($this->getLines()), \Garradin\Accounting\Transactions::get($this->id())->asDetailsArray()); exit; if (!parent::save()) { return false; } foreach ($this->getLines() as $line) { |
︙ | ︙ | |||
515 516 517 518 519 520 521 522 523 524 525 526 527 528 | $is_in_year = $db->test(Year::TABLE, 'id = ? AND start_date <= ? AND end_date >= ?', $this->id_year, $this->date->format('Y-m-d'), $this->date->format('Y-m-d')); $this->assert($is_in_year, 'La date ne correspond pas à l\'exercice sélectionné : ' . $this->date->format('d/m/Y')); $total = 0; $lines = $this->getLines(); $accounts_ids = []; foreach ($lines as $k => $line) { $this->assert($line->credit || $line->debit, sprintf('Ligne %d: Aucun montant au débit ou au crédit', $k)); $this->assert($line->credit >= 0 && $line->debit >= 0, sprintf('Ligne %d: Le montant ne peut être négatif', $k)); $this->assert(($line->credit * $line->debit) === 0 && ($line->credit + $line->debit) > 0, sprintf('Ligne %d: non équilibrée, crédit ou débit doit valoir zéro.', $k)); | > > > > > > | 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | $is_in_year = $db->test(Year::TABLE, 'id = ? AND start_date <= ? AND end_date >= ?', $this->id_year, $this->date->format('Y-m-d'), $this->date->format('Y-m-d')); $this->assert($is_in_year, 'La date ne correspond pas à l\'exercice sélectionné : ' . $this->date->format('d/m/Y')); $total = 0; $lines = $this->getLines(); $count = count($lines); $this->assert($count > 0, 'Cette écriture ne comporte aucune ligne.'); $this->assert($count >= 2, 'Cette écriture comporte moins de deux lignes.'); $this->assert($count == 2 || $this->type == self::TYPE_ADVANCED, sprintf('Une écriture de type "%s" ne peut comporter que deux lignes au maximum.', self::TYPES_NAMES[$this->type])); $accounts_ids = []; foreach ($lines as $k => $line) { $this->assert($line->credit || $line->debit, sprintf('Ligne %d: Aucun montant au débit ou au crédit', $k)); $this->assert($line->credit >= 0 && $line->debit >= 0, sprintf('Ligne %d: Le montant ne peut être négatif', $k)); $this->assert(($line->credit * $line->debit) === 0 && ($line->credit + $line->debit) > 0, sprintf('Ligne %d: non équilibrée, crédit ou débit doit valoir zéro.', $k)); |
︙ | ︙ | |||
963 964 965 966 967 968 969 | $lines = []; foreach ($this->getLines() as $i => $line) { $lines[$i+1] = $line->asDetailsArray(); } return [ | | > | 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 | $lines = []; foreach ($this->getLines() as $i => $line) { $lines[$i+1] = $line->asDetailsArray(); } return [ 'Numéro' => $this->id ?? '--', 'Type' => self::TYPES_NAMES[$this->type], 'Libellé' => $this->label, 'Date' => $this->date, 'Pièce comptable' => $this->reference, 'Remarques' => $this->notes, 'Total crédit' => Utils::money_format($this->getLinesCreditSum()), 'Total débit' => Utils::money_format($this->getLinesDebitSum()), 'Lignes' => $lines, |
︙ | ︙ |