Overview
Comment:Add totals to trial balance, as suggested by @Christian
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA3-256: 7b5e6e0b19a1c1ddacc816a6a29229e69d31dba9cc29647d1ed51f118f1719ef
User & Date: bohwaz on 2022-02-13 22:17:48
Other Links: manifest | tags
Context
2022-02-14
15:32
Add links to transaction numbers in label and notes check-in: 9096dd34ec user: bohwaz tags: trunk, stable
2022-02-13
22:17
Add totals to trial balance, as suggested by @Christian check-in: 7b5e6e0b19 user: bohwaz tags: trunk, stable
2022-02-11
14:39
Replicate changes for display of user services check-in: 38627e26b8 user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Accounting/Reports.php from [224caace98] to [77a691aec9].

291
292
293
294
295
296
297
298
299
300
301





















302
303
304
305
306
307
308
				}
			}
		}

		return $out;
	}

	static public function getTrialBalance(array $criterias): array
	{
		unset($criterias['compare_year']);
		return self::getClosingSumsWithAccounts($criterias, null, false, false);





















	}

	static public function getBalanceSheet(array $criterias): array
	{
		$accounts = ['asset' => [], 'liability' => []];
		$sums = $sums2 = $change = ['asset' => 0, 'liability' => 0];








|


|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
				}
			}
		}

		return $out;
	}

	static public function getTrialBalance(array $criterias): \Iterator
	{
		unset($criterias['compare_year']);
		$out = self::getClosingSumsWithAccounts($criterias, null, false, false);

		$sums = [
			'debit'      => 0,
			'credit'     => 0,
			'sum_debit'  => 0,
			'sum_credit' => 0,
			'label'      => 'Total',
		];

		foreach ($out as $row) {
			$row->sum_debit = $row->sum < 0 ? abs($row->sum) : null;
			$row->sum_credit = $row->sum > 0 ? abs($row->sum) : null;

			$sums['debit'] += $row->debit;
			$sums['credit'] += $row->credit;
			$sums['sum_debit'] += $row->sum_debit;
			$sums['sum_credit'] += $row->sum_credit;
			yield $row;
		}

		yield (object) $sums;
	}

	static public function getBalanceSheet(array $criterias): array
	{
		$accounts = ['asset' => [], 'liability' => []];
		$sums = $sums2 = $change = ['asset' => 0, 'liability' => 0];

Modified src/templates/acc/reports/trial_balance.tpl from [14933bb3ab] to [39246dd174].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
				{if !empty($year)}<a href="{$admin_url}acc/accounts/journal.php?id={$account.id}&amp;year={$year.id}">{$account.code}</a>
				{else}{$account.code}
				{/if}
			</td>
			<th>{$account.label}</th>
			<td class="money">{$account.debit|raw|money}</td>
			<td class="money">{$account.credit|raw|money}</td>
			<td class="money">{if $account.sum < 0}{$account.sum|abs|escape|money}{/if}</td>
			<td class="money">{if $account.sum > 0}{$account.sum|abs|escape|money}{/if}</td>
		</tr>
	{/foreach}
	</tbody>
</table>

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

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







|
|








20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
				{if !empty($year)}<a href="{$admin_url}acc/accounts/journal.php?id={$account.id}&amp;year={$year.id}">{$account.code}</a>
				{else}{$account.code}
				{/if}
			</td>
			<th>{$account.label}</th>
			<td class="money">{$account.debit|raw|money}</td>
			<td class="money">{$account.credit|raw|money}</td>
			<td class="money">{$account.sum_debit|escape|money}</td>
			<td class="money">{$account.sum_credit|escape|money}</td>
		</tr>
	{/foreach}
	</tbody>
</table>

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

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