|
@@ -16,6 +16,8 @@
|
|
|
resCompany: [],
|
|
|
resCurrency: [],
|
|
|
payslipInput: [],
|
|
|
+ accountJournal: [],
|
|
|
+ statementLine: [],
|
|
|
/* init */
|
|
|
init: function (parent) {
|
|
|
this._super(parent);
|
|
@@ -28,6 +30,8 @@
|
|
|
var editAdvancement = this.$el.find('.edit-advancement');
|
|
|
var refreshAdvancement = this.$el.find('.refresh-advancement');
|
|
|
var printAdvancement = this.$el.find('.print-advancement');
|
|
|
+ var exportCash = this.$el.find('.export-cash');
|
|
|
+
|
|
|
// create
|
|
|
addAdvancement.click(function() {
|
|
|
self.fetchAddAdvancement();
|
|
@@ -44,6 +48,9 @@
|
|
|
printAdvancement.click(function() {
|
|
|
self.fetchPrintAdvancement();
|
|
|
});
|
|
|
+ exportCash.click(function() {
|
|
|
+ self.fetchExportCash();
|
|
|
+ });
|
|
|
},
|
|
|
/* Actualizar ID */
|
|
|
updateIdAdvancement: function(id) {
|
|
@@ -126,6 +133,9 @@
|
|
|
return self.fetchResCurrecy();
|
|
|
}).then(function(resCurrency) {
|
|
|
self.resCurrency = resCurrency;
|
|
|
+ return self.fetchJournal();
|
|
|
+ }).then(function(accountJournal) {
|
|
|
+ self.accountJournal = accountJournal;
|
|
|
return self.showPayslipAddAdvancement();
|
|
|
}).then(function() {
|
|
|
return self.recomputeSheet();
|
|
@@ -154,6 +164,13 @@
|
|
|
var salaryRule = new openerp.web.Model('hr.salary.rule');
|
|
|
return salaryRule.query(['name','code']).filter([['code','in',['ADL','CMS']]]).all();
|
|
|
},
|
|
|
+ /* Consultar método de pagos */
|
|
|
+ fetchJournal: function() {
|
|
|
+ var fields = ['id', 'name', 'code', 'type', 'currency', 'default_debit_account_id', 'default_credit_account_id'];
|
|
|
+ var domain = [['active', '=', true], ['type', 'in', ['bank', 'cash']], ['currency', '=', false]];
|
|
|
+ var journalSalario = new openerp.web.Model('account.journal');
|
|
|
+ return journalSalario.query(fields).filter(domain).all();
|
|
|
+ },
|
|
|
/* Description: Modal crear Adealnto/ comision de Funcionario */
|
|
|
showPayslipAddAdvancement: function() {
|
|
|
var self = this;
|
|
@@ -171,7 +188,8 @@
|
|
|
];
|
|
|
var modalAdvancement = QWeb.render('EiruPayslipAddAdvancement',{
|
|
|
employeData: employeData,
|
|
|
- salaryRule: self.salaryRule
|
|
|
+ salaryRule: self.salaryRule,
|
|
|
+ journal: self.accountJournal
|
|
|
});
|
|
|
|
|
|
$('.openerp_webclient_container').after(modalAdvancement);
|
|
@@ -187,6 +205,21 @@
|
|
|
var details = $('.expired-account-modal').find('.advancement-details');
|
|
|
var ammount_input = $('.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");
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
addAdvancement.click(function(e){
|
|
|
/* Operacion */
|
|
@@ -213,7 +246,7 @@
|
|
|
ammount_input.css('border-color','#ccc');
|
|
|
var payslip = new openerp.web.Model('hr.payslip');
|
|
|
if (amount > payslipLine.amount && salary_rule.val() === "ADL"){
|
|
|
- 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));
|
|
|
+ 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();
|
|
|
return;
|
|
|
}
|
|
@@ -228,7 +261,9 @@
|
|
|
id: self.id,
|
|
|
salary_rule: salary_rule.val(),
|
|
|
details: details.val(),
|
|
|
- ammount_input: amount
|
|
|
+ ammount_input: amount,
|
|
|
+ journal: current_journal.val(),
|
|
|
+ journal_ref: journal_ref.val()
|
|
|
}
|
|
|
],{
|
|
|
context: new openerp.web.CompoundContext()
|
|
@@ -304,17 +339,15 @@
|
|
|
var defer = $.Deferred();
|
|
|
var inputSalari = [];
|
|
|
var rule;
|
|
|
+ var payslipInput = self.getpayslipInput('CMS');
|
|
|
|
|
|
- _.each(self.payslipInput, function(item) {
|
|
|
+ _.each(payslipInput, function(item) {
|
|
|
rule = self.getSalaryRule(item.code).shift();
|
|
|
if (!rule){
|
|
|
rule = {};
|
|
|
rule.name= item.code;
|
|
|
}
|
|
|
var amount = item.amount;
|
|
|
- if (item.code === 'ADL'){
|
|
|
- amount = (item.amount * -1);
|
|
|
- }
|
|
|
|
|
|
inputSalari.push(
|
|
|
{
|
|
@@ -479,6 +512,7 @@
|
|
|
$('.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();
|
|
|
});
|
|
|
/* Keyup */
|
|
@@ -563,17 +597,17 @@
|
|
|
return resUser.query(['name']).filter([['active', '=', true],['id', '=', self.uid]]).all();
|
|
|
},
|
|
|
/* Filtar Adelantos */
|
|
|
- getpayslipInput: function() {
|
|
|
+ getpayslipInput: function(code) {
|
|
|
var self = this;
|
|
|
return _.filter(self.payslipInput, function(item) {
|
|
|
- return item.code === "ADL";
|
|
|
+ return item.code === code;
|
|
|
});
|
|
|
|
|
|
},
|
|
|
/* Generar la impresion de Adelanto */
|
|
|
jsPdfPrintAdvancement: function() {
|
|
|
var self = this;
|
|
|
- var payslipInput = self.getpayslipInput();
|
|
|
+ var payslipInput = self.getpayslipInput('ADL');
|
|
|
|
|
|
if (payslipInput.length === 0){
|
|
|
openerp.web.notification.do_warn("Atención","El funcionario no cuenta con adelantos registrado");
|
|
@@ -678,8 +712,9 @@
|
|
|
pdfDoc.text(10, fila, "TOTAL EN LETRAS ");
|
|
|
|
|
|
pdfDoc.setFontType('normal');
|
|
|
- pdfDoc.setFontSize(12);
|
|
|
- pdfDoc.text(50, fila, moneda+": "+openerp.web.num2word(total));
|
|
|
+ pdfDoc.setFontSize(10);
|
|
|
+ var text =moneda+": "+openerp.web.num2word(total);
|
|
|
+ pdfDoc.text(50, fila, pdfDoc.splitTextToSize(text, 150),null, null, null);
|
|
|
|
|
|
fila = fila + 20;
|
|
|
pdfDoc.setFontType('bold');
|
|
@@ -698,13 +733,169 @@
|
|
|
getNameCurrency: function(code) {
|
|
|
var moneda = "";
|
|
|
if (code === 'PYG') {
|
|
|
- moneda ="GUARANÍES"
|
|
|
+ moneda ="GUARANÍES";
|
|
|
}
|
|
|
if (code === 'USD') {
|
|
|
- moneda ="DÓLARES AMERICANOS "
|
|
|
+ moneda ="DÓLARES AMERICANOS";
|
|
|
+ }
|
|
|
+ return moneda;
|
|
|
+ },
|
|
|
+ /*---------------------------------------------------------------------
|
|
|
+ * Description: Exportar los adelanto en Registro de caja
|
|
|
+ * -------------------------------------------------------------------*/
|
|
|
+ /* Description : Metodo Inicial de Exportar adelanto en caja*/
|
|
|
+ fetchExportCash: function() {
|
|
|
+ var self = this;
|
|
|
+
|
|
|
+ self.fetchPayslipInput().then(function(payslipInput) {
|
|
|
+ return payslipInput;
|
|
|
+ }).then(function(payslipInput) {
|
|
|
+ self.payslipInput = payslipInput;
|
|
|
+ return self.fetchJournal();
|
|
|
+ }).then(function(accountJournal) {
|
|
|
+ self.accountJournal = accountJournal;
|
|
|
+ return self.fetchStatementLine();
|
|
|
+ }).then(function(statementLine) {
|
|
|
+ self.statementLine = statementLine;
|
|
|
+ return self.fetchResCompany();
|
|
|
+ }).then(function(resCompany) {
|
|
|
+ self.resCompany = resCompany;
|
|
|
+ return self.fetchResCurrecy();
|
|
|
+ }).then(function(resCurrency) {
|
|
|
+ self.resCurrency = resCurrency;
|
|
|
+ return self.joinInputAdvancement();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* Consultar Lineas de Cajas */
|
|
|
+ fetchStatementLine: function() {
|
|
|
+ var statementLine = new openerp.web.Model('account.bank.statement.line');
|
|
|
+ return statementLine.query(['name', 'note', 'ref']).filter([['ref','=', 'ADL']]).all();
|
|
|
+ },
|
|
|
+ /* Filtar los adelanto que no Exista en caja */
|
|
|
+ joinInputAdvancement: function() {
|
|
|
+ var self = this;
|
|
|
+ var company = self.resCompany.shift();
|
|
|
+ var currency = self.getCurrencyCompany(company.currency_id[0]).shift();
|
|
|
+ var payslipInput = self.getAdvancementNotInBox();
|
|
|
+ var InputPayslip = [];
|
|
|
+ _.each(payslipInput, function(item) {
|
|
|
+ InputPayslip.push({
|
|
|
+ 'id': item.id,
|
|
|
+ 'name': item.name,
|
|
|
+ 'amount': accounting.formatMoney((-1 * item.amount), currency.symbol,currency.decimal_places, currency.thousands_separator, currency.decimal_separator)
|
|
|
+ });
|
|
|
+ })
|
|
|
+ self.showModalAdvancementExportCash(InputPayslip);
|
|
|
+ },
|
|
|
+ /* Filtra los adelanto que no están en caja */
|
|
|
+ getAdvancementNotInBox: function() {
|
|
|
+ var self = this;
|
|
|
+ var payslipInput = self.getpayslipInput('ADL');
|
|
|
+
|
|
|
+ var id_input = _.map(self.statementLine, function(map) {
|
|
|
+ return parseInt(map.note);
|
|
|
+ });
|
|
|
+ return _.filter(payslipInput, function(filter) {
|
|
|
+ return !_.contains(id_input, filter.id);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* Modal Exportar adelanto en caja*/
|
|
|
+ showModalAdvancementExportCash: function(payslipInput){
|
|
|
+ var self = this;
|
|
|
+ var row_export;
|
|
|
+
|
|
|
+ if (payslipInput.length === 0){
|
|
|
+ openerp.web.notification.do_warn("Atención","No existe adelanto para importar en caja");
|
|
|
+ return;
|
|
|
}
|
|
|
- return moneda
|
|
|
- }
|
|
|
+
|
|
|
+ var modalAdvancementExportCash = QWeb.render('EiruAdvancementExportCash', {
|
|
|
+ inputAdvancement: payslipInput,
|
|
|
+ journal: self.accountJournal
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.openerp_webclient_container').after(modalAdvancementExportCash);
|
|
|
+ $('.expired-account-modal').modal();
|
|
|
+
|
|
|
+ /* Salir*/
|
|
|
+ $('.expired-account-modal').on('hidden.bs.modal', function (e) {
|
|
|
+ self.removeModal(e);
|
|
|
+ });
|
|
|
+ //
|
|
|
+ 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 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);
|
|
|
+ advancement_export.attr("disabled", true);
|
|
|
+ /* Seleccionar fila */
|
|
|
+ tableRow.click(function (e) {
|
|
|
+ row_export = $(e.target);
|
|
|
+ tableRow.removeClass('table-row-select');
|
|
|
+ $(e.target).closest('tr').addClass('table-row-select');
|
|
|
+ /* Cargar Campo Description y importe */
|
|
|
+ advancement_details.val(($(e.target).closest('tr').children()[1].textContent).trim());
|
|
|
+ advancement_amount.val(($(e.target).closest('tr').children()[2].textContent).trim());
|
|
|
+ // Actualizar el Id de elemento seleccionado
|
|
|
+ self.row_id_select = parseInt($(e.target).closest('tr').children()[0].textContent);
|
|
|
+ // Habilitar Campos
|
|
|
+ current_journal.removeAttr("disabled");
|
|
|
+ journal_ref.removeAttr("disabled");
|
|
|
+ advancement_export.removeAttr("disabled");
|
|
|
+ current_journal.focus();
|
|
|
+ });
|
|
|
+ // clic en botón exportar
|
|
|
+ advancement_export.click(function() {
|
|
|
+ if (!current_journal.val()){
|
|
|
+ openerp.web.notification.do_warn("Atención","El método de pago es obligatorio");
|
|
|
+ current_journal.focus();
|
|
|
+ current_journal.css('border-color','red');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ current_journal.css('border-color','#ccc');
|
|
|
+
|
|
|
+ self.bankStatementImport(self.row_id_select, parseInt(current_journal.val()), journal_ref.val()).then(function(results){
|
|
|
+ return results;
|
|
|
+ }).then(function() {
|
|
|
+
|
|
|
+ row_export.closest('td').closest('tr').remove();
|
|
|
+
|
|
|
+ current_journal.attr("disabled", true);
|
|
|
+ journal_ref.attr("disabled", true);
|
|
|
+ advancement_export.attr("disabled", true);
|
|
|
+
|
|
|
+ journal_ref.val('');
|
|
|
+ current_journal.val('');
|
|
|
+
|
|
|
+ advancement_details.val('');
|
|
|
+ advancement_amount.val('0');
|
|
|
+
|
|
|
+ row_export = "";
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* bank_statement_import*/
|
|
|
+ bankStatementImport: function(id_imput, journal_id, journal_ref) {
|
|
|
+ var payslip = new openerp.web.Model('hr.payslip');
|
|
|
+ var defer = $.Deferred();
|
|
|
+ payslip.call('bank_statement_import',
|
|
|
+ [
|
|
|
+ {
|
|
|
+ 'id_imput': id_imput,
|
|
|
+ 'journal_id': journal_id,
|
|
|
+ 'journal_ref': journal_ref
|
|
|
+ }
|
|
|
+ ],{
|
|
|
+ context: new openerp.web.CompoundContext()
|
|
|
+ }).then(function(results) {
|
|
|
+ defer.resolve(results)
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
if (openerp.web && openerp.web.FormView) {
|