|
@@ -12,7 +12,8 @@
|
|
|
hrPayslip: [],
|
|
|
payslipLine: [],
|
|
|
salaryRule: [],
|
|
|
-
|
|
|
+ resCompany: [],
|
|
|
+ resCurrency: [],
|
|
|
/* init */
|
|
|
init: function (parent) {
|
|
|
this._super(parent);
|
|
@@ -64,15 +65,35 @@
|
|
|
$('.expired-account-modal').remove();
|
|
|
$('.modal-backdrop').remove();
|
|
|
},
|
|
|
+ /* Description: Consultar Compania*/
|
|
|
+ fetchResCompany: function () {
|
|
|
+ var resComapy = new openerp.web.Model('res.company');
|
|
|
+ return resComapy.query(['id','name', 'currency_id']).filter([['id', '=', 1]]).all();
|
|
|
+ },
|
|
|
+ /* Description: Consultat Moneda Activas */
|
|
|
+ fetchResCurrecy : function() {
|
|
|
+ var fields = ['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
|
|
|
+ var domain = [['active', '=', true]];
|
|
|
+ var resCurrecy = new openerp.web.Model('res.currency');
|
|
|
+ return resCurrecy.query(fields).filter(domain).all();
|
|
|
+ },
|
|
|
+ /* Description: Filtar moneda de la compania */
|
|
|
+ getCurrencyCompany: function(id) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.resCurrency, function(item) {
|
|
|
+ return item.id === id;
|
|
|
+ });
|
|
|
+ },
|
|
|
/* Description: destroy objects*/
|
|
|
- destroyObjects: function(){
|
|
|
+ destroyObjects: function() {
|
|
|
var self = this;
|
|
|
-
|
|
|
self.row_id_select = undefined;
|
|
|
self.row_code_select = undefined;
|
|
|
self.hrPayslip = [];
|
|
|
self.payslipLine = [];
|
|
|
self.salaryRule = [];
|
|
|
+ self.resCompany = [];
|
|
|
+ self.resCurrency = [];
|
|
|
},
|
|
|
/* ---------------------------------------------------------------------
|
|
|
** Description : Crear Adealnto/ comision de Funcionario
|
|
@@ -80,7 +101,6 @@
|
|
|
/* Description: Funcion Inicial Crear Comicion/Adelanto */
|
|
|
fetchAddAdvancement: function() {
|
|
|
var self = this;
|
|
|
-
|
|
|
self.fetchPayslip().then(function(hrPayslip) {
|
|
|
return hrPayslip;
|
|
|
}).then(function(hrPayslip) {
|
|
@@ -91,6 +111,12 @@
|
|
|
return self.fetchSalaryRule();
|
|
|
}).then(function(salaryRule) {
|
|
|
self.salaryRule = salaryRule;
|
|
|
+ return self.fetchResCompany();
|
|
|
+ }).then(function(resCompany) {
|
|
|
+ self.resCompany = resCompany;
|
|
|
+ return self.fetchResCurrecy();
|
|
|
+ }).then(function(resCurrency) {
|
|
|
+ self.resCurrency = resCurrency;
|
|
|
return self.showPayslipAddAdvancement();
|
|
|
}).then(function() {
|
|
|
return self.recomputeSheet();
|
|
@@ -125,20 +151,20 @@
|
|
|
var payslipLine = self.payslipLine.shift();
|
|
|
var hrPayslip = self.hrPayslip.shift();
|
|
|
var defer = $.Deferred()
|
|
|
-
|
|
|
+ var company = self.resCompany.shift();
|
|
|
+ var currency = self.getCurrencyCompany(company.currency_id[0]).shift();
|
|
|
+ var amount_Adl = 0;
|
|
|
var employeData = [
|
|
|
{
|
|
|
'employe_name': hrPayslip.employee_id[1],
|
|
|
- 'salari': payslipLine.amount
|
|
|
+ 'salari': accounting.formatMoney(payslipLine.amount, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator)
|
|
|
}
|
|
|
];
|
|
|
-
|
|
|
var modalAdvancement = QWeb.render('EiruPayslipAddAdvancement',{
|
|
|
employeData: employeData,
|
|
|
salaryRule: self.salaryRule
|
|
|
});
|
|
|
|
|
|
-
|
|
|
$('.openerp_webclient_container').after(modalAdvancement);
|
|
|
$('.expired-account-modal').modal();
|
|
|
|
|
@@ -155,43 +181,36 @@
|
|
|
|
|
|
addAdvancement.click(function(e){
|
|
|
/* Operacion */
|
|
|
+ var amount = parseInt(accounting.unformat(ammount_input.val(),','));
|
|
|
if (!salary_rule.val()) {
|
|
|
openerp.web.notification.do_warn("Atención","Seleccione el tipo de operación.");
|
|
|
salary_rule.css('border-color','red');
|
|
|
- return
|
|
|
- } else {
|
|
|
- salary_rule.css('border-color','#ccc');
|
|
|
+ return;
|
|
|
}
|
|
|
+ salary_rule.css('border-color','#ccc');
|
|
|
/* Detalles */
|
|
|
if (!details.val()) {
|
|
|
openerp.web.notification.do_warn("Atención","Defina una descripción para la operación.");
|
|
|
details.css('border-color','red');
|
|
|
- return
|
|
|
- } else {
|
|
|
- details.css('border-color','#ccc');
|
|
|
+ return;
|
|
|
}
|
|
|
+ details.css('border-color','#ccc');
|
|
|
/* Importe */
|
|
|
- if (ammount_input.val() <= 0) {
|
|
|
+ if (amount <= 0) {
|
|
|
openerp.web.notification.do_warn("Atención","El importe de la operación no debe ser meno o igual 0 (cero).");
|
|
|
ammount_input.css('border-color','red');
|
|
|
- return
|
|
|
- } else {
|
|
|
- ammount_input.css('border-color','#ccc');
|
|
|
+ return;
|
|
|
}
|
|
|
-
|
|
|
+ ammount_input.css('border-color','#ccc');
|
|
|
var payslip = new openerp.web.Model('hr.payslip');
|
|
|
- var amount = parseInt(ammount_input.val());
|
|
|
-
|
|
|
if (amount > payslipLine.amount && salary_rule.val() === "ADL"){
|
|
|
- openerp.web.notification.do_warn("Atención","El Importe del Adelanto no puede superar el Sueldo Neto.");
|
|
|
+ openerp.web.notification.do_warn("Atención","El importe del adelanto no puede superar el dueldo neto,\n Importe permitido "+ accounting.formatMoney(payslipLine.amount, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
ammount_input.focus();
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
if (salary_rule.val() === "ADL") {
|
|
|
- amount = parseInt(ammount_input.val() * -1);
|
|
|
- } else {
|
|
|
- amount = parseInt(ammount_input.val());
|
|
|
+ amount = (amount * -1);
|
|
|
}
|
|
|
|
|
|
payslip.call('create_payslip_input',
|
|
@@ -209,14 +228,10 @@
|
|
|
});
|
|
|
self.removeModal(e);
|
|
|
});
|
|
|
- /* Camobio en el Importe */
|
|
|
- ammount_input.change(function() {
|
|
|
- if (ammount_input.val() > payslipLine.amount && salary_rule.val() === "ADL"){
|
|
|
- openerp.web.notification.do_warn("Atención","El Importe del adelanto no puede superar el sueldo Neto.");
|
|
|
- ammount_input.focus();
|
|
|
- return;
|
|
|
- }
|
|
|
- })
|
|
|
+ ammount_input.keyup(function() {
|
|
|
+ amount_Adl = parseInt(accounting.unformat( ammount_input.val(),','));
|
|
|
+ ammount_input.val(accounting.formatMoney((amount_Adl), currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
+ });
|
|
|
|
|
|
return defer;
|
|
|
},
|
|
@@ -255,15 +270,21 @@
|
|
|
return self.fetchPayslip();
|
|
|
}).then(function(hrPayslip) {
|
|
|
self.hrPayslip = hrPayslip;
|
|
|
+ return self.fetchResCompany();
|
|
|
+ }).then(function(resCompany) {
|
|
|
+ self.resCompany = resCompany;
|
|
|
+ return self.fetchResCurrecy();
|
|
|
+ }).then(function(resCurrency) {
|
|
|
+ self.resCurrency = resCurrency;
|
|
|
return self.showModifyAdvancement();
|
|
|
}).then(function() {
|
|
|
return self.destroyObjects();
|
|
|
});
|
|
|
},
|
|
|
/* Description: COnsultar Payslip Input (hr.payslip.input)*/
|
|
|
- fetchPayslipInput: function(){
|
|
|
+ fetchPayslipInput: function() {
|
|
|
var self = this;
|
|
|
- var fields =['id','name', 'code', 'amount'];
|
|
|
+ var fields = ['id','name', 'code', 'amount'];
|
|
|
var domain = [['payslip_id', '=', self.id]];
|
|
|
var hrPayslipInput = new openerp.web.Model('hr.payslip.input');
|
|
|
return hrPayslipInput.query(fields).filter(domain).all();
|
|
@@ -271,7 +292,7 @@
|
|
|
/* Description: Unir payslip_input con salary_rule*/
|
|
|
joinInputSalari: function() {
|
|
|
var self = this;
|
|
|
- var defer =$.Deferred();
|
|
|
+ var defer = $.Deferred();
|
|
|
var inputSalari = [];
|
|
|
var rule;
|
|
|
|
|
@@ -313,6 +334,10 @@
|
|
|
var row_modify;
|
|
|
var payslipLine = self.payslipLine.shift();
|
|
|
var hrPayslip = self.hrPayslip.shift();
|
|
|
+ var company = self.resCompany.shift();
|
|
|
+ var currency = self.getCurrencyCompany(company.currency_id[0]).shift();
|
|
|
+ var amountSelect = 0;
|
|
|
+ var amount_Adl = 0;
|
|
|
|
|
|
if (self.inputSalari.length === 0) {
|
|
|
openerp.web.notification.do_warn("Atención","No existe registro para modificar");
|
|
@@ -320,10 +345,22 @@
|
|
|
}
|
|
|
var employeData = [{
|
|
|
employe_name: hrPayslip.employee_id[1],
|
|
|
- salari: payslipLine.amount
|
|
|
- }]
|
|
|
+ salari: accounting.formatMoney(payslipLine.amount, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator)
|
|
|
+ }];
|
|
|
+ var inputSalari = [];
|
|
|
+ _.each(self.inputSalari, function(item) {
|
|
|
+ inputSalari.push(
|
|
|
+ {
|
|
|
+ 'id': item.id,
|
|
|
+ 'name': item.name,
|
|
|
+ 'code': item.code,
|
|
|
+ 'amount': accounting.formatMoney(item.amount, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator),
|
|
|
+ 'input_name': item.input_name
|
|
|
+ }
|
|
|
+ )
|
|
|
+ });
|
|
|
var modalModifyAdvancement = QWeb.render('EiruPayslipModifyAdvancement', {
|
|
|
- inputData: self.inputSalari,
|
|
|
+ inputData: inputSalari,
|
|
|
employeData: employeData
|
|
|
});
|
|
|
$('.openerp_webclient_container').after(modalModifyAdvancement);
|
|
@@ -335,6 +372,7 @@
|
|
|
var unlinkAdvancement = $('.expired-account-modal').find('.unlink-advancement');
|
|
|
var tableRow = $('.expired-account-modal').find('.table-tbody').find('tr');
|
|
|
buttonUpdate.attr("disabled", true);
|
|
|
+ /* Salir*/
|
|
|
$('.expired-account-modal').on('hidden.bs.modal', function (e) {
|
|
|
defer.resolve('salir');
|
|
|
self.removeModal(e);
|
|
@@ -349,7 +387,8 @@
|
|
|
$(e.target).closest('tr').addClass('table-row-select');
|
|
|
/* Cargar Campo Description y importe */
|
|
|
descript_input.val(($(e.target).closest('tr').children()[3].textContent).trim());
|
|
|
- amount_input.val(parseInt($(e.target).closest('tr').children()[4].textContent));
|
|
|
+ amountSelect = parseInt(accounting.unformat($(e.target).closest('tr').children()[4].textContent ,',' ));
|
|
|
+ amount_input.val(accounting.formatMoney((amountSelect), currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
// Actualizar el Id de elemento seleccionado
|
|
|
self.row_id_select = parseInt($(e.target).closest('tr').children()[0].textContent);
|
|
|
self.row_code_select = ($(e.target).closest('tr').children()[1].textContent).trim();
|
|
@@ -359,6 +398,7 @@
|
|
|
});
|
|
|
/* Click botón Modificar */
|
|
|
buttonUpdate.click(function() {
|
|
|
+ var amount = parseInt(accounting.unformat(amount_input.val(),','));
|
|
|
if (!descript_input.val()) {
|
|
|
openerp.web.notification.do_warn("Atención","Definir un motivo de la falta .");
|
|
|
descript_input.css('border-color','red');
|
|
@@ -366,50 +406,78 @@
|
|
|
return;
|
|
|
}
|
|
|
descript_input.css('border-color','#ccc');
|
|
|
- if (amount_input.val() <= 0) {
|
|
|
+ if (amount <= 0) {
|
|
|
openerp.web.notification.do_warn("Atención","Días no trabajado, debe ser mayor que 0.");
|
|
|
amount_input.css('border-color','red');
|
|
|
amount_input.focus();
|
|
|
return;
|
|
|
}
|
|
|
- if (amount_input.val() > payslipLine.amount && self.row_code_select === 'ADL') {
|
|
|
- openerp.web.notification.do_warn("Atención","El Importe del Adelanto no puede superar el Sueldo Neto.");
|
|
|
+ var neto = accounting.unformat($('.expired-account-modal').find('.number').val(), ',');
|
|
|
+
|
|
|
+ if (amount > (neto + amountSelect) && self.row_code_select === 'ADL') {
|
|
|
+ openerp.web.notification.do_warn("Atención","El importe del adelanto no puede superar el sueldo neto.\n Importe permitido "+accounting.formatMoney(neto + amountSelect, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
amount_input.css('border-color','red');
|
|
|
amount_input.focus();
|
|
|
return;
|
|
|
}
|
|
|
amount_input.css('border-color','#ccc');
|
|
|
/* Actualizar Adelanto / comision */
|
|
|
- self.writePayslipAdvancement(descript_input.val(), amount_input.val()).then(function(results){
|
|
|
+ self.writePayslipAdvancement(descript_input.val(), amount ).then(function(results){
|
|
|
return results;
|
|
|
}).then(function() {
|
|
|
return self.recomputeSheet();
|
|
|
}).then(function() {
|
|
|
return self.reloadLine();
|
|
|
- }).then(function(reload) {
|
|
|
- defer.resolve(reload);
|
|
|
+ }).then(function() {
|
|
|
+ return self.fetchPayslipLine();
|
|
|
+ }).then(function(payslipLine) {
|
|
|
+ self.payslipLine = payslipLine;
|
|
|
+ payslipLine = payslipLine.shift();
|
|
|
+ $('.expired-account-modal').find('.number').val(accounting.formatMoney(payslipLine.amount, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
+ defer.resolve(payslipLine);
|
|
|
});
|
|
|
row_modify.closest('tr').children()[3].textContent = descript_input.val();
|
|
|
- row_modify.closest('tr').children()[4].textContent = amount_input.val();
|
|
|
+ row_modify.closest('tr').children()[4].textContent = accounting.formatMoney(amount, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator);
|
|
|
+
|
|
|
descript_input.val("");
|
|
|
amount_input.val(0);
|
|
|
+ amountSelect = 0;
|
|
|
buttonUpdate.attr("disabled", true);
|
|
|
});
|
|
|
/* Click boton Unlink/ Eliminar */
|
|
|
unlinkAdvancement.click(function(e) {
|
|
|
var unlink_row = parseInt($(e.target).closest('td').closest('tr').children()[0].textContent);
|
|
|
+ var unlink_code =$(e.target).closest('td').closest('tr').children()[1].textContent;
|
|
|
+ var unlink_amount = parseInt(accounting.unformat($(e.target).closest('tr').children()[4].textContent ,',' ));
|
|
|
+ var neto = accounting.unformat($('.expired-account-modal').find('.number').val(), ',');
|
|
|
+
|
|
|
+ if (unlink_amount > neto && unlink_code === 'CMS'){
|
|
|
+ openerp.web.notification.do_warn("Atención"," No podes eliminar una comisión con el el importe mayor al sueldo neto.\n Sueldo neto actual "+accounting.formatMoney(neto, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
self.unlinkPayslipAdvancement(unlink_row).then(function(results) {
|
|
|
return results;
|
|
|
}).then(function() {
|
|
|
return self.recomputeSheet();
|
|
|
}).then(function() {
|
|
|
return self.reloadLine();
|
|
|
- }).then(function(reload) {
|
|
|
- defer.resolve(reload);
|
|
|
+ }).then(function() {
|
|
|
+ return self.fetchPayslipLine();
|
|
|
+ }).then(function(payslipLine) {
|
|
|
+ self.payslipLine = payslipLine;
|
|
|
+ payslipLine = payslipLine.shift();
|
|
|
+ $('.expired-account-modal').find('.number').val(accounting.formatMoney(payslipLine.amount, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
+ defer.resolve(payslipLine);
|
|
|
});
|
|
|
$(e.target).closest('td').closest('tr').remove();
|
|
|
- })
|
|
|
- return defer
|
|
|
+ });
|
|
|
+ /* Keyup */
|
|
|
+ amount_input.keyup(function() {
|
|
|
+ amount_Adl = parseInt(accounting.unformat(amount_input.val(), ','));
|
|
|
+ amount_input.val(accounting.formatMoney((amount_Adl), currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
},
|
|
|
/* Description: Funcion para Actualizar Adlanto / comision*/
|
|
|
writePayslipAdvancement: function(description, amount_input) {
|
|
@@ -446,7 +514,7 @@
|
|
|
}], {
|
|
|
context: new openerp.web.CompoundContext()
|
|
|
}).then(function(results){
|
|
|
- defer.resolve(results)
|
|
|
+ defer.resolve(results);
|
|
|
});
|
|
|
return defer;
|
|
|
},
|