From: Jan Büren Date: Wed, 23 Feb 2022 09:12:42 +0000 (+0100) Subject: DB-Skript: Reverse Charge für Kreditorenbelege X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~160 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=692cdaa86a5808a2bd7c65a51256a43a9eb109d3;p=kivitendo-erp.git DB-Skript: Reverse Charge für Kreditorenbelege --- diff --git a/SL/DB/MetaSetup/Tax.pm b/SL/DB/MetaSetup/Tax.pm index 55aba86bc..c29a45581 100644 --- a/SL/DB/MetaSetup/Tax.pm +++ b/SL/DB/MetaSetup/Tax.pm @@ -15,6 +15,7 @@ __PACKAGE__->meta->columns( itime => { type => 'timestamp', default => 'now()' }, mtime => { type => 'timestamp' }, rate => { type => 'numeric', default => '0', not_null => 1, precision => 15, scale => 5 }, + reverse_charge_chart_id => { type => 'integer' }, skonto_purchase_chart_id => { type => 'integer' }, skonto_sales_chart_id => { type => 'integer' }, taxdescription => { type => 'text', not_null => 1 }, diff --git a/sql/Pg-upgrade2/tax_reverse_charge.sql b/sql/Pg-upgrade2/tax_reverse_charge.sql new file mode 100644 index 000000000..bf1a07d80 --- /dev/null +++ b/sql/Pg-upgrade2/tax_reverse_charge.sql @@ -0,0 +1,108 @@ +-- @tag: tax_reverse_charge +-- @description: Reverse Charge für Kreditorenbelege +-- @depends: release_3_6_0 +-- @ignore: 1 + +ALTER TABLE tax add column reverse_charge_chart_id integer; + +INSERT INTO chart ( + accno, description, + charttype, category, link, + taxkey_id + ) +SELECT + '1577','Abziehbare Vorst. nach §13b UstG 19%', + 'A', 'E', 'AP_tax:IC_taxpart:IC_taxservice', + 0 +WHERE EXISTS ( -- update only for SKR03 + SELECT coa FROM defaults + WHERE defaults.coa='Germany-DATEV-SKR03EU' AND NOT EXISTS (SELECT id from chart where accno='1577') +); + +INSERT INTO chart ( + accno, description, + charttype, category, link, + taxkey_id + ) +SELECT + '1787','Umsatzsteuer nach §13b UStG 19%', + 'A', 'I', 'AR_tax:IC_taxpart:IC_taxservice', + 0 +WHERE EXISTS ( -- update only for SKR03 + SELECT coa FROM defaults + WHERE defaults.coa='Germany-DATEV-SKR03EU' AND NOT EXISTS (SELECT id from chart where accno='1787') +); + + +INSERT INTO chart ( + accno, description, + charttype, category, link, + taxkey_id + ) +SELECT + '1407','Abziehbare Vorst. nach §13b UstG 19%', + 'A', 'E', 'AP_tax:IC_taxpart:IC_taxservice', + 0 +WHERE EXISTS ( -- update only for SKR04 + SELECT coa FROM defaults + WHERE defaults.coa='Germany-DATEV-SKR04EU' AND NOT EXISTS (SELECT id from chart where accno='1407') +); + +INSERT INTO chart ( + accno, description, + charttype, category, link, + taxkey_id + ) +SELECT + '3837','Umsatzsteuer nach §13b UStG 19%', + 'A', 'I', 'AR_tax:IC_taxpart:IC_taxservice', + 0 +WHERE EXISTS ( -- update only for SKR04 + SELECT coa FROM defaults + WHERE defaults.coa='Germany-DATEV-SKR04EU' AND NOT EXISTS (SELECT id from chart where accno='3837') +); + + + +INSERT INTO tax ( + chart_id, + reverse_charge_chart_id, + rate, + taxkey, + taxdescription, + chart_categories + ) + SELECT + (SELECT id FROM chart WHERE accno = '1577'), + (SELECT id FROM chart WHERE accno = '1787'), 0, + '94', '19% Vorsteuer und 19% Umsatzsteuer', 'EI' +WHERE EXISTS ( -- update only for SKR03 + SELECT coa FROM defaults + WHERE defaults.coa='Germany-DATEV-SKR03EU' +); + + +INSERT INTO tax ( + chart_id, + reverse_charge_chart_id, + rate, + taxkey, + taxdescription, + chart_categories + ) + SELECT + (SELECT id FROM chart WHERE accno = '1407'), + (SELECT id FROM chart WHERE accno = '3837'), 0, + '94', '19% Vorsteuer und 19% Umsatzsteuer', 'EI' +WHERE EXISTS ( -- update only for SKR03 + SELECT coa FROM defaults + WHERE defaults.coa='Germany-DATEV-SKR04EU' +); + +; +-- if not defined +insert into taxkeys(chart_id,tax_id,taxkey_id,startdate) SELECT (SELECT chart_id FROM tax WHERE taxkey = '94'),0,0,'1970-01-01' WHERE NOT EXISTS + (SELECT chart_id from taxkeys where chart_id = ( SELECT chart_id FROM tax WHERE taxkey = '94') ; +insert into taxkeys(chart_id,tax_id,taxkey_id,startdate) SELECT (SELECT reverse_charge_chart_id FROM tax WHERE taxkey = '94'),0,0,'1970-01-01' WHERE NOT EXISTS + (SELECT chart_id from taxkeys where chart_id = ( SELECT reverse_charge_chart_id FROM tax WHERE taxkey = '94'); +