|
@@ -36,39 +36,44 @@ function ranking_doctores(widget) {
|
|
|
getAccountInvoiceLine:function(id) {
|
|
|
var self = this;
|
|
|
return _.flatten(_.filter(self.AccountInvoiceLine,function (inv) {
|
|
|
- return inv.id === id;
|
|
|
- }));
|
|
|
- },
|
|
|
- getAccountInvoice:function(id) {
|
|
|
- var self = this;
|
|
|
- return _.flatten(_.filter(self.AccountInvoice,function (inv) {
|
|
|
- return inv.id === id && inv.type == 'out_invoice';
|
|
|
+ return inv.medic_id === id;
|
|
|
}));
|
|
|
},
|
|
|
+ // getAccountInvoice:function(id) {
|
|
|
+ // var self = this;
|
|
|
+ // return _.flatten(_.filter(self.AccountInvoice,function (inv) {
|
|
|
+ // return inv.id === id && inv.type == 'out_invoice';
|
|
|
+ // }));
|
|
|
+ // },
|
|
|
|
|
|
SalesmanRanking: function() {
|
|
|
var self = this;
|
|
|
+ console.log(self);
|
|
|
var ranking = [];
|
|
|
var amount = 0;
|
|
|
var ResUser = self.ResUser;
|
|
|
//console.log(ResUser);
|
|
|
_.each(ResUser, function (item) {
|
|
|
var AccountInvoiceLine = self.getAccountInvoiceLine(item.medic_id);
|
|
|
- //console.log(AccountInvoiceLine);
|
|
|
- var AccountInvoice = self.getAccountInvoice(AccountInvoiceLine.invoice_id);
|
|
|
- _.each(AccountInvoice, function (item1) {
|
|
|
- if(item1.type == 'out_invoice'){
|
|
|
+ // _.each(AccountInvoiceLine, function (item1) {
|
|
|
+ // if(item1.medic_id){
|
|
|
+ // var AccountInvoice = self.getAccountInvoice(AccountInvoiceLine.invoice_id);
|
|
|
|
|
|
- var account_invoice_amount = _.reduce(_.map(AccountInvoiceLine,function(item) {
|
|
|
- return item.subtotal;
|
|
|
- }),function(memo, num) {
|
|
|
- return memo + num;
|
|
|
- },0);
|
|
|
- amount = (account_invoice_amount);
|
|
|
+ //
|
|
|
+ // if(item1.type == 'out_invoice'){
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
+ var account_invoice_amount = _.reduce(_.map(AccountInvoiceLine,function(item) {
|
|
|
+ return item.quantity;
|
|
|
+ }),function(memo, num) {
|
|
|
+ return memo + num;
|
|
|
+ },0);
|
|
|
+ amount = (account_invoice_amount);
|
|
|
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // });
|
|
|
if(amount > 0 ){
|
|
|
ranking.push({
|
|
|
name: item.name,
|