feat(nas): archive issued-order PDFs to NAS_ORDERS; split NAS_FINANCIALS_PATH into NAS_INVOICES + NAS_ORDERS
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
CreateReceivedInvoiceSchema,
|
||||
UpdateReceivedInvoiceSchema,
|
||||
} from "../../schemas/received-invoices.schema";
|
||||
import { nasFinancialsManager } from "../../services/nas-financials-manager";
|
||||
import { nasInvoicesManager } from "../../services/nas-financials-manager";
|
||||
import { toCzk } from "../../services/exchange-rates";
|
||||
import path from "path";
|
||||
|
||||
@@ -203,12 +203,12 @@ export default async function receivedInvoicesRoutes(
|
||||
});
|
||||
if (!invoice?.file_name) return error(reply, "Soubor nenalezen", 404);
|
||||
|
||||
const relPath = nasFinancialsManager.buildReceivedPath(
|
||||
const relPath = nasInvoicesManager.buildReceivedPath(
|
||||
invoice.file_name,
|
||||
invoice.year,
|
||||
invoice.month,
|
||||
);
|
||||
const nasFile = nasFinancialsManager.readReceivedInvoice(relPath);
|
||||
const nasFile = nasInvoicesManager.readReceived(relPath);
|
||||
if (!nasFile) return error(reply, "Soubor na NAS nenalezen", 404);
|
||||
|
||||
const mime = invoice.file_mime || "application/pdf";
|
||||
@@ -295,7 +295,7 @@ export default async function receivedInvoicesRoutes(
|
||||
const now = new Date();
|
||||
const createdIds: number[] = [];
|
||||
|
||||
const useNas = nasFinancialsManager.isConfigured();
|
||||
const useNas = nasInvoicesManager.isConfigured();
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
@@ -319,7 +319,7 @@ export default async function receivedInvoicesRoutes(
|
||||
return error(reply, "NAS úložiště není nakonfigurováno", 503);
|
||||
}
|
||||
|
||||
const nasResult = nasFinancialsManager.saveReceivedInvoice(
|
||||
const nasResult = nasInvoicesManager.saveReceived(
|
||||
file.name,
|
||||
invoiceYear,
|
||||
invoiceMonth,
|
||||
@@ -584,12 +584,12 @@ export default async function receivedInvoicesRoutes(
|
||||
await prisma.received_invoices.delete({ where: { id } });
|
||||
|
||||
if (existing.file_name) {
|
||||
const relPath = nasFinancialsManager.buildReceivedPath(
|
||||
const relPath = nasInvoicesManager.buildReceivedPath(
|
||||
existing.file_name,
|
||||
existing.year,
|
||||
existing.month,
|
||||
);
|
||||
nasFinancialsManager.deleteReceivedInvoice(relPath);
|
||||
nasInvoicesManager.deleteReceived(relPath);
|
||||
}
|
||||
await logAudit({
|
||||
request,
|
||||
|
||||
Reference in New Issue
Block a user