feat(silo adjustments): added in email if % wrong
This commit is contained in:
@@ -82,7 +82,7 @@ export function LogisticsSideBar({
|
|||||||
const { subModules } = useSubModuleStore();
|
const { subModules } = useSubModuleStore();
|
||||||
|
|
||||||
const items = subModules.filter((m) => m.moduleName === "logistics");
|
const items = subModules.filter((m) => m.moduleName === "logistics");
|
||||||
console.log(items);
|
//console.log(items);
|
||||||
return (
|
return (
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarGroupLabel>Logistics</SidebarGroupLabel>
|
<SidebarGroupLabel>Logistics</SidebarGroupLabel>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { LstCard } from "@/components/extendedUI/LstCard";
|
||||||
|
import { CardHeader } from "@/components/ui/card";
|
||||||
|
|
||||||
|
export default function SiloCard(data: any) {
|
||||||
|
const silo = data.silo;
|
||||||
|
return (
|
||||||
|
<LstCard>
|
||||||
|
<CardHeader>{silo.Description}</CardHeader>
|
||||||
|
<div>
|
||||||
|
<hr />
|
||||||
|
</div>
|
||||||
|
</LstCard>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { getStockSilo } from "@/utils/querys/logistics/siloAdjustments/getStockSilo";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import SiloCard from "./SiloCard";
|
||||||
|
|
||||||
|
export default function SiloPage() {
|
||||||
|
const { data, isError, error, isLoading } = useQuery(getStockSilo());
|
||||||
|
|
||||||
|
if (isLoading) return;
|
||||||
|
|
||||||
|
if (isError) return;
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{" "}
|
||||||
|
There was an error getting the silos please notify your admin if
|
||||||
|
this continues to be an issue
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-row gap-2">
|
||||||
|
{data?.map((s: any) => <SiloCard silo={s} />)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,9 +1,28 @@
|
|||||||
import { createFileRoute } from '@tanstack/react-router'
|
import SiloPage from "@/components/logistics/siloAdjustments/SiloPage";
|
||||||
|
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||||
|
|
||||||
export const Route = createFileRoute('/(logistics)/siloAdjustments/')({
|
export const Route = createFileRoute("/(logistics)/siloAdjustments/")({
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
})
|
beforeLoad: async () => {
|
||||||
|
const auth = localStorage.getItem("auth_token");
|
||||||
|
if (!auth) {
|
||||||
|
throw redirect({
|
||||||
|
to: "/login",
|
||||||
|
search: {
|
||||||
|
// Use the current location to power a redirect after login
|
||||||
|
// (Do not use `router.state.resolvedLocation` as it can
|
||||||
|
// potentially lag behind the actual current location)
|
||||||
|
redirect: location.pathname + location.search,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
return <div>Hello "/(logistics)/siloAdjustments/"!</div>
|
return (
|
||||||
|
<div>
|
||||||
|
<SiloPage />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { queryOptions } from "@tanstack/react-query";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
export function getStockSilo() {
|
||||||
|
const token = localStorage.getItem("auth_token");
|
||||||
|
return queryOptions({
|
||||||
|
queryKey: ["getUsers"],
|
||||||
|
queryFn: () => fetchStockSilo(token),
|
||||||
|
enabled: !!token, // Prevents query if token is null
|
||||||
|
staleTime: 1000,
|
||||||
|
//refetchInterval: 2 * 2000,
|
||||||
|
refetchOnWindowFocus: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchStockSilo = async (token: string | null) => {
|
||||||
|
const { data } = await axios.get(`/api/logistics/getstocksilo`, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// if we are not localhost ignore the devDir setting.
|
||||||
|
//const url: string = window.location.host.split(":")[0];
|
||||||
|
return data.data ?? [];
|
||||||
|
};
|
||||||
@@ -35,6 +35,8 @@ const ignoreList = [
|
|||||||
"frontend/tsconfig.node.json",
|
"frontend/tsconfig.node.json",
|
||||||
"frontend/vite.config.ts",
|
"frontend/vite.config.ts",
|
||||||
"frontend/components.json",
|
"frontend/components.json",
|
||||||
|
//misc files
|
||||||
|
"jsTesting",
|
||||||
];
|
];
|
||||||
|
|
||||||
const shouldIgnore = (itemPath: any) => {
|
const shouldIgnore = (itemPath: any) => {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -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;
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
Please add your comment as to why the variance greater than {{variancePer}}<br/><br/>
|
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;">
|
style="display:inline-block; padding:10px 20px; text-decoration:none; border-radius:5px;">
|
||||||
Add a Comment
|
Add a Comment
|
||||||
</a><br/><br/>
|
</a><br/><br/>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ SELECT
|
|||||||
V_LagerAbteilungen.Bezeichnung AS Description,
|
V_LagerAbteilungen.Bezeichnung AS Description,
|
||||||
V_LagerAbteilungen.IdWarenLager AS WarehouseID,
|
V_LagerAbteilungen.IdWarenLager AS WarehouseID,
|
||||||
V_LagerAbteilungen.IdLagerAbteilung AS LocationID,
|
V_LagerAbteilungen.IdLagerAbteilung AS LocationID,
|
||||||
ROUND(SUM(einlagerungsmengesum), 2) AS Stock_Total,
|
case when ROUND(SUM(einlagerungsmengesum), 2) is null then 0 else ROUND(SUM(einlagerungsmengesum), 2) end AS Stock_Total
|
||||||
COALESCE(LastAdjustment, '1900-01-01') AS LastAdjustment
|
,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)
|
FROM AlplaPROD_test1.dbo.V_LagerAbteilungen (NOLOCK)
|
||||||
JOIN
|
left JOIN
|
||||||
AlplaPROD_test1.dbo.V_LagerPositionenBarcodes ON
|
AlplaPROD_test1.dbo.V_LagerPositionenBarcodes ON
|
||||||
AlplaPROD_test1.dbo.V_LagerAbteilungen.IdLagerAbteilung =
|
AlplaPROD_test1.dbo.V_LagerAbteilungen.IdLagerAbteilung =
|
||||||
AlplaPROD_test1.dbo.V_LagerPositionenBarcodes.IdLagerAbteilung
|
AlplaPROD_test1.dbo.V_LagerPositionenBarcodes.IdLagerAbteilung
|
||||||
@@ -18,9 +18,15 @@ SELECT
|
|||||||
WHERE urheber = 2900
|
WHERE urheber = 2900
|
||||||
GROUP BY IdLagerAbteilung
|
GROUP BY IdLagerAbteilung
|
||||||
) AS LastAdj ON AlplaPROD_test1.dbo.V_LagerAbteilungen.IdLagerAbteilung = LastAdj.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
|
WHERE materialsilo = 1
|
||||||
AND aktiv = 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
|
ORDER BY V_LagerAbteilungen.Bezeichnung
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user