Overview
Comment:Reverse order of transactions for users
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA3-256: 55a079fb33aa283815a6dc90f541a21056619da58961fccf58d270bb23a9ee37
User & Date: bohwaz on 2023-06-03 23:53:51
Other Links: branch diff | manifest | tags
Context
2023-06-03
23:55
Implement 'sent' event in log for mailing sending, also log project and reminder changes check-in: c28b41d3b6 user: bohwaz tags: dev
23:53
Reverse order of transactions for users check-in: 55a079fb33 user: bohwaz tags: dev
23:48
Fix advanced search coming from quick search check-in: e8fe5207b8 user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Accounting/Reports.php from [0f7acbbe10] to [be49fc6e79].

599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624

		$account->all_debit = $debit;
		$account->all_credit = $credit;

		yield $account;
	}

	static public function getJournal(array $criterias): \Generator
	{
		$where = self::getWhereClause($criterias, 't', 'l', 'a');

		$sql = sprintf('SELECT
			t.id_year, l.id_account, l.debit, l.credit, t.id, t.date, t.reference,
			l.reference AS line_reference, t.label, l.label AS line_label,
			a.label AS account_label, a.code AS account_code
			FROM acc_transactions t
			INNER JOIN acc_transactions_lines l ON l.id_transaction = t.id
			INNER JOIN acc_accounts a ON l.id_account = a.id
			WHERE %s ORDER BY t.date, t.id;', $where);

		$transaction = null;
		$db = DB::getInstance();

		foreach ($db->iterate($sql) as $row) {
			if (null !== $transaction && $transaction->id != $row->id) {
				yield $transaction;







|










|







599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624

		$account->all_debit = $debit;
		$account->all_credit = $credit;

		yield $account;
	}

	static public function getJournal(array $criterias, bool $reverse_order = false): \Generator
	{
		$where = self::getWhereClause($criterias, 't', 'l', 'a');

		$sql = sprintf('SELECT
			t.id_year, l.id_account, l.debit, l.credit, t.id, t.date, t.reference,
			l.reference AS line_reference, t.label, l.label AS line_label,
			a.label AS account_label, a.code AS account_code
			FROM acc_transactions t
			INNER JOIN acc_transactions_lines l ON l.id_transaction = t.id
			INNER JOIN acc_accounts a ON l.id_account = a.id
			WHERE %s ORDER BY t.date %s, t.id %2$s;', $where, $reverse_order ? 'DESC' : 'ASC');

		$transaction = null;
		$db = DB::getInstance();

		foreach ($db->iterate($sql) as $row) {
			if (null !== $transaction && $transaction->id != $row->id) {
				yield $transaction;

Modified src/templates/acc/transactions/creator.tpl from [7581f116ec] to [8d3d1b3556].

1




2
3
4
5
{include file="_head.tpl" title="Écritures crées par %s"|args:$transaction_creator.identite current="acc/accounts"}





{include file="acc/reports/_journal.tpl"}

{include file="_foot.tpl"}
|
>
>
>
>




1
2
3
4
5
6
7
8
9
{include file="_head.tpl" title="Écritures créées par %s"|args:$transaction_creator->name() current="acc/accounts"}

<p class="help">
	De la plus récente à la plus ancienne.
</p>

{include file="acc/reports/_journal.tpl"}

{include file="_foot.tpl"}

Modified src/templates/acc/transactions/user.tpl from [9299a647a1] to [6a563c7bfe].

1
2
3
4
5
6
7




8
9
10
11
12
13
14
{include file="_head.tpl" title="Écritures liées à %s"|args:$transaction_user.identite current="acc/accounts"}

{if !$dialog}
<p>
	{linkbutton href="!users/details.php?id=%d"|args:$transaction_user.id label="Retour à la fiche membre" shape="user"}
</p>
{/if}





{include file="acc/reports/_journal.tpl"}

<h2 class="ruler">Solde des comptes</h2>

<form method="get" action="{$self_url_no_qs}">
	<fieldset>
|






>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{include file="_head.tpl" title="Écritures liées à %s"|args:$transaction_user->name() current="acc/accounts"}

{if !$dialog}
<p>
	{linkbutton href="!users/details.php?id=%d"|args:$transaction_user.id label="Retour à la fiche membre" shape="user"}
</p>
{/if}

<p class="help">
	De la plus récente à la plus ancienne.
</p>

{include file="acc/reports/_journal.tpl"}

<h2 class="ruler">Solde des comptes</h2>

<form method="get" action="{$self_url_no_qs}">
	<fieldset>

Modified src/www/admin/acc/transactions/creator.php from [3ffff6389f] to [e16800c5f0].

12
13
14
15
16
17
18
19
20
21
22

if (!$u) {
	throw new UserException('Ce membre n\'existe pas');
}

$criterias = ['creator' => $u->id];

$tpl->assign('journal', Reports::getJournal($criterias));
$tpl->assign('transaction_creator', $u);

$tpl->display('acc/transactions/creator.tpl');







|



12
13
14
15
16
17
18
19
20
21
22

if (!$u) {
	throw new UserException('Ce membre n\'existe pas');
}

$criterias = ['creator' => $u->id];

$tpl->assign('journal', Reports::getJournal($criterias, true));
$tpl->assign('transaction_creator', $u);

$tpl->display('acc/transactions/creator.tpl');

Modified src/www/admin/acc/transactions/user.php from [4e7ffb8f16] to [7e8decf9cc].

18
19
20
21
22
23
24
25
26
27
28
29
$years = Years::listAssoc();
end($years);
$year = (int)qg('year') ?: key($years);

$criterias = ['user' => $u->id];

$tpl->assign('balance', Reports::getAccountsBalances($criterias + ['year' => $year], null, false));
$tpl->assign('journal', Reports::getJournal($criterias));
$tpl->assign(compact('years', 'year'));
$tpl->assign('transaction_user', $u);

$tpl->display('acc/transactions/user.tpl');







|




18
19
20
21
22
23
24
25
26
27
28
29
$years = Years::listAssoc();
end($years);
$year = (int)qg('year') ?: key($years);

$criterias = ['user' => $u->id];

$tpl->assign('balance', Reports::getAccountsBalances($criterias + ['year' => $year], null, false));
$tpl->assign('journal', Reports::getJournal($criterias, true));
$tpl->assign(compact('years', 'year'));
$tpl->assign('transaction_user', $u);

$tpl->display('acc/transactions/user.tpl');