Revision b989d7cf
Von Kivitendo Admin vor mehr als 10 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
747 | 747 |
|
748 | 748 |
# connect to database |
749 | 749 |
my $dbh = $form->dbconnect($myconfig); |
750 |
|
|
750 |
# TODO: extract information about income/expense accounts from new table taxzone_chart |
|
751 | 751 |
my $query = qq|SELECT id, description, |
752 | 752 |
inventory_accno_id, |
753 |
(SELECT accno FROM chart WHERE id = inventory_accno_id) AS inventory_accno, |
|
754 |
income_accno_id_0, |
|
755 |
(SELECT accno FROM chart WHERE id = income_accno_id_0) AS income_accno_0, |
|
756 |
expense_accno_id_0, |
|
757 |
(SELECT accno FROM chart WHERE id = expense_accno_id_0) AS expense_accno_0, |
|
758 |
income_accno_id_1, |
|
759 |
(SELECT accno FROM chart WHERE id = income_accno_id_1) AS income_accno_1, |
|
760 |
expense_accno_id_1, |
|
761 |
(SELECT accno FROM chart WHERE id = expense_accno_id_1) AS expense_accno_1, |
|
762 |
income_accno_id_2, |
|
763 |
(SELECT accno FROM chart WHERE id = income_accno_id_2) AS income_accno_2, |
|
764 |
expense_accno_id_2, |
|
765 |
(select accno FROM chart WHERE id = expense_accno_id_2) AS expense_accno_2, |
|
766 |
income_accno_id_3, |
|
767 |
(SELECT accno FROM chart WHERE id = income_accno_id_3) AS income_accno_3, |
|
768 |
expense_accno_id_3, |
|
769 |
(SELECT accno FROM chart WHERE id = expense_accno_id_3) AS expense_accno_3 |
|
753 |
(SELECT accno FROM chart WHERE id = inventory_accno_id) AS inventory_accno |
|
770 | 754 |
FROM buchungsgruppen |
771 | 755 |
ORDER BY sortkey|; |
772 | 756 |
|
... | ... | |
794 | 778 |
my $dbh = $form->dbconnect($myconfig); |
795 | 779 |
|
796 | 780 |
if ($form->{id}) { |
781 |
# TODO: extract information about income/expense accounts from new table taxzone_chart |
|
797 | 782 |
$query = |
798 | 783 |
qq|SELECT description, inventory_accno_id, |
799 |
(SELECT accno FROM chart WHERE id = inventory_accno_id) AS inventory_accno, |
|
800 |
income_accno_id_0, |
|
801 |
(SELECT accno FROM chart WHERE id = income_accno_id_0) AS income_accno_0, |
|
802 |
expense_accno_id_0, |
|
803 |
(SELECT accno FROM chart WHERE id = expense_accno_id_0) AS expense_accno_0, |
|
804 |
income_accno_id_1, |
|
805 |
(SELECT accno FROM chart WHERE id = income_accno_id_1) AS income_accno_1, |
|
806 |
expense_accno_id_1, |
|
807 |
(SELECT accno FROM chart WHERE id = expense_accno_id_1) AS expense_accno_1, |
|
808 |
income_accno_id_2, |
|
809 |
(SELECT accno FROM chart WHERE id = income_accno_id_2) AS income_accno_2, |
|
810 |
expense_accno_id_2, |
|
811 |
(select accno FROM chart WHERE id = expense_accno_id_2) AS expense_accno_2, |
|
812 |
income_accno_id_3, |
|
813 |
(SELECT accno FROM chart WHERE id = income_accno_id_3) AS income_accno_3, |
|
814 |
expense_accno_id_3, |
|
815 |
(SELECT accno FROM chart WHERE id = expense_accno_id_3) AS expense_accno_3 |
|
784 |
(SELECT accno FROM chart WHERE id = inventory_accno_id) AS inventory_accno |
|
816 | 785 |
FROM buchungsgruppen |
817 | 786 |
WHERE id = ?|; |
818 | 787 |
my $sth = $dbh->prepare($query); |
SL/DB/Buchungsgruppe.pm | ||
---|---|---|
11 | 11 |
class => 'SL::DB::Chart', |
12 | 12 |
column_map => { inventory_accno_id => 'id' }, |
13 | 13 |
}, |
14 |
income_account_0 => { |
|
15 |
type => 'many to one', |
|
16 |
class => 'SL::DB::Chart', |
|
17 |
column_map => { income_accno_id_0 => 'id' }, |
|
18 |
}, |
|
19 |
income_account_1 => { |
|
20 |
type => 'many to one', |
|
21 |
class => 'SL::DB::Chart', |
|
22 |
column_map => { income_accno_id_1 => 'id' }, |
|
23 |
}, |
|
24 |
income_account_2 => { |
|
25 |
type => 'many to one', |
|
26 |
class => 'SL::DB::Chart', |
|
27 |
column_map => { income_accno_id_2 => 'id' }, |
|
28 |
}, |
|
29 |
income_account_3 => { |
|
30 |
type => 'many to one', |
|
31 |
class => 'SL::DB::Chart', |
|
32 |
column_map => { income_accno_id_3 => 'id' }, |
|
33 |
}, |
|
34 |
expense_account_0 => { |
|
35 |
type => 'many to one', |
|
36 |
class => 'SL::DB::Chart', |
|
37 |
column_map => { expense_accno_id_0 => 'id' }, |
|
38 |
}, |
|
39 |
expense_account_1 => { |
|
40 |
type => 'many to one', |
|
41 |
class => 'SL::DB::Chart', |
|
42 |
column_map => { expense_accno_id_1 => 'id' }, |
|
43 |
}, |
|
44 |
expense_account_2 => { |
|
45 |
type => 'many to one', |
|
46 |
class => 'SL::DB::Chart', |
|
47 |
column_map => { expense_accno_id_2 => 'id' }, |
|
48 |
}, |
|
49 |
expense_account_3 => { |
|
50 |
type => 'many to one', |
|
51 |
class => 'SL::DB::Chart', |
|
52 |
column_map => { expense_accno_id_3 => 'id' }, |
|
53 |
}, |
|
54 | 14 |
); |
55 | 15 |
|
56 | 16 |
__PACKAGE__->meta->initialize; |
... | ... | |
59 | 19 |
sub income_accno_id { |
60 | 20 |
my ($self, $taxzone) = @_; |
61 | 21 |
my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; |
62 |
my $method = 'income_accno_id_' . $taxzone_id; |
|
63 |
|
|
64 |
return $self->$method; |
|
22 |
my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id); |
|
23 |
return $taxzone_chart->income_accno_id if $taxzone_chart; |
|
65 | 24 |
} |
66 | 25 |
|
67 | 26 |
sub expense_accno_id { |
68 | 27 |
my ($self, $taxzone) = @_; |
69 | 28 |
my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; |
70 |
my $method = 'expense_accno_id_' . $taxzone_id; |
|
71 |
|
|
72 |
return $self->$method; |
|
29 |
my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id); |
|
30 |
return $taxzone_chart->expense_accno_id if $taxzone_chart; |
|
73 | 31 |
} |
74 | 32 |
|
75 | 33 |
sub income_account { |
76 | 34 |
my ($self, $taxzone) = @_; |
77 | 35 |
my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; |
78 |
my $method = 'income_account_' . $taxzone_id; |
|
79 |
|
|
80 |
return $self->$method; |
|
36 |
my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id); |
|
37 |
return $taxzone_chart->income_accno if $taxzone_chart; |
|
81 | 38 |
} |
82 | 39 |
|
83 | 40 |
sub expense_account { |
84 | 41 |
my ($self, $taxzone) = @_; |
85 | 42 |
my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; |
86 |
my $method = 'expense_account_' . $taxzone_id; |
|
87 |
|
|
88 |
return $self->$method; |
|
43 |
my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id); |
|
44 |
return $taxzone_chart->expense_accno if $taxzone_chart; |
|
89 | 45 |
} |
90 | 46 |
|
91 | 47 |
1; |
SL/DB/Helper/ALL.pm | ||
---|---|---|
98 | 98 |
use SL::DB::Tax; |
99 | 99 |
use SL::DB::TaxKey; |
100 | 100 |
use SL::DB::TaxZone; |
101 |
use SL::DB::TaxzoneChart; |
|
101 | 102 |
use SL::DB::TodoUserConfig; |
102 | 103 |
use SL::DB::TransferType; |
103 | 104 |
use SL::DB::Translation; |
SL/DB/Helper/Mappings.pm | ||
---|---|---|
178 | 178 |
tax => 'tax', |
179 | 179 |
taxkeys => 'tax_key', |
180 | 180 |
tax_zones => 'tax_zone', |
181 |
taxzone_charts => 'taxzone_chart', |
|
181 | 182 |
todo_user_config => 'todo_user_config', |
182 | 183 |
transfer_type => 'transfer_type', |
183 | 184 |
translation => 'translation', |
SL/DB/MetaSetup/Buchungsgruppe.pm | ||
---|---|---|
10 | 10 |
|
11 | 11 |
__PACKAGE__->meta->columns( |
12 | 12 |
description => { type => 'text' }, |
13 |
expense_accno_id_0 => { type => 'integer' }, |
|
14 |
expense_accno_id_1 => { type => 'integer' }, |
|
15 |
expense_accno_id_2 => { type => 'integer' }, |
|
16 |
expense_accno_id_3 => { type => 'integer' }, |
|
17 |
id => { type => 'integer', not_null => 1, sequence => 'id' }, |
|
18 |
income_accno_id_0 => { type => 'integer' }, |
|
19 |
income_accno_id_1 => { type => 'integer' }, |
|
20 |
income_accno_id_2 => { type => 'integer' }, |
|
21 |
income_accno_id_3 => { type => 'integer' }, |
|
22 | 13 |
inventory_accno_id => { type => 'integer' }, |
23 | 14 |
sortkey => { type => 'integer', not_null => 1 }, |
24 | 15 |
); |
SL/DB/MetaSetup/TaxzoneChart.pm | ||
---|---|---|
1 |
# This file has been auto-generated. Do not modify it; it will be overwritten |
|
2 |
# by rose_auto_create_model.pl automatically. |
|
3 |
package SL::DB::TaxzoneChart; |
|
4 |
|
|
5 |
use strict; |
|
6 |
|
|
7 |
use base qw(SL::DB::Object); |
|
8 |
|
|
9 |
__PACKAGE__->meta->table('taxzone_charts'); |
|
10 |
|
|
11 |
__PACKAGE__->meta->columns( |
|
12 |
id => { type => 'serial', not_null => 1 }, |
|
13 |
taxzone_id => { type => 'integer', not_null => 1 }, |
|
14 |
buchungsgruppen_id => { type => 'integer', not_null => 1 }, |
|
15 |
income_accno_id => { type => 'integer', not_null => 1 }, |
|
16 |
expense_accno_id => { type => 'integer', not_null => 1 }, |
|
17 |
itime => { type => 'timestamp', default => 'now()' }, |
|
18 |
); |
|
19 |
|
|
20 |
__PACKAGE__->meta->primary_key_columns([ 'id' ]); |
|
21 |
|
|
22 |
__PACKAGE__->meta->allow_inline_column_values(1); |
|
23 |
|
|
24 |
__PACKAGE__->meta->foreign_keys( |
|
25 |
buchungsgruppen => { |
|
26 |
class => 'SL::DB::Buchungsgruppe', |
|
27 |
key_columns => { buchungsgruppen_id => 'id' }, |
|
28 |
}, |
|
29 |
|
|
30 |
expense_accno => { |
|
31 |
class => 'SL::DB::Chart', |
|
32 |
key_columns => { expense_accno_id => 'id' }, |
|
33 |
}, |
|
34 |
|
|
35 |
income_accno => { |
|
36 |
class => 'SL::DB::Chart', |
|
37 |
key_columns => { income_accno_id => 'id' }, |
|
38 |
}, |
|
39 |
); |
|
40 |
|
|
41 |
# __PACKAGE__->meta->initialize; |
|
42 |
|
|
43 |
1; |
|
44 |
; |
SL/DB/Part.pm | ||
---|---|---|
174 | 174 |
require SL::DB::Buchungsgruppe; |
175 | 175 |
my $bugru = SL::DB::Buchungsgruppe->load_cached($self->buchungsgruppen_id); |
176 | 176 |
my $chart_id = ($type eq 'inventory') ? ($self->inventory_accno_id ? $bugru->inventory_accno_id : undef) |
177 |
: $bugru->call_sub("${type}_accno_id_${taxzone}");
|
|
177 |
: $bugru->call_sub("${type}_accno_id", $taxzone);
|
|
178 | 178 |
|
179 | 179 |
if ($chart_id) { |
180 | 180 |
my $chart = $all_charts->{$chart_id} // SL::DB::Chart->load_cached($chart_id)->load; |
SL/DB/TaxzoneChart.pm | ||
---|---|---|
1 |
# This file has been auto-generated only because it didn't exist. |
|
2 |
# Feel free to modify it at will; it will not be overwritten automatically. |
|
3 |
|
|
4 |
package SL::DB::TaxzoneChart; |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
use SL::DB::MetaSetup::TaxzoneChart; |
|
9 |
|
|
10 |
__PACKAGE__->meta->initialize; |
|
11 |
|
|
12 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
13 |
__PACKAGE__->meta->make_manager_class; |
|
14 |
|
|
15 |
1; |
SL/IC.pm | ||
---|---|---|
319 | 319 |
|
320 | 320 |
if ($form->{"item"} ne "assembly") { |
321 | 321 |
$subq_expense = |
322 |
qq|(SELECT bg.expense_accno_id_0
|
|
323 |
FROM buchungsgruppen bg
|
|
324 |
WHERE bg.id = | . conv_i($form->{"buchungsgruppen_id"}, 'NULL') . qq|)|;
|
|
322 |
qq|(SELECT tc.expense_accno_id
|
|
323 |
FROM taxzone_charts tc
|
|
324 |
WHERE tc.buchungsgruppen_id = | . conv_i($form->{"buchungsgruppen_id"}, 'NULL') . qq| and tc.taxzone_id = 0)|;
|
|
325 | 325 |
} else { |
326 | 326 |
$subq_expense = "NULL"; |
327 | 327 |
} |
... | ... | |
348 | 348 |
buchungsgruppen_id = ?, |
349 | 349 |
payment_id = ?, |
350 | 350 |
inventory_accno_id = $subq_inventory, |
351 |
income_accno_id = (SELECT bg.income_accno_id_0 FROM buchungsgruppen bg WHERE bg.id = ?),
|
|
351 |
income_accno_id = (SELECT tc.income_accno_id FROM taxzone_charts tc WHERE tc.taxzone_id = 0 and tc.buchungsgruppen_id = ?),
|
|
352 | 352 |
expense_accno_id = $subq_expense, |
353 | 353 |
obsolete = ?, |
354 | 354 |
image = ?, |
... | ... | |
1541 | 1541 |
SELECT |
1542 | 1542 |
p.id, p.inventory_accno_id AS is_part, |
1543 | 1543 |
bg.inventory_accno_id, |
1544 |
bg.income_accno_id_$form->{taxzone_id} AS income_accno_id,
|
|
1545 |
bg.expense_accno_id_$form->{taxzone_id} AS expense_accno_id,
|
|
1544 |
tc.income_accno_id AS income_accno_id,
|
|
1545 |
tc.expense_accno_id AS expense_accno_id,
|
|
1546 | 1546 |
c1.accno AS inventory_accno, |
1547 | 1547 |
c2.accno AS income_accno, |
1548 | 1548 |
c3.accno AS expense_accno |
1549 | 1549 |
FROM parts p |
1550 | 1550 |
LEFT JOIN buchungsgruppen bg ON p.buchungsgruppen_id = bg.id |
1551 |
LEFT JOIN taxzone_charts tc on bg.id = tc.buchungsgruppen_id |
|
1551 | 1552 |
LEFT JOIN chart c1 ON bg.inventory_accno_id = c1.id |
1552 |
LEFT JOIN chart c2 ON bg.income_accno_id_$form->{taxzone_id} = c2.id |
|
1553 |
LEFT JOIN chart c3 ON bg.expense_accno_id_$form->{taxzone_id} = c3.id |
|
1554 |
WHERE p.id IN ($in) |
|
1553 |
LEFT JOIN chart c2 ON tc.income_accno_id = c2.id |
|
1554 |
LEFT JOIN chart c3 ON tc.expense_accno_id = c3.id |
|
1555 |
WHERE |
|
1556 |
tc.taxzone_id = '$form->{taxzone_id}' |
|
1557 |
and |
|
1558 |
p.id IN ($in) |
|
1555 | 1559 |
SQL |
1556 | 1560 |
|
1557 | 1561 |
my $sth_tax = prepare_query($::form, $dbh, <<SQL); |
SL/IR.pm | ||
---|---|---|
221 | 221 |
my $taxzone = $form->{taxzone_id} * 1; |
222 | 222 |
$query = |
223 | 223 |
qq|SELECT i.id, i.qty, i.allocated, i.trans_id, i.base_qty, |
224 |
bg.inventory_accno_id, bg.expense_accno_id_${taxzone} AS expense_accno_id, a.transdate
|
|
225 |
FROM invoice i, ar a, parts p, buchungsgruppen bg |
|
224 |
bg.inventory_accno_id, tc.expense_accno_id AS expense_accno_id, a.transdate
|
|
225 |
FROM invoice i, ar a, parts p, buchungsgruppen bg, taxzone_charts tc
|
|
226 | 226 |
WHERE (i.parts_id = p.id) |
227 | 227 |
AND (i.parts_id = ?) |
228 | 228 |
AND ((i.base_qty + i.allocated) > 0) |
229 | 229 |
AND (i.trans_id = a.id) |
230 | 230 |
AND (p.buchungsgruppen_id = bg.id) |
231 |
AND (tc.buchungsgruppen_id = p.buchungsgruppen_id) |
|
232 |
AND (tc.taxzone_id = ${taxzone}) |
|
231 | 233 |
ORDER BY transdate|; |
232 | 234 |
# ORDER BY transdate guarantees FIFO |
233 | 235 |
|
... | ... | |
980 | 982 |
FROM invoice i |
981 | 983 |
JOIN parts p ON (i.parts_id = p.id) |
982 | 984 |
LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id) |
983 |
LEFT JOIN chart c2 ON ((SELECT income_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c2.id)
|
|
984 |
LEFT JOIN chart c3 ON ((SELECT expense_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c3.id)
|
|
985 |
LEFT JOIN chart c2 ON ((SELECT tc.income_accno_id FROM taxzone_charts tc where tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c2.id)
|
|
986 |
LEFT JOIN chart c3 ON ((SELECT tc.expense_accno_id FROM taxzone_charts tc where tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c3.id)
|
|
985 | 987 |
LEFT JOIN project pr ON (i.project_id = pr.id) |
986 | 988 |
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id) |
987 | 989 |
|
... | ... | |
1248 | 1250 |
FROM buchungsgruppen |
1249 | 1251 |
WHERE id = p.buchungsgruppen_id) = c1.id) |
1250 | 1252 |
LEFT JOIN chart c2 ON |
1251 |
((SELECT income_accno_id_${taxzone_id}
|
|
1252 |
FROM buchungsgruppen
|
|
1253 |
WHERE id = p.buchungsgruppen_id) = c2.id) |
|
1253 |
((SELECT tc.income_accno_id
|
|
1254 |
FROM taxzone_charts tc
|
|
1255 |
WHERE tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c2.id)
|
|
1254 | 1256 |
LEFT JOIN chart c3 ON |
1255 |
((SELECT expense_accno_id_${taxzone_id}
|
|
1256 |
FROM buchungsgruppen
|
|
1257 |
WHERE id = p.buchungsgruppen_id) = c3.id) |
|
1257 |
((SELECT tc.expense_accno_id
|
|
1258 |
FROM taxzone_charts tc
|
|
1259 |
WHERE tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c3.id)
|
|
1258 | 1260 |
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id) |
1259 | 1261 |
LEFT JOIN price_factors pfac ON (pfac.id = p.price_factor_id) |
1260 | 1262 |
WHERE $where|; |
SL/IS.pm | ||
---|---|---|
1392 | 1392 |
c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid |
1393 | 1393 |
FROM invoice i, parts p |
1394 | 1394 |
LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id) |
1395 |
LEFT JOIN chart c2 ON ((SELECT income_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c2.id)
|
|
1396 |
LEFT JOIN chart c3 ON ((select expense_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c3.id)
|
|
1395 |
LEFT JOIN chart c2 ON ((SELECT tc.income_accno_id FROM taxzone_charts tc WHERE tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c2.id)
|
|
1396 |
LEFT JOIN chart c3 ON ((SELECT tc.expense_accno_id FROM taxzone_charts tc WHERE tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c3.id)
|
|
1397 | 1397 |
WHERE (i.parts_id = p.id) |
1398 | 1398 |
AND (i.parts_id = ?) |
1399 | 1399 |
AND ((i.base_qty + i.allocated) < 0) |
... | ... | |
1661 | 1661 |
LEFT JOIN pricegroup prg ON (i.pricegroup_id = prg.id) |
1662 | 1662 |
|
1663 | 1663 |
LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id) |
1664 |
LEFT JOIN chart c2 ON ((SELECT income_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c2.id)
|
|
1665 |
LEFT JOIN chart c3 ON ((SELECT expense_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c3.id)
|
|
1664 |
LEFT JOIN chart c2 ON ((SELECT tc.income_accno_id FROM taxzone_charts tc WHERE tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c2.id)
|
|
1665 |
LEFT JOIN chart c3 ON ((SELECT tc.expense_accno_id FROM taxzone_charts tc WHERE tc.taxzone_id = '$taxzone_id' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c3.id)
|
|
1666 | 1666 |
|
1667 | 1667 |
WHERE (i.trans_id = ?) AND NOT (i.assemblyitem = '1') ORDER BY i.id|; |
1668 | 1668 |
|
... | ... | |
1959 | 1959 |
FROM buchungsgruppen |
1960 | 1960 |
WHERE id = p.buchungsgruppen_id) = c1.id) |
1961 | 1961 |
LEFT JOIN chart c2 ON |
1962 |
((SELECT income_accno_id_${taxzone_id}
|
|
1963 |
FROM buchungsgruppen
|
|
1964 |
WHERE id = p.buchungsgruppen_id) = c2.id)
|
|
1962 |
((SELECT tc.income_accno_id
|
|
1963 |
FROM taxzone_charts tc
|
|
1964 |
WHERE tc.buchungsgruppen_id = p.buchungsgruppen_id and tc.taxzone_id = ${taxzone_id}) = c2.id)
|
|
1965 | 1965 |
LEFT JOIN chart c3 ON |
1966 |
((SELECT expense_accno_id_${taxzone_id}
|
|
1967 |
FROM buchungsgruppen
|
|
1968 |
WHERE id = p.buchungsgruppen_id) = c3.id)
|
|
1966 |
((SELECT tc.expense_accno_id
|
|
1967 |
FROM taxzone_charts tc
|
|
1968 |
WHERE tc.buchungsgruppen_id = p.buchungsgruppen_id and tc.taxzone_id = ${taxzone_id}) = c3.id)
|
|
1969 | 1969 |
LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id) |
1970 | 1970 |
LEFT JOIN price_factors pfac ON (pfac.id = p.price_factor_id) |
1971 | 1971 |
WHERE $where|; |
SL/OE.pm | ||
---|---|---|
922 | 922 |
JOIN parts p ON (o.parts_id = p.id) |
923 | 923 |
JOIN oe ON (o.trans_id = oe.id) |
924 | 924 |
LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id=p.buchungsgruppen_id) = c1.id) |
925 |
LEFT JOIN chart c2 ON ((SELECT income_accno_id_$form->{taxzone_id} FROM buchungsgruppen WHERE id=p.buchungsgruppen_id) = c2.id)
|
|
926 |
LEFT JOIN chart c3 ON ((SELECT expense_accno_id_$form->{taxzone_id} FROM buchungsgruppen WHERE id=p.buchungsgruppen_id) = c3.id)
|
|
925 |
LEFT JOIN chart c2 ON ((SELECT tc.income_accno_id FROM taxzone_charts tc WHERE tc.taxzone_id = '$form->{taxzone_id}' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c2.id)
|
|
926 |
LEFT JOIN chart c3 ON ((SELECT tc.expense_accno_id FROM taxzone_charts tc WHERE tc.taxzone_id = '$form->{taxzone_id}' and tc.buchungsgruppen_id = p.buchungsgruppen_id) = c3.id)
|
|
927 | 927 |
LEFT JOIN project pr ON (o.project_id = pr.id) |
928 | 928 |
LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) | . |
929 | 929 |
($form->{id} |
sql/Pg-upgrade2/convert_taxzone.pl | ||
---|---|---|
1 |
# @tag: convert_taxzone |
|
2 |
# @description: Setzt Fremdschlüssel und andere constraints auf die Tabellen tax und taxkeys |
|
3 |
# @depends: taxzone_charts |
|
4 |
package SL::DBUpgrade2::convert_taxzone; |
|
5 |
|
|
6 |
use strict; |
|
7 |
use utf8; |
|
8 |
|
|
9 |
use parent qw(SL::DBUpgrade2::Base); |
|
10 |
|
|
11 |
sub run { |
|
12 |
my ($self) = @_; |
|
13 |
|
|
14 |
# extract all buchungsgruppen data |
|
15 |
my $buchungsgruppen_query = <<SQL; |
|
16 |
SELECT * from buchungsgruppen; |
|
17 |
SQL |
|
18 |
|
|
19 |
my $sth = $self->dbh->prepare($buchungsgruppen_query); |
|
20 |
$sth->execute || $::form->dberror($buchungsgruppen_query); |
|
21 |
|
|
22 |
$::form->{buchungsgruppen} = []; |
|
23 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
24 |
push @{ $::form->{buchungsgruppen} }, $ref; |
|
25 |
} |
|
26 |
$sth->finish; |
|
27 |
|
|
28 |
# extract all tax_zone data |
|
29 |
my $taxzone_query = <<SQL; |
|
30 |
SELECT * from tax_zones; |
|
31 |
SQL |
|
32 |
|
|
33 |
$sth = $self->dbh->prepare($taxzone_query); |
|
34 |
$sth->execute || $::form->dberror($taxzone_query); |
|
35 |
|
|
36 |
$::form->{taxzones} = []; |
|
37 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
38 |
push @{ $::form->{taxzones} }, $ref; |
|
39 |
} |
|
40 |
$sth->finish; |
|
41 |
|
|
42 |
my $taxzone_charts_update_query; |
|
43 |
foreach my $taxzone ( @{$::form->{taxzones}} ) { |
|
44 |
foreach my $buchungsgruppe ( @{$::form->{buchungsgruppen}} ) { |
|
45 |
my $id = $taxzone->{id}; |
|
46 |
my $income_accno_id = $buchungsgruppe->{"income_accno_id_$id"}; |
|
47 |
my $expense_accno_id = $buchungsgruppe->{"expense_accno_id_$id"}; |
|
48 |
# TODO: check if the variables have a value |
|
49 |
$taxzone_charts_update_query .= "INSERT INTO taxzone_charts (taxzone_id, buchungsgruppen_id, income_accno_id, expense_accno_id) VALUES ('$taxzone->{id}', '$buchungsgruppe->{id}', $income_accno_id, $expense_accno_id);\n"; |
|
50 |
}; |
|
51 |
}; |
|
52 |
$self->db_query($taxzone_charts_update_query); |
|
53 |
|
|
54 |
my $clean_buchungsgruppen_query = <<SQL; |
|
55 |
alter table buchungsgruppen drop column income_accno_id_0; |
|
56 |
alter table buchungsgruppen drop column income_accno_id_1; |
|
57 |
alter table buchungsgruppen drop column income_accno_id_2; |
|
58 |
alter table buchungsgruppen drop column income_accno_id_3; |
|
59 |
alter table buchungsgruppen drop column expense_accno_id_0; |
|
60 |
alter table buchungsgruppen drop column expense_accno_id_1; |
|
61 |
alter table buchungsgruppen drop column expense_accno_id_2; |
|
62 |
alter table buchungsgruppen drop column expense_accno_id_3; |
|
63 |
SQL |
|
64 |
$sth = $self->dbh->prepare($clean_buchungsgruppen_query); |
|
65 |
$sth->execute || $::form->dberror($clean_buchungsgruppen_query); |
|
66 |
return 1; |
|
67 |
} # end run |
|
68 |
|
|
69 |
1; |
sql/Pg-upgrade2/taxzones.sql | ||
---|---|---|
1 |
-- @tag: taxzone_charts |
|
2 |
-- @description: Neue Tabelle für Buchungskonten der Steuerzonen |
|
3 |
-- @depends: release_3_0_0 |
|
4 |
-- @ignore: 0 |
|
5 |
|
|
6 |
CREATE TABLE taxzone_charts ( |
|
7 |
id SERIAL PRIMARY KEY, |
|
8 |
taxzone_id integer NOT NULL, |
|
9 |
buchungsgruppen_id integer NOT NULL, |
|
10 |
income_accno_id integer NOT NULL, |
|
11 |
expense_accno_id integer NOT NULL, |
|
12 |
itime timestamp DEFAULT now(), |
|
13 |
FOREIGN KEY (taxzone_id) REFERENCES tax_zones (id), |
|
14 |
FOREIGN KEY (income_accno_id) REFERENCES chart (id), |
|
15 |
FOREIGN KEY (expense_accno_id) REFERENCES chart (id), |
|
16 |
FOREIGN KEY (buchungsgruppen_id) REFERENCES buchungsgruppen (id) |
|
17 |
); |
|
18 |
|
|
19 |
|
Auch abrufbar als: Unified diff
Auf Datenbankebene Steuerzonen konfigurierbar gemacht
Damit können jetzt mehr als die 4 Standardsteuerzonen eingerichtet
werden. Die bisherigen Steuerzonen wurden aus der Tabelle
buchungsgruppen in die neue Tabelle taxzone_charts ausgelagert.
Konzeption siehe Ticket #2295
Es wurden noch keinerlei Veränderungen an der Kivitendo
Benutzeroberfläche durchgeführt, durch dieses Upgrade können die
Buchungsgruppen also nicht mehr konfiguriert werden, dies muß auf
Datenbankebene passieren.
Rose schon angepasst.
Conflicts: