Overview
Comment:Re-add missing merges before [93aeaacac6]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA3-256: 561aebe80cc40139238adb977b0233cccb8253abc2f6eebb2e15e74b0cc73680
User & Date: bohwaz on 2021-05-10 12:19:16
Other Links: manifest | tags
Context
2021-05-10
13:58
Fix string / int comparison for plugins in menu, fix [3297bef8b194f715] check-in: 39a754321d user: bohwaz tags: trunk, stable
12:19
Re-add missing merges before [93aeaacac6] check-in: 561aebe80c user: bohwaz tags: trunk, stable
2021-05-06
20:01
Fix wiki doc check-in: f0cf68d580 user: bohwaz tags: trunk, stable
2021-03-12
19:22
Validation error when trying to create a transaction to a non-existing user or year check-in: 93aeaacac6 user: bohwaz tags: trunk, stable
2021-03-05
19:50
Fix: set status as paid when creating payoff transaction check-in: 1ed3d3d18c user: bohwaz tags: trunk, stable
2021-03-01
02:29
Transform debt and credit payments in advanced transactions check-in: 5595d3ca25 user: bohwaz tags: trunk, stable
2021-02-20
22:09
Fix: debts and credits were marked as non-paid when edited, even if already marked as paid check-in: 5b548dd490 user: bohwaz tags: trunk, stable
2021-02-01
14:39
Fix issue with collective message when SELECT...FROM is on multiple lines check-in: 99358d0e75 user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Entities/Accounting/Transaction.php from [f45c5b736f] to [07be54e40e].

310
311
312
313
314
315
316


317
318
319
320
321
322
323
...
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
...
393
394
395
396
397
398
399



400
401
402
403
404
405
406
...
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480

	public function save(): bool
	{
		if ($this->validated && empty($this->_modified['validated'])) {
			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é');
		}

		if (!parent::save()) {
................................................................................

		foreach ($this->_old_lines as $line)
		{
			$line->delete();
		}

		// Remove flag
		if ((self::TYPE_DEBT == $this->type || self::TYPE_CREDIT == $this->type) && $this->_related) {
			$this->_related->markPaid();
			$this->_related->save();
		}

		return true;
	}

................................................................................

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

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



	}

	public function importFromDepositForm(?array $source = null): void
	{
		if (null === $source) {
			$source = $_POST;
		}
................................................................................
		else {
			$details = self::getTypesDetails();

			if (!array_key_exists($type, $details)) {
				throw new ValidationException('Type d\'écriture inconnu');
			}

			if (empty($this->_related) && ($type == self::TYPE_DEBT || $type == self::TYPE_CREDIT)) {
				$this->addStatus(self::STATUS_WAITING);
			}
			else {
				$this->removeStatus(self::STATUS_WAITING);
			}

			if (empty($source['amount'])) {
				throw new UserException('Montant non précisé');
			}

			$amount = $source['amount'];







>
>







 







|







 







>
>
>







 







|
|

|
|







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
...
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
...
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
...
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485

	public function save(): bool
	{
		if ($this->validated && empty($this->_modified['validated'])) {
			throw new ValidationException('Il n\'est pas possible de modifier une écriture qui a été validée');
		}

		$exists = $this->exists();

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

		if (!parent::save()) {
................................................................................

		foreach ($this->_old_lines as $line)
		{
			$line->delete();
		}

		// Remove flag
		if (!$exists && $this->_related) {
			$this->_related->markPaid();
			$this->_related->save();
		}

		return true;
	}

................................................................................

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

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

		$this->assert($db->test('acc_years', 'id = ?', $this->id_year), 'L\'exercice sélectionné n\'existe pas');
		$this->assert($this->id_creator === null || $db->test('membres', 'id = ?', $this->id_creator), 'Le compte membre créateur de l\'écriture n\'existe pas');
	}

	public function importFromDepositForm(?array $source = null): void
	{
		if (null === $source) {
			$source = $_POST;
		}
................................................................................
		else {
			$details = self::getTypesDetails();

			if (!array_key_exists($type, $details)) {
				throw new ValidationException('Type d\'écriture inconnu');
			}

			if (!empty($this->_related) && ($type == self::TYPE_DEBT || $type == self::TYPE_CREDIT)) {
				$this->set('type', self::TYPE_ADVANCED);
			}
			elseif (!$this->exists() && ($type == self::TYPE_DEBT || $type == self::TYPE_CREDIT)) {
				$this->addStatus(self::STATUS_WAITING);
			}

			if (empty($source['amount'])) {
				throw new UserException('Montant non précisé');
			}

			$amount = $source['amount'];