removed all required condition
This commit is contained in:
parent
aa2e732ff4
commit
3bfe108dab
@ -73,15 +73,16 @@ const PurchasePartyDetails = () => {
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<SelectFieldSearch
|
||||
{...field}
|
||||
label="Organization"
|
||||
placeholder="Select Organization"
|
||||
required
|
||||
required
|
||||
value={field.value}
|
||||
onChange={field.onChange}
|
||||
valueKey="id"
|
||||
labelKey="name"
|
||||
useFetchHook={useGlobaleOrganizations}
|
||||
hookParams={[ITEMS_PER_PAGE, 1]}
|
||||
error={errors?.organizationId?.message}
|
||||
errors={errors?.organizationId}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
@ -109,7 +110,7 @@ const PurchasePartyDetails = () => {
|
||||
</div>
|
||||
|
||||
<div className="col-12 col-md-6 my-0">
|
||||
<Label htmlFor="billingAddress">Billing Address</Label>
|
||||
<Label required htmlFor="billingAddress">Billing Address</Label>
|
||||
|
||||
<textarea
|
||||
id="billingAddress"
|
||||
@ -124,7 +125,7 @@ const PurchasePartyDetails = () => {
|
||||
</div>
|
||||
|
||||
<div className="col-12 col-md-6 my-0 mb-1">
|
||||
<Label htmlFor="shippingAddress">Shipping Address</Label>
|
||||
<Label required htmlFor="shippingAddress">Shipping Address</Label>
|
||||
|
||||
<textarea
|
||||
id="shippingAddress"
|
||||
@ -140,7 +141,7 @@ const PurchasePartyDetails = () => {
|
||||
|
||||
{/* Purchase Order Number */}
|
||||
<div className="col-12 col-md-6 ">
|
||||
<Label htmlFor="purchaseOrderNumber" required>
|
||||
<Label htmlFor="purchaseOrderNumber" >
|
||||
Purchase Order Number
|
||||
</Label>
|
||||
|
||||
@ -160,7 +161,7 @@ const PurchasePartyDetails = () => {
|
||||
|
||||
{/* Purchase Order Date */}
|
||||
<div className="col-12 col-md-6 mb-1">
|
||||
<Label htmlFor="purchaseOrderDate" required>
|
||||
<Label htmlFor="purchaseOrderDate" >
|
||||
Purchase Order Date
|
||||
</Label>
|
||||
|
||||
|
||||
@ -26,15 +26,16 @@ const PurchasePaymentDetails = ({ purchaseId = null }) => {
|
||||
|
||||
const baseAmount = watch("baseAmount");
|
||||
const taxAmount = watch("taxAmount");
|
||||
|
||||
const trCharge = watch("transportCharges");
|
||||
useEffect(() => {
|
||||
const base = parseFloat(baseAmount) || 0;
|
||||
const tax = parseFloat(taxAmount) || 0;
|
||||
const transportCharges = parseFloat(trCharge) || 0;
|
||||
|
||||
if (base || tax) {
|
||||
setValue("totalAmount", (base + tax).toFixed(2));
|
||||
if (base || tax || transportCharges) {
|
||||
setValue("totalAmount", (base + tax + transportCharges));
|
||||
}
|
||||
}, [baseAmount, taxAmount, setValue]);
|
||||
}, [baseAmount, taxAmount, trCharge, setValue]);
|
||||
const invoiceAttachmentType = watch("invoiceAttachmentTypeId");
|
||||
const files = watch("attachments");
|
||||
const toBase64 = (file) =>
|
||||
@ -108,9 +109,7 @@ const PurchasePaymentDetails = ({ purchaseId = null }) => {
|
||||
return (
|
||||
<div className="row g-1 text-start">
|
||||
<div className="col-12 col-md-4">
|
||||
<Label htmlFor="baseAmount" required>
|
||||
Base Amount
|
||||
</Label>
|
||||
<Label htmlFor="baseAmount">Base Amount</Label>
|
||||
|
||||
<input
|
||||
id="baseAmount"
|
||||
@ -127,9 +126,7 @@ const PurchasePaymentDetails = ({ purchaseId = null }) => {
|
||||
</div>
|
||||
|
||||
<div className="col-12 col-md-4">
|
||||
<Label htmlFor="taxAmount" required>
|
||||
Tax Amount
|
||||
</Label>
|
||||
<Label htmlFor="taxAmount">Tax Amount</Label>
|
||||
|
||||
<input
|
||||
id="taxAmount"
|
||||
@ -144,28 +141,7 @@ const PurchasePaymentDetails = ({ purchaseId = null }) => {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="col-12 col-md-4">
|
||||
<Label htmlFor="totalAmount" required>
|
||||
Total Amount
|
||||
</Label>
|
||||
|
||||
<input
|
||||
id="totalAmount"
|
||||
type="number"
|
||||
className="form-control form-control-xs"
|
||||
{...register("totalAmount", { valueAsNumber: true })}
|
||||
readOnly
|
||||
/>
|
||||
|
||||
{errors?.totalAmount && (
|
||||
<div className="small danger-text mt-1">
|
||||
{errors.totalAmount.message}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="col-12 col-md-6">
|
||||
<Label htmlFor="transportCharges">Transport Charges</Label>
|
||||
|
||||
<input
|
||||
@ -182,6 +158,23 @@ const PurchasePaymentDetails = ({ purchaseId = null }) => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="col-12 col-md-6">
|
||||
<Label htmlFor="totalAmount">Total Amount</Label>
|
||||
|
||||
<input
|
||||
id="totalAmount"
|
||||
type="number"
|
||||
className="form-control form-control-xs"
|
||||
{...register("totalAmount", { valueAsNumber: true })}
|
||||
/>
|
||||
|
||||
{errors?.totalAmount && (
|
||||
<div className="small danger-text mt-1">
|
||||
{errors.totalAmount.message}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="col-12 col-md-6">
|
||||
<Label htmlFor="paymentDueDate">Payment Due Date</Label>
|
||||
|
||||
@ -200,9 +193,7 @@ const PurchasePaymentDetails = ({ purchaseId = null }) => {
|
||||
</div>
|
||||
|
||||
<div className="col-12 mb-2">
|
||||
<Label htmlFor="description" required>
|
||||
Description
|
||||
</Label>
|
||||
<Label htmlFor="description">Description</Label>
|
||||
|
||||
<textarea
|
||||
id="description"
|
||||
|
||||
@ -48,12 +48,25 @@ export const PurchaseSchema = z.object({
|
||||
acknowledgmentDate: z.coerce.date().nullable(),
|
||||
acknowledgmentNumber: z.string().nullable(),
|
||||
|
||||
baseAmount: z.number().min(1, { message: "Base amount is required" }),
|
||||
taxAmount: z.number().min(1, { message: "Tax amount is required" }),
|
||||
totalAmount: z.number().min(1, { message: "Total amount is required" }),
|
||||
baseAmount: z
|
||||
.number()
|
||||
.or(z.nan()) // allow NaN
|
||||
.transform((val) => (Number.isNaN(val) ? null : val)),
|
||||
|
||||
taxAmount: z
|
||||
.number()
|
||||
.or(z.nan()) // allow NaN
|
||||
.transform((val) => (Number.isNaN(val) ? null : val)),
|
||||
totalAmount: z
|
||||
.number()
|
||||
.or(z.nan()) // allow NaN
|
||||
.transform((val) => (Number.isNaN(val) ? null : val)),
|
||||
paymentDueDate: z.coerce.date().nullable(),
|
||||
transportCharges: z.number().nullable(),
|
||||
description: z.string().min(1, { message: "Description is required" }),
|
||||
transportCharges: z
|
||||
.number()
|
||||
.or(z.nan()) // allow NaN
|
||||
.transform((val) => (Number.isNaN(val) ? null : val)),
|
||||
description: z.string(),
|
||||
invoiceAttachmentTypeId: z.string().nullable(),
|
||||
attachments: z.array(AttachmentSchema),
|
||||
});
|
||||
@ -85,7 +98,7 @@ export const defaultPurchaseValue = {
|
||||
taxAmount: 0,
|
||||
totalAmount: 0,
|
||||
paymentDueDate: null,
|
||||
transportCharges: null,
|
||||
transportCharges: 0,
|
||||
description: "",
|
||||
invoiceAttachmentTypeId: null,
|
||||
attachments: [],
|
||||
|
||||
@ -13,7 +13,7 @@ const PurchaseTransportDetails = () => {
|
||||
<div className="row g-3 text-start">
|
||||
{/* Invoice Number */}
|
||||
<div className="col-12 col-md-6">
|
||||
<Label htmlFor="invoiceNumber" required>
|
||||
<Label htmlFor="invoiceNumber" >
|
||||
Invoice Number
|
||||
</Label>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user