u
This commit is contained in:
10
.env
10
.env
@@ -1,10 +0,0 @@
|
||||
GOOGLE_CLIENT_ID=928121624463-jbgfdlgem22scs1k9c87ucg4ffvaik6o.apps.googleusercontent.com
|
||||
GOOGLE_CLIENT_SECRET=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
|
||||
REACT_APP_GOOGLE_CLIENT_ID=928121624463-jbgfdlgem22scs1k9c87ucg4ffvaik6o.apps.googleusercontent.com
|
||||
AUTHORIZED_EMAILS=sebgreenbus@gmail.com,growsdd@gmail.com
|
||||
JWT_SECRET=7vK2gQp9zX1wR4eT6sB8uN0cLmY5aV3j
|
||||
DB_SERVER=192.168.56.1
|
||||
DB_DATABASE=eazybusiness
|
||||
DB_USERNAME=app
|
||||
DB_PASSWORD=readonly
|
||||
DB_PORT=1497
|
||||
@@ -1,6 +1,14 @@
|
||||
|
||||
-- Create fibdash schema
|
||||
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'fibdash')
|
||||
BEGIN
|
||||
EXEC('CREATE SCHEMA fibdash')
|
||||
END
|
||||
GO
|
||||
|
||||
|
||||
-- Create Kreditor table
|
||||
CREATE TABLE Kreditor (
|
||||
CREATE TABLE fibdash.Kreditor (
|
||||
id INT IDENTITY(1,1) PRIMARY KEY,
|
||||
iban NVARCHAR(34) NOT NULL,
|
||||
name NVARCHAR(255) NOT NULL,
|
||||
@@ -8,12 +16,12 @@ CREATE TABLE Kreditor (
|
||||
);
|
||||
|
||||
-- Ensure kreditorId is unique to support FK references
|
||||
ALTER TABLE Kreditor
|
||||
ALTER TABLE fibdash.Kreditor
|
||||
ADD CONSTRAINT UQ_Kreditor_kreditorId UNIQUE (kreditorId);
|
||||
|
||||
-- Create AccountingItems table
|
||||
-- Based on CSV structure: umsatz brutto, soll/haben kz, konto, gegenkonto, bu, buchungsdatum, rechnungsnummer, buchungstext, beleglink
|
||||
CREATE TABLE AccountingItems (
|
||||
CREATE TABLE fibdash.AccountingItems (
|
||||
id INT IDENTITY(1,1) PRIMARY KEY,
|
||||
umsatz_brutto DECIMAL(15,2) NOT NULL, -- gross turnover amount
|
||||
soll_haben_kz CHAR(1) NOT NULL CHECK (soll_haben_kz IN ('S', 'H')), -- S = eingang (debit), H = ausgang (credit)
|
||||
@@ -27,19 +35,27 @@ CREATE TABLE AccountingItems (
|
||||
);
|
||||
|
||||
-- Create Konto table
|
||||
CREATE TABLE Konto (
|
||||
CREATE TABLE fibdash.Konto (
|
||||
id INT IDENTITY(1,1) PRIMARY KEY,
|
||||
konto NVARCHAR(10) NOT NULL,
|
||||
name NVARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
-- Create BU table
|
||||
CREATE TABLE BU (
|
||||
-- Ensure Konto.konto is unique to support FK references
|
||||
ALTER TABLE fibdash.Konto
|
||||
ADD CONSTRAINT UQ_Konto_konto UNIQUE (konto);
|
||||
|
||||
-- Create BU table
|
||||
CREATE TABLE fibdash.BU (
|
||||
id INT IDENTITY(1,1) PRIMARY KEY,
|
||||
bu NVARCHAR(10) NOT NULL
|
||||
bu NVARCHAR(10) NOT NULL,
|
||||
name NVARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
-- Ensure BU.bu is unique to support FK references
|
||||
ALTER TABLE fibdash.BU
|
||||
ADD CONSTRAINT UQ_BU_bu UNIQUE (bu);
|
||||
|
||||
/*
|
||||
CSV
|
||||
umsatz brutto ,
|
||||
@@ -65,32 +81,28 @@ CSV
|
||||
*/
|
||||
|
||||
-- Create indexes for better performance
|
||||
CREATE INDEX IX_Users_Email ON Users(email);
|
||||
CREATE INDEX IX_Users_GoogleId ON Users(google_id);
|
||||
CREATE INDEX IX_UserPreferences_UserId ON UserPreferences(user_id);
|
||||
CREATE INDEX IX_Kreditor_IBAN ON Kreditor(iban);
|
||||
CREATE INDEX IX_Kreditor_KreditorId ON Kreditor(kreditorId);
|
||||
CREATE INDEX IX_AccountingItems_Buchungsdatum ON AccountingItems(buchungsdatum);
|
||||
CREATE INDEX IX_AccountingItems_Konto ON AccountingItems(konto);
|
||||
CREATE INDEX IX_AccountingItems_Rechnungsnummer ON AccountingItems(rechnungsnummer);
|
||||
CREATE INDEX IX_AccountingItems_SollHabenKz ON AccountingItems(soll_haben_kz);
|
||||
CREATE INDEX IX_Kreditor_IBAN ON fibdash.Kreditor(iban);
|
||||
CREATE INDEX IX_Kreditor_KreditorId ON fibdash.Kreditor(kreditorId);
|
||||
CREATE INDEX IX_AccountingItems_Buchungsdatum ON fibdash.AccountingItems(buchungsdatum);
|
||||
CREATE INDEX IX_AccountingItems_Konto ON fibdash.AccountingItems(konto);
|
||||
CREATE INDEX IX_AccountingItems_Rechnungsnummer ON fibdash.AccountingItems(rechnungsnummer);
|
||||
CREATE INDEX IX_AccountingItems_SollHabenKz ON fibdash.AccountingItems(soll_haben_kz);
|
||||
|
||||
-- Add FK from AccountingItems.bu -> BU(bu)
|
||||
ALTER TABLE AccountingItems
|
||||
ALTER TABLE fibdash.AccountingItems
|
||||
ADD CONSTRAINT FK_AccountingItems_BU_BU
|
||||
FOREIGN KEY (bu) REFERENCES BU(bu);
|
||||
FOREIGN KEY (bu) REFERENCES fibdash.BU(bu);
|
||||
|
||||
-- Add FK from AccountingItems.gegenkonto -> Kreditor(kreditorId)
|
||||
ALTER TABLE AccountingItems
|
||||
ALTER TABLE fibdash.AccountingItems
|
||||
ADD CONSTRAINT FK_AccountingItems_Gegenkonto_Kreditor
|
||||
FOREIGN KEY (gegenkonto) REFERENCES Kreditor(kreditorId);
|
||||
FOREIGN KEY (gegenkonto) REFERENCES fibdash.Kreditor(kreditorId);
|
||||
|
||||
-- Add FK from AccountingItems.konto -> Konto(konto)
|
||||
ALTER TABLE AccountingItems
|
||||
ALTER TABLE fibdash.AccountingItems
|
||||
ADD CONSTRAINT FK_AccountingItems_Konto_Konto
|
||||
FOREIGN KEY (konto) REFERENCES Konto(konto);
|
||||
FOREIGN KEY (konto) REFERENCES fibdash.Konto(konto);
|
||||
|
||||
-- Insert sample data (optional)
|
||||
-- Note: This will only work after you have real Google user data
|
||||
-- INSERT INTO Users (google_id, email, name, picture)
|
||||
-- VALUES ('sample_google_id', 'user@example.com', 'Lorem Ipsum User', 'https://example.com/picture.jpg');
|
||||
-- INSERT INTO fibdash.Kreditor (iban, name, kreditorId)
|
||||
-- VALUES ('DE89370400440532013000', 'Sample Kreditor', '70001');
|
||||
Reference in New Issue
Block a user