feat(silo adjustments): added in email if % wrong

This commit is contained in:
2025-04-06 07:47:39 -05:00
parent 85e3d46b2e
commit 95bebbde2b
10 changed files with 178 additions and 11 deletions

View File

@@ -35,6 +35,8 @@ const ignoreList = [
"frontend/tsconfig.node.json",
"frontend/vite.config.ts",
"frontend/components.json",
//misc files
"jsTesting",
];
const shouldIgnore = (itemPath: any) => {

View File

@@ -0,0 +1,24 @@
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import { query } from "../../../sqlServer/prodSqlServer.js";
import { siloQuery } from "../../../sqlServer/querys/silo/siloQuery.js";
export const getStockSiloData = async () => {
/**
* will return the current stock info where the silo is checked
*/
const { data, error } = await tryCatch(query(siloQuery, "Get silo data"));
if (error) {
return {
success: false,
message: "There was a n error getting the silo data.",
};
}
return {
success: true,
message: "Current silo data from alplastock.",
data: data,
};
};

View File

@@ -0,0 +1,50 @@
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { authMiddleware } from "../../../auth/middleware/authMiddleware.js";
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
import { getStockSiloData } from "../../controller/siloAdjustments/getCurrentStockSiloData.js";
const app = new OpenAPIHono();
app.openapi(
createRoute({
tags: ["logistics"],
summary: "Returns current stock levels for silos",
method: "get",
path: "/getstocksilo",
middleware: authMiddleware,
// request: {
// params: ParamsSchema,
// body: { content: { "application/json": { schema: Body } } },
// },
// description:
// "Creates a silo adjustment for the silo if and stores the stock numbers.",
responses: responses(),
}),
async (c) => {
//apiHit(c, { endpoint: "api/sqlProd/close" });
try {
//return apiReturn(c, true, access?.message, access?.data, 200);
const silo = await getStockSiloData();
return c.json(
{
success: silo.success,
message: silo.message,
data: silo.data,
},
200
);
} catch (error) {
return c.json(
{
success: false,
message: "Missing data please try again",
error,
},
400
);
}
}
);
export default app;

View File

@@ -29,7 +29,7 @@
Please add your comment as to why the variance greater than {{variancePer}}<br/><br/>
<a href="http://{{server}}:5173/siloAdjustments/comment/{{adjustID}}"
<a href="http://{{server}}:{{port}}/siloAdjustments/comment/{{adjustID}}"
style="display:inline-block; padding:10px 20px; text-decoration:none; border-radius:5px;">
Add a Comment
</a><br/><br/>

View File

@@ -3,10 +3,10 @@ SELECT
V_LagerAbteilungen.Bezeichnung AS Description,
V_LagerAbteilungen.IdWarenLager AS WarehouseID,
V_LagerAbteilungen.IdLagerAbteilung AS LocationID,
ROUND(SUM(einlagerungsmengesum), 2) AS Stock_Total,
COALESCE(LastAdjustment, '1900-01-01') AS LastAdjustment
case when ROUND(SUM(einlagerungsmengesum), 2) is null then 0 else ROUND(SUM(einlagerungsmengesum), 2) end AS Stock_Total
,case when ROUND(SUM(einlagerungsmengesum), 2) is null then COALESCE(b.upd_Date, '1900-01-01') else COALESCE(LastAdjustment, '1900-01-01') end AS LastAdjustment
FROM AlplaPROD_test1.dbo.V_LagerAbteilungen (NOLOCK)
JOIN
left JOIN
AlplaPROD_test1.dbo.V_LagerPositionenBarcodes ON
AlplaPROD_test1.dbo.V_LagerAbteilungen.IdLagerAbteilung =
AlplaPROD_test1.dbo.V_LagerPositionenBarcodes.IdLagerAbteilung
@@ -18,9 +18,15 @@ SELECT
WHERE urheber = 2900
GROUP BY IdLagerAbteilung
) AS LastAdj ON AlplaPROD_test1.dbo.V_LagerAbteilungen.IdLagerAbteilung = LastAdj.IdLagerAbteilung
/* add the actual inventory now that we will display an empty silo and need to add this date */
left join
AlplaPROD_test1.dbo.V_LagerAbteilungenInventuren as b on
AlplaPROD_test1.dbo.V_LagerAbteilungen.IdLagerAbteilung = b.IdLagerAbteilung
WHERE materialsilo = 1
AND aktiv = 1
GROUP BY V_LagerAbteilungen.Bezeichnung, V_LagerAbteilungen.IdWarenLager, V_LagerAbteilungen.IdLagerAbteilung, LastAdjustment
GROUP BY V_LagerAbteilungen.Bezeichnung, V_LagerAbteilungen.IdWarenLager, V_LagerAbteilungen.IdLagerAbteilung, LastAdjustment, b.upd_Date
ORDER BY V_LagerAbteilungen.Bezeichnung
`;