diff --git a/backend/db/migrations/0061_additional_skr03_accounts.sql b/backend/db/migrations/0061_additional_skr03_accounts.sql new file mode 100644 index 0000000..a8e5572 --- /dev/null +++ b/backend/db/migrations/0061_additional_skr03_accounts.sql @@ -0,0 +1,40 @@ +WITH requested_accounts ("number", "label") AS ( + VALUES + ('1576', 'Abziehbare Vorsteuer 19 %'), + ('4110', 'Löhne'), + ('4115', 'Löhne (Konto 4115)'), + ('4120', 'Gehälter'), + ('4130', 'Gesetzliche soziale Aufwendungen'), + ('4140', 'Freiwillige soziale Aufwendungen (lohnsteuerfrei)') +) +UPDATE "accounts" AS account +SET "label" = requested."label", + "description" = NULL +FROM requested_accounts AS requested +WHERE account."accountChart" = 'skr03' + AND account."number" = requested."number"; +--> statement-breakpoint +WITH requested_accounts ("number", "label") AS ( + VALUES + ('1576', 'Abziehbare Vorsteuer 19 %'), + ('4110', 'Löhne'), + ('4115', 'Löhne (Konto 4115)'), + ('4120', 'Gehälter'), + ('4130', 'Gesetzliche soziale Aufwendungen'), + ('4140', 'Freiwillige soziale Aufwendungen (lohnsteuerfrei)') +) +INSERT INTO "accounts" ("number", "label", "description", "accountChart") +SELECT requested."number", requested."label", NULL, 'skr03' +FROM requested_accounts AS requested +WHERE NOT EXISTS ( + SELECT 1 + FROM "accounts" AS account + WHERE account."accountChart" = 'skr03' + AND account."number" = requested."number" +); +--> statement-breakpoint +SELECT setval( + pg_get_serial_sequence('accounts', 'id'), + GREATEST(COALESCE((SELECT MAX("id") FROM "accounts"), 1), 1), + true +); diff --git a/backend/db/migrations/meta/_journal.json b/backend/db/migrations/meta/_journal.json index c784b6e..5a99836 100644 --- a/backend/db/migrations/meta/_journal.json +++ b/backend/db/migrations/meta/_journal.json @@ -407,6 +407,13 @@ "when": 1786086000000, "tag": "0060_document_import_sources", "breakpoints": true + }, + { + "idx": 58, + "version": "7", + "when": 1786280400000, + "tag": "0061_additional_skr03_accounts", + "breakpoints": true } ] }