This commit is contained in:
omkieit 2024-10-13 18:08:36 +05:30
parent e365da1c7a
commit ec25e4d637
4 changed files with 690 additions and 825 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-BiIJaVB0.js"></script>
<script type="module" crossorigin src="/assets/index-CKYSXRdS.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
</head>

View File

@ -206,32 +206,31 @@ const Addproperty = () => {
};
const handlePriceChange = (e, index) => {
let value = e.target.value;
let value = e.target.value;
// Remove the dollar sign before validating
value = value.replace(/^\$/, '').trim(); // Remove '$' if it exists
// 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);
// If valid number, update state, otherwise show the alert
if (isNumber || value === "") {
const updatedCosts = formData.costPaidAtoB.map((cost, i) =>
i === index
? { ...cost, price: value, isInvalid: false } // Reset isInvalid if valid number
: cost
);
setFormData({ ...formData, costPaidAtoB: updatedCosts });
} else {
const updatedCosts = formData.costPaidAtoB.map((cost, i) =>
i === index
? { ...cost, isInvalid: true } // Keep isInvalid true for invalid input
: cost
);
setFormData({ ...formData, costPaidAtoB: updatedCosts });
}
};
// Use a regular expression to allow only numbers and decimals
const isNumber = /^\d*\.?\d*$/.test(value);
// If valid number, update state, otherwise show the alert
if (isNumber || value === "") {
const updatedCosts = formData.costPaidAtoB.map((cost, i) =>
i === index
? { ...cost, price: value, isInvalid: false } // Reset isInvalid if valid number
: cost
);
setFormData({ ...formData, costPaidAtoB: updatedCosts });
} else {
const updatedCosts = formData.costPaidAtoB.map((cost, i) =>
i === index
? { ...cost, isInvalid: true } // Keep isInvalid true for invalid input
: cost
);
setFormData({ ...formData, costPaidAtoB: updatedCosts });
}
};
const calculateTotalPurchaseCosts = () => {
const totalCostsFromArray = formData.costPaidAtoB.reduce((total, cost) => {
@ -272,8 +271,6 @@ 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);
@ -845,10 +842,10 @@ const Addproperty = () => {
return NetProfitBeforeFinancingCosts - FinancingCostClosingCost;
};
const calculaterateofreturn =() => {
const calculaterateofreturn = () => {
const rateofreturn = calculateNetProfit();
return rateofreturn;
}
};
const handleSubmit = () => {
if (
@ -945,7 +942,7 @@ const Addproperty = () => {
netBtoCsalevalue: netBtoCsalevalue,
netprofitbeforefinancingcosts: netprofitbeforefinancingcosts,
NetProfit: NetProfit,
rateofreturn:rateofreturn
rateofreturn: rateofreturn,
};
// Check if propertyTaxInfo is an array and has values
@ -1939,25 +1936,37 @@ const Addproperty = () => {
</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>
<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>
<div className="row gy-3">
{/* Close Date B to C */}
<div className="col-md-4">
@ -1991,23 +2000,34 @@ const Addproperty = () => {
</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.closeDateBtoC).toLocaleDateString('en-US', {
month: 'numeric',
day: 'numeric',
year: 'numeric'
})}</span>
<p>
<span
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
[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>
<div className="row gy-3 align-items-center">
@ -2081,10 +2101,7 @@ const Addproperty = () => {
</div>
</div>
<br />
<br />
<div className="row gy-3 align-items-center">
<span
@ -2114,8 +2131,6 @@ const Addproperty = () => {
</div>
<br />
<hr
style={{
borderColor: "#fda417", // Set the color of the line
@ -2125,56 +2140,56 @@ const Addproperty = () => {
}}
/>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Purchase Price
</span>
<div className="col-md-4">
<input
type="text"
className={`form-control ${formData.isPurchaseCostInvalid ? "is-invalid" : ""}`}
value={`$ ${formData.purchaseCost}`} // Display the dollar sign in the input
name="purchaseCost"
onChange={(e) => {
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,
purchaseCost: 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
});
}
}}
placeholder="Enter Purchase Cost"
style={{ textAlign: "right" }}
required
/>
{formData.isPurchaseCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<div className="row gy-3 align-items-center">
<span
className="col-md-4"
style={{
color: "#fda417",
fontSize: "14px",
fontWeight: "bold",
}}
>
Purchase Price
</span>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
formData.isPurchaseCostInvalid ? "is-invalid" : ""
}`}
value={`$ ${formData.purchaseCost}`} // Display the dollar sign in the input
name="purchaseCost"
onChange={(e) => {
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,
purchaseCost: 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
});
}
}}
placeholder="Enter Purchase Cost"
style={{ textAlign: "right" }}
required
/>
{formData.isPurchaseCostInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
</div>
<hr
style={{
@ -2196,47 +2211,48 @@ const Addproperty = () => {
</span>
{formData.costPaidAtoB.map((cost, index) => (
<div key={index} className="row gy-3 align-items-center">
<div className="col-md-4">
<input
type="text"
className="form-control"
value={cost.title}
onChange={(e) =>
handleCostChange(index, "title", e.target.value)
}
placeholder="Title"
required
/>
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${cost.isInvalid ? "is-invalid" : ""}`}
value={`$ ${cost.price}`}
onChange={(e) => handlePriceChange(e, index)}
placeholder="Price"
style={{ textAlign: "right" }}
required
/>
{cost.isInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
<div className="col-md-2 d-flex justify-content-start">
<button
className="btn btn-danger"
onClick={() => deleteCost(index)}
style={{ marginLeft: "5px" }}
>
x
</button>
</div>
</div>
))}
<div key={index} className="row gy-3 align-items-center">
<div className="col-md-4">
<input
type="text"
className="form-control"
value={cost.title}
onChange={(e) =>
handleCostChange(index, "title", e.target.value)
}
placeholder="Title"
required
/>
</div>
<div className="col-md-4">
<input
type="text"
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
}`}
value={`$ ${cost.price}`}
onChange={(e) => handlePriceChange(e, index)}
placeholder="Price"
style={{ textAlign: "right" }}
required
/>
{cost.isInvalid && (
<div className="invalid-feedback">
Please enter a valid number.
</div>
)}
</div>
<div className="col-md-2 d-flex justify-content-start">
<button
className="btn btn-danger"
onClick={() => deleteCost(index)}
style={{ marginLeft: "5px" }}
>
x
</button>
</div>
</div>
))}
<div className="col-md-4">
<button
@ -2268,21 +2284,20 @@ const Addproperty = () => {
Total Purchase Cost
</span>
<div className="col-md-4">
<input
type="text"
className="form-control"
name="totalPurchaseCosts"
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
color: "#fda417", // Optionally apply text color to the input text
textAlign: "right",
}}
required
/>
</div>
<input
type="text"
className="form-control"
name="totalPurchaseCosts"
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
color: "#fda417", // Optionally apply text color to the input text
textAlign: "right",
}}
required
/>
</div>
</div>
<hr
style={{
@ -2320,8 +2335,9 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${credits.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when 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
placeholder="Price"
@ -2468,8 +2484,9 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={cost.price}
onChange={(e) =>
handlecashAdjustmentsCostChange(e, index)
@ -2621,8 +2638,9 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when 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
placeholder="Price"
@ -2730,8 +2748,9 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when 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
placeholder="Price"
@ -2847,8 +2866,9 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when 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
placeholder="Price"
@ -3024,8 +3044,9 @@ const Addproperty = () => {
<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}
onChange={(e) => {
@ -3100,8 +3121,9 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
className={`form-control ${
cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when invalid
value={cost.price}
onChange={(e) =>
handlecostPaidOutofClosingChange(e, index)
@ -3287,8 +3309,9 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when 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
placeholder="Price"
@ -3438,8 +3461,9 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${cost.isInvalid ? "is-invalid" : ""
}`} // Apply 'is-invalid' class when 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
placeholder="Price"
@ -3605,8 +3629,9 @@ const Addproperty = () => {
<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"
onChange={(e) => {
@ -3680,8 +3705,9 @@ const Addproperty = () => {
<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"
onChange={(e) => {
@ -3730,8 +3756,9 @@ const Addproperty = () => {
<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"
onChange={(e) => {
@ -3780,8 +3807,9 @@ const Addproperty = () => {
<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"
onChange={(e) => {
@ -3830,8 +3858,9 @@ const Addproperty = () => {
<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"
onChange={(e) => {
@ -3911,10 +3940,11 @@ const Addproperty = () => {
<div className="col-md-4">
<input
type="text"
className={`form-control ${formData.isFinancingCostClosingCostInvalid
className={`form-control ${
formData.isFinancingCostClosingCostInvalid
? "is-invalid"
: ""
}`}
}`}
value={formData.FinancingCostClosingCost}
name="FinancingCostClosingCost"
onChange={(e) => {

File diff suppressed because it is too large Load Diff