feat(bulk orders): standard template created

This commit is contained in:
2025-04-17 23:03:23 -05:00
parent a68a3ba640
commit 632e07967a
4 changed files with 60 additions and 1 deletions

10
package-lock.json generated
View File

@@ -25,6 +25,7 @@
"drizzle-kit": "^0.30.5",
"drizzle-orm": "^0.41.0",
"drizzle-zod": "^0.7.0",
"excel-date-to-js": "^1.1.5",
"fast-xml-parser": "^5.0.9",
"fs-extra": "^11.3.0",
"jsonwebtoken": "^9.0.2",
@@ -4054,6 +4055,15 @@
"node": ">=0.8.x"
}
},
"node_modules/excel-date-to-js": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/excel-date-to-js/-/excel-date-to-js-1.1.5.tgz",
"integrity": "sha512-grZW0MPye0VGCzLNljI7H22QWgrI8/hkTCvIUczYsQTTSaPQU/UTcz1fBPHNxWKpiv8Zu2I/98z+aAnlp6STNw==",
"license": "MIT",
"engines": {
"node": ">=4.2.4"
}
},
"node_modules/execa": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz",

View File

@@ -73,6 +73,7 @@
"drizzle-kit": "^0.30.5",
"drizzle-orm": "^0.41.0",
"drizzle-zod": "^0.7.0",
"excel-date-to-js": "^1.1.5",
"fast-xml-parser": "^5.0.9",
"fs-extra": "^11.3.0",
"jsonwebtoken": "^9.0.2",

View File

@@ -0,0 +1,43 @@
import * as XLSX from "xlsx";
export const standardTemplate = async () => {
/**
* Creates the standard Template for bulk orders in
*/
const headers = [
[
"CustomerArticleNumber",
"CustomerOrderNumber",
"CustomerLineNumber",
"CustomerRealeaseNumber",
"Quantity",
"DeliveryDate",
"CustomerID",
// "InvoiceID",
],
];
// create a new workbook
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.aoa_to_sheet(headers);
//const ws2 = XLSX.utils.aoa_to_sheet(headers2);
const columnWidths = headers[0].map((header) => ({
width: header.length + 2,
}));
ws["!cols"] = columnWidths;
// append the worksheet to the workbook
XLSX.utils.book_append_sheet(wb, ws, `Sheet1`);
//XLSX.utils.book_append_sheet(wb, ws2, `Sheet2`);
// Write the excel file and trigger the download'
XLSX.writeFile(wb, "BulkOrdersTemplate");
// Write the workbook to a buffer and return it
const excelBuffer = XLSX.write(wb, { bookType: "xlsx", type: "buffer" });
return excelBuffer;
};

View File

@@ -11,6 +11,8 @@ import { getLanesToCycleCount } from "./controller/warehouse/cycleCountChecks/cy
import getCycleCountCheck from "./route/getCycleCountChecks.js";
import getPPOO from "./route/getPPOO.js";
import getcyclecount from "./route/getCycleCountLanes.js";
import postBulkOrders from "./route/dm/bulkOrdersIn.js";
import standardTemplate from "./route/dm/getStandardTemplate.js";
const app = new OpenAPIHono();
@@ -28,6 +30,9 @@ const routes = [
//warehouse
getPPOO,
getcyclecount,
//DM
postBulkOrders,
standardTemplate,
] as const;
// app.route("/server", modules);