Revision dceb9f20
Von Niclas Zimmermann vor mehr als 11 Jahren hinzugefügt
SL/IR.pm | ||
---|---|---|
269 | 269 |
|
270 | 270 |
# allocated >= 0 |
271 | 271 |
# add entry for inventory, this one is for the sold item |
272 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?), |
|
272 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, |
|
273 |
(SELECT taxkey_id |
|
274 |
FROM taxkeys |
|
275 |
WHERE chart_id= ? |
|
276 |
AND startdate <= ? |
|
277 |
ORDER BY startdate DESC LIMIT 1), |
|
273 | 278 |
(SELECT tax_id |
274 | 279 |
FROM taxkeys |
275 |
WHERE chart_id= (SELECT id |
|
276 |
FROM chart |
|
277 |
WHERE accno = ?) |
|
280 |
WHERE chart_id= ? |
|
278 | 281 |
AND startdate <= ? |
279 | 282 |
ORDER BY startdate DESC LIMIT 1), |
280 | 283 |
(SELECT chart_link FROM chart WHERE id = ?))|; |
281 |
@values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{inventory_accno_id}, $ref->{transdate}, $ref->{inventory_accno_id}); |
|
284 |
@values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{transdate}, |
|
285 |
$ref->{inventory_accno_id}); |
|
282 | 286 |
do_query($form, $dbh, $query, @values); |
283 | 287 |
|
284 | 288 |
# add expense |
285 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, (SELECT taxkey from tax WHERE chart_id = ?), |
|
289 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?, |
|
290 |
(SELECT taxkey_id |
|
291 |
FROM taxkeys |
|
292 |
WHERE chart_id= ? |
|
293 |
AND startdate <= ? |
|
294 |
ORDER BY startdate DESC LIMIT 1), |
|
286 | 295 |
(SELECT tax_id |
287 | 296 |
FROM taxkeys |
288 |
WHERE chart_id= (SELECT id |
|
289 |
FROM chart |
|
290 |
WHERE accno = ?) |
|
297 |
WHERE chart_id= ? |
|
291 | 298 |
AND startdate <= ? |
292 | 299 |
ORDER BY startdate DESC LIMIT 1), |
293 | 300 |
(SELECT chart_link FROM chart WHERE id = ?))|; |
294 |
@values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{expense_accno_id}, $ref->{transdate}, $ref->{expense_accno_id}); |
|
301 |
@values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{transdate}, $ref->{expense_accno_id}, $ref->{transdate}, |
|
302 |
$ref->{expense_accno_id}); |
|
295 | 303 |
do_query($form, $dbh, $query, @values); |
296 | 304 |
} |
297 | 305 |
}; |
... | ... | |
496 | 504 |
|
497 | 505 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id, chart_link) |
498 | 506 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
499 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
|
507 |
(SELECT taxkey_id |
|
508 |
FROM taxkeys |
|
509 |
WHERE chart_id= (SELECT id |
|
510 |
FROM chart |
|
511 |
WHERE accno = ?) |
|
512 |
AND startdate <= ? |
|
513 |
ORDER BY startdate DESC LIMIT 1), |
|
514 |
?, |
|
500 | 515 |
(SELECT tax_id |
501 | 516 |
FROM taxkeys |
502 | 517 |
WHERE chart_id= (SELECT id |
... | ... | |
506 | 521 |
ORDER BY startdate DESC LIMIT 1), |
507 | 522 |
(SELECT link FROM chart WHERE accno = ?))|; |
508 | 523 |
@values = ($trans_id, $accno, $form->{amount}{$trans_id}{$accno}, |
509 |
conv_date($form->{invdate}), $accno, $project_id, $accno, conv_date($form->{invdate}), $accno); |
|
524 |
conv_date($form->{invdate}), $accno, conv_date($form->{invdate}), $project_id, $accno, conv_date($form->{invdate}), $accno);
|
|
510 | 525 |
do_query($form, $dbh, $query, @values); |
511 | 526 |
} |
512 | 527 |
} |
... | ... | |
543 | 558 |
if ($form->{amount}{ $form->{id} }{ $form->{AP} } != 0) { |
544 | 559 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id, tax_id, chart_link) |
545 | 560 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, |
546 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
|
561 |
(SELECT taxkey_id |
|
562 |
FROM taxkeys |
|
563 |
WHERE chart_id= (SELECT id |
|
564 |
FROM chart |
|
565 |
WHERE accno = ?) |
|
566 |
AND startdate <= ? |
|
567 |
ORDER BY startdate DESC LIMIT 1), |
|
568 |
?, |
|
547 | 569 |
(SELECT tax_id |
548 | 570 |
FROM taxkeys |
549 | 571 |
WHERE chart_id= (SELECT id |
... | ... | |
553 | 575 |
ORDER BY startdate DESC LIMIT 1), |
554 | 576 |
(SELECT link FROM chart WHERE accno = ?))|; |
555 | 577 |
@values = (conv_i($form->{id}), $form->{AP}, $amount, |
556 |
$form->{"datepaid_$i"}, $form->{AP}, $project_id, $form->{AP}, conv_date($form->{"datepaid_$i"}), $form->{AP}); |
|
578 |
$form->{"datepaid_$i"}, $form->{AP}, conv_date($form->{"datepaid_$i"}), $project_id, $form->{AP}, conv_date($form->{"datepaid_$i"}), $form->{AP});
|
|
557 | 579 |
do_query($form, $dbh, $query, @values); |
558 | 580 |
} |
559 | 581 |
|
... | ... | |
563 | 585 |
$query = |
564 | 586 |
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, taxkey, project_id, tax_id, chart_link) |
565 | 587 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, |
566 |
(SELECT taxkey_id FROM chart WHERE accno = ?), ?, |
|
588 |
(SELECT taxkey_id |
|
589 |
FROM taxkeys |
|
590 |
WHERE chart_id= (SELECT id |
|
591 |
FROM chart WHERE accno = ?) |
|
592 |
AND startdate <= ? |
|
593 |
ORDER BY startdate DESC LIMIT 1), |
|
594 |
?, |
|
567 | 595 |
(SELECT tax_id |
568 | 596 |
FROM taxkeys |
569 | 597 |
WHERE chart_id= (SELECT id |
... | ... | |
572 | 600 |
ORDER BY startdate DESC LIMIT 1), |
573 | 601 |
(SELECT link FROM chart WHERE accno = ?))|; |
574 | 602 |
@values = (conv_i($form->{id}), $accno, $form->{"paid_$i"}, $form->{"datepaid_$i"}, |
575 |
$gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, $project_id, $accno, conv_date($form->{"datepaid_$i"}), $accno); |
|
603 |
$gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $accno, conv_date($form->{"datepaid_$i"}), $project_id, $accno, conv_date($form->{"datepaid_$i"}), $accno);
|
|
576 | 604 |
do_query($form, $dbh, $query, @values); |
577 | 605 |
|
578 | 606 |
$exchangerate = 0; |
... | ... | |
612 | 640 |
|
613 | 641 |
$query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id, tax_id, chart_link) |
614 | 642 |
VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1', 0, ?, |
615 |
(SELECT tax_id |
|
616 |
FROM taxkeys |
|
617 |
WHERE chart_id= (SELECT id |
|
618 |
FROM chart |
|
619 |
WHERE accno = ?) |
|
620 |
AND startdate <= ? |
|
621 |
ORDER BY startdate DESC LIMIT 1), |
|
643 |
(SELECT id FROM tax WHERE taxkey=0 LIMIT 1), |
|
622 | 644 |
(SELECT link FROM chart WHERE accno = ?))|; |
623 |
@values = (conv_i($form->{id}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $project_id, $accno, $form->{fx}{$accno}{$transdate}, $accno);
|
|
645 |
@values = (conv_i($form->{id}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $project_id, $accno); |
|
624 | 646 |
do_query($form, $dbh, $query, @values); |
625 | 647 |
} |
626 | 648 |
} |
Auch abrufbar als: Unified diff
Bugfix von chart_link und tax_id in acc_trans
Es gab noch einige Bugs bei VK- und EK-Rechnungen.
1. Der Steuerschlüssel wurde nicht richtig geschrieben.
2. tax_id war noch an einigen Stellen NULL.