|
@@ -0,0 +1,194 @@
|
|
|
|
+openerp.eiru_payslip_payments = function(instance, local) {
|
|
|
|
+
|
|
|
|
+ local.widgetInstance = null;
|
|
|
|
+ local.parentInstance = null;
|
|
|
|
+ var Qweb = openerp.web.qweb;
|
|
|
|
+
|
|
|
|
+ local.PayslipPaymentsWidget = instance.Widget.extend({
|
|
|
|
+ template: 'eiru_payslip_payments.PayslipWidget',
|
|
|
|
+ id: undefined,
|
|
|
|
+ payslip: [],
|
|
|
|
+
|
|
|
|
+ init: function(parent) {
|
|
|
|
+ this._super(parent);
|
|
|
|
+ },
|
|
|
|
+ start: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ this.$el.click(function(){
|
|
|
|
+ self.fectchInitial()
|
|
|
|
+ // self.showPayments();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ updateId: function(id) {
|
|
|
|
+ var self = this;
|
|
|
|
+ self.id = id;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ fectchInitial: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ self.fectchHrPayslip().then(function(payslip) {
|
|
|
|
+ return payslip;
|
|
|
|
+ }).then(function(payslip) {
|
|
|
|
+ self.payslip = payslip;
|
|
|
|
+ // console.log(self.payslip);
|
|
|
|
+ return self.fectchHrPayslipLine(payslip);
|
|
|
|
+ }).then(function(payslipLine) {
|
|
|
|
+ self.payslipLine = payslipLine;
|
|
|
|
+ return self.fectchJournalSalario();
|
|
|
|
+ }).then(function(journalSalario) {
|
|
|
|
+ self.journalSalario = journalSalario;
|
|
|
|
+ console.log(journalSalario);
|
|
|
|
+
|
|
|
|
+ // console.log(payslipLine);
|
|
|
|
+ // local.parentInstance.reload();
|
|
|
|
+ // if (!payslip)
|
|
|
|
+ // instance.web.notification.do_warn("Atención","No existe nomina para ser generada, en el periodo seleccionado");
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ fectchHrPayslip: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var fields = ['id', 'name', 'employee_id', 'date_from', 'date_to', 'move_id', 'number', 'line_ids', 'journal_id'];
|
|
|
|
+ var domain = [['payslip_run_id', 'in', [self.id]],['state', '=', 'done']];
|
|
|
|
+ var payslip = new instance.web.Model('hr.payslip');
|
|
|
|
+ payslip.query(fields).filter(domain).all().then(function(results) {
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+ // Hr payslip Line
|
|
|
|
+ fectchHrPayslipLine: function(payslip) {
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+
|
|
|
|
+ var payslip_id = _.map(payslip, function(map) {
|
|
|
|
+ return map.id;
|
|
|
|
+ });
|
|
|
|
+ var fields = ['id', 'name', 'code', 'total', 'amount'];
|
|
|
|
+ var domain = [['slip_id', 'in', payslip_id], ['code', '=', 'NET']];
|
|
|
|
+ var payslipLine = new instance.web.Model('hr.payslip.line');
|
|
|
|
+ payslipLine.query(fields).filter(domain).all().then(function(results) {
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+ // Diario de Salario
|
|
|
|
+ fectchJournalSalario: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+ var journal_id = _.map(self.payslip, function(map) {
|
|
|
|
+ return map.journal_id[0];
|
|
|
|
+ });
|
|
|
|
+ console.log(journal_id);
|
|
|
|
+ var fields = ['id', 'name', 'code', 'type', 'currency', 'default_debit_account_id', 'default_credit_account_id'];
|
|
|
|
+ var domain = [['id', 'in', journal_id]];
|
|
|
|
+ var journalSalario = new instance.web.Model('account.journal');
|
|
|
|
+ journalSalario.query(fields).filter(domain).all().then(function(results) {
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+ // fectchGenerateNomina: function() {
|
|
|
|
+ // var self = this;
|
|
|
|
+ // var defer = $.Deferred();
|
|
|
|
+ // var hr_payslip = new instance.web.Model('hr.payslip');
|
|
|
|
+ //
|
|
|
|
+ // hr_payslip.call('generate_payroll_eiru',[self.id], {
|
|
|
|
+ // context: new instance.web.CompoundContext()
|
|
|
|
+ // }).then(function(results) {
|
|
|
|
+ // defer.resolve(results);
|
|
|
|
+ // });
|
|
|
|
+ // return defer;
|
|
|
|
+ // },
|
|
|
|
+
|
|
|
|
+ showPayments: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ // Nomina Detalle
|
|
|
|
+ var headerModalName = [{
|
|
|
|
+ name: "Nómina salarial de Adrielso Kunert para diciembre-2017"
|
|
|
|
+ }];
|
|
|
|
+ //
|
|
|
|
+ dataPayslip = [{
|
|
|
|
+ employee: 'Adrielso kunert',
|
|
|
|
+ periodo: '01-10-2017 -30-10-2017',
|
|
|
|
+ salario: '5.000.000',
|
|
|
|
+ ref: ' SLIP/062'
|
|
|
|
+ }]
|
|
|
|
+
|
|
|
|
+ var modal = Qweb.render('EiruPayslipPaymentsModal', {
|
|
|
|
+ data: dataPayslip,
|
|
|
|
+ dataName: headerModalName,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $('.openerp_webclient_container').after(modal);
|
|
|
|
+ $('.expired-account-modal').modal();
|
|
|
|
+
|
|
|
|
+ // Cargara los metodo de pago
|
|
|
|
+ var journal = $('.expired-account-modal').find('.current-journal');
|
|
|
|
+ console.log(journal);
|
|
|
|
+ journal.append('<option value="1">TODAS LAS SUC.</option>');
|
|
|
|
+ journal.append('<option value="2">TODAS LAS SUC.</option>');
|
|
|
|
+ journal.append('<option value="3">TODAS LAS SUC.</option>');
|
|
|
|
+ journal.append('<option value="4">TODAS LAS SUC.</option>');
|
|
|
|
+ journal.append('<option value="5">TODAS LAS SUC.</option>');
|
|
|
|
+ // Actualizar monto a pagar
|
|
|
|
+ $('.expired-account-modal').find('.amount-net').val('5.000.000')
|
|
|
|
+
|
|
|
|
+ // Selecion de Journal
|
|
|
|
+ journal.click(function(e){
|
|
|
|
+ $('.expired-account-modal').find('.amount-net').val(journal.val())
|
|
|
|
+ })
|
|
|
|
+ // Click Cerrar
|
|
|
|
+ $('.expired-account-modal').on('hidden.bs.modal', function (e) {
|
|
|
|
+ self.removeModal(e);
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ // clcik boton pagar
|
|
|
|
+ var contenido = $('.expired-account-modal').find('.payments-payslip');
|
|
|
|
+ contenido.click(function (e) {
|
|
|
|
+ // $(contenido).find('tr').removeClass('table-row-select');
|
|
|
|
+ // $(e.target).closest('tr').addClass('table-row-select');
|
|
|
|
+ // var chirdren_id =$(e.target).closest('tr').children()[0].textContent;
|
|
|
|
+ // self.renderForm(chirdren_id);
|
|
|
|
+ // console.log(e);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ // Remover <Modal></Modal>
|
|
|
|
+ removeModal: function (e) {
|
|
|
|
+ $('.expired-account-modal').remove();
|
|
|
|
+ $('.modal-backdrop').remove();
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (instance.web && instance.web.FormView) {
|
|
|
|
+ instance.web.FormView.include({
|
|
|
|
+ load_record: function(record) {
|
|
|
|
+ this._super.apply(this, arguments);
|
|
|
|
+
|
|
|
|
+ if (this.model !== 'hr.payslip.run')
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ local.parentInstance = this;
|
|
|
|
+
|
|
|
|
+ if (local.widgetInstance) {
|
|
|
|
+ local.widgetInstance.updateId(record.id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.$el.find('.payslip-payments').length !== 0 )
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ local.widgetInstance = new local.PayslipPaymentsWidget(this);
|
|
|
|
+
|
|
|
|
+ var elemento = this.$el.find('.oe_form_sheet.oe_form_sheet_width');
|
|
|
|
+ elemento = elemento.find('.oe_right.oe_button_box.eiru-payslip-payments');
|
|
|
|
+
|
|
|
|
+ local.widgetInstance.appendTo(elemento);
|
|
|
|
+ local.widgetInstance.updateId(record.id);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+}
|