done
This commit is contained in:
parent
c8d2af7902
commit
b758b3a1b9
|
@ -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
|
@ -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>
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
@ -229,6 +232,7 @@ const Addproperty = () => {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
const calculateTotalPurchaseCosts = () => {
|
||||
const totalCostsFromArray = formData.costPaidAtoB.reduce((total, cost) => {
|
||||
const price = parseFloat(cost.price) || 0; // Convert price to number
|
||||
|
@ -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>
|
||||
|
||||
<br />
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
<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={{
|
||||
|
@ -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 that’s not a digit or decimal point
|
||||
const isValid = /^\d*\.?\d*$/.test(value); // Regex to allow only numbers and decimal points
|
||||
setFormData({
|
||||
...formData,
|
||||
|
@ -2091,6 +2174,8 @@ const Addproperty = () => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<hr
|
||||
style={{
|
||||
borderColor: "#fda417", // Set the color of the line
|
||||
|
@ -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
|
||||
|
@ -2153,6 +2237,7 @@ const Addproperty = () => {
|
|||
</div>
|
||||
))}
|
||||
|
||||
|
||||
<div className="col-md-4">
|
||||
<button
|
||||
onClick={addCost}
|
||||
|
@ -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
|
||||
|
@ -2197,6 +2282,7 @@ const Addproperty = () => {
|
|||
required
|
||||
/>
|
||||
</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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue