This commit is contained in:
omkieit 2024-10-10 22:19:02 +05:30
parent 95d7c7b00b
commit c8d2af7902
3 changed files with 483 additions and 489 deletions

File diff suppressed because one or more lines are too long

View File

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

View File

@ -67,16 +67,35 @@ const Addproperty = () => {
{ title: "Real Estates fees", price: "0" },
],
renovationCost: [
{ title: "Demolition: Removing existing structures or finishes", price: "0"},
{
title: "Demolition: Removing existing structures or finishes",
price: "0",
},
{ title: "Framing: Making structural changes or additions", price: "0" },
{ title: "Plumbing: Installing or modifying plumbing systems", price: "0"},
{
title: "Plumbing: Installing or modifying plumbing systems",
price: "0",
},
{ title: "Electrical: Updating wiring and fixtures", price: "0" },
{ title: "HVAC: Installing or upgrading heating and cooling systems", price: "0"},
{
title: "HVAC: Installing or upgrading heating and cooling systems",
price: "0",
},
{ title: "Insulation: Adding or replacing insulation", price: "0" },
{ title: "Drywall: Hanging and finishing drywall", price: "0" },
{ title: "Interior Finishes: Painting, flooring, cabinetry, and fixtures", price: "0"},
{ title:"Exterior Work: Addressing siding, roofing, or landscaping, if applicable", price: "0"},
{ title: "Final Inspections: Ensuring everything meets codes", price: "0"},
{
title: "Interior Finishes: Painting, flooring, cabinetry, and fixtures",
price: "0",
},
{
title:
"Exterior Work: Addressing siding, roofing, or landscaping, if applicable",
price: "0",
},
{
title: "Final Inspections: Ensuring everything meets codes",
price: "0",
},
{ title: "Punch List: Completing any remaining task", price: "0" },
],
sellingPriceBtoC: "0",
@ -94,9 +113,7 @@ const Addproperty = () => {
{ title: "Payoff of 2nd Mortgage", price: "0" },
{ title: "Payoff 3rd Mortgage", price: "0" },
],
adjustments:[
{ title: "adjustments", price: "0"},
],
adjustments: [{ title: "adjustments", price: "0" }],
incomestatement: [
{ title: "income statement", price: "0" },
{ title: "income statement", price: "0" },
@ -367,7 +384,6 @@ const Addproperty = () => {
return totalcashAdjustments + totalcredits + totalPurchaseCosts;
};
const addincidentalCost = () => {
setFormData((prevData) => ({
...prevData,
@ -437,9 +453,7 @@ const Addproperty = () => {
};
const deletecarryCosts = (index) => {
const updatedcarryCosts = formData.carryCosts.filter(
(_, i) => i !== index
);
const updatedcarryCosts = formData.carryCosts.filter((_, i) => i !== index);
setFormData((prevData) => ({
...prevData,
carryCosts: updatedcarryCosts,
@ -464,16 +478,14 @@ const Addproperty = () => {
// If valid number, update state, otherwise show the alert
if (isNumber || value === "") {
const updatedcarryCosts = formData.carryCosts.map(
(carryCosts, i) =>
const updatedcarryCosts = formData.carryCosts.map((carryCosts, i) =>
i === index
? { ...carryCosts, price: value, isInvalid: false } // Reset isInvalid if valid number
: carryCosts
);
setFormData({ ...formData, carryCosts: updatedcarryCosts });
} else {
const updatedcarryCosts = formData.carryCosts.map(
(carryCosts, i) =>
const updatedcarryCosts = formData.carryCosts.map((carryCosts, i) =>
i === index
? { ...carryCosts, isInvalid: true } // Set isInvalid true for invalid input
: carryCosts
@ -561,19 +573,22 @@ const Addproperty = () => {
};
const calculatetotalCoststoBuyAtoB = () => {
const totalRenovationsandHoldingCost = calculatetotalRenovationsandHoldingCost();
const totalCashRequiredonSettlement = calculateTotalCashRequiredonSettlement();
const totalRenovationsandHoldingCost =
calculatetotalRenovationsandHoldingCost();
const totalCashRequiredonSettlement =
calculateTotalCashRequiredonSettlement();
// Sum up all the values from the three functions
return totalRenovationsandHoldingCost + totalCashRequiredonSettlement;
};
const addcostPaidOutofClosing = () => {
setFormData((prevData) => ({
...prevData,
costPaidOutofClosing: [...prevData.costPaidOutofClosing, { title: "", price: "" }],
costPaidOutofClosing: [
...prevData.costPaidOutofClosing,
{ title: "", price: "" },
],
}));
};
@ -611,7 +626,10 @@ const Addproperty = () => {
? { ...costPaidOutofClosing, price: value, isInvalid: false } // Reset isInvalid if valid number
: costPaidOutofClosing
);
setFormData({ ...formData, costPaidOutofClosing: updatedcostPaidOutofClosing });
setFormData({
...formData,
costPaidOutofClosing: updatedcostPaidOutofClosing,
});
} else {
const updatedcostPaidOutofClosing = formData.costPaidOutofClosing.map(
(costPaidOutofClosing, i) =>
@ -619,27 +637,30 @@ const Addproperty = () => {
? { ...costPaidOutofClosing, isInvalid: true } // Set isInvalid true for invalid input
: costPaidOutofClosing
);
setFormData({ ...formData, costPaidOutofClosing: updatedcostPaidOutofClosing });
setFormData({
...formData,
costPaidOutofClosing: updatedcostPaidOutofClosing,
});
}
};
// Calculate total from costPaidOutofClosing array
const calculateTotalcostPaidOutofClosing = () => {
return formData.costPaidOutofClosing.reduce((total, costPaidOutofClosing) => {
return formData.costPaidOutofClosing.reduce(
(total, costPaidOutofClosing) => {
const price = parseFloat(costPaidOutofClosing.price);
return total + (isNaN(price) ? 0 : price); // Ensure only valid numbers are added
}, 0);
},
0
);
};
const calculateTotalCosttoSellBtoC = () => {
const sekkingPriceBtoC = formData.sellingPriceBtoC;
const costPaidOutofClosing = calculateTotalcostPaidOutofClosing();
return sekkingPriceBtoC - costPaidOutofClosing;
};
const addadjustments = () => {
setFormData((prevData) => ({
...prevData,
@ -675,16 +696,14 @@ const Addproperty = () => {
// If valid number, update state, otherwise show the alert
if (isNumber || value === "") {
const updatedadjustments = formData.adjustments.map(
(adjustments, i) =>
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) =>
const updatedadjustments = formData.adjustments.map((adjustments, i) =>
i === index
? { ...adjustments, isInvalid: true } // Set isInvalid true for invalid input
: adjustments
@ -707,8 +726,6 @@ const Addproperty = () => {
return sellingPriceBtoC + totaladjustments;
};
const addincomestatement = () => {
setFormData((prevData) => ({
...prevData,
@ -770,32 +787,57 @@ const Addproperty = () => {
}, 0);
};
const calculatenetBtoCsalevalue = () => {
const totalincomestatement = calculateTotalincomestatement();
const totalcosttosellbtoc = calculateTotalCosttoSellBtoC();
return totalincomestatement + totalcosttosellbtoc;
}
};
const calculateNetProfitBeforeFinancingCosts = () => {
const netBtoCsalevalue = calculatenetBtoCsalevalue();
const shorttermrental= formData.shorttermrental;
const OtherIncome = formData.OtherIncome;
const InsuranceClaim = formData.InsuranceClaim;
const LongTermRental= formData.LongTermRental;
const totalCoststoBuyAtoB=calculatetotalCoststoBuyAtoB();
return netBtoCsalevalue + shorttermrental + OtherIncome + InsuranceClaim + LongTermRental - totalCoststoBuyAtoB;
}
// const netBtoCsalevalue = parseFloat(calculatenetBtoCsalevalue());
// const shorttermrental = parseFloat(formData.shorttermrental);
// const OtherIncome = parseFloat(formData.OtherIncome);
// const InsuranceClaim = parseFloat(formData.InsuranceClaim);
// const LongTermRental = parseFloat(formData.LongTermRental);
// const totalCoststoBuyAtoB = parseFloat(calculatetotalCoststoBuyAtoB());
const netBtoCsalevalue = isNaN(parseFloat(calculatenetBtoCsalevalue()))
? 0
: parseFloat(calculatenetBtoCsalevalue());
const shorttermrental = isNaN(parseFloat(formData.shorttermrental))
? 0
: parseFloat(formData.shorttermrental);
const OtherIncome = isNaN(parseFloat(formData.OtherIncome))
? 0
: parseFloat(formData.OtherIncome);
const InsuranceClaim = isNaN(parseFloat(formData.InsuranceClaim))
? 0
: parseFloat(formData.InsuranceClaim);
const LongTermRental = isNaN(parseFloat(formData.LongTermRental))
? 0
: parseFloat(formData.LongTermRental);
const totalCoststoBuyAtoB = isNaN(
parseFloat(calculatetotalCoststoBuyAtoB())
)
? 0
: parseFloat(calculatetotalCoststoBuyAtoB());
// Calculate the sum first, then subtract the total costs
const totalIncome =
netBtoCsalevalue +
shorttermrental +
OtherIncome +
InsuranceClaim +
LongTermRental;
const netProfitBeforeFinancingCosts = totalIncome - totalCoststoBuyAtoB;
return netProfitBeforeFinancingCosts;
};
const calculateNetProfit = () => {
const NetProfitBeforeFinancingCosts = calculateNetProfitBeforeFinancingCosts();
const NetProfitBeforeFinancingCosts =
calculateNetProfitBeforeFinancingCosts();
const FinancingCostClosingCost = formData.FinancingCostClosingCost;
return NetProfitBeforeFinancingCosts - FinancingCostClosingCost;
}
};
const handleSubmit = () => {
if (
@ -839,23 +881,28 @@ const calculatenetBtoCsalevalue = () =>{
formData.FinancingCostClosingCost
) {
const totalPurchaseCosts = calculateTotalPurchaseCosts();
const totalPurchaseCostsaftercredits = calculateTotalPurchaseCostsWithCredits();
const totalPurchaseCostsaftercredits =
calculateTotalPurchaseCostsWithCredits();
const totalcashAdjustments = calculatecashAdjustments();
const totalincidentalCost = calculateTotalincidentalCost();
const totalcredits = calculateTotalCredits();
const totalcashrequiredonsettlement = calculateTotalCashRequiredonSettlement();
const totalcashrequiredonsettlement =
calculateTotalCashRequiredonSettlement();
const totalcarryCosts = calculatetotalcarryCosts();
const totalrenovationCost = calculaterenovationCost();
const totalRenovationsandHoldingCost = calculatetotalRenovationsandHoldingCost();
const totalRenovationsandHoldingCost =
calculatetotalRenovationsandHoldingCost();
const totalCoststoBuyAtoB = calculatetotalCoststoBuyAtoB();
const costPaidOutofClosing = calculateTotalcostPaidOutofClosing();
const totaladjustments = calculateTotaladjustments();
const fundsavailablefordistribution = calculatefundsavailablefordistribution();
const fundsavailablefordistribution =
calculatefundsavailablefordistribution();
const grossproceedsperHUD = calculateTotalCosttoSellBtoC();
const totalCosttoSellBtoC = calculateTotalCosttoSellBtoC();
const totalincomestatement = calculateTotalincomestatement();
const netBtoCsalevalue = calculatenetBtoCsalevalue();
const netprofitbeforefinancingcosts = calculateNetProfitBeforeFinancingCosts();
const netprofitbeforefinancingcosts =
calculateNetProfitBeforeFinancingCosts();
const NetProfit = calculateNetProfit();
// Add user info to formData, including the propertyTaxInfo array
@ -885,7 +932,7 @@ const calculatenetBtoCsalevalue = () =>{
totalincomestatement: totalincomestatement,
netBtoCsalevalue: netBtoCsalevalue,
netprofitbeforefinancingcosts: netprofitbeforefinancingcosts,
NetProfit:NetProfit
NetProfit: NetProfit,
};
// Check if propertyTaxInfo is an array and has values
@ -948,7 +995,6 @@ const calculatenetBtoCsalevalue = () =>{
}
};
return (
<>
<div className="container tabs-wrap">
@ -1995,7 +2041,6 @@ Renovation Risk
}}
/>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
@ -2010,8 +2055,7 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.purchaseCost}
name="purchaseCost"
@ -2083,8 +2127,7 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={cost.price}
onChange={(e) => handlePriceChange(e, index)} // Use a new handler for price validation
@ -2191,8 +2234,7 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
credits.isInvalid ? "is-invalid" : ""
className={`form-control ${credits.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={credits.price}
onChange={(e) => handleCreditPriceChange(e, index)} // New handler for price validation
@ -2340,8 +2382,7 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={cost.price}
onChange={(e) =>
@ -2425,7 +2466,6 @@ Renovation Risk
}}
/>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
@ -2455,8 +2495,6 @@ Renovation Risk
</div>
</div>
<hr
style={{
borderColor: "#fda417", // Set the color of the line
@ -2497,8 +2535,7 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={cost.price}
onChange={(e) => handleincidentalCostChange(e, index)} // Use a new handler for price validation
@ -2598,11 +2635,7 @@ Renovation Risk
className="form-control"
value={cost.title}
onChange={(e) =>
handlecarryCostsTitle(
index,
"title",
e.target.value
)
handlecarryCostsTitle(index, "title", e.target.value)
}
placeholder="Title"
required
@ -2611,13 +2644,10 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={cost.price}
onChange={(e) =>
handlecarryCostsChange(e, index)
} // Use a new handler for price validation
onChange={(e) => handlecarryCostsChange(e, index)} // Use a new handler for price validation
placeholder="Price"
style={{ textAlign: "right" }}
required
@ -2731,8 +2761,7 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
className={`form-control ${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
@ -2895,7 +2924,6 @@ Renovation Risk
}}
/>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
@ -2910,8 +2938,7 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
name="sellingPriceBtoC"
value={formData.sellingPriceBtoC}
@ -2956,8 +2983,6 @@ Renovation Risk
}}
/>
<span
style={{
color: "#fda417",
@ -2989,11 +3014,12 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
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
onChange={(e) =>
handlecostPaidOutofClosingChange(e, index)
} // Use a new handler for price validation
placeholder="Price"
style={{ textAlign: "right" }}
required
@ -3072,7 +3098,6 @@ Renovation Risk
}}
/>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
@ -3111,7 +3136,6 @@ Renovation Risk
}}
/>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
@ -3150,8 +3174,6 @@ Renovation Risk
}}
/>
<span
style={{
color: "#fda417",
@ -3170,11 +3192,7 @@ Renovation Risk
className="form-control"
value={cost.title}
onChange={(e) =>
handleadjustmentsTitle(
index,
"title",
e.target.value
)
handleadjustmentsTitle(index, "title", e.target.value)
}
placeholder="Title"
required
@ -3183,8 +3201,7 @@ Renovation Risk
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
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
@ -3266,7 +3283,6 @@ Renovation Risk
}}
/>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
@ -3296,7 +3312,6 @@ Renovation Risk
</div>
</div>
<hr
style={{
borderColor: "#fda417", // Set the color of the line
@ -3337,8 +3352,7 @@ Income Statement Adjustments:
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={cost.price}
onChange={(e) => handleincomestatementChange(e, index)} // Use a new handler for price validation
@ -3420,8 +3434,6 @@ Income Statement Adjustments:
}}
/>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
@ -3448,7 +3460,6 @@ Income Statement Adjustments:
// placeholder="Total Incidental Cost"
required
/>
</div>
</div>
<hr
@ -3460,9 +3471,6 @@ Income Statement Adjustments:
}}
/>
<span
style={{
color: "#fda417",
@ -3511,8 +3519,7 @@ Income Statement Adjustments:
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isfundspriortoclosingInvalid ? "is-invalid" : ""
className={`form-control ${formData.isfundspriortoclosingInvalid ? "is-invalid" : ""
}`}
value={formData.fundspriortoclosing}
name="fundspriortoclosing"
@ -3585,11 +3592,9 @@ Income Statement Adjustments:
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.shorttermrental}
name="shorttermrental"
@ -3621,7 +3626,6 @@ Income Statement Adjustments:
Please enter a valid number.
</div>
)}
</div>
</div>
<br />
@ -3640,8 +3644,7 @@ Income Statement Adjustments:
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.OtherIncome}
name="OtherIncome"
@ -3691,8 +3694,7 @@ Income Statement Adjustments:
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.InsuranceClaim}
name="InsuranceClaim"
@ -3742,8 +3744,7 @@ Income Statement Adjustments:
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.LongTermRental}
name="LongTermRental"
@ -3824,8 +3825,9 @@ Income Statement Adjustments:
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isFinancingCostClosingCostInvalid ? "is-invalid" : ""
className={`form-control ${formData.isFinancingCostClosingCostInvalid
? "is-invalid"
: ""
}`}
value={formData.FinancingCostClosingCost}
name="FinancingCostClosingCost"
@ -3860,7 +3862,6 @@ Income Statement Adjustments:
</div>
</div>
<br />
<div className="row gy-3 align-items-center">
@ -3889,16 +3890,9 @@ Income Statement Adjustments:
// placeholder="Total Incidental Cost"
required
/>
</div>
</div>
<div className="col-md-4">
<button
className="btn btn-primary back"