fix(po): tighten filters and export data
This commit is contained in:
parent
2c39f0225f
commit
32ea27331c
7 changed files with 31 additions and 21 deletions
|
|
@ -27,7 +27,7 @@ export default async function ApprovalsPage({ searchParams }: Props) {
|
|||
|
||||
const { q, vesselId, dateFrom } = await searchParams;
|
||||
|
||||
const where: Parameters<typeof db.purchaseOrder.findMany>[0]["where"] = {
|
||||
const where: NonNullable<Parameters<typeof db.purchaseOrder.findMany>[0]>["where"] = {
|
||||
status: "MGR_REVIEW",
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,16 @@ export default async function HistoryPage({ searchParams }: Props) {
|
|||
|
||||
const { dateFrom, dateTo, vesselId, status } = await searchParams;
|
||||
|
||||
const where: Parameters<typeof db.purchaseOrder.findMany>[0]["where"] = {};
|
||||
if (dateFrom) where.createdAt = { ...where.createdAt, gte: new Date(dateFrom) };
|
||||
if (dateTo) {
|
||||
const end = new Date(dateTo);
|
||||
end.setDate(end.getDate() + 1);
|
||||
where.createdAt = { ...where.createdAt, lt: end };
|
||||
const where: NonNullable<Parameters<typeof db.purchaseOrder.findMany>[0]>["where"] = {};
|
||||
if (dateFrom || dateTo) {
|
||||
const createdAt: { gte?: Date; lt?: Date } = {};
|
||||
if (dateFrom) createdAt.gte = new Date(dateFrom);
|
||||
if (dateTo) {
|
||||
const end = new Date(dateTo);
|
||||
end.setDate(end.getDate() + 1);
|
||||
createdAt.lt = end;
|
||||
}
|
||||
where.createdAt = createdAt;
|
||||
}
|
||||
if (vesselId) where.vesselId = vesselId;
|
||||
if (status) where.status = status as POStatus;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export default async function PaymentHistoryPage({ searchParams }: Props) {
|
|||
|
||||
const { dateFrom, dateTo, vesselId } = await searchParams;
|
||||
|
||||
const where: Parameters<typeof db.purchaseOrder.findMany>[0]["where"] = {
|
||||
const where: NonNullable<Parameters<typeof db.purchaseOrder.findMany>[0]>["where"] = {
|
||||
status: { in: ["PAID_DELIVERED", "CLOSED"] },
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ export function EditPoForm({ po, vessels, accounts, vendors }: Props) {
|
|||
const canSubmit = po.status === "DRAFT";
|
||||
const canResubmit = po.status === "EDITS_REQUESTED";
|
||||
|
||||
async function handleSubmit(intent: "save" | "resubmit") {
|
||||
async function handleSubmit(intent: "save" | "submit" | "resubmit") {
|
||||
setSubmitting(intent);
|
||||
setError("");
|
||||
const form = document.getElementById("edit-po-form") as HTMLFormElement;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ export async function GET(request: NextRequest, { params }: Props) {
|
|||
const po = await db.purchaseOrder.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
submitter: true, vessel: true, account: true, vendor: true,
|
||||
submitter: true, vessel: true, account: true,
|
||||
vendor: { include: { contacts: { where: { isPrimary: true }, take: 1 } } },
|
||||
lineItems: { orderBy: { sortOrder: "asc" } },
|
||||
actions: { include: { actor: true }, orderBy: { createdAt: "asc" } },
|
||||
},
|
||||
|
|
@ -126,7 +127,8 @@ export async function GET(request: NextRequest, { params }: Props) {
|
|||
po.vendor?.address,
|
||||
po.vendor?.gstin ? `GSTIN: ${po.vendor.gstin}` : null,
|
||||
].filter(Boolean).join(" ");
|
||||
const vendorContact = [po.vendor?.contactName, po.vendor?.contactMobile, po.vendor?.contactEmail]
|
||||
const primaryContact = po.vendor?.contacts?.[0];
|
||||
const vendorContact = [primaryContact?.name, primaryContact?.mobile, primaryContact?.email]
|
||||
.filter(Boolean).join(" ");
|
||||
|
||||
// ── GST summary row label ─────────────────────────────────────────────────
|
||||
|
|
@ -390,8 +392,10 @@ export async function GET(request: NextRequest, { params }: Props) {
|
|||
const imgId = wb.addImage({ base64: signatureBase64, extension: imgType });
|
||||
// Span the image across columns A-D in the sig row
|
||||
ws.addImage(imgId, {
|
||||
tl: { col: 0, row: SIG_ROW - 1 },
|
||||
br: { col: 4, row: SIG_ROW },
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
tl: { col: 0, row: SIG_ROW - 1 } as any,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
br: { col: 4, row: SIG_ROW } as any,
|
||||
editAs: "oneCell",
|
||||
});
|
||||
sc(SIG_ROW, 1, "", { border: { top: thin(), left: thin(), right: thin() } });
|
||||
|
|
|
|||
|
|
@ -27,12 +27,16 @@ export async function GET(request: NextRequest) {
|
|||
const vesselId = sp.get("vesselId");
|
||||
const status = sp.get("status");
|
||||
|
||||
const where: Parameters<typeof db.purchaseOrder.findMany>[0]["where"] = {};
|
||||
if (dateFrom) where.createdAt = { ...where.createdAt, gte: new Date(dateFrom) };
|
||||
if (dateTo) {
|
||||
const end = new Date(dateTo);
|
||||
end.setDate(end.getDate() + 1);
|
||||
where.createdAt = { ...where.createdAt, lt: end };
|
||||
const where: NonNullable<Parameters<typeof db.purchaseOrder.findMany>[0]>["where"] = {};
|
||||
if (dateFrom || dateTo) {
|
||||
const createdAt: { gte?: Date; lt?: Date } = {};
|
||||
if (dateFrom) createdAt.gte = new Date(dateFrom);
|
||||
if (dateTo) {
|
||||
const end = new Date(dateTo);
|
||||
end.setDate(end.getDate() + 1);
|
||||
createdAt.lt = end;
|
||||
}
|
||||
where.createdAt = createdAt;
|
||||
}
|
||||
if (vesselId) where.vesselId = vesselId;
|
||||
if (status) where.status = status as POStatus;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import {
|
|||
Upload,
|
||||
MapPin,
|
||||
ShoppingCart,
|
||||
BarChart3,
|
||||
UserCircle,
|
||||
ShieldCheck,
|
||||
} from "lucide-react";
|
||||
|
|
@ -59,7 +58,6 @@ const ADMIN_ITEMS: NavItem[] = [
|
|||
{ href: "/admin/users", label: "Users", icon: Users },
|
||||
{ href: "/admin/superuser-requests", label: "SuperUser Requests", icon: ShieldCheck },
|
||||
{ href: "/admin/accounts", label: "Accounts", icon: Building2 },
|
||||
{ href: "/reports", label: "Reports", icon: BarChart3 },
|
||||
];
|
||||
|
||||
export function Sidebar({ userRole }: { userRole: Role }) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue