done
This commit is contained in:
parent
928df792c6
commit
0e7abb67d3
|
@ -206,11 +206,14 @@ const propertySchema = mongoose.Schema({
|
|||
type: Number,
|
||||
required: true, // Set to true if this field is mandatory
|
||||
},
|
||||
grossproceedsperHUD:{
|
||||
totaladjustments:{
|
||||
type: Number,
|
||||
required: true, // Set to true if this field is mandatory
|
||||
},
|
||||
fundsavailablefordistribution:{
|
||||
type: Number,
|
||||
required: true, // Set to true if this field is mandatory
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
const PropertyModal = mongoose.model("property", propertySchema);
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -45,7 +45,7 @@
|
|||
|
||||
|
||||
|
||||
<script type="module" crossorigin src="/assets/index-CQLqv-UN.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-D_QrejLk.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
|
||||
</head>
|
||||
|
||||
|
|
|
@ -93,6 +93,9 @@ const Addproperty = () => {
|
|||
{ title: "Payoff of 1st Mortgage", price: "0"},
|
||||
{ title: "Payoff of 2nd Mortgage", price: "0"},
|
||||
{ title: "Payoff 3rd Mortgage", price: "0"},
|
||||
],
|
||||
adjustments:[
|
||||
{ title: "adjustments", price: "0"},
|
||||
]
|
||||
});
|
||||
|
||||
|
@ -623,11 +626,81 @@ const Addproperty = () => {
|
|||
const sekkingPriceBtoC= formData.sellingPriceBtoC;
|
||||
const costPaidOutofClosing = calculateTotalcostPaidOutofClosing();
|
||||
return sekkingPriceBtoC - costPaidOutofClosing;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
const addadjustments = () => {
|
||||
setFormData((prevData) => ({
|
||||
...prevData,
|
||||
adjustments: [...prevData.adjustments, { title: "", price: "" }],
|
||||
}));
|
||||
};
|
||||
|
||||
const deleteadjustments = (index) => {
|
||||
const updatedadjustments = formData.adjustments.filter(
|
||||
(_, i) => i !== index
|
||||
);
|
||||
setFormData((prevData) => ({
|
||||
...prevData,
|
||||
adjustments: updatedadjustments,
|
||||
}));
|
||||
};
|
||||
|
||||
// Function to handle changes to incidentalCost title and price
|
||||
const handleadjustmentsTitle = (index, field, value) => {
|
||||
const updatedadjustments = [...formData.adjustments];
|
||||
updatedadjustments[index][field] = value;
|
||||
setFormData((prevData) => ({
|
||||
...prevData,
|
||||
adjustments: updatedadjustments,
|
||||
}));
|
||||
};
|
||||
|
||||
const handleadjustmentsChange = (e, index) => {
|
||||
const value = e.target.value;
|
||||
|
||||
// Regular expression to allow only numbers and optional decimals
|
||||
const isNumber = /^\d*\.?\d*$/.test(value);
|
||||
|
||||
// If valid number, update state, otherwise show the alert
|
||||
if (isNumber || value === "") {
|
||||
const updatedadjustments = formData.adjustments.map(
|
||||
(adjustments, i) =>
|
||||
i === index
|
||||
? { ...adjustments, price: value, isInvalid: false } // Reset isInvalid if valid number
|
||||
: adjustments
|
||||
);
|
||||
setFormData({ ...formData, adjustments: updatedadjustments });
|
||||
} else {
|
||||
const updatedadjustments = formData.adjustments.map(
|
||||
(adjustments, i) =>
|
||||
i === index
|
||||
? { ...adjustments, isInvalid: true } // Set isInvalid true for invalid input
|
||||
: adjustments
|
||||
);
|
||||
setFormData({ ...formData, adjustments: updatedadjustments });
|
||||
}
|
||||
};
|
||||
|
||||
// Calculate total from incidentalCost array
|
||||
const calculateTotaladjustments = () => {
|
||||
return formData.adjustments.reduce((total, adjustments) => {
|
||||
const price = parseFloat(adjustments.price);
|
||||
return total + (isNaN(price) ? 0 : price); // Ensure only valid numbers are added
|
||||
}, 0);
|
||||
};
|
||||
|
||||
const calculatefundsavailablefordistribution =() => {
|
||||
const sekkingPriceBtoC= formData.sellingPriceBtoC;
|
||||
const costPaidOutofClosing = calculateTotalcostPaidOutofClosing();
|
||||
return sekkingPriceBtoC - costPaidOutofClosing;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (
|
||||
formData.address &&
|
||||
|
@ -674,6 +747,7 @@ const Addproperty = () => {
|
|||
const totalRenovationsandHoldingCost = calculatetotalRenovationsandHoldingCost();
|
||||
const totalCoststoBuyAtoB = calculatetotalCoststoBuyAtoB();
|
||||
const costPaidOutofClosing = calculateTotalcostPaidOutofClosing();
|
||||
const totaladjustments = calculateTotaladjustments();
|
||||
|
||||
// Add user info to formData, including the propertyTaxInfo array
|
||||
const formDataWithUserInfo = {
|
||||
|
@ -695,6 +769,7 @@ const Addproperty = () => {
|
|||
totalRenovationsandHoldingCost: totalRenovationsandHoldingCost,
|
||||
totalCoststoBuyAtoB: totalCoststoBuyAtoB,
|
||||
costPaidOutofClosing:costPaidOutofClosing,
|
||||
totaladjustments:totaladjustments
|
||||
};
|
||||
|
||||
// Check if propertyTaxInfo is an array and has values
|
||||
|
@ -2948,6 +3023,162 @@ Renovation Risk
|
|||
</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",
|
||||
fontSize: "14px",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
Adjustments:
|
||||
</span>
|
||||
|
||||
{formData.adjustments.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) =>
|
||||
handleadjustmentsTitle(
|
||||
index,
|
||||
"title",
|
||||
e.target.value
|
||||
)
|
||||
}
|
||||
placeholder="Title"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="col-md-4">
|
||||
<input
|
||||
type="text"
|
||||
className={`form-control ${
|
||||
cost.isInvalid ? "is-invalid" : ""
|
||||
}`} // Apply 'is-invalid' class when invalid
|
||||
value={cost.price}
|
||||
onChange={(e) => handleadjustmentsChange(e, index)} // Use a new handler for price validation
|
||||
placeholder="Price"
|
||||
style={{ textAlign: "right" }}
|
||||
required
|
||||
/>
|
||||
{cost.isInvalid && (
|
||||
<div className="invalid-feedback">
|
||||
Please enter a valid number.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="col-md-2 d-flex justify-content-start">
|
||||
<button
|
||||
className="btn btn-danger"
|
||||
onClick={() => deleteadjustments(index)}
|
||||
style={{ marginLeft: "5px" }}
|
||||
>
|
||||
x
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
<div className="col-md-4">
|
||||
<button
|
||||
className="btn btn-primary back"
|
||||
onClick={addadjustments}
|
||||
style={{ backgroundColor: "#fda417", border: "#fda417" }}
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
fontSize: "20px",
|
||||
fontWeight: "normal",
|
||||
}}
|
||||
>
|
||||
+
|
||||
</span>{" "}
|
||||
Add Adjustments
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="row gy-3 align-items-center">
|
||||
<span
|
||||
className="col-md-4"
|
||||
style={{
|
||||
color: "#fda417",
|
||||
fontSize: "14px",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
Total Adjustments
|
||||
</span>
|
||||
<div className="col-md-4">
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
name="totaladjustments"
|
||||
value={calculateTotaladjustments()}
|
||||
readOnly
|
||||
style={{
|
||||
borderColor: "#fda417", // Custom border color for the input field
|
||||
color: "#fda417", // Optionally apply text color to the input text
|
||||
textAlign: "right",
|
||||
}}
|
||||
// placeholder="Total Incidental Cost"
|
||||
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
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
<div className="row gy-3 align-items-center">
|
||||
<span
|
||||
className="col-md-4"
|
||||
style={{
|
||||
color: "#fda417",
|
||||
fontSize: "14px",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
Funds Available for distribution
|
||||
</span>
|
||||
<div className="col-md-4">
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
name="fundsavailablefordistribution"
|
||||
value={calculatefundsavailablefordistribution()}
|
||||
readOnly
|
||||
style={{
|
||||
borderColor: "#fda417", // Custom border color for the input field
|
||||
color: "#fda417", // Optionally apply text color to the input text
|
||||
textAlign: "right",
|
||||
}}
|
||||
// placeholder="Total Incidental Cost"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue