Hello Team,
I am trying to sort data in my table from starting date to the end date and any time the date rang is selectd it should display the following on the HTML Page
Product quantity, subTotal, DiscountTotal, VatTotal, and Total below the data table.
HTML PAGE
id="exampleInputUser" aria-describedby="emailHelp"
ng-change="{{TotalAmount}}">
Quantity : {{totalQty}}
Subtotal : Ghc{{subTotal}}
Discount (%) : Ghc{{DiscountTotal}}
VAT (%) : Ghc{{VatTotal}}
Total : Ghc{{Total}}

Vishal JoshiRank #377 · 6.7K reputationPosted Apr 16, 2023, 1:32 AM EDT
Hello
As per the question you can get the total below the table. you can get it by below code.
$scope.totalQty = 0; $scope.subTotal = 0; $scope.DiscountTotal = 0; $scope.VatTotal = 0; $scope.Total = 0; $.each(salesRecordArray, function (index, val) { $scope.totalQty += val.quantity; $scope.subTotal += val.subTotal, $scope.DiscountTotal += val.DiscountTotal; $scope.VatTotal += val.VatTotal; $scope.Total += val.Total });Thanks
Vishal
Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Apr 15, 2023, 11:37 AM EDT
AngularJs Controller
(function () {
app.controller('PrintSalesRecord', ['$scope', '$http', '$compile', function ($scope, $http, $compile) {
// declaring a global scope variable
$scope.PrintSalesRecord = new Object();
var init = function () {
//GetProducts();
GetAllPrintSalesRecord();
}; // end of init
init(); //init is called
(function () {
app.controller('PrintSalesRecord', ['$scope', '$http', '$compile', function ($scope, $http, $compile) {
// declaring a global scope variable
$scope.PrintSalesRecord = new Object();
var init = function () {
GetAllPrintSalesRecord();
};
init();
}]);
}).call(angular);
HOME CONTROLLER
[HttpGet]
public ActionResult GetAllPrintSalesRecord()
{
ASPNETMASTERPOSTEntities db = new ASPNETMASTERPOSTEntities();
var dataList = db.tblSales.Join(
db.tblSalesDetails,
sales => sales.SalesId,
detail => detail.SalesId,
(sales, detail) => new { Sales = sales, detail = detail });
var modifiedData = dataList.Select(x => new
{
SalesDetailId = x.detail.SalesDetailId,
Quantity = x.detail.Quantity,
ProductId = x.detail.ProductId,
ProductName = x.detail.tblProduct.ProductName,
SalesId = x.Sales.SalesId,
OrderDate = x.Sales.OrderDate,
SubTotal = x.Sales.SubTotal,
DiscountPercent = x.Sales.DiscountPercent,
VatPercent = x.Sales.VatPercent,
TotalAmount = x.Sales.TotalAmount
}).ToList();
return Json(modifiedData, JsonRequestBehavior.AllowGet);
}
Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Apr 16, 2023, 5:26 AM EDT
Thank you so much Vishal for the help, it is working for me now