|
@@ -13,6 +13,8 @@ function report_salesman_commission(reporting) {
|
|
|
'click #generate': 'fetchGenerate',
|
|
|
'change #current-company': 'updateSelections',
|
|
|
'change #current-store': 'updateUsers',
|
|
|
+ 'change #current-period' : 'updatePeriodSelections',
|
|
|
+ 'change #current-date' : 'ShowDateRange',
|
|
|
},
|
|
|
|
|
|
init: function(parent) {
|
|
@@ -37,6 +39,17 @@ function report_salesman_commission(reporting) {
|
|
|
return valor;
|
|
|
},
|
|
|
|
|
|
+ ShowDateRange : function(){
|
|
|
+ var self = this;
|
|
|
+ var date = self.$el.find('#current-date').val();
|
|
|
+ if(date == 'range'){
|
|
|
+ self.$el.find('.datepicker').css('display','block');
|
|
|
+ }
|
|
|
+ if(date != 'range'){
|
|
|
+ self.$el.find('.datepicker').css('display','none');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
checkModel: function(model) {
|
|
|
var self = this;
|
|
|
return _.filter(self.IrModuleModule, function(item) {
|
|
@@ -239,6 +252,9 @@ function report_salesman_commission(reporting) {
|
|
|
var store = self.$el.find('#current-store').val();
|
|
|
var period = self.$el.find('#current-period').val();
|
|
|
var company = self.$el.find('#current-company').val();
|
|
|
+ var date = self.$el.find('#current-date').val();
|
|
|
+ var desde = self.$el.find('#from').val();
|
|
|
+ var hasta = self.$el.find('#to').val();
|
|
|
|
|
|
if (store && store != 9999999) {
|
|
|
var journal_ids = _.map(_.filter(self.AccountJournal, function(item) {
|
|
@@ -266,6 +282,38 @@ function report_salesman_commission(reporting) {
|
|
|
domain.push(['period_id', '=', parseInt(period)]);
|
|
|
}
|
|
|
|
|
|
+ if(date && date != 9999999){
|
|
|
+ if(date == 'range'){
|
|
|
+ if(desde){
|
|
|
+ var date = desde.split('/')
|
|
|
+ date = (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
+ domain.push(['date_invoice','>=',date]);
|
|
|
+ }
|
|
|
+ if(hasta){
|
|
|
+ var date = hasta.split('/')
|
|
|
+ date = (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
+ domain.push(['date_invoice','<=',date]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(date == 'today'){
|
|
|
+ var today = moment().format('YYYY-MM-DD');
|
|
|
+ domain.push(['date_invoice','=',today]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(date == 'yesterday'){
|
|
|
+ var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
|
|
|
+ domain.push(['date_invoice','=',yesterday]);
|
|
|
+ }
|
|
|
+ if(date == 'currentMonth'){
|
|
|
+ var currentMonth = moment().format('YYYY-MM');
|
|
|
+ domain.push(['date_invoice','like',currentMonth]);
|
|
|
+ }
|
|
|
+ if(date == 'lastMonth'){
|
|
|
+ var lastMonth = moment().add(-1,'months').format('YYYY-MM');
|
|
|
+ domain.push(['date_invoice','like',lastMonth]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var field = ['id', 'number', 'state', 'type', 'amount_total', 'user_id', 'company_id', 'period_id', 'date_invoice', 'journal_id', 'credito', 'contado'];
|
|
|
var AccountInvoice = new model.web.Model('account.invoice');
|
|
|
AccountInvoice.query(field).filter(domain).all().then(function(results) {
|
|
@@ -354,6 +402,19 @@ function report_salesman_commission(reporting) {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ updatePeriodSelections: function () {
|
|
|
+ var self = this;
|
|
|
+ var period = self.$el.find('#current-period').val();
|
|
|
+ if(period != 9999999){
|
|
|
+ self.$el.find('#current-date').val(9999999);
|
|
|
+ self.$el.find('#current-date').prop('disabled','disabled');
|
|
|
+ self.$el.find('.datepicker').css('display','none');
|
|
|
+ }else{
|
|
|
+ self.$el.find('#current-date').prop('disabled',false);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
/*====================================================================
|
|
|
GET RES COMPANY
|
|
|
====================================================================*/
|
|
@@ -572,6 +633,9 @@ function report_salesman_commission(reporting) {
|
|
|
var store = self.$el.find('#current-store').val();
|
|
|
var user = self.$el.find('#current-user').val();
|
|
|
var period = self.$el.find('#current-period').val();
|
|
|
+ var date = self.$el.find('#current-date').val();
|
|
|
+ var desde = self.$el.find('#from').val();
|
|
|
+ var hasta = self.$el.find('#to').val();
|
|
|
|
|
|
var filter = [];
|
|
|
if (company && company != 9999999) {
|
|
@@ -613,6 +677,40 @@ function report_salesman_commission(reporting) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ if(date && date != 9999999){
|
|
|
+ moment.locale('es', {
|
|
|
+ months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
|
|
|
+ });
|
|
|
+
|
|
|
+ if(date == 'range'){
|
|
|
+ filter.push({
|
|
|
+ title: 'Fecha',
|
|
|
+ value: desde +' al '+hasta,
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if(date == 'today'){
|
|
|
+ var fecha = moment().format('DD/MM/YYYY');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(date == 'yesterday'){
|
|
|
+ var fecha = moment().add(-1,'days').format('DD/MM/YYYY');
|
|
|
+ }
|
|
|
+ if(date == 'currentMonth'){
|
|
|
+ var fecha = moment().format('MMMM/YYYY');
|
|
|
+ }
|
|
|
+ if(date == 'lastMonth'){
|
|
|
+ var fecha = moment().add(-1,'months').format('MMMM/YYYY');
|
|
|
+ }
|
|
|
+
|
|
|
+ filter.push({
|
|
|
+ title: 'Fecha',
|
|
|
+ value: fecha,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return filter;
|
|
|
},
|
|
|
});
|