test(silo): backend silo stuff

This commit is contained in:
2025-04-08 06:48:12 -05:00
parent b630bae50d
commit b4a4dfcb75
9 changed files with 227 additions and 13 deletions

View File

@@ -4,7 +4,6 @@ import getArticles from "./route/getActiveArticles.js";
import currentInv from "./route/getInventory.js";
import getCustomerInv from "./route/getCustomerInv.js";
import getOpenOrders from "./route/getOpenOrders.js";
import siloAdjustments from "./route/getSiloAdjustments.js";
const app = new OpenAPIHono();
@@ -14,7 +13,6 @@ const routes = [
currentInv,
getCustomerInv,
getOpenOrders,
siloAdjustments,
] as const;
const appRoutes = routes.forEach((route) => {

View File

@@ -72,7 +72,7 @@ const current: any = [
// },
{
name: "getSiloAdjustment",
endpoint: "/api/v1/warehouse/getSiloAdjustment",
endpoint: "/api/logistics/getsilosdjustment",
// description: "Returns all inventory, by default excludes running numebrs, also excludes inv locations.",
description:
"Returns all siloadjustments in selected date range IE: 1/1/2025 to 1/31/2025",

View File

@@ -1,69 +0,0 @@
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { responses } from "../../../globalUtils/routeDefs/responses.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";
import { getOpenOrders } from "../controller/getOpenOrders.js";
import axios from "axios";
const app = new OpenAPIHono({ strict: false });
// const Body = z.object({
// includeRunnningNumbers: z.string().openapi({ example: "x" }),
// });
app.openapi(
createRoute({
tags: ["dataMart"],
summary: "Returns All open orders.",
method: "get",
path: "/getsilosdjustment",
// request: {
// body: {
// content: {
// "application/json": { schema: Body },
// },
// },
// },
responses: responses(),
}),
async (c) => {
const customer: any = c.req.queries();
// make sure we have a vaid user being accessed thats really logged in
//apiHit(c, { endpoint: `api/logger/logs/id` });
// const { data, error } = await tryCatch(
// getOpenOrders(customer ? customer : null)
// );
// if (error) {
// return c.json(
// {
// success: false,
// message: "There was an error getting the inv.",
// data: error,
// },
// 400
// );
// }
const dates: any = c.req.queries();
const { data, error } = await tryCatch(
axios.get(
`http://localhost:4400/api/v1/warehouse/getSilosAdjustment?startDate=${dates.startDate[0]}&endDate=${dates.endDate[0]}`
)
);
if (error) {
return c.json({
success: false,
message: "Error running query",
data: error,
});
}
return c.json({
success: data?.data.success,
message: data?.data.message,
data: data?.data.data,
});
}
);
export default app;