var app = angular.module('plunker', []);
app.filter('sumOfValue', function() {
return function (data, key) {
debugger;
if (angular.isUndefined(data) && angular.isUndefined(key))
return 0;
var sum = 0;
angular.forEach(data,function(v,k){
sum = sum + parseFloat(v[key]);
});
return sum.toFixed(2);
}
}).filter('totalSumCV', function() {
return function (data, key1, key2) {
if (angular.isUndefined(data) && angular.isUndefined(key1) && angular.isUndefined(key2))
return 0;
var sum = 0;
angular.forEach(data,function(v,k){
sum = sum + (parseFloat(v[key1]) * parseFloat(v[key2])/100);
});
return sum.toFixed(2);
}
}).controller('MainCtrl', function($scope) {
$scope.sryarndebitnote = [
{
"_id": "57ecb2861365a8150a34c660",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-09-29T06:19:50.046Z",
"shipment_id": "57dc0ad6a752016f1638c6bc",
"raised": false,
"conversion_rate": "62",
"percentage_tds": "10",
"percentage_servicetax": "15",
"percentage_commission": "3",
"invoice_value_fob": "300",
"invoice_value_cif": "50",
"invoice_quantity": "40",
"supplier_name": "asd",
"buyer_name": "Rohit"
},
{
"_id": "57ecb2861365a8150a34c660",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-09-29T06:19:50.046Z",
"shipment_id": "57dc0ad6a752016f1638c6bc",
"raised": false,
"conversion_rate": "62",
"percentage_tds": "10",
"percentage_servicetax": "15",
"percentage_commission": "6",
"invoice_value_fob": "600",
"invoice_value_cif": "50",
"invoice_quantity": "40",
"supplier_name": "asd",
"buyer_name": "Rohit"
},
{
"_id": "57ecb2861365a8150a34c660",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-09-29T06:19:50.046Z",
"shipment_id": "57dc0ad6a752016f1638c6bc",
"raised": true,
"conversion_rate": "62",
"percentage_tds": "10",
"percentage_servicetax": "15",
"percentage_commission": "4",
"invoice_value_fob": "400",
"invoice_value_cif": "50",
"invoice_quantity": "40",
"supplier_name": "asd",
"buyer_name": "Rohit"
},
{
"_id": "57ecb2861365a8150a34c660",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-09-29T06:19:50.046Z",
"shipment_id": "57dc0ad6a752016f1638c6bc",
"raised": true,
"conversion_rate": "62",
"percentage_tds": "10",
"percentage_servicetax": "15",
"percentage_commission": "3",
"invoice_value_fob": "100",
"invoice_value_cif": "50",
"invoice_quantity": "40",
"supplier_name": "asd",
"buyer_name": "Rohit"
},]
});
/* Put your css in here */
body {
font-size: 14px;
}
table
{
border-collapse:collapse;
}
table, td, th
{
border:1px solid black;
}
td{
padding: 2px;
}
.servicetaxinclusivetrue:before{
color: green!important;
content: "\f00c";
}
.servicetaxinclusivefalse:before{
color: red!important;
content: "\f00d";
}
.servicetaxexclusivetrue:before{
color: green!important;
content: "\f00c";
}
.servicetaxexclusivefalse:before{
color: red!important;
content: "\f00d";
}
.margin{
margin-top: 20px;
}
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<script data-require="[email protected]" src="https://code.angularjs.org/1.4.12/angular.js" data-semver="1.4.9"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<table ng-table="tableParams" class="table table-bordered ">
<thead>
<tr>
<th rowspan="2"> S.No </th>
<th rowspan="2"> fob </th>
<th rowspan="2"> Commision </th>
<th rowspan="2">Quantity</th>
</tr>
</thead>
<tr ng-repeat="mani in resultValue=(sryarndebitnote | filter:{raised: 'false'})">
<td >{{$index + 1}}</td>
<td >{{mani.invoice_value_fob}}</td>
<td >{{(mani.invoice_value_fob * (mani.percentage_commission/100)) | number:2}}</td>
<td >{{mani.invoice_quantity}}</td>
</tr>
<tr>
<td>sum</td>
<td>{{resultValue | sumOfValue:'invoice_value_fob'}}</td>
<td>A = {{resultValue | totalSumCV:'invoice_value_fob':'percentage_commission'}}</td>
<td></td>
</tr>
</table>
<table ng-table="tableParams" class="margin table table-bordered ">
<thead>
<tr>
<th rowspan="2"> S.No </th>
<th rowspan="2"> fob </th>
<th rowspan="2"> Commision </th>
<th rowspan="2">Quantity</th>
</tr>
</thead>
<tr ng-repeat="mani in resultValue2=(sryarndebitnote | filter:{raised: 'true'})">
<td >{{$index + 1}}</td>
<td >{{mani.invoice_value_fob}}</td>
<td >{{(mani.invoice_value_fob * (mani.percentage_commission/100)) | number:2}}</td>
<td >{{mani.invoice_quantity}}</td>
</tr>
<tr>
<td>sum</td>
<td>{{resultValue2 | sumOfValue:'invoice_value_fob'}}</td>
<td>B = {{resultValue2 | totalSumCV:'invoice_value_fob':'percentage_commission'}}</td>
<td></td>
</tr>
</table>
<table ng-table="tableParams" class="margin table table-bordered ">
<thead>
<tr>
<th rowspan="2"> S.No </th>
<th rowspan="2"> A + B </th>
</tr>
</thead>
<td >{{resultValue2 | totalSumCV:'invoice_value_fob':'percentage_commission'}}</td>
<td >C = {{((resultValue | totalSumCV:'invoice_value_fob':'percentage_commission') * 1) + ((resultValue2 | totalSumCV:'invoice_value_fob':'percentage_commission')*1)}}</td>
</table>
</body>
</html>
Здравствуйте @mani, вы пробовали это? – Sravan