done
This commit is contained in:
parent
cbc7003537
commit
928df792c6
|
@ -198,6 +198,19 @@ const propertySchema = mongoose.Schema({
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true, // Set to true if this field is mandatory
|
required: true, // Set to true if this field is mandatory
|
||||||
},
|
},
|
||||||
|
costPaidOutofClosing:{
|
||||||
|
type: Number,
|
||||||
|
required: true, // Set to true if this field is mandatory
|
||||||
|
},
|
||||||
|
totalCosttoSellBtoC:{
|
||||||
|
type: Number,
|
||||||
|
required: true, // Set to true if this field is mandatory
|
||||||
|
},
|
||||||
|
grossproceedsperHUD:{
|
||||||
|
type: Number,
|
||||||
|
required: true, // Set to true if this field is mandatory
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const PropertyModal = mongoose.model("property", propertySchema);
|
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-BRIgFlBi.js"></script>
|
<script type="module" crossorigin src="/assets/index-CQLqv-UN.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,21 @@ const Addproperty = () => {
|
||||||
{ title: "Final Inspections: Ensuring everything meets codes", price: "0"},
|
{ title: "Final Inspections: Ensuring everything meets codes", price: "0"},
|
||||||
{ title: "Punch List: Completing any remaining task", price: "0" },
|
{ title: "Punch List: Completing any remaining task", price: "0" },
|
||||||
],
|
],
|
||||||
sellingPriceBtoC:"0"
|
sellingPriceBtoC:"0",
|
||||||
|
costPaidOutofClosing:[
|
||||||
|
{ title: "Buyers Agent Commission", price: "0"},
|
||||||
|
{ title: "Sellers Agent Commission", price: "0"},
|
||||||
|
{ title: "Home Warranty", price: "0"},
|
||||||
|
{ title: "Document Preparation", price: "0"},
|
||||||
|
{ title: "Excise Tax", price: "0"},
|
||||||
|
{ title: "Legal Fees", price: "0"},
|
||||||
|
{ title: "Wire Fees/courier Fees", price: "0"},
|
||||||
|
{ title: "County Taxes", price: "0"},
|
||||||
|
{ title: "HOA Fee", price: "0"},
|
||||||
|
{ title: "Payoff of 1st Mortgage", price: "0"},
|
||||||
|
{ title: "Payoff of 2nd Mortgage", price: "0"},
|
||||||
|
{ title: "Payoff 3rd Mortgage", price: "0"},
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const [submitted, setSubmitted] = useState(false);
|
const [submitted, setSubmitted] = useState(false);
|
||||||
|
@ -539,6 +553,76 @@ const Addproperty = () => {
|
||||||
|
|
||||||
// Sum up all the values from the three functions
|
// Sum up all the values from the three functions
|
||||||
return totalRenovationsandHoldingCost + totalCashRequiredonSettlement;
|
return totalRenovationsandHoldingCost + totalCashRequiredonSettlement;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const addcostPaidOutofClosing = () => {
|
||||||
|
setFormData((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
costPaidOutofClosing: [...prevData.costPaidOutofClosing, { title: "", price: "" }],
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const deletecostPaidOutofClosing = (index) => {
|
||||||
|
const updatedcostPaidOutofClosing = formData.costPaidOutofClosing.filter(
|
||||||
|
(_, i) => i !== index
|
||||||
|
);
|
||||||
|
setFormData((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
costPaidOutofClosing: updatedcostPaidOutofClosing,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
// Function to handle changes to incidentalCost title and price
|
||||||
|
const handlecostPaidOutofClosingTitle = (index, field, value) => {
|
||||||
|
const updatedcostPaidOutofClosing = [...formData.costPaidOutofClosing];
|
||||||
|
updatedcostPaidOutofClosing[index][field] = value;
|
||||||
|
setFormData((prevData) => ({
|
||||||
|
...prevData,
|
||||||
|
costPaidOutofClosing: updatedcostPaidOutofClosing,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlecostPaidOutofClosingChange = (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 updatedcostPaidOutofClosing = formData.costPaidOutofClosing.map(
|
||||||
|
(costPaidOutofClosing, i) =>
|
||||||
|
i === index
|
||||||
|
? { ...costPaidOutofClosing, price: value, isInvalid: false } // Reset isInvalid if valid number
|
||||||
|
: costPaidOutofClosing
|
||||||
|
);
|
||||||
|
setFormData({ ...formData, costPaidOutofClosing: updatedcostPaidOutofClosing });
|
||||||
|
} else {
|
||||||
|
const updatedcostPaidOutofClosing = formData.costPaidOutofClosing.map(
|
||||||
|
(costPaidOutofClosing, i) =>
|
||||||
|
i === index
|
||||||
|
? { ...costPaidOutofClosing, isInvalid: true } // Set isInvalid true for invalid input
|
||||||
|
: costPaidOutofClosing
|
||||||
|
);
|
||||||
|
setFormData({ ...formData, costPaidOutofClosing: updatedcostPaidOutofClosing });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Calculate total from costPaidOutofClosing array
|
||||||
|
const calculateTotalcostPaidOutofClosing = () => {
|
||||||
|
return formData.costPaidOutofClosing.reduce((total, costPaidOutofClosing) => {
|
||||||
|
const price = parseFloat(costPaidOutofClosing.price);
|
||||||
|
return total + (isNaN(price) ? 0 : price); // Ensure only valid numbers are added
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const calculateTotalCosttoSellBtoC =() => {
|
||||||
|
const sekkingPriceBtoC= formData.sellingPriceBtoC;
|
||||||
|
const costPaidOutofClosing = calculateTotalcostPaidOutofClosing();
|
||||||
|
return sekkingPriceBtoC - costPaidOutofClosing;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -575,7 +659,9 @@ const Addproperty = () => {
|
||||||
formData.totalSqft &&
|
formData.totalSqft &&
|
||||||
formData.renovationRisk &&
|
formData.renovationRisk &&
|
||||||
formData.closeDateAtoB &&
|
formData.closeDateAtoB &&
|
||||||
formData.closeDateBtoC
|
formData.closeDateBtoC &&
|
||||||
|
formData.totalCosttoSellBtoC &&
|
||||||
|
formData.grossproceedsperHUD
|
||||||
) {
|
) {
|
||||||
const totalPurchaseCosts = calculateTotalPurchaseCosts();
|
const totalPurchaseCosts = calculateTotalPurchaseCosts();
|
||||||
const totalPurchaseCostsaftercredits = calculateTotalPurchaseCostsWithCredits();
|
const totalPurchaseCostsaftercredits = calculateTotalPurchaseCostsWithCredits();
|
||||||
|
@ -587,6 +673,7 @@ const Addproperty = () => {
|
||||||
const totalrenovationCost = calculaterenovationCost();
|
const totalrenovationCost = calculaterenovationCost();
|
||||||
const totalRenovationsandHoldingCost = calculatetotalRenovationsandHoldingCost();
|
const totalRenovationsandHoldingCost = calculatetotalRenovationsandHoldingCost();
|
||||||
const totalCoststoBuyAtoB = calculatetotalCoststoBuyAtoB();
|
const totalCoststoBuyAtoB = calculatetotalCoststoBuyAtoB();
|
||||||
|
const costPaidOutofClosing = calculateTotalcostPaidOutofClosing();
|
||||||
|
|
||||||
// Add user info to formData, including the propertyTaxInfo array
|
// Add user info to formData, including the propertyTaxInfo array
|
||||||
const formDataWithUserInfo = {
|
const formDataWithUserInfo = {
|
||||||
|
@ -607,6 +694,7 @@ const Addproperty = () => {
|
||||||
totalrenovationCost: totalrenovationCost,
|
totalrenovationCost: totalrenovationCost,
|
||||||
totalRenovationsandHoldingCost: totalRenovationsandHoldingCost,
|
totalRenovationsandHoldingCost: totalRenovationsandHoldingCost,
|
||||||
totalCoststoBuyAtoB: totalCoststoBuyAtoB,
|
totalCoststoBuyAtoB: totalCoststoBuyAtoB,
|
||||||
|
costPaidOutofClosing:costPaidOutofClosing,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if propertyTaxInfo is an array and has values
|
// Check if propertyTaxInfo is an array and has values
|
||||||
|
@ -2675,6 +2763,195 @@ Renovation Risk
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
color: "#fda417",
|
||||||
|
fontSize: "14px",
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Less:Costs paid out of closing Hud B to C:
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{formData.costPaidOutofClosing.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) =>
|
||||||
|
handlecostPaidOutofClosingTitle(
|
||||||
|
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) => handlecostPaidOutofClosingChange(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={() => deletecostPaidOutofClosing(index)}
|
||||||
|
style={{ marginLeft: "5px" }}
|
||||||
|
>
|
||||||
|
x
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<div className="col-md-4">
|
||||||
|
<button
|
||||||
|
className="btn btn-primary back"
|
||||||
|
onClick={addcostPaidOutofClosing}
|
||||||
|
style={{ backgroundColor: "#fda417", border: "#fda417" }}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
fontSize: "20px",
|
||||||
|
fontWeight: "normal",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
+
|
||||||
|
</span>{" "}
|
||||||
|
Add Cost Paid Out of Closing
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row gy-3 align-items-center">
|
||||||
|
<span
|
||||||
|
className="col-md-4"
|
||||||
|
style={{
|
||||||
|
color: "#fda417",
|
||||||
|
fontSize: "14px",
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Total cost paid out of closing
|
||||||
|
</span>
|
||||||
|
<div className="col-md-4">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
name="costPaidOutofClosing"
|
||||||
|
value={calculateTotalcostPaidOutofClosing()}
|
||||||
|
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",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Total Cost to Sell B to C
|
||||||
|
</span>
|
||||||
|
<div className="col-md-4">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
name="totalCosttoSellBtoC"
|
||||||
|
value={calculateTotalCosttoSellBtoC()}
|
||||||
|
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",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Gross Proceeds per HUD
|
||||||
|
</span>
|
||||||
|
<div className="col-md-4">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
name="grossproceedsperHUD"
|
||||||
|
value={calculateTotalCosttoSellBtoC()}
|
||||||
|
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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className="col-md-4">
|
<div className="col-md-4">
|
||||||
<button
|
<button
|
||||||
className="btn btn-primary back"
|
className="btn btn-primary back"
|
||||||
|
|
Loading…
Reference in New Issue