Hi,
I have 3 tables on database
Orders
Orderid OrderName Orderdate
1 aaaaaaaaa 1/2/2019
Items
ItemId OrderId ItemName Price Quantity
1 1 a 1234 12
2 1 b 100 1
Taxes
TId ItemId Type Per
1 1 CGST 12
2 1 SGST 10
3 2 IGST 5
4 2 Normal 10
after clicking of button based upon orderid based upon OrderId need to generate pdf like below
Excepted o/p
OrderId :1 OrderName:aaaaaaaaaaa OrderDate:1/2/2019
ItemId OrderId ItemName Prcie Quantity Total TTotal GTotal
1 1 a 1234 12 14808 3257.76 18065.76
2 1 b 100 1 100 15 115
FinalTotal:18180.76
coming to calculations
1) I am getting Total value based upon Prcie and quantity
Total = Prcie * Quantity
2) TTotal based upon ItemId i hvae some values on Taxes table
Ex:Itemid=1 has 2 values on Taxes table(1,2)
I am going to do calculations
TId ItemId Type Per Tvalue
1 1 CGST 12 1776.96
2 1 SGST 10 1480.6
I am getting Tvalue based upon below formula
Tvalue = Total + per
Ex: Tval=14808+12/100=1776.96
Tval=14808+10/100=1480.0
TToatl = sum of Tval
like that i am going to do n no rows
3) I am getting GTotal based upon Total + total
AT last display total sum of Gtotal on form
I don't know how to do calculations on controller
Could you please help me
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Index</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp', []);
app.controller('MyController', ['$scope', '$http', function ($scope, $http) {
$http({
method: 'GET',
url: '/Home/getAll/'
}).success(function (data) {
$scope.items = data;
});
$scope.GenerateReport = function (id) {
$http({
method: 'POST',
url: '/Home/GenerateReport/',
params: { eId: id }
}).success(function (data) {
window.location = '/Home/Download?filename=' + data.FileName;
});;
};
} ]);
</script>
</head>
<body ng-app="MyApp" ng-controller="MyController">
<div class="container" id="printarea">
<table class="table table-bordered">
<tr class="success">
<th>OrderId</th>
<th>OrderName</th>
<th>OrderDate</th>
</tr>
<tr ng-repeat="item in items">
<td>{{item.OrderId}}</td>
<td>{{item.OrderName}}</td>
<td>{{item.OrderDate}}</td>
<td>
<button class="btn btn-success btn-sm" ng-click="GenerateReport(item.OrderId)">
<span class="glyphicon glyphicon-print"></span> PDF
</button>
</td>
</tr>
</table>
</div>
</body>
</html>