done
This commit is contained in:
parent
df7b057580
commit
c996a2801d
|
@ -94,7 +94,7 @@ const propertySchema = mongoose.Schema({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
totalCostsAtoB: {
|
totalPurchaseCosts: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true, // Set to true if this field is mandatory
|
required: true, // Set to true if this field is mandatory
|
||||||
},
|
},
|
||||||
|
@ -114,7 +114,7 @@ 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
|
||||||
},
|
},
|
||||||
totalCostsAtoBaftercredits: {
|
totalPurchaseCostsaftercredits: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true, // Set to true if this field is mandatory
|
required: true, // Set to true if this field is mandatory
|
||||||
},
|
},
|
||||||
|
@ -134,7 +134,8 @@ 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
|
||||||
},
|
},
|
||||||
totalcashsurplus :{
|
|
||||||
|
totalcashrequiredonsettlement:{
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true, // Set to true if this field is mandatory
|
required: true, // Set to true if this field is mandatory
|
||||||
},
|
},
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script type="module" crossorigin src="/assets/index-BvZiYelZ.js"></script>
|
<script type="module" crossorigin src="/assets/index-COiggoDj.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ const Addproperty = () => {
|
||||||
{ title: "Recording Fee", price: "" },
|
{ title: "Recording Fee", price: "" },
|
||||||
{ title: "Property Tax", price: "" },
|
{ title: "Property Tax", price: "" },
|
||||||
],
|
],
|
||||||
credits: [{ title: "Credits received on settlement", price: "" }],
|
credits: [{ title: "Credits", price: "" }],
|
||||||
cashAdjustments: [{ title: "Credits received on settlement", price: "" }],
|
cashAdjustments: [{ title: "Cash Adjustments", price: "" }],
|
||||||
incidentalCost: [
|
incidentalCost: [
|
||||||
{ title: "Accounting Fees", price: "" },
|
{ title: "Accounting Fees", price: "" },
|
||||||
{ title: "Bank Charges", price: "" },
|
{ title: "Bank Charges", price: "" },
|
||||||
|
@ -203,7 +203,7 @@ const Addproperty = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const calculateTotalCosts = () => {
|
const calculateTotalPurchaseCosts = () => {
|
||||||
const totalCostsFromArray = formData.costPaidAtoB.reduce((total, cost) => {
|
const totalCostsFromArray = formData.costPaidAtoB.reduce((total, cost) => {
|
||||||
const price = parseFloat(cost.price) || 0; // Convert price to number
|
const price = parseFloat(cost.price) || 0; // Convert price to number
|
||||||
return total + price;
|
return total + price;
|
||||||
|
@ -270,7 +270,7 @@ const Addproperty = () => {
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const calculateTotalCostsWithCredits = () => {
|
const calculateTotalPurchaseCostsWithCredits = () => {
|
||||||
// Calculate total from costPaidAtoB array
|
// Calculate total from costPaidAtoB array
|
||||||
const totalCostsFromArray = formData.costPaidAtoB.reduce((total, cost) => {
|
const totalCostsFromArray = formData.costPaidAtoB.reduce((total, cost) => {
|
||||||
const price = parseFloat(cost.price) || 0; // Convert price to number
|
const price = parseFloat(cost.price) || 0; // Convert price to number
|
||||||
|
@ -349,6 +349,16 @@ const Addproperty = () => {
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const calculateTotalCashRequiredonSettlement= () => {
|
||||||
|
const totalcashAdjustments = calculatecashAdjustments();
|
||||||
|
const totalcredits = calculateTotalCredits();
|
||||||
|
const totalPurchaseCosts= calculateTotalPurchaseCosts();
|
||||||
|
|
||||||
|
// Sum up all the values from the three functions
|
||||||
|
return totalcashAdjustments + totalcredits + totalPurchaseCosts;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const addincidentalCost = () => {
|
const addincidentalCost = () => {
|
||||||
setFormData((prevData) => ({
|
setFormData((prevData) => ({
|
||||||
...prevData,
|
...prevData,
|
||||||
|
@ -541,23 +551,7 @@ const Addproperty = () => {
|
||||||
return totalIncidentalCost + totalUtilMaintenanceCost + totalRenovationCost;
|
return totalIncidentalCost + totalUtilMaintenanceCost + totalRenovationCost;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNumericInput = (e) => {
|
|
||||||
const value = e.target.value;
|
|
||||||
|
|
||||||
// Check if the input is not a valid number
|
|
||||||
if (isNaN(value)) {
|
|
||||||
setFormData({
|
|
||||||
...formData,
|
|
||||||
isInvalid: true, // Set validation flag if not a number
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setFormData({
|
|
||||||
...formData,
|
|
||||||
totalcashsurplus: value,
|
|
||||||
isInvalid: false, // Reset validation flag if valid
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (
|
if (
|
||||||
|
@ -589,16 +583,17 @@ const Addproperty = () => {
|
||||||
formData.roofing &&
|
formData.roofing &&
|
||||||
formData.totalSqft &&
|
formData.totalSqft &&
|
||||||
formData.renovationRisk &&
|
formData.renovationRisk &&
|
||||||
formData.totalcashsurplus &&
|
|
||||||
formData.sellpricebtoc &&
|
formData.sellpricebtoc &&
|
||||||
formData.closeDateAtoB &&
|
formData.closeDateAtoB &&
|
||||||
formData.closeDateBtoC
|
formData.closeDateBtoC
|
||||||
) {
|
) {
|
||||||
const totalCostsAtoB = calculateTotalCosts();
|
const totalPurchaseCosts = calculateTotalPurchaseCosts();
|
||||||
const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits();
|
const totalPurchaseCostsaftercredits = calculateTotalPurchaseCostsWithCredits();
|
||||||
const totalcashAdjustments = calculatecashAdjustments();
|
const totalcashAdjustments = calculatecashAdjustments();
|
||||||
const totalincidentalCost = calculateTotalincidentalCost();
|
const totalincidentalCost = calculateTotalincidentalCost();
|
||||||
const totalcredits = calculateTotalCredits();
|
const totalcredits = calculateTotalCredits();
|
||||||
|
const totalcashrequiredonsettlement = calculateTotalCashRequiredonSettlement();
|
||||||
const totalutilMaintenanceCost = calculatetotalutilMaintenanceCost();
|
const totalutilMaintenanceCost = calculatetotalutilMaintenanceCost();
|
||||||
const totalrenovationCost = calculaterenovationCost();
|
const totalrenovationCost = calculaterenovationCost();
|
||||||
const costsAfterPropertyAcquisition =
|
const costsAfterPropertyAcquisition =
|
||||||
|
@ -613,10 +608,11 @@ const Addproperty = () => {
|
||||||
usertitle: user?.result?.title,
|
usertitle: user?.result?.title,
|
||||||
useremail: user?.result?.email,
|
useremail: user?.result?.email,
|
||||||
userId: user?.result?.userId,
|
userId: user?.result?.userId,
|
||||||
totalCostsAtoB: totalCostsAtoB,
|
totalPurchaseCosts: totalPurchaseCosts,
|
||||||
totalcredits: totalcredits,
|
totalcredits: totalcredits,
|
||||||
totalCostsAtoBaftercredits: totalCostsAtoBaftercredits,
|
totalPurchaseCostsaftercredits: totalPurchaseCostsaftercredits,
|
||||||
totalcashAdjustments: totalcashAdjustments,
|
totalcashAdjustments: totalcashAdjustments,
|
||||||
|
totalcashrequiredonsettlement:totalcashrequiredonsettlement,
|
||||||
totalincidentalCost: totalincidentalCost,
|
totalincidentalCost: totalincidentalCost,
|
||||||
totalutilMaintenanceCost: totalutilMaintenanceCost,
|
totalutilMaintenanceCost: totalutilMaintenanceCost,
|
||||||
totalrenovationCost: totalrenovationCost,
|
totalrenovationCost: totalrenovationCost,
|
||||||
|
@ -1674,7 +1670,6 @@ const Addproperty = () => {
|
||||||
color: "#fda417", // Optionally apply text color to the input text
|
color: "#fda417", // Optionally apply text color to the input text
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
}}
|
}}
|
||||||
placeholder="Total Costs to Buy A to B"
|
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1730,27 +1725,18 @@ Renovation Risk
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
color: "#fda417",
|
|
||||||
fontSize: "14px",
|
|
||||||
fontWeight: "bold",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Property Acquisition A to B:
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<br />
|
<div className="row gy-3 align-items-center">
|
||||||
<div className="row gy-3">
|
<span
|
||||||
<div className="col-md-4">
|
className="col-md-4"
|
||||||
<input
|
style={{
|
||||||
type="text"
|
color: "#fda417",
|
||||||
className="form-control"
|
fontSize: "14px",
|
||||||
placeholder="Purchase Cost"
|
fontWeight: "bold",
|
||||||
required
|
}}
|
||||||
disabled
|
>
|
||||||
/>
|
Purchase Price
|
||||||
</div>
|
</span>
|
||||||
<div className="col-md-4">
|
<div className="col-md-4">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
@ -1789,6 +1775,7 @@ Renovation Risk
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr
|
<hr
|
||||||
style={{
|
style={{
|
||||||
borderColor: "#fda417", // Set the color of the line
|
borderColor: "#fda417", // Set the color of the line
|
||||||
|
@ -1879,14 +1866,14 @@ Renovation Risk
|
||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Total Costs to Buy A to B
|
Total Purchase Cost
|
||||||
</span>
|
</span>
|
||||||
<div className="col-md-4">
|
<div className="col-md-4">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
name="totalCostsAtoB"
|
name="totalPurchaseCosts"
|
||||||
value={calculateTotalCosts()}
|
value={calculateTotalPurchaseCosts()}
|
||||||
readOnly
|
readOnly
|
||||||
style={{
|
style={{
|
||||||
borderColor: "#fda417", // Custom border color for the input field
|
borderColor: "#fda417", // Custom border color for the input field
|
||||||
|
@ -2025,21 +2012,20 @@ Renovation Risk
|
||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Total Costs to Buy A to B After credits
|
Total Purchase Cost after Credits Received
|
||||||
</span>
|
</span>
|
||||||
<div className="col-md-4">
|
<div className="col-md-4">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
name="totalCostsAtoBaftercredits"
|
name="totalPurchaseCostsaftercredits"
|
||||||
value={calculateTotalCostsWithCredits()}
|
value={calculateTotalPurchaseCostsWithCredits()}
|
||||||
readOnly
|
readOnly
|
||||||
style={{
|
style={{
|
||||||
borderColor: "#fda417", // Custom border color for the input field
|
borderColor: "#fda417", // Custom border color for the input field
|
||||||
color: "#fda417", // Optionally apply text color to the input text
|
color: "#fda417", // Optionally apply text color to the input text
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
}}
|
}}
|
||||||
// placeholder="Total Costs to Buy A to B After credits"
|
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2169,7 +2155,8 @@ Renovation Risk
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="row gy-3 align-items-center">
|
|
||||||
|
<div className="row gy-3 align-items-center">
|
||||||
<span
|
<span
|
||||||
className="col-md-4"
|
className="col-md-4"
|
||||||
style={{
|
style={{
|
||||||
|
@ -2178,33 +2165,30 @@ Renovation Risk
|
||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Total Cash Required/(Surplus) on Settlement
|
Total Cash Required on Settlement
|
||||||
</span>
|
</span>
|
||||||
<div className="col-md-4">
|
<div className="col-md-4">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className={`form-control ${
|
className="form-control"
|
||||||
formData.isInvalid ? "is-invalid" : ""
|
name="totalcashrequiredonsettlement"
|
||||||
}`} // Apply 'is-invalid' class if invalid
|
value={calculateTotalCashRequiredonSettlement()}
|
||||||
name="totalcashsurplus"
|
|
||||||
value={formData.totalcashsurplus}
|
|
||||||
onChange={handleNumericInput} // Add handler for numeric validation
|
readOnly
|
||||||
style={{
|
style={{
|
||||||
borderColor: "#fda417", // Custom border color for the input field
|
borderColor: "#fda417", // Custom border color for the input field
|
||||||
color: "#fda417", // Optionally apply text color to the input text
|
color: "#fda417", // Optionally apply text color to the input text
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
}}
|
}}
|
||||||
placeholder="Enter only numbers"
|
// placeholder="Total Incidental Cost"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
{formData.isInvalid && (
|
|
||||||
<div className="invalid-feedback">
|
|
||||||
Please enter a valid number.
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<hr
|
<hr
|
||||||
style={{
|
style={{
|
||||||
borderColor: "#fda417", // Set the color of the line
|
borderColor: "#fda417", // Set the color of the line
|
||||||
|
|
Loading…
Reference in New Issue