This commit is contained in:
omkieit 2024-10-12 14:54:41 +05:30
parent c8d2af7902
commit b758b3a1b9
6 changed files with 266 additions and 165 deletions

View File

@ -82,6 +82,10 @@ const propertySchema = mongoose.Schema({
type: Number,
required: true, // Set to true if this field is mandatory
},
rateofreturn :{
type: Number,
required: true, // Set to true if this field is mandatory
},
costPaidAtoB: [
{
title: {

File diff suppressed because one or more lines are too long

View File

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

View File

@ -16,6 +16,7 @@
"ef-ui": "file:",
"jwt-decode": "^4.0.0",
"mdb-react-ui-kit": "^8.0.0",
"moment": "^2.30.1",
"primeicons": "^7.0.0",
"prop-types": "^15.8.1",
"react": "^18.3.1",
@ -2727,6 +2728,15 @@
"node": "*"
}
},
"node_modules/moment": {
"version": "2.30.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
"integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
"license": "MIT",
"engines": {
"node": "*"
}
},
"node_modules/ms": {
"version": "2.1.2",
"dev": true,

View File

@ -18,6 +18,7 @@
"ef-ui": "file:",
"jwt-decode": "^4.0.0",
"mdb-react-ui-kit": "^8.0.0",
"moment": "^2.30.1",
"primeicons": "^7.0.0",
"prop-types": "^15.8.1",
"react": "^18.3.1",

View File

@ -26,7 +26,7 @@ const Addproperty = () => {
const [formData, setFormData] = useState({
propertyTaxInfo: [
{ propertytaxowned: "", ownedyear: "", taxassessed: "", taxyear: "" },
{ propertytaxowned: "0", ownedyear: "0", taxassessed: "0", taxyear: "0" },
],
images: [{ title: "", file: "" }], // Array to hold image objects
googleMapLink: "", // Field for Google Maps link
@ -206,7 +206,10 @@ const Addproperty = () => {
};
const handlePriceChange = (e, index) => {
const value = e.target.value;
let value = e.target.value;
// Remove the dollar sign before validating
value = value.replace(/^\$/, '').trim(); // Remove '$' if it exists
// Use a regular expression to allow only numbers and decimals
const isNumber = /^\d*\.?\d*$/.test(value);
@ -227,7 +230,8 @@ const Addproperty = () => {
);
setFormData({ ...formData, costPaidAtoB: updatedCosts });
}
};
};
const calculateTotalPurchaseCosts = () => {
const totalCostsFromArray = formData.costPaidAtoB.reduce((total, cost) => {
@ -268,6 +272,8 @@ const Addproperty = () => {
const handleCreditPriceChange = (e, index) => {
const value = e.target.value;
// Regular expression to allow only numbers and optional decimals
const isNumber = /^\d*\.?\d*$/.test(value);
@ -839,6 +845,11 @@ const Addproperty = () => {
return NetProfitBeforeFinancingCosts - FinancingCostClosingCost;
};
const calculaterateofreturn =() => {
const rateofreturn = calculateNetProfit();
return rateofreturn;
}
const handleSubmit = () => {
if (
formData.address &&
@ -880,6 +891,7 @@ const Addproperty = () => {
formData.LongTermRental &&
formData.FinancingCostClosingCost
) {
const rateofreturn = calculaterateofreturn();
const totalPurchaseCosts = calculateTotalPurchaseCosts();
const totalPurchaseCostsaftercredits =
calculateTotalPurchaseCostsWithCredits();
@ -933,6 +945,7 @@ const Addproperty = () => {
netBtoCsalevalue: netBtoCsalevalue,
netprofitbeforefinancingcosts: netprofitbeforefinancingcosts,
NetProfit: NetProfit,
rateofreturn:rateofreturn
};
// Check if propertyTaxInfo is an array and has values
@ -1924,9 +1937,26 @@ const Addproperty = () => {
required
/>
</div>
<div>
<p><span style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}>[M-D-Y] </span>: <span style={{
color: "#000000",
fontSize: "14px",
fontWeight: "normal",
}}>{new Date(formData.closeDateAtoB).toLocaleDateString('en-US', {
month: 'numeric',
day: 'numeric',
year: 'numeric'
})}</span></p>
</div>
</div>
<br />
<div className="row gy-3">
{/* Close Date B to C */}
@ -1959,37 +1989,26 @@ const Addproperty = () => {
required
/>
</div>
</div>
<br />
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
<div>
<p><span style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Turn Time
</span>
<div className="col-md-4">
<input
type="text"
className="form-control"
value={turnTime}
readOnly
style={{
borderColor: "#fda417", // Custom border color for the input field
color: "#fda417", // Optionally apply text color to the input text
textAlign: "right",
}}
required
/>
}}>[M-D-Y] : </span>
<span style={{
color: "#000000",
fontSize: "14px",
fontWeight: "normal",
}}>{new Date(formData.closeDateBtoC).toLocaleDateString('en-US', {
month: 'numeric',
day: 'numeric',
year: 'numeric'
})}</span>
</p>
</div>
</div>
</div>
<br />
<div className="row gy-3 align-items-center">
<span
@ -2031,6 +2050,71 @@ const Addproperty = () => {
))}
</div>
</div>
<br />
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Rate of Return
</span>
<div className="col-md-4">
<input
type="text"
className="form-control"
name="rateofreturn"
// value={calculaterateofreturn()}
value={`$ ${calculaterateofreturn().toFixed(2)}`}
readOnly
style={{
borderColor: "#fda417", // Custom border color for the input field
color: "#fda417", // Optionally apply text color to the input text
textAlign: "right",
}}
required
/>
</div>
</div>
<br />
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Turn Time
</span>
<div className="col-md-4">
<input
type="text"
className="form-control"
value={turnTime}
readOnly
style={{
borderColor: "#fda417", // Custom border color for the input field
color: "#fda417", // Optionally apply text color to the input text
textAlign: "right",
}}
required
/>
</div>
</div>
<br />
<hr
style={{
@ -2041,7 +2125,7 @@ const Addproperty = () => {
}}
/>
<div className="row gy-3 align-items-center">
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
@ -2055,12 +2139,11 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={formData.purchaseCost}
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""}`}
value={`$ ${formData.purchaseCost}`} // Display the dollar sign in the input
name="purchaseCost"
onChange={(e) => {
const value = e.target.value;
let value = e.target.value.replace(/[^\d.]/g, ''); // Remove anything thats not a digit or decimal point
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
setFormData({
...formData,
@ -2089,7 +2172,9 @@ const Addproperty = () => {
</div>
)}
</div>
</div>
</div>
<hr
style={{
@ -2127,10 +2212,9 @@ const Addproperty = () => {
<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) => handlePriceChange(e, index)} // Use a new handler for price validation
className={`form-control ${cost.isInvalid ? "is-invalid" : ""}`}
value={`$ ${cost.price}`}
onChange={(e) => handlePriceChange(e, index)}
placeholder="Price"
style={{ textAlign: "right" }}
required
@ -2151,7 +2235,8 @@ const Addproperty = () => {
</button>
</div>
</div>
))}
))}
<div className="col-md-4">
<button
@ -2187,7 +2272,7 @@ const Addproperty = () => {
type="text"
className="form-control"
name="totalPurchaseCosts"
value={calculateTotalPurchaseCosts()}
value={`$ ${calculateTotalPurchaseCosts().toFixed(2)}`} // Add dollar sign before the calculated total and format it to 2 decimal places
readOnly
style={{
borderColor: "#fda417", // Custom border color for the input field
@ -2196,7 +2281,8 @@ const Addproperty = () => {
}}
required
/>
</div>
</div>
</div>
<hr
style={{
@ -2733,7 +2819,7 @@ const Addproperty = () => {
fontWeight: "bold",
}}
>
Reno and Holding Costs
Reno/Construction
</span>
{formData.renovationCost.map((cost, index) => (
@ -2801,7 +2887,7 @@ const Addproperty = () => {
>
+
</span>{" "}
Add Renovation and Holding cost
Add Reno/Construction
</button>
</div>