This commit is contained in:
omkieit 2024-10-08 21:53:59 +05:30
parent 63d13247c1
commit 3148ade7c0
4 changed files with 217 additions and 172 deletions

View File

@ -66,6 +66,12 @@ const propertySchema = mongoose.Schema({
type: Number,
default: new Date().getFullYear(),
},
closeDataAtoB:{
type: Number,
},
closeDataBtoC:{
type: Number,
},
purchaseCost: {
type: Number,
required: true, // Set to true if this field is mandatory

File diff suppressed because one or more lines are too long

View File

@ -45,7 +45,7 @@
<script type="module" crossorigin src="/assets/index-C-cZIHwO.js"></script>
<script type="module" crossorigin src="/assets/index-BbbEpMBr.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
</head>

View File

@ -65,16 +65,35 @@ const Addproperty = () => {
{ title: "Real Estates fees", price: "" },
],
renovationCost: [
{ title: "Demolition: Removing existing structures or finishes", price: "" },
{
title: "Demolition: Removing existing structures or finishes",
price: "",
},
{ title: "Framing: Making structural changes or additions", price: "" },
{ title: "Plumbing: Installing or modifying plumbing systems", price: "" },
{
title: "Plumbing: Installing or modifying plumbing systems",
price: "",
},
{ title: "Electrical: Updating wiring and fixtures", price: "" },
{ title: "HVAC: Installing or upgrading heating and cooling systems", price: "" },
{
title: "HVAC: Installing or upgrading heating and cooling systems",
price: "",
},
{ title: "Insulation: Adding or replacing insulation", price: "" },
{ title: "Drywall: Hanging and finishing drywall", price: "" },
{ title: "Interior Finishes: Painting, flooring, cabinetry, and fixtures", price: "" },
{ title: "Exterior Work: Addressing siding, roofing, or landscaping, if applicable", price: "" },
{ title: "Final Inspections: Ensuring everything meets codes", price: "" },
{
title: "Interior Finishes: Painting, flooring, cabinetry, and fixtures",
price: "",
},
{
title:
"Exterior Work: Addressing siding, roofing, or landscaping, if applicable",
price: "",
},
{
title: "Final Inspections: Ensuring everything meets codes",
price: "",
},
{ title: "Punch List: Completing any remaining task", price: "" },
],
});
@ -389,7 +408,6 @@ const Addproperty = () => {
}, 0);
};
const addutilMaintenanceCost = () => {
setFormData((prevData) => ({
...prevData,
@ -451,14 +469,6 @@ const Addproperty = () => {
}, 0);
};
const addrenovationCost = () => {
setFormData((prevData) => ({
...prevData,
@ -520,23 +530,14 @@ const Addproperty = () => {
}, 0);
};
const calculatecostsAfterPropertyAcquisition = () => {
const totalIncidentalCost = calculateTotalincidentalCost();
const totalUtilMaintenanceCost = calculatetotalutilMaintenanceCost();
const totalRenovationCost = calculaterenovationCost();
// Sum up all the values from the three functions
return totalIncidentalCost + totalUtilMaintenanceCost + totalRenovationCost;
};
const handleNumericInput = (e) => {
const value = e.target.value;
@ -586,7 +587,9 @@ const Addproperty = () => {
formData.roofing &&
formData.totalSqft &&
formData.totalcashsurplus &&
formData.sellpricebtoc
formData.sellpricebtoc &&
formData.closeDataAtoB &&
formData.closeDataBtoC
) {
const totalCostsAtoB = calculateTotalCosts();
const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits();
@ -594,8 +597,9 @@ const Addproperty = () => {
const totalincidentalCost = calculateTotalincidentalCost();
const totalcredits = calculateTotalCredits();
const totalutilMaintenanceCost = calculatetotalutilMaintenanceCost();
const totalrenovationCost= calculaterenovationCost();
const costsAfterPropertyAcquisition= calculatecostsAfterPropertyAcquisition();
const totalrenovationCost = calculaterenovationCost();
const costsAfterPropertyAcquisition =
calculatecostsAfterPropertyAcquisition();
// Add user info to formData, including the propertyTaxInfo array
const formDataWithUserInfo = {
@ -612,8 +616,8 @@ const Addproperty = () => {
totalcashAdjustments: totalcashAdjustments,
totalincidentalCost: totalincidentalCost,
totalutilMaintenanceCost: totalutilMaintenanceCost,
totalrenovationCost:totalrenovationCost,
costsAfterPropertyAcquisition:costsAfterPropertyAcquisition,
totalrenovationCost: totalrenovationCost,
costsAfterPropertyAcquisition: costsAfterPropertyAcquisition,
};
// Check if propertyTaxInfo is an array and has values
@ -1551,38 +1555,80 @@ const Addproperty = () => {
borderRadius: "8px",
}}
>
<h3
<br />
<div className="row gy-3">
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Close Date A to B"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="date"
className="form-control"
value={formData.closeDataAtoB}
placeholder="Close Date A to B"
style={{ textAlign: "right" }}
required
/>
</div>
</div>
<br />
<div className="row gy-3">
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Close Date B to C"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="date"
className="form-control"
value={formData.closeDataBtoC}
placeholder="Close Date B to C"
style={{ textAlign: "right" }}
required
/>
</div>
</div>
<hr
style={{
borderColor: "#fda417", // Set the color of the line
borderWidth: "1px", // Optional: Adjust the thickness of the line
backgroundColor: "#fda417", // Optional: Apply color if using for background
height: "1px", // Optional: Set height to match the border width
}}
/>
<span
style={{
color: "#fda417",
border: "#fda417",
fontSize: "20px",
fontWeight: "normal",
fontSize: "14px",
fontWeight: "bold",
}}
>
Property Acquisition A to B:
</h3>
<br />
</span>
{/* <div className="form-floating mb-3">
<span style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}>Purchase Cost</span>
<input
type="text"
className="form-control"
value={formData.purchaseCost}
onChange={(e) =>
setFormData({
...formData,
purchaseCost: e.target.value,
})
}
placeholder="Enter Purchase Cost"
required
/>
</div> */}
<br />
<div className="row gy-3">
<div className="col-md-4">
<input
@ -1594,41 +1640,42 @@ const Addproperty = () => {
/>
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""}`}
value={formData.purchaseCost}
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({
...formData,
purchaseCost: value,
isPurchaseCostInvalid: !isValid, // Set isPurchaseCostInvalid to true if the value is not a valid number
});
}}
onKeyPress={(e) => {
const charCode = e.charCode;
// Allow only numbers and decimal points
if ((charCode < 48 || charCode > 57) && charCode !== 46) {
e.preventDefault(); // Prevent non-numeric input
setFormData({
...formData,
isPurchaseCostInvalid: true, // Set isPurchaseCostInvalid to true to show the alert
});
}
}}
placeholder="Enter Purchase Cost"
style={{ textAlign: "right" }}
required
/>
{formData.isPurchaseCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.purchaseCost}
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({
...formData,
purchaseCost: value,
isPurchaseCostInvalid: !isValid, // Set isPurchaseCostInvalid to true if the value is not a valid number
});
}}
onKeyPress={(e) => {
const charCode = e.charCode;
// Allow only numbers and decimal points
if ((charCode < 48 || charCode > 57) && charCode !== 46) {
e.preventDefault(); // Prevent non-numeric input
setFormData({
...formData,
isPurchaseCostInvalid: true, // Set isPurchaseCostInvalid to true to show the alert
});
}
}}
placeholder="Enter Purchase Cost"
style={{ textAlign: "right" }}
required
/>
{formData.isPurchaseCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<hr
style={{
@ -2285,9 +2332,7 @@ const Addproperty = () => {
}}
/>
<span
<span
style={{
color: "#fda417",
fontSize: "14px",
@ -2299,21 +2344,25 @@ const Addproperty = () => {
{formData.renovationCost.map((cost, index) => (
<div key={index} className="row gy-3 align-items-center">
<div className="col-md-4">
<input
type="text"
className="form-control"
value={cost.title}
onChange={(e) =>
handlerenovationCostTitle(index, "title", e.target.value)
}
placeholder="Title"
required
style={{
fontSize: "10px", // Set the desired font size
}}
/>
</div>
<div className="col-md-4">
<input
type="text"
className="form-control"
value={cost.title}
onChange={(e) =>
handlerenovationCostTitle(
index,
"title",
e.target.value
)
}
placeholder="Title"
required
style={{
fontSize: "10px", // Set the desired font size
}}
/>
</div>
<div className="col-md-4">
<input
@ -2322,9 +2371,7 @@ const Addproperty = () => {
cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={cost.price}
onChange={(e) =>
handlerenovationCostChange(e, index)
} // Use a new handler for price validation
onChange={(e) => handlerenovationCostChange(e, index)} // Use a new handler for price validation
placeholder="Price"
style={{ textAlign: "right" }}
required
@ -2403,7 +2450,7 @@ const Addproperty = () => {
}}
/>
<div className="row gy-3 align-items-center">
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
@ -2441,8 +2488,7 @@ const Addproperty = () => {
}}
/>
<div className="row gy-3 align-items-center">
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
@ -2454,45 +2500,43 @@ const Addproperty = () => {
Selling Price B to C
</span>
<div className="col-md-4">
<input
type="text"
className={`form-control ${formData.isInvalid ? "is-invalid" : ""}`}
name="sellpricebtoc"
value={formData.sellpricebtoc}
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Allow only numbers and decimal points
setFormData({
...formData,
sellpricebtoc: value,
isInvalid: !isValid, // Set isInvalid to true if the value is not a valid number
});
}}
onKeyPress={(e) => {
const charCode = e.charCode;
// Allow only numbers and decimal point
if ((charCode < 48 || charCode > 57) && charCode !== 46) {
e.preventDefault(); // Prevent non-numeric input
setFormData({
...formData,
isInvalid: true, // Set isInvalid to true to show the alert
});
}
}}
placeholder="Selling Price B to C"
style={{ textAlign: "right" }}
required
/>
{formData.isInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
<input
type="text"
className={`form-control ${
formData.isInvalid ? "is-invalid" : ""
}`}
name="sellpricebtoc"
value={formData.sellpricebtoc}
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Allow only numbers and decimal points
setFormData({
...formData,
sellpricebtoc: value,
isInvalid: !isValid, // Set isInvalid to true if the value is not a valid number
});
}}
onKeyPress={(e) => {
const charCode = e.charCode;
// Allow only numbers and decimal point
if ((charCode < 48 || charCode > 57) && charCode !== 46) {
e.preventDefault(); // Prevent non-numeric input
setFormData({
...formData,
isInvalid: true, // Set isInvalid to true to show the alert
});
}
}}
placeholder="Selling Price B to C"
style={{ textAlign: "right" }}
required
/>
{formData.isInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<hr
@ -2504,11 +2548,6 @@ const Addproperty = () => {
}}
/>
<div className="col-md-4">
<button
className="btn btn-primary back"