added place to telecommunication, added contract documents, added invoice to other contracts
This commit is contained in:
@@ -143,3 +143,38 @@ export async function deleteInvoice(req: Request, res: Response): Promise<void>
|
||||
} as ApiResponse);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== CONTRACT-BASIERTE RECHNUNGEN (für alle Vertragstypen) ====================
|
||||
|
||||
export async function getInvoicesByContract(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const contractId = parseInt(req.params.id);
|
||||
const invoices = await invoiceService.getInvoicesByContract(contractId);
|
||||
res.json({ success: true, data: invoices } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(500).json({ success: false, error: 'Fehler beim Laden der Rechnungen' } as ApiResponse);
|
||||
}
|
||||
}
|
||||
|
||||
export async function addInvoiceByContract(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const contractId = parseInt(req.params.id);
|
||||
const { invoiceDate, invoiceType, notes } = req.body;
|
||||
const invoice = await invoiceService.addInvoiceByContract(contractId, {
|
||||
invoiceDate: new Date(invoiceDate),
|
||||
invoiceType,
|
||||
notes,
|
||||
});
|
||||
await logChange({
|
||||
req, action: 'CREATE', resourceType: 'Invoice',
|
||||
resourceId: invoice.id.toString(),
|
||||
label: `Rechnung (${invoiceType}) hinzugefügt`,
|
||||
});
|
||||
res.status(201).json({ success: true, data: invoice } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Fehler beim Hinzufügen',
|
||||
} as ApiResponse);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user