Overview
Comment:Show volunteering accounts differently, mark them in the chart, and allow to select them in advanced transaction creation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b59f477a0f3a50b29985df57b21b9ff8e0a86819
User & Date: bohwaz on 2020-12-08 00:58:05
Other Links: manifest | tags
Context
2020-12-08
02:06
Fix reference value was missing in simple transaction edit check-in: c8034ab481 user: bohwaz tags: trunk
00:58
Show volunteering accounts differently, mark them in the chart, and allow to select them in advanced transaction creation check-in: b59f477a0f user: bohwaz tags: trunk
2020-12-07
22:50
Add description in projects check-in: 4804b1ad1a user: bohwaz tags: trunk, stable
Changes

Modified src/VERSION from [b9e6774b5c] to [cc30f43448].

1
1.0.0-rc9
|
1
1.0.0-rc10

Added src/include/data/1.0.0-rc10_migration.sql version [b42d7c368c].





>
>
1
2
UPDATE acc_accounts SET type = 8, position = 4 WHERE id_chart = (SELECT id FROM acc_charts WHERE code IS NOT NULL) AND (code LIKE '86_%');
UPDATE acc_accounts SET type = 8, position = 5 WHERE id_chart = (SELECT id FROM acc_charts WHERE code IS NOT NULL) AND (code LIKE '87_%');

Modified src/include/data/charts/fr_1999.csv from [38d9f67e8d] to [f957a5ce4c].

279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
78,REPRISES SUR AMORTISSEMENTS ET PROVISIONS,,Produit,
79,TRANSFERT DE CHARGES,,Produit,
791,Transferts de charges d'exploitation,,Produit,
796,Transferts de charges financières,,Produit,
797,Transferts de charges exceptionnels,,Produit,
8,Classe 8 ­— Comptes spéciaux,,,
86,RÉPARTITION PAR NATURE DE CHARGES,,Charge,
861,Mise à dispositions gratuites de biens,,Charge,
862,Prestations,,Charge,
864,Personnel bénévole,,Charge,
87,RÉPARTITION PAR NATURE DE RESSOURCES,,Produit,
870,Bénévolat,,Produit,
871,Prestations en nature,,Produit,
875,Dons en nature,,Produit,
89,BILAN,,,
890,Bilan d'ouverture,,,Ouverture
891,Bilan de clôture,,,Clôture
9,Classe 9 — Comptes analytiques,,,
99,Projets,,,Analytique







|
|
|

|
|
|





279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
78,REPRISES SUR AMORTISSEMENTS ET PROVISIONS,,Produit,
79,TRANSFERT DE CHARGES,,Produit,
791,Transferts de charges d'exploitation,,Produit,
796,Transferts de charges financières,,Produit,
797,Transferts de charges exceptionnels,,Produit,
8,Classe 8 ­— Comptes spéciaux,,,
86,RÉPARTITION PAR NATURE DE CHARGES,,Charge,
861,Mise à dispositions gratuites de biens,,Charge,Bénévolat
862,Prestations,,Charge,Bénévolat
864,Personnel bénévole,,Charge,Bénévolat
87,RÉPARTITION PAR NATURE DE RESSOURCES,,Produit,
870,Bénévolat,,Produit,Bénévolat
871,Prestations en nature,,Produit,Bénévolat
875,Dons en nature,,Produit,Bénévolat
89,BILAN,,,
890,Bilan d'ouverture,,,Ouverture
891,Bilan de clôture,,,Clôture
9,Classe 9 — Comptes analytiques,,,
99,Projets,,,Analytique

Modified src/include/data/charts/fr_2018.csv from [7724166e91] to [29cd16b637].

526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
7896,Utilisations des fds dédiés / générosité,,Produit,
79,TRANSFERT DE CHARGES,,Produit,
791,Transferts de charges d'exploitation,,Produit,
796,Transferts de charges financières,,Produit,
797,Transferts de charges exceptionnelles,,Produit,
8,Classe 8 ­— Comptes spéciaux,,,
86,EMPLOIS CONTRIBUTIONS VOLONTAIRES EN NATURE,,,
860,Secours en nature,,,
8601,Alimentaires,,,
8602,Vestimentaires,,,
861,Mise à dispositions gratuites de biens,,,
8611,Locaux,,,
8612,Matériels,,,
862,Prestations,,,
864,Personnel bénévole,,,
87,CONTRIBUTIONS VOLONTAIRES EN NATURE,,,
870,Dons en nature,,,
871,Prestations en nature,,,
875,Bénévolat,,,Bénévolat
89,COMPTES DE BILAN,,,
890,Bilan d'ouverture,,,Ouverture
891,Bilan de clôture,,,Clôture
9,Classe 9 — Comptes analytiques,,,
90,COMPTES RÉFLÉCHIS,,,
906,Charges réfléchies,,,
907,Produits réfléchis,,,
99,Projets,,,Analytique







|
|
|
|
|
|
|
|

|
|
|








526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
7896,Utilisations des fds dédiés / générosité,,Produit,
79,TRANSFERT DE CHARGES,,Produit,
791,Transferts de charges d'exploitation,,Produit,
796,Transferts de charges financières,,Produit,
797,Transferts de charges exceptionnelles,,Produit,
8,Classe 8 ­— Comptes spéciaux,,,
86,EMPLOIS CONTRIBUTIONS VOLONTAIRES EN NATURE,,,
860,Secours en nature,,Charge,Bénévolat
8601,Alimentaires,,Charge,Bénévolat
8602,Vestimentaires,,Charge,Bénévolat
861,Mise à dispositions gratuites de biens,,Charge,Bénévolat
8611,Locaux,,Charge,Bénévolat
8612,Matériels,,Charge,Bénévolat
862,Prestations,,Charge,Bénévolat
864,Personnel bénévole,,Charge,Bénévolat
87,CONTRIBUTIONS VOLONTAIRES EN NATURE,,,
870,Dons en nature,,Produit,Bénévolat
871,Prestations en nature,,Produit,Bénévolat
875,Bénévolat,,Produit,Bénévolat
89,COMPTES DE BILAN,,,
890,Bilan d'ouverture,,,Ouverture
891,Bilan de clôture,,,Clôture
9,Classe 9 — Comptes analytiques,,,
90,COMPTES RÉFLÉCHIS,,,
906,Charges réfléchies,,,
907,Produits réfléchis,,,
99,Projets,,,Analytique

Modified src/include/lib/Garradin/Accounting/Accounts.php from [104aa964ca] to [36e8a3ddb7].

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

	/**
	 * Return common accounting accounts from current chart
	 * (will not return analytical and volunteering accounts)
	 */
	public function listCommonTypes(): array
	{
		return $this->em->all('SELECT * FROM @TABLE WHERE id_chart = ? AND type != 0 AND type NOT IN (?, ?) ORDER BY code COLLATE NOCASE;',
			$this->chart_id, Account::TYPE_ANALYTICAL, Account::TYPE_VOLUNTEERING);
	}

	/**
	 * Return all accounts from current chart
	 */
	public function listAll(): array
	{







|
|







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

	/**
	 * Return common accounting accounts from current chart
	 * (will not return analytical and volunteering accounts)
	 */
	public function listCommonTypes(): array
	{
		return $this->em->all('SELECT * FROM @TABLE WHERE id_chart = ? AND type != 0 AND type NOT IN (?) ORDER BY code COLLATE NOCASE;',
			$this->chart_id, Account::TYPE_ANALYTICAL);
	}

	/**
	 * Return all accounts from current chart
	 */
	public function listAll(): array
	{

Modified src/include/lib/Garradin/Accounting/Reports.php from [3c67f495cc] to [657f1c3461].

26
27
28
29
30
31
32
33
34
35
36





37
38
39
40
41
42
43

		if (!empty($criterias['exclude_position'])) {
			$db = DB::getInstance();
			$where[] = $db->where('position', 'NOT IN', $criterias['exclude_position']);
		}

		if (!empty($criterias['type'])) {
			$db = DB::getInstance();
			$criterias['type'] = array_map('intval', (array)$criterias['type']);
			$where[] = sprintf('a.type IN (%s)', implode(',', $criterias['type']));
		}






		if (!empty($criterias['user'])) {
			$where[] = sprintf('t.id IN (SELECT id_transaction FROM acc_transactions_users WHERE id_user = %d)', $criterias['user']);
		}

		if (!empty($criterias['creator'])) {
			$where[] = sprintf('t.id_creator = %d', $criterias['creator']);







<



>
>
>
>
>







26
27
28
29
30
31
32

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

		if (!empty($criterias['exclude_position'])) {
			$db = DB::getInstance();
			$where[] = $db->where('position', 'NOT IN', $criterias['exclude_position']);
		}

		if (!empty($criterias['type'])) {

			$criterias['type'] = array_map('intval', (array)$criterias['type']);
			$where[] = sprintf('a.type IN (%s)', implode(',', $criterias['type']));
		}

		if (!empty($criterias['exclude_type'])) {
			$criterias['exclude_type'] = array_map('intval', (array)$criterias['exclude_type']);
			$where[] = sprintf('a.type NOT IN (%s)', implode(',', $criterias['exclude_type']));
		}

		if (!empty($criterias['user'])) {
			$where[] = sprintf('t.id IN (SELECT id_transaction FROM acc_transactions_users WHERE id_user = %d)', $criterias['user']);
		}

		if (!empty($criterias['creator'])) {
			$where[] = sprintf('t.id_creator = %d', $criterias['creator']);
442
443
444
445
446
447
448
449























		if (null === $transaction) {
			return;
		}

		yield $transaction;
	}
}





























|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475

		if (null === $transaction) {
			return;
		}

		yield $transaction;
	}

	static public function getStatement(array $criterias): array
	{
		$revenue = Reports::getClosingSumsWithAccounts($criterias + ['position' => Account::REVENUE]);
		$expense = Reports::getClosingSumsWithAccounts($criterias + ['position' => Account::EXPENSE], null, true);

		$get_sum = function (array $in): int {
			$sum = 0;

			foreach ($in as $row) {
				$sum += $row->sum;
			}

			return abs($sum);
		};

		$revenue_sum = $get_sum($revenue);
		$expense_sum = $get_sum($expense);
		$result = $revenue_sum - $expense_sum;

		return compact('revenue', 'expense', 'revenue_sum', 'expense_sum', 'result');
	}
}

Modified src/include/lib/Garradin/Upgrade.php from [846a817db9] to [c40d4d26aa].

85
86
87
88
89
90
91







92
93
94
95
96
97
98

			if (version_compare($v, '1.0.0-beta1', '>=') && version_compare($v, '1.0.0-rc3', '<'))
			{
				$db->beginSchemaUpdate();
				$db->import(ROOT . '/include/data/1.0.0-rc3_migration.sql');
				$db->commitSchemaUpdate();
			}








			// Vérification de la cohérence des clés étrangères
			$db->foreignKeyCheck();

			Utils::clearCaches();

			$config->setVersion(garradin_version());







>
>
>
>
>
>
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

			if (version_compare($v, '1.0.0-beta1', '>=') && version_compare($v, '1.0.0-rc3', '<'))
			{
				$db->beginSchemaUpdate();
				$db->import(ROOT . '/include/data/1.0.0-rc3_migration.sql');
				$db->commitSchemaUpdate();
			}

			if (version_compare($v, '1.0.0-beta1', '>=') && version_compare($v, '1.0.0-rc10', '<'))
			{
				$db->beginSchemaUpdate();
				$db->import(ROOT . '/include/data/1.0.0-rc10_migration.sql');
				$db->commitSchemaUpdate();
			}

			// Vérification de la cohérence des clés étrangères
			$db->foreignKeyCheck();

			Utils::clearCaches();

			$config->setVersion(garradin_version());

Added src/templates/acc/reports/_statement.tpl version [2408ac0c3b].









































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
56
57
58
59
60
61
62
63
64
65
66
67
68
<table class="statement">
	<colgroup>
		<col width="50%" />
		<col width="50%" />
	</colgroup>
	<tbody>
		<tr>
			<td>
				{include file="acc/reports/_statement_table.tpl" accounts=$statement.expense caption=$caption1}
			</td>
			<td>
				{include file="acc/reports/_statement_table.tpl" accounts=$statement.revenue caption=$caption2}
			</td>
		</tr>
	</tbody>
	<tfoot>
		<tr>
			<td>
				<table>
					<tfoot>
						<tr>
							<th>Total</th>
							<td class="money">{$statement.expense_sum|raw|html_money:false}</td>
						</tr>
					</tfoot>
				</table>
			</td>
			<td>
				<table>
					<tfoot>
						<tr>
							<th>Total</th>
							<td class="money">{$statement.revenue_sum|raw|html_money:false}</td>
						</tr>
					</tfoot>
				</table>
			</td>
		</tr>
		{if $statement.result}
		<tr>
			<td>
			{if ($statement.result < 0)}
				<table>
					<tfoot>
						<tr>
							<th>Résultat (perte)</th>
							<td class="money">{$statement.result|raw|html_money:false}</td>
						</tr>
					</tfoot>
				</table>
			{/if}
			</td>
			<td>
			{if ($statement.result >= 0)}
				<table>
					<tfoot>
						<tr>
							<th>Résultat (excédent)</th>
							<td class="money">{$statement.result|raw|html_money:false}</td>
						</tr>
					</tfoot>
				</table>
			{/if}
			</td>
		</tr>
		{/if}
	</tfoot>
</table>

Modified src/templates/acc/reports/statement.tpl from [d32f95b6f7] to [176cb70b6d].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{include file="admin/_head.tpl" title="Compte de résultat" current="acc/years"}

{include file="acc/reports/_header.tpl" current="statement" title="Compte de résultat"}

<table class="statement">
	<colgroup>
		<col width="50%" />
		<col width="50%" />
	</colgroup>
	<tbody>
		<tr>
			<td>
				{include file="acc/reports/_statement_table.tpl" accounts=$expense caption="Charges"}
			</td>
			<td>
				{include file="acc/reports/_statement_table.tpl" accounts=$revenue caption="Produits"}
			</td>
		</tr>
	</tbody>
	<tfoot>
		<tr>
			<td>
				<table>
					<tfoot>
						<tr>
							<th>Total charges</th>
							<td class="money">{$expense_sum|raw|html_money:false}</td>
						</tr>
					</tfoot>
				</table>
			</td>
			<td>
				<table>
					<tfoot>
						<tr>
							<th>Total produits</th>
							<td class="money">{$revenue_sum|raw|html_money:false}</td>
						</tr>
					</tfoot>
				</table>
			</td>
		</tr>
		{if $result}
		<tr>
			<td>
			{if ($result < 0)}
				<table>
					<tfoot>
						<tr>
							<th>Résultat (perte)</th>
							<td class="money">{$result|raw|html_money:false}</td>
						</tr>
					</tfoot>
				</table>

			{/if}
			</td>
			<td>
			{if ($result >= 0)}
				<table>
					<tfoot>
						<tr>
							<th>Résultat (excédent)</th>
							<td class="money">{$result|raw|html_money:false}</td>
						</tr>
					</tfoot>
				</table>
			{/if}
			</td>
		</tr>
		{/if}
	</tfoot>
</table>

<p class="help">Toutes les écritures sont libellées en {$config.monnaie}.</p>

{include file="admin/_foot.tpl"}




<
<
<
<
<
<
<
<
|
|
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
>
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




1
2
3
4








5
6












7























8



9
10

















11
12
13
14
{include file="admin/_head.tpl" title="Compte de résultat" current="acc/years"}

{include file="acc/reports/_header.tpl" current="statement" title="Compte de résultat"}









{include file="acc/reports/_statement.tpl" statement=$general caption1="Charges" caption2="Produits"}













{if !empty($volunteering.expense_sum) || !empty($volunteering.revenue_sum)}























	<h2 class="ruler">Contributions en nature</h2>



	{include file="acc/reports/_statement.tpl" statement=$volunteering header=false caption1="Emplois des contributions volontaires en nature" caption2="Contributions volontaires en nature"}
{/if}


















<p class="help">Toutes les écritures sont libellées en {$config.monnaie}.</p>

{include file="admin/_foot.tpl"}

Modified src/www/admin/acc/reports/statement.php from [a66219b6ce] to [3be4e9af46].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

namespace Garradin;

use Garradin\Accounting\Reports;
use Garradin\Entities\Accounting\Account;

require_once __DIR__ . '/_inc.php';

$revenue = Reports::getClosingSumsWithAccounts($criterias + ['position' => Account::REVENUE]);
$expense = Reports::getClosingSumsWithAccounts($criterias + ['position' => Account::EXPENSE], null, true);

$get_sum = function (array $in): int {
	$sum = 0;

	foreach ($in as $row) {
		$sum += $row->sum;
	}

	return abs($sum);
};

$revenue_sum = $get_sum($revenue);
$expense_sum = $get_sum($expense);
$result = $revenue_sum - $expense_sum;

$tpl->assign(compact('revenue', 'expense', 'revenue_sum', 'expense_sum', 'result'));

$tpl->display('acc/reports/statement.tpl');









<
<
|
<
<
|
<
<
|
<
<
<
<
<
<
<
<
<
<

1
2
3
4
5
6
7
8
9


10


11


12










13
<?php

namespace Garradin;

use Garradin\Accounting\Reports;
use Garradin\Entities\Accounting\Account;

require_once __DIR__ . '/_inc.php';



$tpl->assign('general', Reports::getStatement($criterias + ['exclude_type' => Account::TYPE_VOLUNTEERING]));


$tpl->assign('volunteering', Reports::getStatement($criterias + ['type' => Account::TYPE_VOLUNTEERING]));













$tpl->display('acc/reports/statement.tpl');