Overview
Comment:Fix: Avoid 'Undefined variable: l' in import, improve export file name
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev | 1.0.0-alpha4
Files: files | file ages | folders
SHA1: 0df6faebfe15306603051d0c822765a5e01cf1ea
User & Date: bohwaz on 2020-11-05 12:02:24
Other Links: branch diff | manifest | tags
Context
2020-11-05
12:50
Fix: error message when line ID is not found check-in: 514825be77 user: bohwaz tags: dev, 1.0.0-alpha4
12:02
Fix: Avoid 'Undefined variable: l' in import, improve export file name check-in: 0df6faebfe user: bohwaz tags: dev, 1.0.0-alpha4
00:14
Fix the redirect should be in the callback check-in: 0c014ff5a5 user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Accounting/Transactions.php from [d366de1bb9] to [a14d2193c0].

160
161
162
163
164
165
166


167
168
169
170
171
172
173
		$db = DB::getInstance();
		$db->begin();

		$accounts = $year->accounts();
		$transaction = null;
		$types = array_flip(Transaction::TYPES_NAMES);



		try {
			foreach (CSV::importUpload($file, self::EXPECTED_CSV_COLUMNS_SELF) as $l => $row) {
				$row = (object) $row;

				$has_transaction = !empty($row->id) || !empty($row->type) || !empty($row->status) || !empty($row->label) || !empty($row->date) || !empty($row->notes) || !empty($row->reference);

				if (null !== $transaction && $has_transaction) {







>
>







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
		$db = DB::getInstance();
		$db->begin();

		$accounts = $year->accounts();
		$transaction = null;
		$types = array_flip(Transaction::TYPES_NAMES);

		$l = 0;

		try {
			foreach (CSV::importUpload($file, self::EXPECTED_CSV_COLUMNS_SELF) as $l => $row) {
				$row = (object) $row;

				$has_transaction = !empty($row->id) || !empty($row->type) || !empty($row->status) || !empty($row->label) || !empty($row->date) || !empty($row->notes) || !empty($row->reference);

				if (null !== $transaction && $has_transaction) {
253
254
255
256
257
258
259

260
261
262
263
264
265
266

		if ($skip_lines)
		{
			$table = array_slice($table, $skip_lines, null, true);
		}

		$accounts = $year->accounts();


		try {
			foreach ($table as $l => $row) {
				$row = (object) array_combine($translation_table, $row);

				if (!isset($row->credit_account, $row->debit_account, $row->amount)) {
					throw new UserException('Une des colonnes compte de crédit, compte de débit ou montant est manquante.');







>







255
256
257
258
259
260
261
262
263
264
265
266
267
268
269

		if ($skip_lines)
		{
			$table = array_slice($table, $skip_lines, null, true);
		}

		$accounts = $year->accounts();
		$l = 0;

		try {
			foreach ($table as $l => $row) {
				$row = (object) array_combine($translation_table, $row);

				if (!isset($row->credit_account, $row->debit_account, $row->amount)) {
					throw new UserException('Une des colonnes compte de crédit, compte de débit ou montant est manquante.');

Modified src/www/admin/acc/charts/export.php from [ab31a7f6c3] to [34dc474779].

11
12
13
14
15
16
17
18
19
20

if (!$chart) {
	throw new UserException("Le plan comptable demandé n'existe pas.");
}

CSV::export(
	null !== qg('ods') ? 'ods' : 'csv',
	sprintf('Plan comptable - %s', $chart->label),
	$chart->accounts()->export()
);







|


11
12
13
14
15
16
17
18
19
20

if (!$chart) {
	throw new UserException("Le plan comptable demandé n'existe pas.");
}

CSV::export(
	null !== qg('ods') ? 'ods' : 'csv',
	sprintf('Plan comptable - %s - %s', Config::getInstance()->get('nom_asso'), $chart->label),
	$chart->accounts()->export()
);

Modified src/www/admin/acc/years/import.php from [00e26e9709] to [132ee14e66].

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
if (!$year) {
	throw new UserException('Exercice inconnu.');
}

if (qg('export')) {
	CSV::export(
		qg('export'),
		sprintf('Export comptable - %s', $year->label),
		Transactions::export($year->id())
	);
	exit;
}

if ($year->closed) {
	throw new UserException('Impossible de modifier un exercice clôturé.');







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
if (!$year) {
	throw new UserException('Exercice inconnu.');
}

if (qg('export')) {
	CSV::export(
		qg('export'),
		sprintf('Export comptable - %s - %s', Config::getInstance()->get('nom_asso'), $year->label),
		Transactions::export($year->id())
	);
	exit;
}

if ($year->closed) {
	throw new UserException('Impossible de modifier un exercice clôturé.');