Overview
Comment: | Fix date handling when the year only has two digits (thanks libreoffice!) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
b922ed650cba40d06fb8d5a93ca8ca5a |
User & Date: | bohwaz on 2020-10-25 21:07:49 |
Other Links: | branch diff | manifest | tags |
Context
2020-10-25
| ||
22:06 | Fix issues with transaction import, eg. account code to account ID was flawed check-in: 96940550fd user: bohwaz tags: dev, 1.0.0-alpha2 | |
21:07 | Fix date handling when the year only has two digits (thanks libreoffice!) check-in: b922ed650c user: bohwaz tags: dev | |
20:56 | Fix CSV import in accounting check-in: 3da926df9c user: bohwaz tags: dev, 1.0.0-alpha2 | |
Changes
Modified src/include/lib/Garradin/Entities/Accounting/Transaction.php from [a541c3ab67] to [c11a0c87f6].
︙ | ︙ | |||
260 261 262 263 264 265 266 | // ID d'exercice obligatoire if (null === $this->id_year) { throw new \LogicException('Aucun exercice spécifié.'); } if (!$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'))) { | | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | // ID d'exercice obligatoire if (null === $this->id_year) { throw new \LogicException('Aucun exercice spécifié.'); } if (!$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'))) { throw new ValidationException('La date ne correspond pas à l\'exercice sélectionné : ' . $this->date->format('d/m/Y')); } $total = 0; $lines = $this->getLines(); foreach ($lines as $line) { |
︙ | ︙ |
Modified src/include/lib/Garradin/Entity.php from [920d7eeb20] to [a75474c4ab].
︙ | ︙ | |||
30 31 32 33 34 35 36 | return $this->import($source); } protected function filterUserValue(string $type, $value, string $key) { if ($type == 'date') { | > > > > | > | 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 | return $this->import($source); } protected function filterUserValue(string $type, $value, string $key) { if ($type == 'date') { if (preg_match('!^\d{2}/\d{2}/\d{2}$!', $value)) { return \DateTime::createFromFormat('d/m/y', $value); } elseif (preg_match('!^\d{2}/\d{2}/\d{4}$!', $value)) { return \DateTime::createFromFormat('d/m/Y', $value); } } else { return parent::filterUserValue($type, $value, $key); } } protected function assert(bool $test, string $message = null): void { if (null !== $message && !$test) { throw new ValidationException($message); } } } |