Overview
Comment:Partial fix for [679a0c9f05] when user creator does not exist
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA3-256: 1298f9ba259683ee6b15dc1246fb3bc0d48671333fa6bec26aa3a02d6e50a94b
User & Date: bohwaz on 2021-04-25 15:53:54
Other Links: manifest | tags
Context
2021-04-25
15:58
Fix upgrade from RC in 1.1 check-in: 7889479ac6 user: bohwaz tags: trunk, stable
15:53
Partial fix for [679a0c9f05] when user creator does not exist check-in: 1298f9ba25 user: bohwaz tags: trunk, stable
15:41
Fix 'Undefined property: stdClass::$lettre_infos' error check-in: 8e1c1419f9 user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Entities/Accounting/Transaction.php from [d39e3b122c] to [fc30269f84].

362
363
364
365
366
367
368
369
370
371
372
373
374
375




376
377
378
379



380
381
382
383
384
385
386
387
388
389
390
391
392

393
394
395
396
397
398
399
400
401
402
403
404
362
363
364
365
366
367
368

369
370




371
372
373
374




375
376
377

378
379
380
381
382
383
384
385
386
387


388





389
390
391
392
393
394
395







-


-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-










-
-
+
-
-
-
-
-








		return parent::delete();
	}

	public function selfCheck(): void
	{
		parent::selfCheck();

		$db = DB::getInstance();

		// ID d'exercice obligatoire
		if (null === $this->id_year) {
			throw new \LogicException('Aucun exercice spécifié.');
		}
		$this->assert(null !== $this->id_year, 'Aucun exercice spécifié.');
		$this->assert(array_key_exists($this->type, self::TYPES_NAMES), 'Type d\'écriture inconnu : ' . $this->type);
		$this->assert(null === $this->id_creator || $db->test('membres', 'id = ?', $this->id_creator), 'Le membre créateur de l\'écriture n\'existe pas ou plus');


		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'));
		$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();

		foreach ($lines as $line) {
			$total += $line->credit;
			$total -= $line->debit;
		}

		if (0 !== $total) {
			throw new ValidationException(sprintf('Écriture non équilibrée : déséquilibre (%s) entre débits et crédits', Utils::money_format($total)));
		$this->assert(0 === $total, sprintf('Écriture non équilibrée : déséquilibre (%s) entre débits et crédits', Utils::money_format($total)));
		}

		if (!array_key_exists($this->type, self::TYPES_NAMES)) {
			throw new ValidationException('Type d\'écriture inconnu : ' . $this->type);
		}
	}

	public function importFromDepositForm(?array $source = null): void
	{
		if (null === $source) {
			$source = $_POST;
		}