Browse Source

[ADD] payments IPSE

adrielso 6 years ago
parent
commit
33ad0ec5c5

+ 1 - 0
__init__.py

@@ -1,2 +1,3 @@
 # -*- coding: utf-8 -*-
 from model import eiru_payslip_payments
+from model import eiru_payslip_payments_ipse

+ 1 - 0
__openerp__.py

@@ -16,6 +16,7 @@ Modulo para generar pagos de nóminas.
     ],
     'qweb': [
         'static/src/xml/*.xml',
+        'static/src/xml/modal/*.xml',
     ],
 
     'installable': True,

+ 97 - 69
model/eiru_payslip_payments.py

@@ -7,27 +7,18 @@ from pytz import timezone
 class HrPayslip(models.Model):
     _inherit = 'hr.payslip'
 
-    '''
-        Get timezone
-    '''
+    ''' Get timezone '''
     def get_timezone(self):
         tz_name = self._context.get('tz') or self.env.user.tz
         return timezone(tz_name)
 
-    '''
-        Get server date
-    '''
+    ''' Get server date'''
     def get_server_datetime(self):
         return datetime.now(self.get_timezone()).strftime(DATE_FORMAT)
 
-    '''
-        GET Statement
-    '''
+    ''' GET Statement - Obtener las caja abierta/nueva  del usuario '''
     @api.model
     def get_bank_statement_available(self):
-        '''
-            Obtener las caja abierta/nueva  del usuario
-        '''
         BankStatement = []
         for statement in self.env['account.bank.statement'].search([('state','!=','confirm'),('user_id','=',self.env.user.id)]):
 
@@ -56,53 +47,46 @@ class HrPayslip(models.Model):
         |_|   \__,_|\__, |_| |_| |_|\___|_| |_|\__|___/  |_|   \__,_|\__, |___/_|_| .__/
                     |___/                                            |___/        |_|
     '''
-    '''
-        Verificar si la nomina ya esta en un registro de caja
-    '''
+    ''' Verificar si la nomina ya esta en un registro de caja '''
     def verify_statement_line(self, payslip):
         return self.env['account.bank.statement.line'].search([('ref', 'in', [payslip.number])])
 
-    '''
-        Get Payslip
-    '''
+    ''' Get Payslip '''
     def get_eiru_payslip_payments(self, id):
         return self.env['hr.payslip'].browse(id)
 
-    '''
-        Get payslip line
-    '''
+    ''' Get payslip line '''
     def get_eiru_payslip_line_payments(self, payslipId, code):
         return self.env['hr.payslip.line'].search([('slip_id', '=', payslipId), ('code','=', code)])
 
-    '''
-        Get Journal
-    '''
+    ''' Get Journal '''
     def get_eiru_journal_payments(self, journalId):
         return self.env['account.journal'].browse(journalId)
 
-    '''
-        Get move line to payslip
-    '''
-    def get_eiru_move_line_payslip(self, payslip):
-        moveline = self.env['account.move.line'].search([('move_id', 'in', [payslip.move_id.id]),('partner_id', 'in', [payslip.employee_id.address_home_id.id]),('account_id', '=', 75)])
-
+    ''' Get move line to payslip '''
+    def get_eiru_move_line_payslip(self, payslip, account):
+        ''' Account.Account
+          | id   |       Name                                           |
+          | 75  ==> 241000  - Deudas Sociales / Sueldos a Pagar.        |
+          | 25  ==> 134000  - Otros Créditos / Anticipo al Personal.    |
+          | 167 ==> 245000  - Deudas Sociales / IPS a pagar.            |
+          | 168  ==> 515.1   - IPS Aporte Patronal                      |
+        '''
+        domain = [('move_id', 'in', [payslip.move_id.id]),('partner_id', 'in', [payslip.employee_id.address_home_id.id]),('account_id', '=', account)]
         line_move = []
-        for line in moveline:
+        for line in self.env['account.move.line'].search(domain):
             line_move.append({
-                'name': ":/ "+str(line.name),
+                'name': "/: %s" % (line.name),
                 'debit': line.credit if line.credit > 0 else 0.0 ,
                 'credit': line.debit if line.debit > 0 else 0.0 ,
                 'counterpart_move_line_id': line.id,
             })
-
         return line_move
 
-    '''
-        create bank Statement
-    '''
+    ''' create bank Statement '''
     def create_eiru_payslip_bank_statement(self, accountJournal, statementId, date_server, resUser):
         period = self.env['account.period'].search([('date_start', '<=', date_server),('date_stop', '>=', date_server)])
-        ## Domian default
+        ''' Domian default '''
         domain = [('journal_id', '=', accountJournal.id),('user_id', '=', resUser)]
         if (statementId):
             domain.append(('id', '=', statementId))
@@ -133,35 +117,21 @@ class HrPayslip(models.Model):
     '''
         Create Account Bank Statement Line
     '''
-    def create_eiru_payslip_bank_statement_line(self, statement, payslip, payslipline):
-        bank_statement_line = {
-            'statement_id': statement.id,
-            'name': payslip.name,
-            'partner_id': payslip.employee_id.address_home_id.id,
-            'amount': (-1* payslipline.amount) ,
-            'ref': payslip.number
-        }
-
-        return self.env['account.bank.statement.line'].create(bank_statement_line)
+    def create_eiru_payslip_bank_statement_line(self, line):
+        return self.env['account.bank.statement.line'].create(line)
 
-    '''
-        Process Reconciliation Payslip
-    '''
+    ''' Process Reconciliation Payslip '''
     def eiru_payslip_process_reconciliation(self, statementLine, moveLine):
         return statementLine.process_reconciliation(moveLine)
 
-    '''
-        Paymnets Payslip
-    '''
+    ''' Paymnets Payslip '''
     @api.model
     def create_from_prayslip(self, values):
-        ### Date server
+        ''' Date server '''
         dateServer = self.get_server_datetime()
-
-        ### UserID
+        ''' UserID'''
         resUserId = self.env.user.id
-
-        ### payslip
+        ''' payslip '''
         payslip = self.get_eiru_payslip_payments(values['id'])
         if (not payslip):
             return {
@@ -169,7 +139,7 @@ class HrPayslip(models.Model):
                 'message': 'El registro de la nomina es errónea, por-favor actualice su pagina.'
             }
 
-        ### Payslip line
+        '''GET Payslip line (NET)'''
         payslip_line = self.get_eiru_payslip_line_payments(payslip.id, 'NET')
         if (not payslip_line):
             return {
@@ -177,7 +147,7 @@ class HrPayslip(models.Model):
                 'message': 'No se pudo obtener el sueldo neto de la nomina'
             }
 
-        ### Account Journal
+        ''' Get Account Journal'''
         journal =self.get_eiru_journal_payments(values['journalId'])
         if (not journal):
             return {
@@ -185,22 +155,22 @@ class HrPayslip(models.Model):
                 'message': 'El método de pago no es valido.'
             }
 
-        ### verify statement line
+        ''' verify statement line '''
         payslipVerify = self.verify_statement_line(payslip)
         if (payslipVerify):
             return {
                 'state': False,
                 'message': 'No se pudo completar el pago de nomina, porque ya se encuentra en un registros de caja/extractos bancarios (Referencia: '+str(payslipVerify.statement_id.name)+')'
             }
-
-        moveLine = self.get_eiru_move_line_payslip(payslip)
+        ''' Get Move Line  payslip '''
+        moveLine = self.get_eiru_move_line_payslip(payslip, 75)
         if (not moveLine):
             return {
                 'state': False,
                 'message': 'No se puedo obtener las lineas para reconciliar el pagos.'
             }
 
-        ### Create account bank Statement line
+        ''' Create account bank Statement line '''
         statement = self.create_eiru_payslip_bank_statement(journal, values['statementId'], dateServer, resUserId)
         if (not statement):
             return {
@@ -208,23 +178,81 @@ class HrPayslip(models.Model):
                 'message': 'No se pudo crear la caja.'
             }
 
-        ### Create account bank Statement line
-        statementLine = self.create_eiru_payslip_bank_statement_line(statement, payslip, payslip_line)
+        '''Create lineStatement '''
+        lineStatement = {
+            'statement_id': statement.id,
+            'name': payslip.name,
+            'partner_id': payslip.employee_id.address_home_id.id,
+            'amount': (-1* payslip_line.amount) ,
+            'ref': payslip.number
+        }
+        ''' Create account bank Statement line '''
+        statementLine = self.create_eiru_payslip_bank_statement_line(lineStatement)
         if (not statementLine):
             return {
                 'state': False,
                 'message': 'No se pudo crear el detalle de la caja.'
             }
 
-        ### process_reconciliation
+        ''' Process_reconciliation '''
         reconciled = self.eiru_payslip_process_reconciliation(statementLine, moveLine)
-
         if (not reconciled):
             return {
                 'state': False,
-                'message': 'No se pudo reconciliar la nomina.'
+                'message': 'Error, en la reconciliación de la nomina.'
             }
 
+        ''' ADL '''
+        payslip_ADL = self.get_eiru_payslip_line_payments(payslip.id, 'ADPER')
+        if (payslip_ADL):
+            movelineADL = self.get_eiru_move_line_payslip(payslip, 25)
+            if (not movelineADL):
+                return {
+                    'state': False,
+                    'message': 'No se puedo obtener las lineas para reconciliar el adelanto.'
+                }
+
+            ''' Statement Line '''
+            lineStatementADL = {
+                'statement_id': statement.id,
+                'name': "%s / %s" % (payslip.name, "Adelanto Percibido"),
+                'partner_id': payslip.employee_id.address_home_id.id,
+                'amount': payslip_ADL.total ,
+                'ref': 'ADL'
+            }
+
+            ''' Create account bank Statement line '''
+            statementLineADL = self.create_eiru_payslip_bank_statement_line(lineStatementADL)
+            if (not statementLineADL):
+                return {
+                    'state': False,
+                    'message': 'No se pudo crear el detalle de la caja para el adelanto.'
+                }
+
+            reconciledADL = self.eiru_payslip_process_reconciliation(statementLineADL, movelineADL)
+            if (not reconciledADL):
+                return {
+                    'state': False,
+                    'message': 'Error, en la reconciliación de adelanto.'
+                }
+
+            lineStatementADLBalance = {
+                'statement_id': statement.id,
+                'name': "%s / %s" % (payslip.name, "Adelanto Percibido"),
+                'partner_id': payslip.employee_id.address_home_id.id,
+                'amount': abs(payslip_ADL.total) ,
+                'ref': 'Balance',
+                'account_id': statement.journal_id.internal_account_id.id,
+                'journal_id': statement.journal_id.id,
+            }
+
+            statementLineADLBalance = self.create_eiru_payslip_bank_statement_line(lineStatementADLBalance)
+            if (not statementLineADLBalance):
+                return {
+                    'state': False,
+                    'message': 'No se pudo crear el balance de la caja para el adelanto.'
+                }
+
         payslip.write({'state': 'paid'})
 
         return {

+ 296 - 0
model/eiru_payslip_payments_ipse.py

@@ -0,0 +1,296 @@
+# -*- coding: utf-8 -*-
+from openerp import api, fields, models
+from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
+from pytz import timezone
+from datetime import datetime,timedelta
+import logging
+_logger = logging.getLogger(__name__)
+
+class EiruHrPayslipRun(models.Model):
+    _inherit = 'hr.payslip.run'
+
+    ''' Timezone '''
+    def get_timezone(self):
+        return timezone(self._context.get('tz') or self.env.user.tz)
+
+    ''' Datetime '''
+    def get_datetime(self):
+        return datetime.now(self.get_timezone()).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
+
+    ''' Date '''
+    def get_date(self):
+        return datetime.now(self.get_timezone()).strftime(DEFAULT_SERVER_DATE_FORMAT)
+
+    ''' GET PAYSLIP LINE IPS '''
+    @api.model
+    def eiru_get_payslip_payments_ipse(self, idRun):
+        _logger.info('Get payslip payments ipse')
+        ''' Get Payslip Run '''
+        payslipRun = self.env['hr.payslip.run'].browse(idRun)
+        if (not payslipRun):
+            return {
+                'state': False,
+                'message': 'Error en obtener el procesamiento de nominas'
+            }
+
+        ''' Get Payslip '''
+        payslipIds = map(lambda x: x.id, payslipRun.slip_ids)
+        payslip = self.env['hr.payslip'].search([('id', 'in', payslipIds)])
+        if (not payslip):
+            return {
+                'state': False,
+                'message': 'No existe nominas relacionada'
+            }
+
+        ''' Generate Employee list IPSE '''
+        slipEmployee = []
+        for slip in payslip:
+            line = self.env['hr.payslip.line'].search([('slip_id', '=', slip.id), ('code','=', 'IPSE')])
+            if (line):
+                domain = [('move_id', 'in', [slip.move_id.id]),('partner_id', 'in', [slip.employee_id.address_home_id.id]),('account_id', '=', 167),('reconcile_id', '!=', False)]
+                moveLineReconlide = self.env['account.move.line'].search(domain)
+                if (moveLineReconlide):
+                    continue
+
+                slipEmployee.append(
+                    {
+                        'slipId': slip.id,
+                        'slipName': slip.name,
+                        'slipEmployeeId': slip.employee_id.id,
+                        'slipEmployee': slip.employee_id.name,
+                        'amount': abs(line.total),
+                        'lineName': line.name,
+                        'amountFormat': 0,
+                        'currency': {
+                            'id': slip.company_id.currency_id.id,
+                            'name': slip.company_id.currency_id.name,
+                            'symbol': slip.company_id.currency_id.symbol,
+                            'localName': slip.company_id.currency_id.local_name,
+                            'rate': slip.company_id.currency_id.rate,
+                            'thousandsSeparator': slip.company_id.currency_id.thousands_separator,
+                            'decimalSeparator': slip.company_id.currency_id.decimal_separator,
+                            'decimalPlaces': slip.company_id.currency_id.decimal_places,
+                            'position': slip.company_id.currency_id.position,
+                        }
+                    }
+                )
+                slip.company_id.currency_id
+        return slipEmployee
+
+    ''' GET PAYSLIP RUN'''
+    @api.model
+    def eiru_get_payslip_run(self, idRun):
+        _logger.info('Get payslip Run')
+        ''' Get Payslip Run '''
+        return [{
+            'id': run.id,
+            'name': run.name,
+            'date_start': run.date_start,
+            'date_end': run.date_end,
+            'currency': [{
+                'id': currency.id,
+                'name': currency.name,
+                'symbol': currency.symbol,
+                'localName': currency.local_name,
+                'rate': currency.rate,
+                'thousandsSeparator': currency.thousands_separator,
+                'decimalSeparator': currency.decimal_separator,
+                'decimalPlaces': currency.decimal_places,
+                'position': currency.position,
+            } for currency in self.env.user.company_id.currency_id]
+        } for run in self.env['hr.payslip.run'].browse(idRun)]
+
+    ''' GET ACCOUNT JOURNAL '''
+    @api.model
+    def eiru_get_payslip_account_journal(self):
+        accountJournal = []
+
+        for journal in self.env['account.journal'].search([('active', '=', True), ('type', 'in', ['bank', 'cash']),('currency', '=', False)]):
+            bankStatement = []
+            for statement in self.env['account.bank.statement'].search([('state','!=','confirm'),('user_id.id','=',self.env.user.id),('journal_id.id', '=',journal.id )]):
+                if (statement.journal_id.type == 'cash' and statement.state =='draft'):
+                    continue
+
+                bankStatement.append({
+                    'id': statement.id,
+                    'name': statement.name,
+                    'journalID': statement.journal_id.id,
+                    'userId': statement.user_id.id,
+                    'date': statement.date,
+                    'createDate': statement.create_date,
+                    'periodId': statement.period_id.id,
+                    'state': statement.state,
+                    'journalType': statement.journal_id.type
+                })
+
+            accountJournal.append({
+                'id': journal.id,
+                'name': journal.name,
+                'code': journal.code,
+                'statementOpen': bankStatement
+            })
+
+        return accountJournal
+
+
+    '''
+          ____   _ __   ____  __ _____ _   _ _____ ____    ___ ____  ____  _____
+         |  _ \ / \\ \ / /  \/  | ____| \ | |_   _/ ___|  |_ _|  _ \/ ___|| ____|
+         | |_) / _ \\ V /| |\/| |  _| |  \| | | | \___ \   | || |_) \___ \|  _|
+         |  __/ ___ \| | | |  | | |___| |\  | | |  ___) |  | ||  __/ ___) | |___
+         |_| /_/   \_\_| |_|  |_|_____|_| \_| |_| |____/  |___|_|   |____/|_____|
+    '''
+    @api.model
+    def eiru_payslip_payments_ipse(self, values):
+        _logger.info('Payements payslip IPSE')
+        ''' Date Server '''
+        dateServer = self.get_date()
+        ''' Get User '''
+        resUserId = self.env.user.id
+        ''' Get payslip Run '''
+        runPayslip = self.env['hr.payslip.run'].browse(values['runId'])
+        if (not runPayslip):
+            return {
+                'state': False,
+                'message': "No se pudo obtener el procesamiento de nominas."
+            }
+        ''' Get payslip  '''
+        hrPayslip = self.env['hr.payslip'].browse(values['slipIds'])
+        if (not hrPayslip):
+            return {
+                'state': False,
+                'message':  "No es posible obtener las nominas."
+            }
+
+        ''' Get journal '''
+        accountJournal = self.env['account.journal'].browse(values['journalId'])
+        if (not accountJournal):
+            return {
+                'state': False,
+                'message': "No es posible localizar el  método de pago seleccionado."
+            }
+
+        for slip in hrPayslip:
+            ''' Get Payslip Line '''
+            payslip_ips = self.env['hr.payslip.line'].search([('slip_id', '=', slip.id), ('code','=', 'IPSE')])
+
+            ''' Hr Employee '''
+            employee = self.env['hr.employee'].browse(slip.employee_id.id)
+            if (not employee):
+                return {
+                    'state': False,
+                    'message': "No fue posible  localizar el funcionario. "
+                }
+
+            ''' Res Partner '''
+            partner = self. env['res.partner'].browse(employee.address_home_id.id)
+            if (not partner):
+                return {
+                    'state': False,
+                    'message': "No fue posible localizar el socio."
+                }
+
+            ''' Get MoveLines  '''
+            moveLines = self._get_move_line_payslit_run(slip, partner, 167)
+            if (not moveLines):
+                return {
+                    'state': False,
+                    'message': "No fue posible localizar los  Asientos contables"
+                }
+
+            ''' Account Bank statement '''
+            bankStatement = self._create_eiru_payslip_bank_statement(accountJournal, values['statementId'], dateServer, resUserId)
+            if (not bankStatement):
+                return {
+                    'state': False,
+                    'message': "No fue posible crear la caja."
+                }
+
+            ''' Statemen Line '''
+            lineStatementips = {
+                    'statement_id': bankStatement.id,
+                    'name': "%s / %s" % (slip.name, "Liquidacion I.P.S.E. "),
+                    'partner_id': partner.id,
+                    'amount': payslip_ips.total,
+                    'ref': values['refPayments']
+            }
+            statementLine = self._create_eiru_payslip_bank_statement_line(lineStatementips)
+            if (not statementLine):
+                return {
+                    'state': False,
+                    'message': "No fue posible crear las lineas de la caja."
+                }
+
+            '''  process_reconciliation '''
+            reconcilIPS = self._eiru_payslip_process_reconciliation(statementLine, moveLines)
+            if (not reconcilIPS):
+                return {
+                    'state': False,
+                    'message': 'Error, en la reconciliación de adelanto.'
+                }
+
+        return {
+            'state': True,
+            'message': "Operación exitosa."
+        }
+
+    ''' Get Move line '''
+    def _get_move_line_payslit_run(self, payslip, partner, accountId):
+        '''
+            Account.Account_______________________________________________
+            | id   |       Name                                           |
+            | 75  ==> 241000  - Deudas Sociales / Sueldos a Pagar.        |
+            | 25  ==> 134000  - Otros Créditos / Anticipo al Personal.    |
+            | 167 ==> 245000  - Deudas Sociales / IPS a pagar.            |
+            | 168 ==> 515.1   - IPS Aporte Patronal.                      |
+        '''
+        domain = [('move_id', 'in', [payslip.move_id.id]),('partner_id', 'in', [partner.id]),('account_id', '=', accountId)]
+        line_move = []
+        for line in self.env['account.move.line'].search(domain):
+            line_move.append({
+                'name': "/: %s" % (line.name),
+                'debit': line.credit if line.credit > 0 else 0.0 ,
+                'credit': line.debit if line.debit > 0 else 0.0 ,
+                'counterpart_move_line_id': line.id,
+            })
+
+        return line_move
+
+    '''  Create Bank Statement  '''
+    def _create_eiru_payslip_bank_statement(self, accountJournal, statementId, date_server, resUser):
+        period = self.env['account.period'].search([('date_start', '<=', date_server),('date_stop', '>=', date_server)])
+        ''' Domian default '''
+        domain = [('journal_id', '=', accountJournal.id),('user_id', '=', resUser)]
+        if (statementId):
+            domain.append(('id', '=', statementId))
+        else:
+            domain.append(('date', '=', date_server))
+
+        bank_statement = self.env['account.bank.statement'].search(domain)
+
+        bank = {
+            'journal_id': accountJournal.id,
+            'period_id': period.id,
+            'date': date_server,
+            'user_id': resUser,
+            'state': 'open' if accountJournal.type == 'cash' else 'draft',
+        }
+        bankStatement = bank_statement
+
+        if bank_statement:
+            if len(bank_statement) != 1:
+                bankStatement = bank_statement[len(bank_statement) -1]
+
+            bankStatement.write({'state': 'open' if accountJournal.type == 'cash' else 'draft'})
+        else:
+            bankStatement = bank_statement.create(bank)
+
+        return bankStatement
+
+    '''  Create Account Bank Statement Line  '''
+    def _create_eiru_payslip_bank_statement_line(self, line):
+        return self.env['account.bank.statement.line'].create(line)
+
+    '''  Process Reconciliation Payslip  '''
+    def _eiru_payslip_process_reconciliation(self, statementLine, moveLine):
+        return statementLine.process_reconciliation(moveLine)

+ 122 - 6
static/src/css/style.css

@@ -27,6 +27,18 @@
     text-align: right;
     padding-right: 20px;
 }
+.input-amount {
+    width: calc(100% - 30px);
+}
+.payments-payslip-symbol {
+    width: 30px;
+    height: 30px;
+    float: right;
+    text-align: center;
+    font-size: 16pt;
+    border: 1px solid #ccc;
+    background: #e3e3e3;
+}
 .paymnet-payslip-separator-hr {
     border: 0px;
     margin-top: 5px;
@@ -40,7 +52,6 @@
     height: 40px;
     font-size: 12pt !important;
 }
-
 .eiru-payslip-payments {
     width: auto;
     float: left;
@@ -77,11 +88,6 @@
     width: 150px;
     text-align: right;
 }
-
-/* .current-journal {
-    width: 200px;
-    height: 30px;
-} */
 .journal-ref {
     width: 200px;
     height: 30px;
@@ -96,3 +102,113 @@
     width: 100px;
     height: 30px;
 }
+.payments-payslip-ips {
+    margin-top: 0px !important;
+}
+.expired-account-modal .selected-interest {
+     background: #d4e2f3  !important;
+}
+.expired-account-modal  .modal-head-wrapper-payslip-ips {
+    width: 100%;
+}
+.expired-account-modal .modal-item-payments-payslip-ips {
+    width: 100%;
+    height: 246px;
+    overflow-y: auto;
+}
+.expired-account-modal .payments-payslip-ips table tbody tr {
+    height: 35px;
+}
+.expired-account-modal .payments-payslip-ips table thead tr {
+    height: 40px !important;
+}
+.header-paymsnt-ips {
+    font-size: 14pt !important;
+}
+.expired-account-modal .selected-ips {
+     background: #d4e2f3  !important;
+}
+ /*
+      _____ _   _ _____    _    ____
+     |_   _| | | | ____|  / \  |  _ \
+       | | | |_| |  _|   / _ \ | | | |
+       | | |  _  | |___ / ___ \| |_| |
+       |_| |_| |_|_____/_/   \_\____/
+*/
+/* id */
+.expired-account-modal table thead tr th:nth-child(1){
+      display: none;
+}
+/* checkbox */
+.expired-account-modal .payments-payslip-ips table thead tr th:nth-child(2){
+      width: 38px;
+}
+/* slip */
+.expired-account-modal .payments-payslip-ips table thead tr th:nth-child(3){
+    width: 600px;
+    padding-left: 10px;
+    font-size: 12pt;
+    font-weight: bold;
+}
+/* Amount */
+.expired-account-modal .payments-payslip-ips table thead tr th:nth-child(4){
+    width: 200px;
+    text-align: center;
+    font-size: 12pt;
+    font-weight: bold;
+}
+/*
+      _____  _    ____  _     _____
+     |_   _|/ \  | __ )| |   | ____|
+       | | / _ \ |  _ \| |   |  _|
+       | |/ ___ \| |_) | |___| |___
+       |_/_/   \_\____/|_____|_____|
+*/
+/* id */
+.expired-account-modal .payments-payslip-ips table tbody tr td:nth-child(1){
+    display: none;
+}
+/* checkbox */
+.expired-account-modal .payments-payslip-ips table tbody tr td:nth-child(2){
+    width: 38px ;
+}
+/* Slip */
+.expired-account-modal .payments-payslip-ips table tbody tr td:nth-child(3){
+    width: 600px ;
+    font-size: 11pt;
+    padding-left: 10px;
+    padding-top: 8px;
+}
+/* Amount */
+.expired-account-modal .payments-payslip-ips table tbody tr td:nth-child(4){
+    width: 185px ;
+    text-align: center;
+    font-size: 11pt;
+    padding-top: 8px;
+}
+
+.payments-payslip-ips-button {
+    font-size: 12pt !important;
+    width: 130px;
+    height: 35px;
+}
+.ref-payments-ips-select{
+    color: #ad1a1a;
+    font-size: 10pt;
+    font-weight: bolder;
+    padding-left: 18px;
+}
+.statement-open-ips {
+    display: none;
+}
+.widget-content.widget-loading-payments-ips {
+    position: absolute;
+    width: 100%;
+    height: 100%;
+    color : #000;
+    display: none;
+    z-index: 1100;
+    background: #8080806b;
+    align-items: center;
+    justify-content: center;
+}

+ 377 - 0
static/src/js/payslip_payments_ipse.js

@@ -0,0 +1,377 @@
+
+openerp.eiru_payslip_payments = function(instance, local) {
+    local.widgetInstancePayslipPaymentsIPSE = null;
+    local.parentInstancePayslipPaymentsIPSE = null;
+    var Qweb = openerp.web.qweb;
+
+    local.PayslipPaymentsIPSE = instance.Widget.extend({
+        template: 'eiru_payslip_payments.IPSE',
+        id: undefined,
+        payslipIpse: [],
+        payslispRun: [],
+        accountJournal: [],
+        init: function(parent) {
+            this._super(parent);
+            this.buttons = parent.$buttons;
+        },
+        start: function() {
+            var self = this;
+            this.$el.click(function(){
+                self.fectchInitial()
+            });
+
+            self.buttons.click(function(e) {
+                /* E (Editar) */
+                if (e.target.accessKey === 'E')
+                    self.$el.css('display','none');
+                /* S (Guarrdar) */
+                if (e.target.accessKey === 'S')
+                    self.$el.css('display','flex');
+                /* D (Cancelar) */
+                if (e.target.accessKey === 'D')
+                    self.$el.css('display','flex');
+            });
+        },
+        updateId: function(id) {
+            var self = this;
+            self.id = id;
+        },
+
+        /* Remover */
+        removeModal: function() {
+            $('.expired-account-modal').remove();
+            $('.modal-backdrop').remove();
+        },
+
+        /* Metodo Inicial */
+        fectchInitial: function() {
+            var self = this;
+            self.fetchPayslipPaymentsIpse(self.id).then(function(payslipIpse) {
+                return payslipIpse;
+            }).then(function(payslipIpse) {
+                self.payslipIpse = payslipIpse;
+                return self.fetchPayslipRun(self.id)
+            }).then(function(payslispRun) {
+                self.payslispRun = payslispRun;
+                return  self.fetchAccountJournal();
+            }).then(function(accountJournal) {
+                self.accountJournal = accountJournal;
+                if (!self.payslipIpse.length){
+                    instance.web.notification.do_warn("Atención","No existe registro de I.P,S, empleado a reconciliar.");
+                    return false;
+                }
+                return self.showPaymentsIpse()
+            });
+        },
+
+        /* Get statement Available*/
+        fetchPayslipPaymentsIpse: function(id) {
+            var payslipRun = new openerp.web.Model('hr.payslip.run');
+            return payslipRun.call('eiru_get_payslip_payments_ipse',[id],{
+                    context: new openerp.web.CompoundContext()
+            });
+        },
+
+        // payslip
+        fetchPayslipRun: function(id) {
+            var payslipRun = new openerp.web.Model('hr.payslip.run');
+            return payslipRun.call('eiru_get_payslip_run',[id],{
+                    context: new openerp.web.CompoundContext()
+            });
+        },
+        // Account Journal
+        fetchAccountJournal: function(id) {
+            var payslip = new openerp.web.Model('hr.payslip.run');
+            return payslip.call('eiru_get_payslip_account_journal',{
+                    context: new openerp.web.CompoundContext()
+            });
+        },
+        // amoutn Formata currency
+        addAmountCurrency: function(){
+            var self = this;
+            _.each(self.payslipIpse, function(item) {
+                item.amountFormat = openerp.web.formatCurrency(item.amount, item.currency);
+            })
+            return  self.payslipIpse;
+        },
+        /* Filter ips Payments */
+        getPayslipPayments: function(id){
+            var self = this;
+            return _.filter(self.payslipIpse, function(item) {
+                return  item.slipId === id;
+            });
+        },
+
+        /* Get Account Journal Select */
+        getAccountJournal: function(){
+            var self = this;
+            var journal = [];
+            _.each(self.accountJournal, function(item) {
+                journal.push({
+                    'id': item.id,
+                    'name': item.name,
+                });
+            });
+
+            if (journal.length) {
+                journal.unshift({
+                    'id': '',
+                    'name': ''
+                });
+            }
+            return journal
+        },
+
+        /* Filter Journal select */
+        filterAccountJournal: function(id){
+            var self = this;
+            return _.filter(self.accountJournal, function(item){
+                return  item.id === id;
+            });
+        },
+
+        /* Modal */
+        showPaymentsIpse: function(payslip, currency, journal) {
+            var self = this;
+            var defer = $.Deferred();
+            var state = true;
+            var slipRun = self.payslispRun[0];
+            var currency = slipRun.currency;
+            var accountJournal = self.getAccountJournal();
+            var slip = self.addAmountCurrency();
+            var ipsPayments = []
+            var payslispRun = self.payslispRun[0];
+
+            var header = [];
+            if (payslispRun) {
+                header.push({
+                    'title': "Procesamiento "+ moment(payslispRun.date_start).format('DD/MM/YYYY')+" - "+moment(payslispRun.date_end).format('DD/MM/YYYY')
+                })
+            }
+
+            var modal = Qweb.render('eiruPayslipPayments.IPSEModal', {
+                'slip': slip,
+                'header': header,
+                'journal': accountJournal,
+            });
+
+            $('.openerp_webclient_container').after(modal);
+            $('.expired-account-modal').modal();
+
+            var selectIpsAll = $('.expired-account-modal').find('.select-ips-all');
+            var tableRow = $('.expired-account-modal').find('.table-tbody').find('tr');
+            /* amount */
+            var ipsTotal = $('.expired-account-modal').find('.amount-total');
+            /* journal && statement */
+            var journalSelected = $('.expired-account-modal').find('.journal-selected');
+            var statementSelected = $('.expired-account-modal').find('.statement-selected');
+            var refPaymsntIps = $('.expired-account-modal').find('.ref-paymsnt-ips');
+
+
+            /* button */
+            var buttonAccept  = $('.expired-account-modal').find('.button-accept');
+            $('.expired-account-modal').find('.amount-symbol-payslip').text(currency[0].symbol);
+            $('.expired-account-modal').find('.ref-payments-ips-select').text("Nóminas seleccionadas\t"+ ipsPayments.length +"/"+ self.payslipIpse.length);
+
+            /* click */
+            selectIpsAll.click(function(e) {
+                var check = false;
+                if (e.target.checked === true) {
+                    check = e.target.checked;
+                }
+
+                var amountTotal = 0;
+                ipsPayments = [];
+                /* Disabled Chech Moveline */
+                _.each(tableRow, function(tr) {
+                    ($($(tr).children()[1]).find('.select-payments-ips'))[0].checked = check;
+
+                    $(tr).removeClass('selected-ips');
+
+                    if (check) {
+                        idRow = parseInt(($(tr).children()[0].textContent).trim());
+                        selectIps = self.getPayslipPayments(idRow).shift();
+
+                        $(tr).addClass('selected-ips');
+
+                        if (selectIps) {
+                            ipsPayments.push({
+                                'slipId':selectIps.slipId,
+                                'amount': selectIps.amount,
+                                'employee_id': selectIps.slipEmployeeId
+                            });
+                            amountTotal += selectIps.amount;
+                        }
+                    }
+                });
+
+                ipsTotal.val(openerp.web.formatCurrency(amountTotal, currency));
+                $('.expired-account-modal').find('.ref-payments-ips-select').text("Nóminas seleccionadas\t"+ ipsPayments.length +"/"+ self.payslipIpse.length)
+            });
+
+            /* Selecionar las cuotas */
+            tableRow.click(function(e) {
+                if (($(e.target).index() !== 0) ||(($(e.target).index() === 0) && ($(e.target)[0].className !== 'select-payments-ips')))
+                    return false;
+
+                selectIpsAll[0].checked = false;
+
+                if (e.target.checked === true) {
+                    idRow = parseInt(($(e.target).closest('tr').children()[0].textContent).trim());
+                    selectIps = self.getPayslipPayments(idRow).shift();
+
+                    $(e.target).closest('tr').addClass('selected-ips');
+
+                    ipsPayments.push({
+                        'slipId':selectIps.slipId,
+                        'amount': selectIps.amount,
+                        'employee_id': selectIps.slipEmployeeId
+                    });
+                } else {
+                    $(e.target).closest('tr').removeClass('selected-ips');
+
+                    var indexSplice = undefined;
+                    _.each(ipsPayments, function(item, index){
+                        if (item.id === idRow)
+                            indexSplice = index
+                    })
+
+                    ipsPayments.splice(indexSplice,1);
+                }
+
+                var amountTotal = _.reduce(_.map(ipsPayments, function(map){
+                    return map.amount;
+                }), function(memo, num) {
+                    return memo + num;
+                }, 0);
+
+                ipsTotal.val(openerp.web.formatCurrency(amountTotal, currency));
+                $('.expired-account-modal').find('.ref-payments-ips-select').text("Nóminas seleccionadas\t"+ ipsPayments.length +"/"+ self.payslipIpse.length);
+            });
+
+            /* Journal Change */
+            journalSelected.change(function(e){
+                $('.expired-account-modal').find('.paymnet-payslip-statement-open').css('display','none');
+                statementSelected.empty();
+                if (!!journalSelected.val()) {
+                    var statementjournal =  self.filterAccountJournal(parseInt(journalSelected.val())).shift();
+                    var statementOpen = statementjournal.statementOpen;
+
+                    if (!!statementOpen.length){
+                        $('.expired-account-modal').find('.paymnet-payslip-statement-open').css('display','flex');
+                        statementSelected.append('<option value=""></option>');
+                       _.each(statementOpen, function(item) {
+                           statementSelected.append('<option value="' + item.id + '">' + item.name+" - "+moment(item.date).format("DD-MM-YYYY")+ '</option>');
+                       });
+                    }
+                }
+            });
+
+            buttonAccept.click(function(e) {
+                if (!ipsPayments.length){
+                    instance.web.notification.do_warn("Atención","Tienes que seleccionar al menos un ítem (ips) para continuar.");
+                    tableRow.focus();
+                    return false;
+                }
+
+                if (!journalSelected.val()) {
+                    instance.web.notification.do_warn("Atención","Tienes que seleccionar un método de pago para continuar.");
+                    journalSelected.css('border-color','red');
+                    journalSelected.focus();
+                    return false;
+                }
+                journalSelected.css('border-color','#ccc');
+                var statementjournal =  self.filterAccountJournal(parseInt(journalSelected.val())).shift();
+                var statementOpen = statementjournal.statementOpen;
+
+                if (!!statementOpen.length && !statementSelected.val()) {
+                    instance.web.notification.do_warn("Atención","Tienes que seleccionar una caja para continuar.");
+                    statementSelected.css('border-color','red');
+                    statementSelected.focus();
+                    return false;
+
+                }
+                statementSelected.css('border-color','#ccc');
+
+                if (!refPaymsntIps.val().trim()) {
+                    instance.web.notification.do_warn("Atención","Debes ingresar una referencia de pago para continuar.");
+                    refPaymsntIps.css('border-color','red');
+                    refPaymsntIps.focus();
+                    return false;
+                }
+                refPaymsntIps.css('border-color','#ccc');
+
+                var slipIds = _.map(ipsPayments, function(map){
+                    return map.slipId;
+                });
+
+                paymenstIps = {
+                    'runId': self.id,
+                    'journalId': parseInt(journalSelected.val()),
+                    'statementId': parseInt(statementSelected.val()),
+                    'refPayments': refPaymsntIps.val().trim(),
+                    'slipIds': slipIds
+                }
+                /* Guardar */
+                $('.expired-account-modal').find('.widget-content.widget-loading-payments-ips').css('display','flex');
+                self.paymentsPayslipIps(paymenstIps).then(function(paymentsIps){
+                    return paymentsIps;
+                }).then(function(paymentsIps) {
+                    if (!paymentsIps.state) {
+                        instance.web.notification.do_warn("Atención", paymentsIps.message, true);
+                    }
+                    $('.expired-account-modal').find('.widget-content.widget-loading-payments-ips').css('display','none');
+                    self.removeModal(e);
+                    defer.resolve(paymentsIps)
+                });
+            });
+
+            /* Click Cerrar */
+            $('.expired-account-modal').on('hidden.bs.modal', function (e) {
+                defer.resolve(false);
+                self.removeModal(e);
+            });
+
+            return defer;
+        },
+
+        /*Pagar nominas */
+        paymentsPayslipIps: function(paymenstIps) {
+            var payslipRun = new  instance.web.Model('hr.payslip.run');
+            return payslipRun.call('eiru_payslip_payments_ipse', [paymenstIps],{
+                context: new instance.web.CompoundContext()
+            });
+        },
+    });
+
+    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.parentInstancePayslipPaymentsIPSE = this;
+
+                if (local.widgetInstancePayslipPaymentsIPSE) {
+                    local.widgetInstancePayslipPaymentsIPSE.updateId(record.id);
+                    if (this.$el.find('.payslip-payments-ipse').length !== 0){
+                        return
+                    }
+                }
+
+                if (this.$el.find('.payslip-payments-ipse').length !== 0 )
+                    return;
+
+                local.widgetInstancePayslipPaymentsIPSE = new local.PayslipPaymentsIPSE(this);
+
+                var elemento = this.$el.find('.oe_form').find('.eiru-payslip-payments');
+
+                local.widgetInstancePayslipPaymentsIPSE.appendTo(elemento);
+                local.widgetInstancePayslipPaymentsIPSE.updateId(record.id);
+            },
+        });
+    }
+
+}

+ 9 - 0
static/src/xml/eiru_payslip_payments_ipse.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<templates xml:space="preserve">
+    <t t-name="eiru_payslip_payments.IPSE">
+        <button class="payslip-payments-ipse oe_button oe_form_button oe_highlight">
+            <div>Pagar IPS Empleados</div>
+        </button>
+  </t>
+</templates>

+ 0 - 0
static/src/xml/hr_payslip_payments.xml → static/src/xml/modal/hr_payslip_payments.xml


+ 114 - 0
static/src/xml/modal/payslip_payments_ipse.xml

@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="eiruPayslipPayments.IPSEModal">
+        <div class="modal in expired-account-modal" tabindex="-1" role="dialog">
+            <div class="modal-dialog modal-lg" role="document">
+                <div class="modal-content openerp">
+                    <div class="widget-content widget-loading-payments-ips">
+                        <i class='fa fa-cog fa-spin fa-3x fa-fw'></i>
+                    </div>
+                    <!-- title  -->
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">×</button>
+                        <h3 class="modal-title header-paymsnt-ips" t-foreach="header" t-as="header">
+                            Liquidación I.P.S empleado.
+                            <small><t t-esc="header_value.title"/></small>
+                        </h3>
+                    </div>
+                    <!-- Body -->
+                    <div class="modal-body">
+                        <!-- Table -->
+                        <div class=" oe_view_manager_body payments-payslip-ips">
+                            <div class="modal-head-wrapper-payslip-ips">
+                                <table class="oe_list_content">
+                                    <thead >
+                                        <tr class="oe_list_header_columns"  >
+                                            <th class="oe_list_header_char oe_sortable"></th>
+                                            <th class="oe_list_header_char oe_sortable"><input type="checkbox" class="select-ips-all"></input></th>
+                                            <th class="oe_list_header_char oe_sortable">Nómina</th>
+                                            <th class="oe_list_header_char oe_sortable">Monto I.P.S.</th>
+                                        </tr>
+                                    </thead>
+                                </table>
+                            </div>
+                            <div class="modal-item-payments-payslip-ips">
+                                <table class="oe_list_content">
+                                    <tbody class="table-tbody">
+                                        <tr t-foreach="slip" t-as="slip">
+                                            <td>
+                                                <t t-esc="slip_value.slipId"/>
+                                            </td>
+                                            <td>
+                                                <input type="checkbox" class="select-payments-ips"></input>
+                                            </td>
+                                            <td>
+                                                <t t-esc="slip_value.slipName"/>
+                                            </td>
+                                            <td>
+                                                <t t-esc="slip_value.amountFormat"/>
+                                            </td>
+                                        </tr>
+                                    </tbody>
+                                </table>
+                            </div>
+                        </div>
+
+                        <!-- detalles -->
+                        <div class="row ">
+                            <div class="col-xs-6">
+                                <span class="ref-payments-ips-select"></span>
+                            </div>
+
+                            <div class="col-xs-6">
+                                <label class="paymnet-payslip-label">Total a Pagar</label>
+                                <div class="paymnet-payslip-group">
+                                    <input type="text" class="paymnet-payslip-input input-disabled input-number input-amount amount-total" readonly="readonly" value="0"></input>
+                                      <div class="payments-payslip-symbol">
+                                        <span class="amount-symbol-payslip"></span>
+                                      </div>
+                                </div>
+                            </div>
+                        </div>
+
+                        <div class="row">
+                            <div class="col-xs-6">
+                                <label class="paymnet-payslip-label">Método de pago: </label>
+                                <div class="paymnet-payslip-group">
+                                    <select class="paymnet-payslip-input journal-selected">
+                                        <t t-foreach="journal" t-as="journal">
+                                            <option t-attf-value="{{ journal_value.id }}" >
+                                                <t t-esc="journal_value.name"/>
+                                            </option>
+                                        </t>
+                                    </select>
+                                </div>
+                            </div>
+                            <div class="col-xs-6 paymnet-payslip-statement-open">
+                                <label class="paymnet-payslip-label">Caja</label>
+                                <div class="paymnet-payslip-group">
+                                    <select class="paymnet-payslip-input statement-selected">
+                                    </select>
+                                </div>
+                            </div>
+                        </div>
+
+                        <div class="row">
+                            <div class = "col-xs-12">
+                                <label class="paymnet-payslip-label">Referencia de pago: </label>
+                                <div class="paymnet-payslip-group">
+                                    <input type="text" class="paymnet-payslip-input ref-paymsnt-ips"></input>
+                                </div>
+                            </div>
+                        </div>
+
+                    </div>
+                    <!-- Pie de Pagina -->
+                    <div class="modal-footer paymnets-invoice-footer">
+                        <button type="button" class="oe_button oe_form_button oe_highlight payments-payslip-ips-button button-accept">Guardar</button>
+                        <button type="button" class="oe_button oe_form_button oe_link dismmis-modal payments-payslip-ips-button" data-dismiss="modal">Salir</button>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </t>
+</template>

+ 2 - 1
view/template.xml

@@ -3,8 +3,9 @@
         <template id="eiru_payslip_payments.eiru_assets" name="aeiru_payslip_payments_eiru_assets" inherit_id="eiru_assets.assets">
             <xpath expr="." position="inside">
                 <link rel="stylesheet" href="/eiru_payslip_payments/static/src/css/style.css"/>
-                <script type="text/javascript" src="/eiru_payslip_payments/static/src/js/payslip_payments.js"/>
+                <!-- <script type="text/javascript" src="/eiru_payslip_payments/static/src/js/payslip_payments.js"/> -->
                 <script type="text/javascript" src="/eiru_payslip_payments/static/src/js/payslip_payments_unity.js"/>
+                <script type="text/javascript" src="/eiru_payslip_payments/static/src/js/payslip_payments_ipse.js"/>
             </xpath>
         </template>
     </data>