public ActionResult GetAllPrintSalesRecord()
{
decimal total = 0;
decimal tax = 0;
decimal discount = 0;
if (modifiedData != null)
{
total = Convert.ToDecimal(TotalAmount);
discount = Sum(a=>a.DiscountPercent);
tax = Sum(discount * VatPercent) / 100);
}
return Json(new { modifiedData = modifiedData, total = total, discount = discount, tax = tax }, JsonRequestBehavior.AllowGet);
}
Loading
Vishal JoshiPosted Feb 8, 2024, 12:32 PM
Hello Emmmanuel,
You need to check if data is in list format or in single object. if it's in list format you need to sum all and then need to calculate discount on it.
Try the below code
Please change variable names accordingly.
Thanks
Vishal
Emmmanuel FIADUFEPosted Feb 8, 2024, 3:06 PM
Thank you team, it is working perfectly
Abhishek YadavPosted Feb 8, 2024, 12:16 PM
It seems that there is an inconsistency in the application of discount and VAT values in the controller code.
In the code snippet provided, the variables `discount` and `tax` are being calculated based on the `Sum` method, which is not clear from the code snippet what it is summing. Additionally, there is a syntax error in calculating the `tax` variable, as there is an extra closing parenthesis after dividing by 100.
To ensure consistency, it is important to check how the `discount` and `VatPercent` values are being calculated or retrieved before performing any calculations. It is also advisable to review the logic of the code to ensure accuracy in the calculation of the `discount` and `tax` variables.
Can you provide more details or context on how the `discount` and `VatPercent` values are being determined in your application?