Overview
Comment:Try to find a valid code
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable | 1.2.2
Files: files | file ages | folders
SHA3-256: 8c851bb35e72dfdaa84d28f0807b87b43e3e21395b3ac103373a43c13288ee44
User & Date: bohwaz on 2022-11-09 17:06:17
Other Links: manifest | tags
Context
2022-11-09
18:03
Fix last transactions table check-in: 7ac71389a2 user: bohwaz tags: trunk, stable, 1.2.2
17:06
Try to find a valid code check-in: 8c851bb35e user: bohwaz tags: trunk, stable, 1.2.2
17:00
Change account code for accounts not in 512* but that are probably still bank accounts check-in: 0504e72d19 user: bohwaz tags: trunk, stable
Changes

Modified src/include/migrations/1.2/1.2.2.php from [5c12ab0f8f] to [a4b2e1e622].

9
10
11
12
13
14
15





16
17
18
19
20
21
22
23
24
25
26
	AND c.country = \'FR\'
	GROUP BY a.id;';

$db->begin();

foreach ($db->iterate($sql) as $row) {
	$new_code = '5120' . substr($row->code, 2);





	// Change code
	$db->preparedQuery('UPDATE acc_accounts SET code = ?, type = 1, user = ? WHERE id = ?;', [$new_code, $row->chart_code ? 1 : 0, $row->id]);

	// If the account was part of the official chart, put it back in the chart
	if ($row->chart_code && !$row->user) {
		$db->preparedQuery('INSERT INTO acc_accounts (id_chart, code, label, position, user) VALUES (?, ?, ?, ?, ?);',
			[$row->id_chart, $row->code, $row->label, $row->position, 0]);
	}
}

$db->commit();







>
>
>
>
>











9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
	AND c.country = \'FR\'
	GROUP BY a.id;';

$db->begin();

foreach ($db->iterate($sql) as $row) {
	$new_code = '5120' . substr($row->code, 2);

	if ($db->firstColumn('SELECT 1 FROM acc_accounts WHERE code = ? AND id_chart = ?;', $new_code, $row->id_chart)) {
		$new_code = '51200' . substr($row->code, 2);
	}

	// Change code
	$db->preparedQuery('UPDATE acc_accounts SET code = ?, type = 1, user = ? WHERE id = ?;', [$new_code, $row->chart_code ? 1 : 0, $row->id]);

	// If the account was part of the official chart, put it back in the chart
	if ($row->chart_code && !$row->user) {
		$db->preparedQuery('INSERT INTO acc_accounts (id_chart, code, label, position, user) VALUES (?, ?, ?, ?, ?);',
			[$row->id_chart, $row->code, $row->label, $row->position, 0]);
	}
}

$db->commit();