25 lines
707 B
TypeScript
25 lines
707 B
TypeScript
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
|
import { format } from "date-fns";
|
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
|
import { lastPurchasePrice } from "../../sqlServer/querys/eom/lstPurchasePrice.js";
|
|
|
|
export const lastPurchase = async () => {
|
|
const { data, error } = (await tryCatch(
|
|
query(lastPurchasePrice, "Last purchase price")
|
|
)) as any;
|
|
|
|
if (error) {
|
|
return {
|
|
success: false,
|
|
message: "Error getting the last purchase price",
|
|
data: error,
|
|
};
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
message: `Last purchase price for all av in the last 5 years`,
|
|
data: data.data,
|
|
};
|
|
};
|