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:
BOHA
2026-06-09 20:52:06 +02:00
parent 313d9218c1
commit 841ab676ec
11 changed files with 158 additions and 62 deletions

View File

@@ -7,7 +7,7 @@ import { logAudit } from "../../services/audit";
import { success, error, parseId, paginated } from "../../utils/response";
import { parsePagination, buildPaginationMeta } from "../../utils/pagination";
import { parseBody } from "../../schemas/common";
import { nasFinancialsManager } from "../../services/nas-financials-manager";
import { nasInvoicesManager } from "../../services/nas-financials-manager";
import {
getItemAvailableQty,
getItemTotalStock,
@@ -1315,11 +1315,11 @@ export default async function warehouseRoutes(
const year = now.getFullYear();
const month = now.getMonth() + 1;
if (!nasFinancialsManager.isConfigured()) {
if (!nasInvoicesManager.isConfigured()) {
return error(reply, "Úložiště souborů není dostupné", 503);
}
const result = nasFinancialsManager.saveReceivedInvoice(
const result = nasInvoicesManager.saveReceived(
part.filename,
year,
month,
@@ -1344,9 +1344,7 @@ export default async function warehouseRoutes(
},
});
} catch (e) {
const removed = nasFinancialsManager.deleteReceivedInvoice(
result.filePath,
);
const removed = nasInvoicesManager.deleteReceived(result.filePath);
request.log.error(
{ err: e, filePath: result.filePath, orphanRemoved: removed },
"warehouse attachment DB insert failed after NAS write; rolled back NAS file",
@@ -1392,7 +1390,7 @@ export default async function warehouseRoutes(
// Delete file from NAS. A failure here is non-fatal (we still remove the
// DB row) but must not be silent — log it so an undeleted NAS file is
// visible rather than leaking quietly.
const nasDeleted = nasFinancialsManager.deleteReceivedInvoice(
const nasDeleted = nasInvoicesManager.deleteReceived(
attachment.file_path,
);
if (!nasDeleted) {