Revision f6b81fe9
Von Jan Büren vor mehr als 4 Jahren hinzugefügt
- ID f6b81fe9e746da60be1c3c8a98c244c46864523e
- Vorgänger 21d995a6
sql/Pg-upgrade2/konjunkturpaket_2020.pl | ||
---|---|---|
1 |
# @tag: konjunkturpaket_2020 |
|
2 |
# @description: Deutsches Konjunkturpaket 2020 |
|
3 |
# @depends: release_3_5_5 |
|
4 |
package SL::DBUpgrade2::konjunkturpaket_2020; |
|
5 |
|
|
6 |
use strict; |
|
7 |
use utf8; |
|
8 |
|
|
9 |
use parent qw(SL::DBUpgrade2::Base); |
|
10 |
|
|
11 |
use SL::DB::Chart; |
|
12 |
|
|
13 |
use List::MoreUtils qw(any); |
|
14 |
use Data::Dumper; |
|
15 |
|
|
16 |
sub update { |
|
17 |
my ($self) = @_; |
|
18 |
|
|
19 |
# checks: |
|
20 |
# 1. detect if client uses 4, 5 or 6 digits for ledger accnos |
|
21 |
# bonus: call fails with a good error message if client has mixed accnos |
|
22 |
# 2. create tax accnos based on the result of 1 |
|
23 |
# 3. check if created accnos are not in use, otherwise fail with a error message |
|
24 |
|
|
25 |
# do: |
|
26 |
# 1. -> create tax accnos in chart |
|
27 |
|
|
28 |
$self->{length_of_accounts} = SL::DATEV->new->check_valid_length_of_accounts(return_length => 1); |
|
29 |
|
|
30 |
die $::locale->text("invalid length of accounts") unless $self->{length_of_accounts} =~ /[4-6]/; |
|
31 |
|
|
32 |
# test foreach |
|
33 |
# $self->{length_of_accounts} = 6; |
|
34 |
|
|
35 |
foreach my $key (keys %{ $self->{accnos} }) { |
|
36 |
$self->{accnos}{$key} *=10 if $self->{length_of_accounts} == 5; |
|
37 |
$self->{accnos}{$key} *=100 if $self->{length_of_accounts} == 6; |
|
38 |
# check if chart accno already exists |
|
39 |
if (ref SL::DB::Chart->new(accno => $self->{accnos}{$key})->load(speculative => 1) eq 'SL::DB::Chart') { |
|
40 |
die $::locale->text("Chart #1 already exists, cannot safely upgrade the tax charts. Please contact your kivi admin", $self->{accnos}{$key}); |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
$self->db_query(<<EOSQL); |
|
45 |
INSERT INTO chart (accno, description, charttype, category, link, taxkey_id, pos_eur, datevautomatik) |
|
46 |
VALUES ($self->{accnos}{base_five_accno_credit}, 'Mwst reduziert reduziert', 'A', 'E','AP_tax:IC_taxpart:IC_taxservice',2,27,'f') |
|
47 |
EOSQL |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
sub run { |
|
52 |
my ($self) = @_; |
|
53 |
|
|
54 |
# 1. upgrade is only important for german companies |
|
55 |
# set only basic numbers in 4 digits for the two german DATEV standard ledgers |
|
56 |
# and upgrade |
|
57 |
|
|
58 |
if ($self->check_coa('Germany-DATEV-SKR03EU')) { |
|
59 |
$self->{accnos} = { base_five_accno_credit => 1779, |
|
60 |
base_sixt_accno_credit => 1781, |
|
61 |
base_five_accno_debit => 1579, |
|
62 |
base_sixt_accno_debit => 1811, |
|
63 |
}; |
|
64 |
$self->update; |
|
65 |
return 1; |
|
66 |
} |
|
67 |
|
|
68 |
if ($self->check_coa('Germany-DATEV-SKR04EU')) { |
|
69 |
$self->{accnos} = { base_five_accno_credit => 1459, |
|
70 |
base_sixt_accno_credit => 1472, |
|
71 |
base_five_accno_debit => 3809, |
|
72 |
base_sixt_accno_debit => 3811, |
|
73 |
}; |
|
74 |
$self->update; |
|
75 |
return 1; |
|
76 |
} |
|
77 |
|
|
78 |
if (any { $self->check_coa($_) } qw(Switzerland-deutsch-MWST-2014 Switzerland-deutsch-ohneMWST-2014 Switzerland-deutsch-Verein-2017)) { |
|
79 |
# Nichts zu tun für diese Kontenrahmen |
|
80 |
return 1; |
|
81 |
} |
|
82 |
|
|
83 |
die $::locale->text('This database upgrade is incompatible with the installed chart of accounts.'); |
|
84 |
} |
|
85 |
|
|
86 |
1; |
Auch abrufbar als: Unified diff
Konjunkturpaket Deutschland - Gerüst
Legt ein neues MwSt-Konto an, falls alle Prüfungen vorher positiv sind.
TODO:
- Alle Konten anlegen
- Konten mit Automatiksteuerkonten zum Stichtag verknüpfen
- Alte Steuerkonten mit Automatik zum Stichtag ändern