diff --git a/src/components/purchase/ManagePurchase.jsx b/src/components/purchase/ManagePurchase.jsx index 89c1b1b3..fb757b54 100644 --- a/src/components/purchase/ManagePurchase.jsx +++ b/src/components/purchase/ManagePurchase.jsx @@ -28,21 +28,21 @@ const ManagePurchase = ({ onClose, purchaseId }) => { const stepsConfig = useMemo( () => [ { - name: "Party Details", + name: "Vendor & Project Details", icon: "bx bx-user bx-md", - subtitle: "Supplier & project information", + subtitle: "Vendor information and project association", component: , }, { - name: "Invoice & Transport", + name: "Invoice & Logistics", icon: "bx bx-receipt bx-md", - subtitle: "Invoice, eWay bill & transport info", + subtitle: "Invoice, e-Way bill, and logistics information", component: , }, { - name: "Payment Details", + name: "Invoice & Tax Amount", icon: "bx bx-credit-card bx-md", - subtitle: "Amount, tax & due date", + subtitle: "Payment terms, tax breakdown, and due dates", component: , }, ], diff --git a/src/components/purchase/PurchasePayment.jsx b/src/components/purchase/PurchasePayment.jsx new file mode 100644 index 00000000..a1e440a4 --- /dev/null +++ b/src/components/purchase/PurchasePayment.jsx @@ -0,0 +1,298 @@ +import React from "react"; +import { + AppFormController, + AppFormProvider, + useAppForm, +} from "../../hooks/appHooks/useAppForm"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { AddPurchasePayment, defaultPurchasePayment } from "./PurchaseSchema"; +import { usePaymentAjustmentHead } from "../../hooks/masterHook/useMaster"; +import { formatFigure, localToUtc } from "../../utils/appUtils"; +import Label from "../common/Label"; +import DatePicker from "../common/DatePicker"; +import { + useAddPurchasePayment, + usePurchase, + usePurchasePaymentHistory, +} from "../../hooks/usePurchase"; +import SelectField from "../common/Forms/SelectField"; +import { SpinnerLoader } from "../common/Loader"; +import { formatUTCToLocalTime } from "../../utils/dateUtils"; +import Avatar from "../common/Avatar"; + +const PurchasePayment = ({ purchaseId }) => { + const { + data: Purchase, + isLoading: isPurchaseLoading, + error: purchaseError, + } = usePurchase(purchaseId); + const methods = useAppForm({ + resolver: zodResolver(AddPurchasePayment), + defaultValues: defaultPurchasePayment, + }); + const { + control, + register, + handleSubmit, + reset, + formState: { errors }, + } = methods; + + const { + data: paymentTypes, + isLoading: isPaymentTypeLoading, + isError: isPaymentTypeError, + error: paymentError, + } = usePaymentAjustmentHead(true); + + const { mutate: AddPayment, isPending } = useAddPurchasePayment(() => { + handleClose(); + }); + const { data, isLoading, isError, error } = + usePurchasePaymentHistory(purchaseId); + const onSubmit = (formData) => { + const payload = { + ...formData, + paymentReceivedDate: localToUtc(formData.paymentReceivedDate), + invoiceId: purchaseId, + }; + AddPayment(payload); + }; + + const handleClose = (formData) => { + reset(defaultPurchasePayment); + }; + return ( +
+
+

Supplier / Vendor Transaction

+
+
+
+ +
+
+
+ + + {errors.transactionId && ( + + {errors.transactionId.message} + + )} +
+ +
+ + + {errors.paymentReceivedDate && ( + + {errors.paymentReceivedDate.message} + + )} +
+ +
+ ( + + )} + /> + {errors.paymentAdjustmentHeadId && ( + + {errors.paymentAdjustmentHeadId.message} + + )} +
+ +
+ + + {errors.amount && ( + + {errors.amount.message} + + )} +
+
+ +