Revision 2a4516c1
Von Niclas Zimmermann vor fast 12 Jahren hinzugefügt
SL/AR.pm | ||
---|---|---|
192 | 192 |
# add recievables |
193 | 193 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) |
194 | 194 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
195 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
195 |
(SELECT tax_id |
|
196 |
FROM taxkeys |
|
197 |
WHERE chart_id= (SELECT id |
|
198 |
FROM chart |
|
199 |
WHERE accno = ?) |
|
200 |
AND startdate <= ? |
|
201 |
ORDER BY startdate DESC LIMIT 1))|; |
|
196 | 202 |
@values = (conv_i($form->{id}), $form->{AR_amounts}{receivables}, conv_i($form->{receivables}), conv_date($form->{transdate}), |
197 | 203 |
$form->{AR_amounts}{receivables}, $form->{AR_amounts}{receivables}, conv_date($form->{transdate})); |
198 | 204 |
do_query($form, $dbh, $query, @values); |
... | ... | |
233 | 239 |
# add receivable |
234 | 240 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, taxkey, tax_id) |
235 | 241 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
236 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
242 |
(SELECT tax_id |
|
243 |
FROM taxkeys |
|
244 |
WHERE chart_id= (SELECT id |
|
245 |
FROM chart |
|
246 |
WHERE accno = ?) |
|
247 |
AND startdate <= ? |
|
248 |
ORDER BY startdate DESC LIMIT 1))|; |
|
237 | 249 |
@values = (conv_i($form->{id}), $form->{AR}{receivables}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR}{receivables}, $form->{AR}{receivables}, conv_date($form->{"datepaid_$i"})); |
238 | 250 |
do_query($form, $dbh, $query, @values); |
239 | 251 |
} |
... | ... | |
245 | 257 |
$amount = $form->{"paid_$i"} * -1; |
246 | 258 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey, tax_id) |
247 | 259 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
248 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
260 |
(SELECT tax_id |
|
261 |
FROM taxkeys |
|
262 |
WHERE chart_id= (SELECT id |
|
263 |
FROM chart |
|
264 |
WHERE accno = ?) |
|
265 |
AND startdate <= ? |
|
266 |
ORDER BY startdate DESC LIMIT 1))|; |
|
249 | 267 |
@values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $form->{AR}{"paid_$i"}, |
250 | 268 |
$form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"})); |
251 | 269 |
do_query($form, $dbh, $query, @values); |
... | ... | |
256 | 274 |
if ($amount != 0) { |
257 | 275 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) |
258 | 276 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
259 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
277 |
(SELECT tax_id |
|
278 |
FROM taxkeys |
|
279 |
WHERE chart_id= (SELECT id |
|
280 |
FROM chart |
|
281 |
WHERE accno = ?) |
|
282 |
AND startdate <= ? |
|
283 |
ORDER BY startdate DESC LIMIT 1))|; |
|
260 | 284 |
@values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AR}{"paid_$i"}, |
261 | 285 |
$form->{AR}{"paid_$i"}, conv_date($form->{"datepaid_$i"})); |
262 | 286 |
do_query($form, $dbh, $query, @values); |
... | ... | |
269 | 293 |
my $accno = ($amount > 0) ? $form->{fxgain_accno} : $form->{fxloss_accno}; |
270 | 294 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, fx_transaction, cleared, project_id, taxkey, tax_id) |
271 | 295 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, 't', 'f', ?, (SELECT taxkey_id FROM chart WHERE accno = ?), |
272 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
296 |
(SELECT tax_id |
|
297 |
FROM taxkeys |
|
298 |
WHERE chart_id= (SELECT id |
|
299 |
FROM chart |
|
300 |
WHERE accno = ?) |
|
301 |
AND startdate <= ? |
|
302 |
ORDER BY startdate DESC LIMIT 1))|; |
|
273 | 303 |
@values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{"datepaid_$i"}), $project_id, $accno, $accno, conv_date($form->{"datepaid_$i"})); |
274 | 304 |
do_query($form, $dbh, $query, @values); |
275 | 305 |
} |
Auch abrufbar als: Unified diff
Bessere Formatierung
Verbessert die Formatierung von Commit 5c5e92bc37819dd9df952068b9e58b47dd0b0de2
(Großschreibung von SQL-Befehlen, Zeilenumbrüche bei langen Sub-Queries)