From 3afbacf294bdbe21b08047c0a9fc1ad92f4c5c37 Mon Sep 17 00:00:00 2001
From: Philip Reetz
Date: Mon, 11 Dec 2006 10:30:47 +0000
Subject: [PATCH] Neue Berechnung der Steuersaetze
---
SL/IR.pm | 12 ++++++------
SL/IS.pm | 10 +++++-----
SL/OE.pm | 6 +++---
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/SL/IR.pm b/SL/IR.pm
index 90a17e0b3..c84778110 100644
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -927,10 +927,10 @@ sub retrieve_invoice {
# get tax rates and description
$accno_id =
($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
- $query = qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
- FROM tax t LEFT join chart c ON (c.id=t.chart_id)
- WHERE t.taxkey in (SELECT taxkey_id from chart where accno = '$accno_id')
- ORDER BY accno|;
+ $query = qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
+ FROM tax t LEFT JOIN chart c on (c.id=t.chart_id)
+ WHERE t.id in (SELECT tk.tax_id from taxkeys tk where tk.chart_id = (SELECT id from chart WHERE accno='$accno_id') AND startdate<=$transdate ORDER BY startdate desc LIMIT 1)
+ ORDER BY c.accno|;
$stw = $dbh->prepare($query);
$stw->execute || $form->dberror($query);
$ref->{taxaccounts} = "";
@@ -1177,8 +1177,8 @@ sub retrieve_item {
$accno_id =
($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
$query = qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
- FROM tax t LEFT JOIN chart c ON (c.id=t.chart_id)
- WHERE t.taxkey in (SELECT taxkey_id from chart where accno = '$accno_id')
+ FROM tax t LEFT JOIN chart c on (c.id=t.chart_id)
+ WHERE t.id in (SELECT tk.tax_id from taxkeys tk where tk.chart_id = (SELECT id from chart WHERE accno='$accno_id') AND startdate<=$transdate ORDER BY startdate desc LIMIT 1)
ORDER BY c.accno|;
$stw = $dbh->prepare($query);
$stw->execute || $form->dberror($query);
diff --git a/SL/IS.pm b/SL/IS.pm
index 7943fa60f..ba1062b05 100644
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -1597,10 +1597,10 @@ sub retrieve_invoice {
# get tax rates and description
$accno_id =
($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
- $query = qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
- FROM tax t LEFT join chart c ON (c.id=t.chart_id)
- WHERE t.taxkey in (SELECT taxkey_id from chart where accno = '$accno_id')
- ORDER BY accno|;
+ $query = qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
+ FROM tax t LEFT JOIN chart c on (c.id=t.chart_id)
+ WHERE t.id in (SELECT tk.tax_id from taxkeys tk where tk.chart_id = (SELECT id from chart WHERE accno='$accno_id') AND startdate<=$transdate ORDER BY startdate desc LIMIT 1)
+ ORDER BY c.accno|;
$stw = $dbh->prepare($query);
$stw->execute || $form->dberror($query);
$ref->{taxaccounts} = "";
@@ -1957,7 +1957,7 @@ sub retrieve_item {
($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
$query = qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
FROM tax t LEFT JOIN chart c on (c.id=t.chart_id)
- WHERE t.taxkey in (SELECT c2.taxkey_id from chart c2 where c2.accno = '$accno_id')
+ WHERE t.id in (SELECT tk.tax_id from taxkeys tk where tk.chart_id = (SELECT id from chart WHERE accno='$accno_id') AND startdate<=$transdate ORDER BY startdate desc LIMIT 1)
ORDER BY c.accno|;
$stw = $dbh->prepare($query);
$stw->execute || $form->dberror($query);
diff --git a/SL/OE.pm b/SL/OE.pm
index 5dc3128f5..c5e36654d 100644
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -872,9 +872,9 @@ sub retrieve {
$accno_id =
($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno};
$query = qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber
- FROM tax t LEFT JOIN chart c ON (c.id=t.chart_id)
- WHERE t.taxkey in (SELECT taxkey_id from chart where accno = '$accno_id')
- ORDER BY accno|;
+ FROM tax t LEFT JOIN chart c on (c.id=t.chart_id)
+ WHERE t.id in (SELECT tk.tax_id from taxkeys tk where tk.chart_id = (SELECT id from chart WHERE accno='$accno_id') AND startdate<=$transdate ORDER BY startdate desc LIMIT 1)
+ ORDER BY c.accno|;
$stw = $dbh->prepare($query);
$stw->execute || $form->dberror($query);
$ref->{taxaccounts} = "";
--
2.20.1