Skip to content

Commit

Permalink
Sonntag 19:00
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Hornburger committed Jan 21, 2024
1 parent ccf4a6f commit 3d170bc
Show file tree
Hide file tree
Showing 7 changed files with 383 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/constclass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class Constclass {
public readonly LOPListecollectionName: string;
public readonly EmailcollectionName: string;
public readonly NotizenkapitelcollectionName: string;
public readonly SimontabellencollectionName: string;
public readonly BAESiteID: string;
public readonly FestlegungskategoriecollectionName: string;

Expand All @@ -29,6 +30,7 @@ export class Constclass {
this.LOPListecollectionName = 'lopliste';
this.EmailcollectionName = 'email';
this.NotizenkapitelcollectionName = 'notizenkapitel';
this.SimontabellencollectionName = 'simontabellen';
this.FestlegungskategoriecollectionName = 'festlegungskategorie';
this.BAESiteID = 'baeeu.sharepoint.com,1b93d6ea-3f8b-4416-9ff1-a50aaba6f8ca,134790cc-e062-4882-ae5e-18813809cc87'; // Projekte Seite
}
Expand Down
160 changes: 160 additions & 0 deletions src/database/simontabelledbclass.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import {Document, model} from "mongoose";
import {DebugClass} from "../debug";
import {Constclass} from "../constclass";
import * as mongoose from "mongoose";
import {ISimontabellestruktur, Simontabelleshema} from "../datenstrukturen/simontabellestruktur_server";

export class SimontabelleDBClass {

private Debug: DebugClass;
private Const: Constclass;

constructor() {

this.Debug = new DebugClass();
this.Const = new Constclass();
}

public ReadSimontabelleliste(projektkey: string): Promise<any> {

try {

let SimontabellemodelClass: mongoose.Model<mongoose.Document>;
let Liste: ISimontabellestruktur[] = [];

return new Promise((resolve, reject) => {

SimontabellemodelClass = model(this.Const.SimontabellencollectionName, Simontabelleshema);

SimontabellemodelClass.find( { Deleted: false, Projektkey: projektkey } ).then((data: any) => {

data.forEach((simontabelle) => {

Liste.push(simontabelle._doc);
});

resolve(Liste);

}).catch((error: any) => {

reject(error);
});

});

} catch (error) {

this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'ReadSimontabelleliste');
}
}

public RemoveSimontabelle(simontabelle: ISimontabellestruktur): Promise<any> {

try {

let SimontabellemodelClass: mongoose.Model<mongoose.Document>;

return new Promise<any>((resolve, reject) => {

SimontabellemodelClass = model(this.Const.SimontabellencollectionName, Simontabelleshema);

SimontabellemodelClass.deleteOne({_id: simontabelle._id}).then((result: any) => {

resolve(true);

}).catch((error) => {

reject(error);
});

});

} catch (error) {

this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'RemoveSimontabelle');
}
}

public AddSimontabelle(data: ISimontabellestruktur):Promise<any> {

try {

let Simontabellemodel: mongoose.Document;

return new Promise<any>((resolve, reject) => {

delete data._id;

Simontabellemodel = this.GetSimontabelleModel(data);

Simontabellemodel.save().then((result: Document<any>) => {

resolve(result);

}).catch((error) => {

reject(error);
});
});

} catch (error) {

this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'AddSimontabelle');
}
}

public UpdateSimontabelle(data: ISimontabellestruktur):Promise<any> {

try {

let SImontabellemodelClass: mongoose.Model<mongoose.Document>;

return new Promise<any>((resolve, reject) => {

SImontabellemodelClass = model(this.Const.SimontabellencollectionName, Simontabelleshema);

SImontabellemodelClass.findById(data._id).then((simontabelle: mongoose.Document) => {

if(simontabelle) {

simontabelle.set(data);
simontabelle.save().then((result: Document) => {

resolve(result);

}).catch((error) => {

reject(error);
});
}
else {

resolve(null);
}
}).catch((error) => {

reject(error);
});
});

} catch (error) {

this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'UpdateSimontabelle');
}
}

public GetSimontabelleModel(data: ISimontabellestruktur): mongoose.Document {

try {

const SimontabellemodelClass = model(this.Const.SimontabellencollectionName, Simontabelleshema);
const Simontabellemodel: mongoose.Document = new SimontabellemodelClass(data);

return Simontabellemodel;
}
catch (error) {

this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'GetSimontabelleModel');
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import mongoose from "mongoose";

interface ISimontabellebesondereleistungstruktur {

LeistungID: string;
Nummer: string;
Titel: string;
Beschreibung: string;
Honorar: number;
};

const Simontabellebesondereleistungshema = new mongoose.Schema({

LeistungID: {type: String, required: false},
Nummer: {type: String, required: false},
Titel: {type: String, required: false},
Beschreibung: {type: String, required: false},
Honorar: {type: Number, required: false, default: 0},

}, {_id: false} );

export { ISimontabellebesondereleistungstruktur, Simontabellebesondereleistungshema };
19 changes: 19 additions & 0 deletions src/datenstrukturen/simontabelleeintragstruktur_server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import mongoose from "mongoose";

interface ISimontabelleeintragstruktur {

Buchstabe: string;
Beschreibung: string;
Von: number;
Bis: number;
Vertrag: number;
};

const Simontabelleeintragshema = new mongoose.Schema({

Buchstabe: {type: String, required: false},
Vertrag: {type: String, required: false},

}, {_id: false});

export { ISimontabelleeintragstruktur, Simontabelleeintragshema };
42 changes: 42 additions & 0 deletions src/datenstrukturen/simontabellestruktur_server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import mongoose from "mongoose";
import {Bautagebucheintragshema} from "./bautagebucheintragstruktur_server";
import {IVerfasserstruktur, Verfassershema} from "./verfasserstruktur_server";
import {ISimontabelleeintragstruktur, Simontabelleeintragshema} from "./simontabelleeintragstruktur_server";
import {
ISimontabellebesondereleistungstruktur,
Simontabellebesondereleistungshema
} from "./simontabellebesondereleistungstruktur_server";

interface ISimontabellestruktur {

_id: string;
Projektkey: string;
Leistungsphase: string;
Anlagengruppe: number;
Durchschnittswert: number;
Verfasser: IVerfasserstruktur;
Eintraegeliste: ISimontabelleeintragstruktur[];
Deleted: boolean;
Kosten: number;
Honorar: number;
Umbauzuschlag: number;
Nebenkosten: number;
Besondereleistungenliste: ISimontabellebesondereleistungstruktur[];
};

const Simontabelleshema = new mongoose.Schema({

Projektkey: {type: String, required: false},
Leistungsphase: {type: String, required: false},
Kosten: {type: Number, required: false, default: 0},
Honorar: {type: Number, required: false, default: 0},
Umbauzuschlag: {type: Number, required: false, default: 0},
Nebenkosten: {type: Number, required: false, default: 0},
Besondereleistungenliste: [Simontabellebesondereleistungshema],
Anlagengruppe: {type: Number, required: false},
Deleted: {type: Boolean, required: false, default: true},
Verfasser: Verfassershema,
Eintraegeliste: [Simontabelleeintragshema],
});

export { ISimontabellestruktur, Simontabelleshema };
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {SendLOPListeroutsClass} from "./routes/sendloplisterouts";
import {SaveLOPListeroutsClass} from "./routes/saveloplisterouts";
import {SendReminderroutsClass} from "./routes/sendreminderrouts";
import {FestlegungskategorieouterClass} from "./routes/festlegungskategorierouts";
import {SimontabelleroutsClass} from "./routes/simontabellerouts";


const app: Application = express();
Expand Down Expand Up @@ -88,6 +89,7 @@ const SendReminderrouts: SendReminderroutsClass = new SendReminderroutsClass();
const SendLOPListerouter: SendLOPListeroutsClass = new SendLOPListeroutsClass();
const SaveFestlegungenrouts: SaveFestlegungenroutsClass = new SaveFestlegungenroutsClass();
const Addsubscriptionrouts: AddsubscriptionroutsClass = new AddsubscriptionroutsClass();
const Simontabellenrouts: SimontabelleroutsClass = new SimontabelleroutsClass();
const NONE = 'NONE';

let Port: string = 'none';
Expand Down Expand Up @@ -178,6 +180,7 @@ SendReminderrouts.Init(Config);
SaveFestlegungenrouts.Init(Config);
SaveLOPListerouter.Init(Config);
Addsubscriptionrouts.Init(Config);
Simontabellenrouts.Init(Config);

Homerouter.SetRoutes();
Errorrouter.SetRoutes();
Expand Down Expand Up @@ -207,6 +210,7 @@ Emailrouter.SetRoutes();
Addsubscriptionrouts.SetRoutes();
Notizenkapitelroutes.SetRoutes();
Festlegungskategorieroutes.SetRoutes();
Simontabellenrouts.SetRoutes();

app.use('/', Homerouter.homerouter);
app.use('/.auth/login/aad/callback', Homerouter.homerouter);
Expand Down Expand Up @@ -237,6 +241,7 @@ app.use('/email', Emailrouter.emailrouter);
app.use('/subscription', Addsubscriptionrouts.subscriptionrouter);
app.use('/notizenkapitel', Notizenkapitelroutes.notizenkapitelrouter);
app.use('/festlegungskategorie', Festlegungskategorieroutes.festlegungskategorierouter);
app.use('/simontabellen', Simontabellenrouts.simontabellerouter);

// eventcallback

Expand Down
Loading

0 comments on commit 3d170bc

Please sign in to comment.