|
@@ -18,6 +18,10 @@
|
|
|
payslipInput: [],
|
|
|
accountJournal: [],
|
|
|
statementLine: [],
|
|
|
+ statementAvailable: [],
|
|
|
+ /* Config */
|
|
|
+ statementConfig: [],
|
|
|
+ eiruAccountBankUtatementUtility: [],
|
|
|
/* init */
|
|
|
init: function (parent) {
|
|
|
this._super(parent);
|
|
@@ -66,6 +70,26 @@
|
|
|
reloadLine: function() {
|
|
|
openerp.parentInstance.reload();
|
|
|
},
|
|
|
+ /* Verificar modulo instalados */
|
|
|
+ fetchVerifyModule: function(module) {
|
|
|
+ if (!module)
|
|
|
+ return [];
|
|
|
+ var moduleModule =new openerp.web.Model('ir.module.module');
|
|
|
+ var fields = ['id', 'name', 'state'];
|
|
|
+ var domain = [['name', '=', module], ['state', '=', 'installed']];
|
|
|
+ return moduleModule.query(fields).filter(domain).all();
|
|
|
+ },
|
|
|
+ /* statement Config */
|
|
|
+ fetchStatementConfig: function() {
|
|
|
+ var self = this;
|
|
|
+ if (!self.eiruAccountBankUtatementUtility.length)
|
|
|
+ return [];
|
|
|
+
|
|
|
+ var fields = ['id','name', 'active', 'import_statement_payslip'];
|
|
|
+ var domain = [['active', '=', true]];
|
|
|
+ var statementConfig = new openerp.web.Model('account.bank.statement.config');
|
|
|
+ return statementConfig.query(fields).filter(domain).all();
|
|
|
+ },
|
|
|
/* Description: Función para recalcular las faltas */
|
|
|
recomputeSheet: function() {
|
|
|
var self = this;
|
|
@@ -79,6 +103,11 @@
|
|
|
});
|
|
|
|
|
|
return defer;
|
|
|
+ // var self = this;
|
|
|
+ // var recomputePayslip = new openerp.web.Model('hr.payslip');
|
|
|
+ // return recomputePayslip.call('recompute_sheet',[ self.id ], {
|
|
|
+ // context: new openerp.web.CompoundContext()
|
|
|
+ // });
|
|
|
},
|
|
|
/* Description: Función para remover el modal */
|
|
|
removeModal: function() {
|
|
@@ -97,6 +126,14 @@
|
|
|
var resCurrecy = new openerp.web.Model('res.currency');
|
|
|
return resCurrecy.query(fields).filter(domain).all();
|
|
|
},
|
|
|
+ /* Get statement Available*/
|
|
|
+ fetchStatementAvailable: function() {
|
|
|
+ var self = this;
|
|
|
+ var statementAvailable = new openerp.web.Model('hr.payslip');
|
|
|
+ return statementAvailable.call('get_statement_available',{
|
|
|
+ context: new openerp.web.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
/* Description: Filtar moneda de la compania */
|
|
|
getCurrencyCompany: function(id) {
|
|
|
var self = this;
|
|
@@ -104,6 +141,13 @@
|
|
|
return item.id === id;
|
|
|
});
|
|
|
},
|
|
|
+ /* GET statement JournalId*/
|
|
|
+ getStatementeJournal: function(journalId) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.statementAvailable, function(item){
|
|
|
+ return item.journalID === journalId;
|
|
|
+ });
|
|
|
+ },
|
|
|
/* Description: destroy objects*/
|
|
|
destroyObjects: function() {
|
|
|
var self = this;
|
|
@@ -116,10 +160,14 @@
|
|
|
self.resCurrency = [];
|
|
|
self.payslipInput =[];
|
|
|
},
|
|
|
- /* ---------------------------------------------------------------------
|
|
|
- ** Description : Crear Adealnto/ comision de Funcionario
|
|
|
- ** -------------------------------------------------------------------*/
|
|
|
- /* Description: Funcion Inicial Crear Comicion/Adelanto */
|
|
|
+ /*******************************************************************************************
|
|
|
+ Crear Adealnto / comision de Funcionario
|
|
|
+ _ _ _ _ ____ _ _
|
|
|
+ / \ __| | ___ __ _| |_ __ | |_ ___ / ___|___ _ __ ___ (_)___(_) ___ _ __
|
|
|
+ / _ \ / _` |/ _ \/ _` | | '_ \| __/ _ \ _____| | / _ \| '_ ` _ \| / __| |/ _ \| '_ \
|
|
|
+ / ___ \ (_| | __/ (_| | | | | | || (_) |_____| |__| (_) | | | | | | \__ \ | (_) | | | |
|
|
|
+ /_/ \_\__,_|\___|\__,_|_|_| |_|\__\___/ \____\___/|_| |_| |_|_|___/_|\___/|_| |_|
|
|
|
+ ********************************************************************************************/
|
|
|
fetchAddAdvancement: function() {
|
|
|
var self = this;
|
|
|
self.fetchPayslip().then(function(hrPayslip) {
|
|
@@ -141,6 +189,15 @@
|
|
|
return self.fetchJournal();
|
|
|
}).then(function(accountJournal) {
|
|
|
self.accountJournal = accountJournal;
|
|
|
+ return self.fetchVerifyModule('eiru_account_bank_statement_utility');
|
|
|
+ }).then(function(eiruAccountBankUtatementUtility) {
|
|
|
+ self.eiruAccountBankUtatementUtility= eiruAccountBankUtatementUtility;
|
|
|
+ return self.fetchStatementConfig();
|
|
|
+ }).then(function(statementConfig) {
|
|
|
+ self.statementConfig= statementConfig;
|
|
|
+ return self.fetchStatementAvailable();
|
|
|
+ }).then(function(statementAvailable) {
|
|
|
+ self.statementAvailable = statementAvailable;
|
|
|
return self.showPayslipAddAdvancement();
|
|
|
}).then(function() {
|
|
|
return self.recomputeSheet();
|
|
@@ -179,111 +236,181 @@
|
|
|
/* Description: Modal crear Adealnto/ comision de Funcionario */
|
|
|
showPayslipAddAdvancement: function() {
|
|
|
var self = this;
|
|
|
- var payslipLine = self.payslipLine.shift();
|
|
|
- var hrPayslip = self.hrPayslip.shift();
|
|
|
var defer = $.Deferred()
|
|
|
- var company = self.resCompany.shift();
|
|
|
+ var results = true;
|
|
|
+ var payslipLine = self.payslipLine[0];
|
|
|
+ var hrPayslip = self.hrPayslip[0];
|
|
|
+ var company = self.resCompany[0];
|
|
|
var currency = self.getCurrencyCompany(company.currency_id[0]).shift();
|
|
|
var amount_Adl = 0;
|
|
|
+ var salaryRule = self.salaryRule;
|
|
|
+ var journal = self.accountJournal;
|
|
|
+
|
|
|
+ if (!!salaryRule){
|
|
|
+ salaryRule.unshift({
|
|
|
+ 'code': '',
|
|
|
+ 'name': ''
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!!journal){
|
|
|
+ journal.unshift({
|
|
|
+ 'id':'',
|
|
|
+ 'name':'',
|
|
|
+ });
|
|
|
+ }
|
|
|
var employeData = [
|
|
|
{
|
|
|
'employe_name': hrPayslip.employee_id[1],
|
|
|
'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,
|
|
|
+ salaryRule: salaryRule,
|
|
|
journal: self.accountJournal
|
|
|
});
|
|
|
-
|
|
|
$('.openerp_webclient_container').after(modalAdvancement);
|
|
|
$('.expired-account-modal').modal();
|
|
|
|
|
|
- /* Close modal */
|
|
|
- $('.expired-account-modal').on('hidden.bs.modal', function (e) {
|
|
|
- defer.resolve(true);
|
|
|
- self.removeModal(e);
|
|
|
- });
|
|
|
-
|
|
|
- var salary_rule = $('.expired-account-modal').find('.salary-rule');
|
|
|
+ /* Variable */
|
|
|
+ var salaryRule = $('.expired-account-modal').find('.salary-rule');
|
|
|
var details = $('.expired-account-modal').find('.advancement-details');
|
|
|
- var ammount_input = $('.expired-account-modal').find('.advancement-amount');
|
|
|
+ var ammountInput = $('.expired-account-modal').find('.advancement-amount');
|
|
|
var addAdvancement = $('.expired-account-modal').find('.add-advancement');
|
|
|
- var current_journal = $('.expired-account-modal').find('.current-journal');
|
|
|
- var journal_ref = $('.expired-account-modal').find('.journal-ref');
|
|
|
-
|
|
|
- salary_rule.change(function(){
|
|
|
- if (salary_rule.val() !== 'ADL'){
|
|
|
- current_journal.attr("disabled", true);
|
|
|
- current_journal.css("color", '#cfcfcf');
|
|
|
-
|
|
|
- journal_ref.attr("disabled", true);
|
|
|
- } else {
|
|
|
- current_journal.removeAttr("disabled");
|
|
|
- current_journal.css("color", '#4c4c4c');
|
|
|
- journal_ref.removeAttr("disabled");
|
|
|
+ var journalSelected = $('.expired-account-modal').find('.journal-selected');
|
|
|
+ var statementSelected = $('.expired-account-modal').find('.statement-selected');
|
|
|
+
|
|
|
+ /* Type Operation */
|
|
|
+ salaryRule.change(function() {
|
|
|
+ $('.expired-account-modal').find('.is-advancement').css('display','none');
|
|
|
+ $('.expired-account-modal').find('.statement-open').css('display','none');
|
|
|
+ statementSelected.empty();
|
|
|
+ if (salaryRule.val() === 'ADL')
|
|
|
+ $('.expired-account-modal').find('.is-advancement').css('display','flex');
|
|
|
+ });
|
|
|
+ /*Journal Selected */
|
|
|
+ journalSelected.change(function(e) {
|
|
|
+ statementSelected.empty();
|
|
|
+ $('.expired-account-modal').find('.statement-open').css('display','none');
|
|
|
+ if (!!journalSelected.val() && !!self.eiruAccountBankUtatementUtility.length && !!self.statementConfig.length) {
|
|
|
+ if (self.statementConfig[0].import_statement_payslip === 'manual_import') {
|
|
|
+ var statement = self.getStatementeJournal(parseInt(journalSelected.val()));
|
|
|
+ if (!!statement.length) {
|
|
|
+ $('.expired-account-modal').find('.statement-open').css('display','flex');
|
|
|
+ statementSelected.append('<option value=""></option>');
|
|
|
+ _.each(statement, function(item) {
|
|
|
+ statementSelected.append('<option value="' + item.id + '">' + item.name+" - "+moment(item.date).format("DD-MM-YYYY")+ '</option>');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
-
|
|
|
+ });
|
|
|
+ /* Imputn amount */
|
|
|
+ ammountInput.keyup(function() {
|
|
|
+ amount_Adl = parseInt(accounting.unformat( ammountInput.val(),','));
|
|
|
+ ammountInput.val(accounting.formatMoney((amount_Adl), currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
+ });
|
|
|
+ /* button Guardar */
|
|
|
addAdvancement.click(function(e){
|
|
|
- /* Operacion */
|
|
|
- var amount = parseInt(accounting.unformat(ammount_input.val(),','));
|
|
|
- if (!salary_rule.val()) {
|
|
|
+ var amount = parseInt(accounting.unformat(ammountInput.val(),','));
|
|
|
+ /* Type Operacion */
|
|
|
+ if (!salaryRule.val()) {
|
|
|
openerp.web.notification.do_warn("Atención","Seleccione el tipo de operación.");
|
|
|
- salary_rule.css('border-color','red');
|
|
|
- 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');
|
|
|
+ salaryRule.css('border-color','red');
|
|
|
+ salaryRule.focus();
|
|
|
return;
|
|
|
}
|
|
|
- details.css('border-color','#ccc');
|
|
|
- /* Importe */
|
|
|
+ salaryRule.css('border-color','#ccc');
|
|
|
+
|
|
|
+ /* amount */
|
|
|
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');
|
|
|
+ ammountInput.css('border-color','red');
|
|
|
+ ammountInput.focus();
|
|
|
return;
|
|
|
}
|
|
|
- ammount_input.css('border-color','#ccc');
|
|
|
- var payslip = new openerp.web.Model('hr.payslip');
|
|
|
- if (amount > payslipLine.amount && salary_rule.val() === "ADL"){
|
|
|
+ if (amount > payslipLine.amount && salaryRule.val() === "ADL"){
|
|
|
openerp.web.notification.do_warn("Atención","El importe del adelanto no puede superar el sueldo neto,\n Importe permitido "+ accounting.formatMoney(payslipLine.amount, currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator));
|
|
|
- ammount_input.focus();
|
|
|
+ ammountInput.css('border-color','red');
|
|
|
+ ammountInput.focus();
|
|
|
return;
|
|
|
}
|
|
|
+ ammountInput.css('border-color','#ccc');
|
|
|
|
|
|
- if (salary_rule.val() === "ADL") {
|
|
|
+ if (salaryRule.val() === "ADL") {
|
|
|
amount = (amount * -1);
|
|
|
+ /* Journal */
|
|
|
+ if (!journalSelected.val()){
|
|
|
+ openerp.web.notification.do_warn("Atención","Seleccione el método de pago.");
|
|
|
+ journalSelected.css('border-color','red');
|
|
|
+ journalSelected.focus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ journalSelected.css('border-color','#ccc');
|
|
|
+ /* statement */
|
|
|
+ if (!!self.eiruAccountBankUtatementUtility.length && !!self.statementConfig.length) {
|
|
|
+ if (self.statementConfig[0].import_statement_payslip === 'manual_import') {
|
|
|
+ var statement = self.getStatementeJournal(parseInt(journalSelected.val()));
|
|
|
+ if (!!statement.length) {
|
|
|
+ if (!statementSelected.val()){
|
|
|
+ openerp.web.notification.do_warn("Atención","Seleccione una caja para continuar.");
|
|
|
+ statementSelected.css('border-color','red');
|
|
|
+ statementSelected.focus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ statementSelected.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');
|
|
|
+ details.focus();
|
|
|
+ return;
|
|
|
}
|
|
|
+ details.css('border-color','#ccc');
|
|
|
|
|
|
- payslip.call('create_payslip_input',
|
|
|
- [
|
|
|
- {
|
|
|
- id: self.id,
|
|
|
- salary_rule: salary_rule.val(),
|
|
|
- details: details.val(),
|
|
|
- ammount_input: amount,
|
|
|
- journal: current_journal.val(),
|
|
|
- journal_ref: journal_ref.val()
|
|
|
- }
|
|
|
- ],{
|
|
|
- context: new openerp.web.CompoundContext()
|
|
|
- }).then(function(results) {
|
|
|
- defer.resolve(results)
|
|
|
+ values = {
|
|
|
+ 'id': parseInt(self.id),
|
|
|
+ 'salaryRule': salaryRule.val(),
|
|
|
+ 'details': details.val(),
|
|
|
+ 'amount': amount,
|
|
|
+ 'journal': parseInt(journalSelected.val()),
|
|
|
+ 'statementId': !!statementSelected.val() ? parseInt(statementSelected.val()) : '',
|
|
|
+ 'statementConfigId': !!self.statementConfig.length ? self.statementConfig[0].id : '',
|
|
|
+ };
|
|
|
+
|
|
|
+ self.createPayslipInput(values).then(function(resultsPayslip){
|
|
|
+ return resultsPayslip;
|
|
|
+ }).then(function(resultsPayslip){
|
|
|
+ self.removeModal(e);
|
|
|
+ defer.resolve(resultsPayslip);
|
|
|
+ // results = resultsPayslip;
|
|
|
});
|
|
|
- self.removeModal(e);
|
|
|
+
|
|
|
+ // defer.resolve(results);
|
|
|
+ // console.log(defer);
|
|
|
+ return defer;
|
|
|
});
|
|
|
- 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));
|
|
|
+ /* Close modal */
|
|
|
+ $('.expired-account-modal').on('hidden.bs.modal', function (e) {
|
|
|
+ results = false;
|
|
|
+ defer.resolve(results);
|
|
|
+ self.removeModal(e);
|
|
|
});
|
|
|
-
|
|
|
return defer;
|
|
|
},
|
|
|
+ /* Crear Adelanto - comisiones */
|
|
|
+ createPayslipInput: function(values) {
|
|
|
+ var payslip = new openerp.web.Model('hr.payslip');
|
|
|
+ return payslip.call('create_payslip_input',[values],{
|
|
|
+ context: new openerp.web.CompoundContext()
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
/* ---------------------------------------------------------------------
|
|
|
** Description: Recalcular Nominas
|
|
|
** -------------------------------------------------------------------*/
|
|
@@ -923,12 +1050,12 @@
|
|
|
var advancement_details = $('.expired-account-modal').find('.advancement-details');
|
|
|
var advancement_amount = $('.expired-account-modal').find('.advancement-amount');
|
|
|
var current_journal = $('.expired-account-modal').find('.current-journal');
|
|
|
- var journal_ref = $('.expired-account-modal').find('.journal-ref');
|
|
|
+ // var journal_ref = $('.expired-account-modal').find('.journal-ref');
|
|
|
var advancement_export = $('.expired-account-modal').find('.advancement-export');
|
|
|
var tableRow = $('.expired-account-modal').find('.table-tbody').find('tr');
|
|
|
// Deshabilitar Campos
|
|
|
current_journal.attr("disabled", true);
|
|
|
- journal_ref.attr("disabled", true);
|
|
|
+ // journal_ref.attr("disabled", true);
|
|
|
advancement_export.attr("disabled", true);
|
|
|
/* Seleccionar fila */
|
|
|
tableRow.click(function (e) {
|
|
@@ -942,7 +1069,7 @@
|
|
|
self.row_id_select = parseInt($(e.target).closest('tr').children()[0].textContent);
|
|
|
// Habilitar Campos
|
|
|
current_journal.removeAttr("disabled");
|
|
|
- journal_ref.removeAttr("disabled");
|
|
|
+ // journal_ref.removeAttr("disabled");
|
|
|
advancement_export.removeAttr("disabled");
|
|
|
current_journal.focus();
|
|
|
});
|
|
@@ -963,10 +1090,10 @@
|
|
|
row_export.closest('td').closest('tr').remove();
|
|
|
|
|
|
current_journal.attr("disabled", true);
|
|
|
- journal_ref.attr("disabled", true);
|
|
|
+ // journal_ref.attr("disabled", true);
|
|
|
advancement_export.attr("disabled", true);
|
|
|
|
|
|
- journal_ref.val('');
|
|
|
+ // journal_ref.val('');
|
|
|
current_journal.val('');
|
|
|
|
|
|
advancement_details.val('');
|
|
@@ -985,7 +1112,7 @@
|
|
|
{
|
|
|
'id_imput': id_imput,
|
|
|
'journal_id': journal_id,
|
|
|
- 'journal_ref': journal_ref
|
|
|
+ // 'journal_ref': journal_ref
|
|
|
}
|
|
|
],{
|
|
|
context: new openerp.web.CompoundContext()
|