Compare commits
2 Commits
90e797b8fa
...
v1.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44d389201c | ||
|
|
3106aaf314 |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "app-ts",
|
"name": "app-ts",
|
||||||
"version": "1.4.9",
|
"version": "1.5.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "app-ts",
|
"name": "app-ts",
|
||||||
"version": "1.4.9",
|
"version": "1.5.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "app-ts",
|
"name": "app-ts",
|
||||||
"version": "1.4.9",
|
"version": "1.5.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/server.js",
|
"main": "dist/server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1008,6 +1008,7 @@ ${indentCSS}
|
|||||||
? new Date(invoice.issue_date)
|
? new Date(invoice.issue_date)
|
||||||
: new Date();
|
: new Date();
|
||||||
const saveMode = query.save === "1";
|
const saveMode = query.save === "1";
|
||||||
|
nasFinancialsManager.cleanIssuedInvoice(invoice.invoice_number!);
|
||||||
const pdfPromise = htmlToPdf(html)
|
const pdfPromise = htmlToPdf(html)
|
||||||
.then((pdfBuffer) => {
|
.then((pdfBuffer) => {
|
||||||
nasFinancialsManager.saveIssuedInvoicePdf(
|
nasFinancialsManager.saveIssuedInvoicePdf(
|
||||||
|
|||||||
@@ -30,6 +30,28 @@ class NasFinancialsManager {
|
|||||||
|
|
||||||
// ── Created (issued) invoices ────────────────────────────────────
|
// ── Created (issued) invoices ────────────────────────────────────
|
||||||
|
|
||||||
|
/** Remove any existing PDF for this invoice number across all year/month folders */
|
||||||
|
cleanIssuedInvoice(invoiceNumber: string): void {
|
||||||
|
if (!this.basePath) return;
|
||||||
|
const safeName = this.sanitizeFilename(invoiceNumber) + ".pdf";
|
||||||
|
const issuedDir = path.join(this.basePath, DIR_ISSUED);
|
||||||
|
try {
|
||||||
|
if (!fs.existsSync(issuedDir)) return;
|
||||||
|
for (const yearDir of fs.readdirSync(issuedDir)) {
|
||||||
|
const yearPath = path.join(issuedDir, yearDir);
|
||||||
|
if (!fs.statSync(yearPath).isDirectory()) continue;
|
||||||
|
for (const monthDir of fs.readdirSync(yearPath)) {
|
||||||
|
const filePath = path.join(yearPath, monthDir, safeName);
|
||||||
|
if (fs.existsSync(filePath)) {
|
||||||
|
fs.unlinkSync(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// best effort
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
saveIssuedInvoicePdf(
|
saveIssuedInvoicePdf(
|
||||||
invoiceNumber: string,
|
invoiceNumber: string,
|
||||||
year: number,
|
year: number,
|
||||||
|
|||||||
Reference in New Issue
Block a user