done
This commit is contained in:
parent
ff5192bb80
commit
992a358b6f
|
@ -98,6 +98,10 @@ const propertySchema = mongoose.Schema({
|
|||
},
|
||||
},
|
||||
],
|
||||
totalcredits:{
|
||||
type: Number,
|
||||
required: true, // Set to true if this field is mandatory
|
||||
},
|
||||
totalCostsAtoBaftercredits: {
|
||||
type: Number,
|
||||
required: true, // Set to true if this field is mandatory
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -45,7 +45,7 @@
|
|||
|
||||
|
||||
|
||||
<script type="module" crossorigin src="/assets/index-ZCzzzmuO.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-m-bZKZ3O.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
|
||||
</head>
|
||||
|
||||
|
|
|
@ -212,6 +212,14 @@ const Addproperty = () => {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
const calculateTotalCredits = () => {
|
||||
return formData.credits.reduce((total, credits) => {
|
||||
const price = parseFloat(credits.price);
|
||||
return total + (isNaN(price) ? 0 : price); // Ensure only valid numbers are added
|
||||
}, 0);
|
||||
};
|
||||
|
||||
const calculateTotalCostsWithCredits = () => {
|
||||
// Calculate total from costPaidAtoB array
|
||||
const totalCostsFromArray = formData.costPaidAtoB.reduce((total, cost) => {
|
||||
|
@ -324,6 +332,7 @@ const Addproperty = () => {
|
|||
const totalCostsAtoB = calculateTotalCosts();
|
||||
const totalCostsAtoBaftercredits = calculateTotalCostsWithCredits();
|
||||
const totalincidentalCost = calculateTotalincidentalCost();
|
||||
const totalcredits= calculateTotalCredits();
|
||||
|
||||
// Add user info to formData, including the propertyTaxInfo array
|
||||
const formDataWithUserInfo = {
|
||||
|
@ -335,6 +344,7 @@ const Addproperty = () => {
|
|||
useremail: user?.result?.email,
|
||||
userId: user?.result?.userId,
|
||||
totalCostsAtoB: totalCostsAtoB,
|
||||
totalcredits:totalcredits,
|
||||
totalCostsAtoBaftercredits: totalCostsAtoBaftercredits,
|
||||
totalincidentalCost:totalincidentalCost,
|
||||
};
|
||||
|
@ -1312,7 +1322,7 @@ const Addproperty = () => {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<hr />
|
||||
|
||||
<span
|
||||
style={{
|
||||
|
@ -1414,6 +1424,7 @@ const Addproperty = () => {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<span
|
||||
style={{
|
||||
|
@ -1487,6 +1498,39 @@ const Addproperty = () => {
|
|||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="row gy-3 align-items-center">
|
||||
<span
|
||||
className="col-md-4"
|
||||
style={{
|
||||
color: "#fda417",
|
||||
fontSize: "14px",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
Total credits
|
||||
</span>
|
||||
<div className="col-md-4">
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
name="totalcredits"
|
||||
value={calculateTotalCredits()}
|
||||
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 />
|
||||
|
||||
|
||||
|
||||
<div className="row gy-3 align-items-center">
|
||||
<span
|
||||
className="col-md-4"
|
||||
|
@ -1619,8 +1663,10 @@ const Addproperty = () => {
|
|||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
<div className="col-md-4">
|
||||
|
|
Loading…
Reference in New Issue