Overview
Comment:Fix: use analytical ID in form when using duplicate feature (reported by @zou)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk | stable
Files: files | file ages | folders
SHA3-256: e7c5779282bbeb75a41e965f0aa3a9f5c6c73e4c3f7b2aa6e7782918fb6724fc
User & Date: bohwaz on 2021-10-28 03:12:33
Other Links: manifest | tags
Context
2021-10-28
03:12
Fix: use analytical ID in form when using duplicate feature (reported by @zou) Leaf check-in: e7c5779282 user: bohwaz tags: trunk, stable
02:11
Duplicate analytical account too, if the chart matches, fix bug reported by @zou check-in: a80494ca43 user: bohwaz tags: trunk, stable
Changes

Modified src/templates/acc/transactions/new.tpl from [91b454b44d] to [08d51e9571].

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
		</dl>
		<dl>
			{input type="list" multiple=true name="users" label="Membres associés" target="membres/selector.php"}
			{input type="textarea" name="notes" label="Remarques" rows=4 cols=30}
		</dl>
		<dl data-types="all-but-advanced">
			{if count($analytical_accounts) > 1}
				{input type="select" name="id_analytical" label="Projet (compte analytique)" options=$analytical_accounts}
			{/if}
		</dl>
	</fieldset>

	<p class="submit">
		{csrf_field key="acc_transaction_new"}
		{button type="submit" name="save" label="Enregistrer" shape="right" class="main"}







|







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
		</dl>
		<dl>
			{input type="list" multiple=true name="users" label="Membres associés" target="membres/selector.php"}
			{input type="textarea" name="notes" label="Remarques" rows=4 cols=30}
		</dl>
		<dl data-types="all-but-advanced">
			{if count($analytical_accounts) > 1}
				{input type="select" name="id_analytical" label="Projet (compte analytique)" options=$analytical_accounts default=$id_analytical}
			{/if}
		</dl>
	</fieldset>

	<p class="submit">
		{csrf_field key="acc_transaction_new"}
		{button type="submit" name="save" label="Enregistrer" shape="right" class="main"}

Modified src/www/admin/acc/transactions/new.php from [c93d48adea] to [b9f3447f1f].

19
20
21
22
23
24
25

26
27
28
29
30
31
32

33
34
35
36
37
38
39
...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
$accounts = $chart->accounts();

$transaction = new Transaction;
$lines = [[], []];
$amount = 0;
$payoff_for = qg('payoff_for') ?: f('payoff_for');
$types_accounts = null;


// Duplicate transaction
if (qg('copy')) {
	$old = Transactions::get((int)qg('copy'));
	$transaction = $old->duplicate($current_year);
	$lines = $transaction->getLinesWithAccounts();
	$payoff_for = null;

	$amount = $transaction->getLinesCreditSum();
	$types_accounts = $transaction->getTypesAccounts();
	$transaction->resetLines();

	foreach ($lines as $k => &$line) {
		$line->account = [$line->id_account => sprintf('%s — %s', $line->account_code, $line->account_name)];
	}
................................................................................
		Utils::redirect(Utils::getSelfURI(false) . '?ok=' . $transaction->id());
	}
	catch (UserException $e) {
		$form->addError($e->getMessage());
	}
}

$tpl->assign(compact('transaction', 'payoff_for', 'amount', 'lines', 'types_accounts'));
$tpl->assign('payoff_targets', implode(':', [Account::TYPE_BANK, Account::TYPE_CASH, Account::TYPE_OUTSTANDING]));
$tpl->assign('ok', (int) qg('ok'));

$tpl->assign('types_details', Transaction::getTypesDetails());
$tpl->assign('chart_id', $chart->id());

$tpl->assign('analytical_accounts', ['' => '-- Aucun'] + $accounts->listAnalytical());
$tpl->display('acc/transactions/new.tpl');







>







>







 







|








19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
$accounts = $chart->accounts();

$transaction = new Transaction;
$lines = [[], []];
$amount = 0;
$payoff_for = qg('payoff_for') ?: f('payoff_for');
$types_accounts = null;
$id_analytical = null;

// Duplicate transaction
if (qg('copy')) {
	$old = Transactions::get((int)qg('copy'));
	$transaction = $old->duplicate($current_year);
	$lines = $transaction->getLinesWithAccounts();
	$payoff_for = null;
	$id_analytical = $old->getAnalyticalId();
	$amount = $transaction->getLinesCreditSum();
	$types_accounts = $transaction->getTypesAccounts();
	$transaction->resetLines();

	foreach ($lines as $k => &$line) {
		$line->account = [$line->id_account => sprintf('%s — %s', $line->account_code, $line->account_name)];
	}
................................................................................
		Utils::redirect(Utils::getSelfURI(false) . '?ok=' . $transaction->id());
	}
	catch (UserException $e) {
		$form->addError($e->getMessage());
	}
}

$tpl->assign(compact('transaction', 'payoff_for', 'amount', 'lines', 'types_accounts', 'id_analytical'));
$tpl->assign('payoff_targets', implode(':', [Account::TYPE_BANK, Account::TYPE_CASH, Account::TYPE_OUTSTANDING]));
$tpl->assign('ok', (int) qg('ok'));

$tpl->assign('types_details', Transaction::getTypesDetails());
$tpl->assign('chart_id', $chart->id());

$tpl->assign('analytical_accounts', ['' => '-- Aucun'] + $accounts->listAnalytical());
$tpl->display('acc/transactions/new.tpl');