Skip to content

Commit

Permalink
feat: squashed commit of major page overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseydah authored and fr-ser committed Oct 26, 2024
1 parent a51ac92 commit aee1bf9
Show file tree
Hide file tree
Showing 50 changed files with 2,105 additions and 186 deletions.
16 changes: 16 additions & 0 deletions backend/src/global/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,19 @@ export function round(number: number, decimals: number = 0): number {
export function formatIsoDateString(isoDate: string): string {
return new Date(isoDate).toLocaleDateString("de-DE");
}
export function getNetAmount(item?: number, price?: number) {
if (item && price) {
return item * price;
} else {
return undefined;
}
}
export function getVatAmount(amount?: number, price?: number, date?: string) {
const netto = getNetAmount(amount, price);

if (netto) {
return netto * getVatRate({ isoDate: date });
} else {
return undefined;
}
}
6 changes: 6 additions & 0 deletions backend/src/global/types/appTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ export enum ClientSalutation {
misses_doctor = "Frau Dr.",
mister_doctor = "Herr Dr.",
}

export enum SubItemKind {
offer = "OFFER",
invoice = "INVOICE",
overdueNotice = "OVERDUE",
}
18 changes: 17 additions & 1 deletion backend/src/global/types/dataEditTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import type { Article, Client, Invoice, InvoiceItem, Offer, OfferItem, Order } from "./entities";
import type {
Article,
Client,
Invoice,
InvoiceItem,
Offer,
OfferItem,
Order,
OverdueNotice,
} from "./entities";

export type ClientCreate = Omit<Client, "id" | "created_at" | "updated_at">;
export type ClientUpdate = Partial<Omit<Client, "id">>;
Expand Down Expand Up @@ -32,3 +41,10 @@ export type InvoiceCreate = Omit<
export type InvoiceUpdate = Partial<Omit<Invoice, "id">>;

export type OfferUpdate = Partial<Omit<Offer, "id">>;

export type OverdueNoticeCreate = Omit<
OverdueNotice,
"id" | "order" | "invoice_documents" | "created_at" | "updated_at"
>;

export type OverdueNoticeUpdate = Partial<Omit<OverdueNotice, "id">>;
4 changes: 4 additions & 0 deletions backend/src/routes/documents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { checkAuth } from "@/helpers/roleManagement";
import { mergeSortedDocuments } from "@/helpers/utils";
import { renderMultiplePDF } from "@/pdf/renderPDF";
import { invoiceDocumentsRouter } from "@/routes/documents/invoice_documents";
import { offerDocumentsRouter } from "@/routes/documents/offer_documents";
import { overdueNoticeDocumentsRouter } from "@/routes/documents/overdue_notice_documents";

export const documentsRouter = express.Router();

Expand Down Expand Up @@ -145,4 +147,6 @@ documentsRouter.post(
}
},
);
documentsRouter.use("/offers", offerDocumentsRouter);
documentsRouter.use("/overdue_notices", overdueNoticeDocumentsRouter);
documentsRouter.use("/invoices", invoiceDocumentsRouter);
1 change: 1 addition & 0 deletions backend/src/routes/orders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ordersRouter.get(
}

const result = await dataSource.manager.findAndCount(Order, {
relations: ["invoices", "offer", "overdue_notices", "client"],
skip,
take,
order: { created_at: "DESC" },
Expand Down
43 changes: 43 additions & 0 deletions backend/src/routes/orders/overdue_notices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getAppDataSource } from "@/db";
import { OverdueNoticeDocument } from "@/db/entities/documents";
import { OverdueNotice } from "@/db/entities/overdue_notice";
import { ErrorCode, UserRole } from "@/global/types/backendTypes";
import { OverdueNoticeCreate } from "@/global/types/dataEditTypes";
import { ApiError } from "@/helpers/apiErrors";
import { checkAuth } from "@/helpers/roleManagement";

Expand All @@ -23,6 +24,48 @@ overdueNoticesRouter.get(
},
);

overdueNoticesRouter.post(
"",
[checkAuth({ yes: [UserRole.admin, UserRole.partner] })],
async (req: express.Request, res: express.Response) => {
const dataSource = getAppDataSource();
const payload = req.body as OverdueNoticeCreate;

const overdueNotice = dataSource.manager.create(OverdueNotice, { ...payload });

await dataSource.transaction(async (transactionalEntityManager) => {
await transactionalEntityManager.save(OverdueNotice, overdueNotice);
});

res.json(overdueNotice);
},
);

overdueNoticesRouter.patch(
"/:id",
[checkAuth({ yes: [UserRole.admin, UserRole.partner] })],
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const dataSource = getAppDataSource();
let overdueNotice: OverdueNotice | null = null;

delete req.body.id;
delete req.body.invoice_documents;

try {
await dataSource.manager.update(OverdueNotice, req.params.id, req.body);
overdueNotice = await dataSource.manager.findOne(OverdueNotice, {
where: { id: parseInt(req.params.id) },
});
} catch (error) {
next(error);
return;
}

if (overdueNotice != null) res.json(overdueNotice);
else next(new ApiError(ErrorCode.ENTITY_NOT_FOUND));
},
);

overdueNoticesRouter.delete(
"/:id",
[checkAuth({ yes: [UserRole.admin, UserRole.partner] })],
Expand Down
30 changes: 25 additions & 5 deletions frontend/src/backendClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type {
OfferUpdate,
OrderCreate,
OrderUpdate,
OverdueNoticeCreate,
OverdueNoticeUpdate,
} from "@/global/types/dataEditTypes";
import {
type Article,
Expand All @@ -23,6 +25,7 @@ import {
type Offer,
type OfferDocument,
type Order,
type OverdueNotice,
type OverdueNoticeDocument,
} from "@/global/types/entities";

Expand Down Expand Up @@ -135,10 +138,27 @@ export async function updateInvoice(id: number, invoice: InvoiceUpdate): Promise
return response.data;
}

export async function getDocuments(): Promise<
(OfferDocument | OverdueNoticeDocument | InvoiceDocument)[]
> {
const response = await axiosInstance.get(`/api/documents`);
export async function createOverdueNotice(
overdue_notice: OverdueNoticeCreate,
): Promise<OverdueNotice> {
const response = await axiosInstance.post(`/api/orders/overdue_notices/`, overdue_notice);
return response.data;
}

export async function updateOverdueNotice(
id: number,
overdueNotice: OverdueNoticeUpdate,
): Promise<OverdueNotice> {
const response = await axiosInstance.patch(`/api/orders/overdue_notices/${id}`, overdueNotice);
return response.data;
}

export async function getDocuments(
query?: string,
): Promise<(OfferDocument | OverdueNoticeDocument | InvoiceDocument)[]> {
const params: Record<string, string> = {};
if (query) params.search = query;
const response = await axiosInstance.get(`/api/documents`, { params });
return response.data;
}

Expand Down Expand Up @@ -167,7 +187,7 @@ export async function createDocumentBySubOrder(
kind: DocumentKind,
): Promise<OverdueNoticeDocument | InvoiceDocument | OfferDocument> {
const response = await axiosInstance.post(
`/api/orders/${getUrlEntityForKind(kind)}/${id}/documents/create`,
`/api/orders/${getUrlEntityForKind(kind)}/${id}/documents`,
);
return response.data;
}
Expand Down
23 changes: 14 additions & 9 deletions frontend/src/components/NavigationBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,35 @@ import Menubar from "primevue/menubar";
import { ref } from "vue";
import { useRoute } from "vue-router";
import { ROUTES } from "@/router";
import * as routes from "@/helpers/routes";
const route = useRoute();
const items = ref([
{
label: ROUTES.CLIENT.label,
label: "Kunden",
icon: "pi pi-user",
route: ROUTES.CLIENT.path,
route: routes.getClientListPath(),
},
{
label: ROUTES.ORDER.label,
label: "Aufträge",
icon: "pi pi-shopping-cart",
route: ROUTES.ORDER.path,
route: routes.getOrderListPath(),
},
{
label: ROUTES.DOCUMENTS.label,
label: "Übersicht",
icon: "pi pi-clipboard",
route: routes.getOverviewPath(),
},
{
label: "Dokumente",
icon: "pi pi-file",
route: ROUTES.DOCUMENTS.path,
route: routes.getDocumentListPath(),
},
{
label: ROUTES.ARTICLES.label,
label: "Artikel",
icon: "pi pi-list",
route: ROUTES.ARTICLES.path,
route: routes.getArticleListPath(),
},
]);
</script>
Expand Down
38 changes: 38 additions & 0 deletions frontend/src/components/documents/DocumentFooter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script setup></script>
<template>
<section class="text-xs">
<hr class="border-black border-1 mb-3" />
<div class="grid grid-cols-4 grid-rows-1 gap-1">
<div>
<p class="font-bold">redacted</p>
<p>redacted</p>
<p>redacted</p>
<p>St-Nr: redacted</p>
<p>USt-Id: redacted</p>
</div>
<div>
<p class="font-bold">Kontaktinformation</p>
<p>redacted</p>
<p>Phone: redacted</p>
<p>Mobil: redacted</p>
<p>E-Mail: redacted</p>
</div>
<div class="col-span-2 flex flex-col gap-2">
<p class="font-bold self-center">Bankverbindung</p>
<div class="flex flex-row">
<div>
<p>Bankverbindung redacted</p>
<p>IBAN: redacted</p>
<p>BIC: redacted</p>
</div>
<div>
<p>redacted</p>
<p>IBAN: redacted</p>
<p>BIC: redacted</p>
</div>
</div>
<p class="self-center">Web: redacted</p>
</div>
</div>
</section>
</template>
Loading

0 comments on commit aee1bf9

Please sign in to comment.