Revision 2a4516c1
Von Niclas Zimmermann vor fast 12 Jahren hinzugefügt
SL/IR.pm | ||
---|---|---|
270 | 270 |
# allocated >= 0 |
271 | 271 |
# add entry for inventory, this one is for the sold item |
272 | 272 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?), |
273 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
273 |
(SELECT tax_id |
|
274 |
FROM taxkeys |
|
275 |
WHERE chart_id= (SELECT id |
|
276 |
FROM chart |
|
277 |
WHERE accno = ?) |
|
278 |
AND startdate <= ? |
|
279 |
ORDER BY startdate DESC LIMIT 1))|; |
|
274 | 280 |
@values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{inventory_accno_id}, $ref->{transdate}); |
275 | 281 |
do_query($form, $dbh, $query, @values); |
276 | 282 |
|
277 | 283 |
# add expense |
278 | 284 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, (SELECT taxkey from tax WHERE chart_id = ?), |
279 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
285 |
(SELECT tax_id |
|
286 |
FROM taxkeys |
|
287 |
WHERE chart_id= (SELECT id |
|
288 |
FROM chart |
|
289 |
WHERE accno = ?) |
|
290 |
AND startdate <= ? |
|
291 |
ORDER BY startdate DESC LIMIT 1))|; |
|
280 | 292 |
@values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{expense_accno_id}, $ref->{transdate}); |
281 | 293 |
do_query($form, $dbh, $query, @values); |
282 | 294 |
} |
... | ... | |
483 | 495 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id) |
484 | 496 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
485 | 497 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
486 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
498 |
(SELECT tax_id |
|
499 |
FROM taxkeys |
|
500 |
WHERE chart_id= (SELECT id |
|
501 |
FROM chart |
|
502 |
WHERE accno = ?) |
|
503 |
AND startdate <= ? |
|
504 |
ORDER BY startdate DESC LIMIT 1))|; |
|
487 | 505 |
@values = ($trans_id, $accno, $form->{amount}{$trans_id}{$accno}, |
488 | 506 |
conv_date($form->{invdate}), $accno, $project_id, $accno, conv_date($form->{invdate})); |
489 | 507 |
do_query($form, $dbh, $query, @values); |
... | ... | |
523 | 541 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id) |
524 | 542 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
525 | 543 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
526 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
544 |
(SELECT tax_id |
|
545 |
FROM taxkeys |
|
546 |
WHERE chart_id= (SELECT id |
|
547 |
FROM chart |
|
548 |
WHERE accno = ?) |
|
549 |
AND startdate <= ? |
|
550 |
ORDER BY startdate DESC LIMIT 1))|; |
|
527 | 551 |
@values = (conv_i($form->{id}), $form->{AP}, $amount, |
528 | 552 |
$form->{"datepaid_$i"}, $form->{AP}, $project_id, $form->{AP}, conv_date($form->{"datepaid_$i"})); |
529 | 553 |
do_query($form, $dbh, $query, @values); |
... | ... | |
536 | 560 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id, tax_id) |
537 | 561 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, |
538 | 562 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
539 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
563 |
(SELECT tax_id |
|
564 |
FROM taxkeys |
|
565 |
WHERE chart_id= (SELECT id |
|
566 |
FROM chart WHERE accno = ?) |
|
567 |
AND startdate <= ? |
|
568 |
ORDER BY startdate DESC LIMIT 1))|; |
|
540 | 569 |
@values = (conv_i($form->{id}), $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"}, |
541 | 570 |
$gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id, $accno, conv_date($form->{"datepaid_$i"})); |
542 | 571 |
do_query($form, $dbh, $query, @values); |
... | ... | |
578 | 607 |
|
579 | 608 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id, tax_id) |
580 | 609 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1', 0, ?, |
581 |
(SELECT tax_id FROM taxkeys WHERE chart_id= (SELECT id FROM chart WHERE accno = ?) AND startdate <= ? ORDER BY startdate DESC LIMIT 1))|; |
|
610 |
(SELECT tax_id |
|
611 |
FROM taxkeys |
|
612 |
WHERE chart_id= (SELECT id |
|
613 |
FROM chart |
|
614 |
WHERE accno = ?) |
|
615 |
AND startdate <= ? |
|
616 |
ORDER BY startdate DESC LIMIT 1))|; |
|
582 | 617 |
@values = (conv_i($form->{id}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $project_id, $accno, $form->{fx}{$accno}{$transdate}); |
583 | 618 |
do_query($form, $dbh, $query, @values); |
584 | 619 |
} |
Auch abrufbar als: Unified diff
Bessere Formatierung
Verbessert die Formatierung von Commit 5c5e92bc37819dd9df952068b9e58b47dd0b0de2
(Großschreibung von SQL-Befehlen, Zeilenumbrüche bei langen Sub-Queries)