diff --git a/src/routes/purchase.routes.ts b/src/routes/purchase.routes.ts index 963e12f..a12cf4e 100644 --- a/src/routes/purchase.routes.ts +++ b/src/routes/purchase.routes.ts @@ -16,11 +16,28 @@ router.get("/", (req,res) => {
-
`; + +
+ + +
+ + +
+ + +
+ + +
+ +
+ `; res.send(html); }); +// gère la réception d'un ou de plusieurs fichiers PDF router.post("/file", async (req,res) => { try { const files = await file_form_handler(req); @@ -38,7 +55,7 @@ router.post("/file", async (req,res) => { } const results_of_parsing = []; - + for (const path of file_paths) { results_of_parsing.push(await pdf_parse(path)); }; @@ -51,6 +68,23 @@ router.post("/file", async (req,res) => { } }); +// gère la récéption de produit saisie manuellement +router.post("/new", async (req, res) => { + const nom_produit : string = req.body.nom_produit ; + const quantite : number = Number(req.body.quantite); + const prixHT : number = Number(req.body.prixHT); + const tva : string = req.body.tva; + + res.send({ + [nom_produit]: { + quantité: quantite, + prixHT: prixHT, + TVA: tva + } + }); +}); + + // fonction pour gérer la récéption des fichier par un form function file_form_handler(req: ExpressRequest): Promise { return new Promise((resolve, reject) => {