feat(eom): all endpoints created for the eom template to run in all plants
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "../../../../database/dbclient.js";
|
||||
import { settings } from "../../../../database/schema/settings.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||
import { activeArticle } from "../../sqlServer/querys/dataMart/article.js";
|
||||
|
||||
export const getActiveAv = async () => {
|
||||
export const getActiveAv = async (includePlantToken: boolean = false) => {
|
||||
let articles: any = [];
|
||||
try {
|
||||
const res = await query(activeArticle, "Get active articles");
|
||||
@@ -10,5 +14,20 @@ export const getActiveAv = async () => {
|
||||
articles = error;
|
||||
}
|
||||
|
||||
return articles;
|
||||
if (includePlantToken) {
|
||||
const { data, error } = (await tryCatch(
|
||||
db.select().from(settings).where(eq(settings.name, "plantToken"))
|
||||
)) as any;
|
||||
|
||||
if (error) {
|
||||
console.log("Error getting articles");
|
||||
return articles;
|
||||
}
|
||||
|
||||
return articles.map((n: any) => {
|
||||
return { plantToken: data[0].value, ...n };
|
||||
});
|
||||
} else {
|
||||
return articles;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,7 +5,10 @@ import {
|
||||
totalInvRn,
|
||||
} from "../../sqlServer/querys/dataMart/totalINV.js";
|
||||
|
||||
export const getINV = async (rn: boolean) => {
|
||||
export const getINV = async (
|
||||
rn: boolean,
|
||||
includePlantToken: boolean = false
|
||||
) => {
|
||||
let inventory: any = [];
|
||||
|
||||
let updatedQuery = totalInvNoRn;
|
||||
|
||||
Reference in New Issue
Block a user