This commit is contained in:
omkieit 2024-10-10 20:46:02 +05:30
parent 17d889edc3
commit 95d7c7b00b
5 changed files with 597 additions and 90 deletions

View File

@ -254,6 +254,38 @@ 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
}, },
fundspriortoclosing:{
type: Number,
required: true, // Set to true if this field is mandatory
},
shorttermrental:{
type: Number,
required: true, // Set to true if this field is mandatory
},
OtherIncome:{
type: Number,
required: true, // Set to true if this field is mandatory
},
InsuranceClaim:{
type: Number,
required: true, // Set to true if this field is mandatory
},
LongTermRental:{
type: Number,
required: true, // Set to true if this field is mandatory
},
netprofitbeforefinancingcosts:{
type: Number,
required: true, // Set to true if this field is mandatory
},
FinancingCostClosingCost:{
type: Number,
required: true, // Set to true if this field is mandatory
},
NetProfit:{
type: Number,
required: true, // Set to true if this field is mandatory
},
}); });
const PropertyModal = mongoose.model("property", propertySchema); const PropertyModal = mongoose.model("property", propertySchema);

85
ef-ui/dist/assets/index-CJfbdL2a.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

@ -100,7 +100,13 @@ const Addproperty = () => {
incomestatement:[ incomestatement:[
{ title: "income statement", price: "0"}, { title: "income statement", price: "0"},
{ title: "income statement", price: "0"}, { title: "income statement", price: "0"},
] ],
fundspriortoclosing:"0",
shorttermrental:"0",
OtherIncome:"0",
InsuranceClaim:"0",
LongTermRental:"0",
FinancingCostClosingCost:"0",
}); });
const [submitted, setSubmitted] = useState(false); const [submitted, setSubmitted] = useState(false);
@ -771,6 +777,23 @@ const calculatenetBtoCsalevalue = () =>{
return totalincomestatement + totalcosttosellbtoc; 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 calculateNetProfit = () => {
const NetProfitBeforeFinancingCosts = calculateNetProfitBeforeFinancingCosts();
const FinancingCostClosingCost = formData.FinancingCostClosingCost ;
return NetProfitBeforeFinancingCosts - FinancingCostClosingCost;
}
@ -807,7 +830,13 @@ const calculatenetBtoCsalevalue = () =>{
formData.closeDateAtoB && formData.closeDateAtoB &&
formData.closeDateBtoC && formData.closeDateBtoC &&
formData.purchaseCost && formData.purchaseCost &&
formData.sellingPriceBtoC formData.sellingPriceBtoC &&
formData.fundspriortoclosing &&
formData.shorttermrental &&
formData.OtherIncome &&
formData.InsuranceClaim &&
formData.LongTermRental &&
formData.FinancingCostClosingCost
) { ) {
const totalPurchaseCosts = calculateTotalPurchaseCosts(); const totalPurchaseCosts = calculateTotalPurchaseCosts();
const totalPurchaseCostsaftercredits = calculateTotalPurchaseCostsWithCredits(); const totalPurchaseCostsaftercredits = calculateTotalPurchaseCostsWithCredits();
@ -826,6 +855,8 @@ const calculatenetBtoCsalevalue = () =>{
const totalCosttoSellBtoC = calculateTotalCosttoSellBtoC(); const totalCosttoSellBtoC = calculateTotalCosttoSellBtoC();
const totalincomestatement = calculateTotalincomestatement(); const totalincomestatement = calculateTotalincomestatement();
const netBtoCsalevalue = calculatenetBtoCsalevalue(); const netBtoCsalevalue = calculatenetBtoCsalevalue();
const netprofitbeforefinancingcosts = calculateNetProfitBeforeFinancingCosts();
const NetProfit = calculateNetProfit();
// Add user info to formData, including the propertyTaxInfo array // Add user info to formData, including the propertyTaxInfo array
const formDataWithUserInfo = { const formDataWithUserInfo = {
@ -852,7 +883,9 @@ const calculatenetBtoCsalevalue = () =>{
grossproceedsperHUD:grossproceedsperHUD, grossproceedsperHUD:grossproceedsperHUD,
totalCosttoSellBtoC:totalCosttoSellBtoC, totalCosttoSellBtoC:totalCosttoSellBtoC,
totalincomestatement:totalincomestatement, totalincomestatement:totalincomestatement,
netBtoCsalevalue:netBtoCsalevalue netBtoCsalevalue:netBtoCsalevalue,
netprofitbeforefinancingcosts:netprofitbeforefinancingcosts,
NetProfit:NetProfit
}; };
// Check if propertyTaxInfo is an array and has values // Check if propertyTaxInfo is an array and has values
@ -1911,6 +1944,7 @@ const calculatenetBtoCsalevalue = () =>{
</div> </div>
</div> </div>
<br /> <br />
<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"
@ -2117,7 +2151,6 @@ Renovation Risk
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>
@ -3418,6 +3451,448 @@ Income Statement Adjustments:
</div> </div>
</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",
}}
>
Net Profit Computation
</span>
<div className="row gy-3 align-items-center">
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Total Costs to Buy A to B"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="text"
className="form-control"
name="totalCoststoBuyAtoBagain"
value={calculatetotalCoststoBuyAtoB()}
style={{ textAlign: "right" }}
required
/>
</div>
</div>
<br />
<div className="row gy-3">
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Funds Prior to Closing"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isfundspriortoclosingInvalid ? "is-invalid" : ""
}`}
value={formData.fundspriortoclosing}
name="fundspriortoclosing"
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({
...formData,
fundspriortoclosing: value,
isfundspriortoclosingInvalid: !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,
isfundspriortoclosingInvalid: true, // Set isPurchaseCostInvalid to true to show the alert
});
}
}}
style={{ textAlign: "right" }}
required
/>
{formData.isfundspriortoclosingInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<br />
<div className="row gy-3">
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Net B to C Sale Value"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="text"
className="form-control"
name="netBtoCsalevalue"
value={calculatenetBtoCsalevalue()}
style={{ textAlign: "right" }}
required
/>
</div>
</div>
<br />
<div className="row gy-3">
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Short Term Rental"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.shorttermrental}
name="shorttermrental"
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({
...formData,
shorttermrental: 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
});
}
}}
style={{ textAlign: "right" }}
required
/>
{formData.isPurchaseCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<br />
<div className="row gy-3">
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Other Income"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.OtherIncome}
name="OtherIncome"
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({
...formData,
OtherIncome: 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
});
}
}}
style={{ textAlign: "right" }}
required
/>
{formData.isPurchaseCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<br />
<div className="row gy-3">
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Insurance Claim"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.InsuranceClaim}
name="InsuranceClaim"
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({
...formData,
InsuranceClaim: 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
});
}
}}
style={{ textAlign: "right" }}
required
/>
{formData.isPurchaseCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<br />
<div className="row gy-3">
<div className="col-md-4">
<input
type="text"
className="form-control"
placeholder="Long Term Rental"
required
disabled
/>
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.LongTermRental}
name="LongTermRental"
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({
...formData,
LongTermRental: 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
});
}
}}
style={{ textAlign: "right" }}
required
/>
{formData.isPurchaseCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<br />
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Net Profit Before Financing Costs
</span>
<div className="col-md-4">
<input
type="text"
className="form-control"
name="netprofitbeforefinancingcosts"
value={calculateNetProfitBeforeFinancingCosts()}
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>
<br />
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Financing Cost/Other Closing Costs
</span>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isFinancingCostClosingCostInvalid ? "is-invalid" : ""
}`}
value={formData.FinancingCostClosingCost}
name="FinancingCostClosingCost"
onChange={(e) => {
const value = e.target.value;
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({
...formData,
FinancingCostClosingCost: value,
isFinancingCostClosingCostInvalid: !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,
isFinancingCostClosingCostInvalid: true, // Set isPurchaseCostInvalid to true to show the alert
});
}
}}
style={{ textAlign: "right" }}
required
/>
{formData.isFinancingCostClosingCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<br />
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Net Profit
</span>
<div className="col-md-4">
<input
type="text"
className="form-control"
name="netprofit"
value={calculateNetProfit()}
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>