import React, { useEffect } from "react"; import Label from "../common/Label"; import { useAppFormContext } from "../../hooks/appHooks/useAppForm"; import DatePicker from "../common/DatePicker"; import { useInvoiceAttachmentTypes } from "../../hooks/masterHook/useMaster"; const PurchasePaymentDetails = () => { const { data, isLoading, error, isError } = useInvoiceAttachmentTypes(); const { register, watch, setValue, control, formState: { errors }, } = useAppFormContext(); const baseAmount = watch("baseAmount"); const taxAmount = watch("taxAmount"); useEffect(() => { const base = parseFloat(baseAmount) || 0; const tax = parseFloat(taxAmount) || 0; if (base || tax) { setValue("totalAmount", (base + tax).toFixed(2)); } }, [baseAmount, taxAmount, setValue]); return (
{errors?.baseAmount && (
{errors.baseAmount.message}
)}
{errors?.taxAmount && (
{errors.taxAmount.message}
)}
{errors?.totalAmount && (
{errors.totalAmount.message}
)}
{errors?.transportCharges && (
{errors.transportCharges.message}
)}
{errors?.paymentDueDate && (
{errors.paymentDueDate.message}
)}