Overview
Comment:Improve reconcile: fix reconcile sum, improve form UI for small screens
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: c9518cd0c712818bb63761cd1128a9f453555880
User & Date: bohwaz on 2020-11-26 13:05:33
Other Links: branch diff | manifest | tags
Context
2020-11-26
18:04
Keep transaction type when migrating check-in: 904fef3ed6 user: bohwaz tags: dev
13:05
Improve reconcile: fix reconcile sum, improve form UI for small screens check-in: c9518cd0c7 user: bohwaz tags: dev
12:53
Fix reset of analytical in import check-in: 47fcf7c0d9 user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Entities/Accounting/Account.php from [6c62b2445b] to [185a3a4c5f].

248
249
250
251
252
253
254

255
256
257
258
259
260
261
262
263
264
			FROM acc_transactions_lines l
			INNER JOIN acc_transactions t ON t.id = l.id_transaction
			WHERE l.id_account = ? AND t.id_year = ? AND t.date >= ? AND t.date <= ? %s
			ORDER BY t.date, t.id;';
		$rows = $db->iterate(sprintf($sql, $condition), $this->id(), $year_id, $start_date->format('Y-m-d'), $end_date->format('Y-m-d'));

		$sum = $this->getSumAtDate($year_id, $start_date);


		$start_sum = false;
		$reconciled_sum = $sum;

		foreach ($rows as $row) {
			if (!$start_sum) {
				yield (object) ['sum' => $sum, 'date' => $start_date];
				$start_sum = true;
			}








>


<







248
249
250
251
252
253
254
255
256
257

258
259
260
261
262
263
264
			FROM acc_transactions_lines l
			INNER JOIN acc_transactions t ON t.id = l.id_transaction
			WHERE l.id_account = ? AND t.id_year = ? AND t.date >= ? AND t.date <= ? %s
			ORDER BY t.date, t.id;';
		$rows = $db->iterate(sprintf($sql, $condition), $this->id(), $year_id, $start_date->format('Y-m-d'), $end_date->format('Y-m-d'));

		$sum = $this->getSumAtDate($year_id, $start_date);
		$reconciled_sum = $this->getSumAtDate($year_id, $start_date, true);

		$start_sum = false;


		foreach ($rows as $row) {
			if (!$start_sum) {
				yield (object) ['sum' => $sum, 'date' => $start_date];
				$start_sum = true;
			}

398
399
400
401
402
403
404
405
406
407
408
409
410


411
412
413
414
415
416
417
			$sum *= -1;
		}

		return $sum;
	}


	public function getSumAtDate(int $year_id, DateTimeInterface $date): int
	{
		return (int) DB::getInstance()->firstColumn('SELECT SUM(l.credit) - SUM(l.debit)
			FROM acc_transactions_lines l
			INNER JOIN acc_transactions t ON t.id = l.id_transaction
			wHERE l.id_account = ? AND t.id_year = ? AND t.date < ?;', $this->id(), $year_id, $date->format('Y-m-d'));


	}

	public function importSimpleForm(array $translate_type_position, array $translate_type_codes, ?array $source = null)
	{
		if (null === $source) {
			$source = $_POST;
		}







|

|


|
>
>







398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
			$sum *= -1;
		}

		return $sum;
	}


	public function getSumAtDate(int $year_id, DateTimeInterface $date, bool $reconciled_only = false): int
	{
		$sql = sprintf('SELECT SUM(l.credit) - SUM(l.debit)
			FROM acc_transactions_lines l
			INNER JOIN acc_transactions t ON t.id = l.id_transaction
			wHERE l.id_account = ? AND t.id_year = ? AND t.date < ? %s;',
			$reconciled_only ? 'AND l.reconciled = 1' : '');
		return (int) DB::getInstance()->firstColumn($sql, $this->id(), $year_id, $date->format('Y-m-d'));
	}

	public function importSimpleForm(array $translate_type_position, array $translate_type_codes, ?array $source = null)
	{
		if (null === $source) {
			$source = $_POST;
		}

Modified src/templates/acc/accounts/reconcile.tpl from [94c65302b7] to [eccd019e3c].

19
20
21
22
23
24
25
26
27
28
29
30
31
32


33
34
35
36
37
38
39
			{/if}
			{if $next}
				{linkbutton shape="right" href=$next.url label=$next.date|date_fr:'F Y'}
			{/if}
		</p>
	</fieldset>
	{/if}
	<fieldset>
		<legend>Période de rapprochement</legend>
		<p>
			Du
			{input type="date" name="start" default=$start}
			au
			{input type="date" name="end" default=$end}


			<label>{input type="checkbox" name="only" value=1 default=$only} Seulement les écritures non rapprochées</label>
			<input type="hidden" name="id" value="{$account.id}" />
			<input type="submit" value="Afficher" />
		</p>
	</fieldset>
</form>








|






>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
			{/if}
			{if $next}
				{linkbutton shape="right" href=$next.url label=$next.date|date_fr:'F Y'}
			{/if}
		</p>
	</fieldset>
	{/if}
	<fieldset class="shortFormLeft">
		<legend>Période de rapprochement</legend>
		<p>
			Du
			{input type="date" name="start" default=$start}
			au
			{input type="date" name="end" default=$end}
		</p>
		<p>
			<label>{input type="checkbox" name="only" value=1 default=$only} Seulement les écritures non rapprochées</label>
			<input type="hidden" name="id" value="{$account.id}" />
			<input type="submit" value="Afficher" />
		</p>
	</fieldset>
</form>

Modified src/www/admin/static/styles/02-common.css from [937f333e35] to [14d9c47672].

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
.shortFormRight {
    width: 30em;
    float: right;
    text-align: center;
    margin-left: 1em;
}

.shortFormLeft {
    font-size: 80%;
}

.shortFormLeft .special {
    display: none;
}

.shortFormRight p.submit {







|
|







218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
.shortFormRight {
    width: 30em;
    float: right;
    text-align: center;
    margin-left: 1em;
}

.shortFormLeft p {
    display: inline-block;
}

.shortFormLeft .special {
    display: none;
}

.shortFormRight p.submit {