소스 검색

[ADD] Ajuste de saldo

adrielso 6 년 전
부모
커밋
fe191c6c4e

+ 4 - 6
__openerp__.py

@@ -10,14 +10,12 @@
         'eiru_assets',
         'currency_utility',
         'point_of_sale',
+        'eiru_account_bank_statement_utility'
     ],
     'data': [
-        'views/template.xml',
-        'security/ir.model.access.csv',
-        'views/account_bank_statement_type.xml',
-        'views/eiru_statement_utility.xml',
-        'views/import_statement.xml',
-        'views/account_bank_statemente_config.xml',
+        'views/templates.xml',
+        'views/statement_pos.xml',
+        'views/account_bank_config.xml',
     ],
     'qweb': [
         'static/src/xml/*.xml',

+ 3 - 0
models/__init__.py

@@ -1 +1,4 @@
 # -*- coding: utf-8 -*-
+
+import eiru_statement_pos_confirm
+import account_bank_statement_config

+ 10 - 0
models/account_bank_statement_config.py

@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+from openerp import models, fields, tools, api
+
+class PosAccountBankStatementConfig(models.Model):
+    _inherit = "account.bank.statement.config"
+
+    pos_journal_permitted = fields.Many2many('account.journal', 'pos_journal_permitted', 'account_bank_statement_config_id', 'account_journal_id',
+    domain="[('journal_user', '=', True ), ('type', 'in', ['bank', 'cash'])]", string='Método de pago')
+    pos_statement_output = fields.Boolean('Permitir sacar dinero', default=False, help="Permitir sacar dinero.")
+    pos_statement_transfer = fields.Boolean('Permitir realizar transferencia', default=False, help="Permitir realizar transferencia.")

+ 390 - 0
models/eiru_statement_pos_confirm.py

@@ -0,0 +1,390 @@
+# -*- coding: utf-8 -*-
+from openerp import models, fields, tools, api
+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 EiruPosSessionConfirm(models.Model):
+    _inherit = 'pos.session'
+
+    ''' 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 POS SESSION + Statemen '''
+    @api.model
+    def eiru_get_pos_session_statement(self, id):
+        _logger.info('Obtener los detalles de las caja de las seccion')
+        statementId = []
+        sessionPos = []
+
+        posSession = self.env['pos.session'].search([('id', '=', id ), ('state', '=','opened')])
+        if (not posSession):
+            return {
+                'state': False,
+                'message': "Error en obtener la sesión del pos.",
+            }
+        statementIds = map(lambda x: x.id, posSession.statement_ids)
+        bankStatement = self.env['account.bank.statement'].search([('id', 'in', statementIds),('state', '=', 'open')])
+        if (not bankStatement):
+            return {
+                'state':False,
+                'message': "No existe ninguna caja asociada con la sesión",
+            }
+
+        for statement in bankStatement:
+            statementGeneral = []
+            amount = 0.00
+
+            AccountJournal = self.env['account.journal'].browse(statement.journal_id.id)
+            statementType = self.env['account.bank.statement.type'].search([('code', '=', 'GENERAL')])
+            statementG = self.env['account.bank.statement'].search([('journal_id.id', '=', AccountJournal.id), ('type_statement.id', '=', statementType.id),('state', '=', 'open')])
+
+            for generalStatement in statementG:
+                statementGeneral.append({
+                    'id': generalStatement.id,
+                    'name': generalStatement.name
+                })
+
+            for line in statement.line_ids:
+                amount += line.amount
+
+            if (statement.balance_start > 0):
+                amount += statement.balance_start
+
+            statementId.append({
+                'id': statement.id,
+                'name': statement.name,
+                'amount': amount,
+                'joutnalType': AccountJournal.type,
+                'journalId': AccountJournal.id,
+                'statementGeneral': statementGeneral,
+                'currency':[{
+                    'id': resCurrency.id,
+                    'name': resCurrency.name,
+                    'symbol': resCurrency.symbol,
+                    'localName': resCurrency.local_name,
+                    'rate': resCurrency.rate,
+                    'thousandsSeparator': resCurrency.thousands_separator,
+                    'decimalSeparator': resCurrency.decimal_separator,
+                    'decimalPlaces': resCurrency.decimal_places,
+                    'position': resCurrency.position,
+                }for resCurrency in self.env['res.currency'].browse(statement.currency.id)]
+            })
+
+        sessionPos = {
+            'id': posSession.id,
+            'name': posSession.name,
+            'state': posSession.state,
+            'statement': statementId,
+        }
+
+        return sessionPos
+
+    ''' ***********************************************************************
+           ____ _                  ____                _
+          / ___| | ___  ___  ___  / ___|  ___  ___ ___(_) ___  _ __
+         | |   | |/ _ \/ __|/ _ \ \___ \ / _ \/ __/ __| |/ _ \| '_ \
+         | |___| | (_) \__ \  __/  ___) |  __/\__ \__ \ | (_) | | | |
+          \____|_|\___/|___/\___| |____/ \___||___/___/_|\___/|_| |_|
+    *************************************************************************'''
+    @api.model
+    def eiru_pos_session_close(self, id):
+        _logger.info('Validar y contabilizar asiento(s) de cierre')
+        posSession = self.env['pos.session'].browse(id)
+        return posSession.signal_workflow('close')
+
+    ''' ***********************************************************************
+          ____  _        _                            _     ____
+         / ___|| |_ __ _| |_ ___ _ __ ___   ___ _ __ | |_  |  _ \ ___  ___
+         \___ \| __/ _` | __/ _ \ '_ ` _ \ / _ \ '_ \| __| | |_) / _ \/ __|
+          ___) | || (_| | ||  __/ | | | | |  __/ | | | |_  |  __/ (_) \__ \
+         |____/ \__\__,_|\__\___|_| |_| |_|\___|_| |_|\__| |_|   \___/|___/
+    *************************************************************************'''
+    @api.model
+    def eiru_statement_confirm_pos(self, sessionId, statements):
+        _logger.info('Confirm Statement Pos')
+        user = self.env.user
+        dateServer = self.get_date()
+
+        for statement in statements:
+            bankStatement =  self.confirm_pos_get_statement(statement['id'])
+
+            if (not bankStatement):
+                return {
+                    'state': False,
+                    'message': "Error en Obtener la lineas"
+                }
+
+            amountStatement = 0.0
+            for line in bankStatement.line_ids:
+                amountStatement += line.amount
+            if (bankStatement.balance_start > 0):
+                amountStatement += bankStatement.balance_start
+
+            balanceLine = []
+            if(amountStatement != statement['amountConfirm']):
+                amountConfirm = statement['amountConfirm'] - amountStatement
+                name = "Ajuste de cierre de caja (POS)"
+                referencia = "Ganancia" if(amountConfirm > 0) else "Perdida"
+
+                balanceLine = self.confirm_pos_create_statement_line( bankStatement, name, amountConfirm, referencia)
+
+            cashboxConfirm = {
+                'name': "CIERRE DE CAJA (%s)" %(bankStatement.name),
+                'date': dateServer,
+                'ref': "Cierre de caja (TPV)",
+                'statement_id': bankStatement.id,
+                'user_statement': bankStatement.user_id.id,
+                'user_confirm': user.id,
+                'journal_id' : bankStatement.journal_id.id,
+                'amount_statement': amountStatement,
+                'amount_real': statement['amountConfirm'],
+                'line_difference': balanceLine.id if (balanceLine) else '',
+                'amount_difference': balanceLine.amount if (balanceLine) else 0.0,
+                'amount_next_open': 0.0,
+                'state_avaliable': False,
+            }
+            statementConfirm = self.confirm_pos_create_cashbox_statement_confirm(cashboxConfirm, bankStatement)
+
+            '''
+                Salida de Dinero.
+            '''
+            if (statement['OutputPos']):
+                #Crear Line en caja
+                name = "Retiro de dinero"
+                lineOutput = self.confirm_pos_create_statement_line( bankStatement, name, (- statement['amountOutput']), "TPV")
+                # Crear Salida
+                cashboxOutput = self.confirm_pos_create_cashbox_output(lineOutput, statement['amountOutput'], statementConfirm)
+
+            '''
+                Transferencia.
+            '''
+            if (statement['transferPos']):
+                statementTransfer = self.confirm_pos_get_statement(statement['statementTransfer'])
+                if (not statementTransfer):
+                    return {
+                        'state': False,
+                        'message': "Erro, no se pudo encontrar la caja destino de la transferencia."
+                    }
+
+                ## Salida
+                name = "TRANSFERENCIA/%s (Salida)" % (statementTransfer.name)
+                transferOutput = self.confirm_pos_create_statement_line( bankStatement, name, (- statement['amountTransfer']), "TPV")
+                ## Entrada
+                name = "TRANSFERENCIA/%s (Entrada)" % (bankStatement.name)
+                transferinput = self.confirm_pos_create_statement_line( statementTransfer, name, statement['amountTransfer'], "TPV")
+                ## Transferencia
+                transferencia = self.confirm_pos_create_cashbox_transfer("TPV", statement['amountTransfer'], transferOutput, transferinput, statementConfirm)
+
+            '''
+                Saldo para próxima apertura de caja.
+            '''
+            amountStatement = 0.0
+            for line in bankStatement.line_ids:
+                amountStatement += line.amount
+            if (bankStatement.balance_start > 0):
+                amountStatement += bankStatement.balance_start
+
+            if (amountStatement > 0.0):
+                name="Saldo para próxima apertura de caja"
+                lineNextOpen = self.confirm_pos_create_statement_line(bankStatement, name, (- amountStatement), "TPV")
+                if (not lineNextOpen):
+                    return {
+                        'state' : False,
+                        'message': "Error,  En el registro de saldo."
+                    }
+                statementConfirm.write({
+                    'line_next_open': lineNextOpen.id,
+                    'amount_next_open': abs(amountStatement),
+                    'state_avaliable': True,
+                })
+
+        return {
+            'state': True,
+            'message': "Operación exitosa"
+        }
+
+    ''' Get Statement  '''
+    def confirm_pos_get_statement(self,id):
+        return self.env['account.bank.statement'].browse(id)
+
+    ''' Create Line Statemen '''
+    def confirm_pos_create_statement_line(self, statement, name, amount, ref):
+        statementLine = {
+            'statement_id': statement.id,
+            'name': name,
+            'amount': amount,
+            'ref': ref,
+            'account_id': statement.journal_id.internal_account_id.id,
+            'journal_id': statement.journal_id.id,
+            'is_deleted': True
+        }
+        return self.env['account.bank.statement.line'].create(statementLine)
+
+    ''' Create cashbox Confirm '''
+    def confirm_pos_create_cashbox_statement_confirm(self,values, statement):
+        casbox = self.env['cashbox.statement.confirm'].search([('statement_id.id', '=', statement.id)])
+        if (not casbox):
+            confirm = self.env['cashbox.statement.confirm'].create(values)
+        else:
+            confirm = casbox.write(values)
+            if (confirm):
+                confirm = self.env['cashbox.statement.confirm'].search([('statement_id.id', '=', statement.id)])
+
+        return confirm
+
+    ''' Create cashBox output '''
+    def confirm_pos_create_cashbox_output(self, line, amount, confirm):
+        cash = {
+            'name': "Retiro de dinero (%s)" % (line.statement_id.name),
+            'amount': amount,
+            'ref': 'TPV',
+            'date': line.date,
+            'line_id': line.id,
+            'statement_id': line.statement_id.id,
+            'cashbox_confirm_id': confirm.id
+        }
+        return self.env['cash.box.out'].create(cash)
+
+    ''' Create cash box transfer '''
+    def confirm_pos_create_cashbox_transfer(self, ref, amount, lineOutput, lineInput, confirm):
+        cash = {
+            'name': "TRANSFERENCIA %s a %s" %((lineOutput.statement_id.name),(lineInput.statement_id.name)),
+            'amount': amount,
+            'ref': ref,
+            'input_line': lineInput.id,
+            'output_line': lineOutput.id,
+            'input_statement': lineInput.statement_id.id,
+            'output_statement': lineOutput.statement_id.id,
+            'date': lineOutput.date,
+            'cashbox_confirm_id': confirm.id,
+        }
+        return self.env['cash.box.transfer'].create(cash)
+
+
+    '''
+          ____  ____  ___ _   _ _____   ____ _____  _  _____ _____ __  __ _____ _   _ _____
+         |  _ \|  _ \|_ _| \ | |_   _| / ___|_   _|/ \|_   _| ____|  \/  | ____| \ | |_   _|
+         | |_) | |_) || ||  \| | | |   \___ \ | | / _ \ | | |  _| | |\/| |  _| |  \| | | |
+         |  __/|  _ < | || |\  | | |    ___) || |/ ___ \| | | |___| |  | | |___| |\  | | |
+         |_|   |_| \_\___|_| \_| |_|   |____/ |_/_/   \_\_| |_____|_|  |_|_____|_| \_| |_|
+    '''
+    ''' Get Pos Session Statemen Confirm Print'''
+    @api.model
+    def confirm_pos_get_statement_print(self, id):
+        _logger.info('Generar resume de cierre de las caja')
+        posStatement = []
+
+        posSession =  self.env['pos.session'].search([('id', '=', id),('state', '=', 'closed')])
+        if (not posSession):
+            return False
+
+        statementIds = map(lambda x: x.id, posSession.statement_ids)
+
+        statements = self.env['account.bank.statement'].search([('id', 'in', statementIds),('state', '=', 'confirm')])
+
+        if (not statements):
+            return False
+        statemntPos = []
+        for statement in statements:
+            statementConfirm = []
+            accountJournal = self.env['account.journal'].browse(statement.journal_id.id)
+
+
+            ''' Verificar si existe cierre '''
+            confirm = self.env['cashbox.statement.confirm'].search([('statement_id.id', '=', statement.id)])
+
+            if (not confirm):
+                amountStatement = 0.0
+                for line in statement.line_ids:
+                    amountStatement += line.amount
+                if (statement.balance_start > 0):
+                    amountStatement += statement.balance_start
+
+                statementConfirm.append({
+                    'amountStatement': amountStatement,
+                    'amountConfirm': 0,
+                    'amountDifference': 0,
+                    'amountOutput': 0,
+                    'amountTransfer': 0,
+                    'amountNextOpen': 0,
+                })
+
+            if (confirm):
+
+                amountDifference = self.confirm_pos_get_statement_line(confirm.line_difference.id)
+                amountNextOpen = abs(self.confirm_pos_get_statement_line(confirm.line_next_open.id))
+
+                transferID = map(lambda x: x.id, confirm.cashbox_transfer_ids)
+                amountTransfer = self.confirm_pos_get_casbox_transfer(transferID)
+
+                outputIds = map(lambda x: x.id, confirm.cashbox_output_ids)
+                amountOutput =self.confirm_pos_get_casbox_output(outputIds)
+
+                statementConfirm.append({
+                    'amountStatement': confirm.amount_statement,
+                    'amountConfirm': confirm.amount_real,
+                    'amountDifference': amountDifference,
+                    'amountNextOpen': amountNextOpen,
+                    'amountTransfer': amountTransfer,
+                    'amountOutput': amountOutput,
+                })
+
+            statemntPos.append({
+                'id': statement.id,
+                'name':statement.name,
+                'journalType': accountJournal.type,
+                'journalName': accountJournal.name,
+                'journalId': accountJournal.id,
+                'confirm': statementConfirm,
+                'currency':[{
+                    'id': resCurrency.id,
+                    'name': resCurrency.name,
+                    'symbol': resCurrency.symbol,
+                    'localName': resCurrency.local_name,
+                    'rate': resCurrency.rate,
+                    'thousandsSeparator': resCurrency.thousands_separator,
+                    'decimalSeparator': resCurrency.decimal_separator,
+                    'decimalPlaces': resCurrency.decimal_places,
+                    'position': resCurrency.position,
+                }for resCurrency in self.env['res.currency'].browse(statement.currency.id)]
+            })
+
+        posStatement.append({
+            'name': posSession.name,
+            'startAt': posSession.start_at,
+            'stopAt': posSession.stop_at,
+            'userName': posSession.user_id.name,
+            'statemnt': statemntPos
+        })
+
+        return posStatement
+
+    ''' get amount statemnt Line '''
+    def confirm_pos_get_statement_line(self, id):
+        _logger.info('Obtener  la linea de la caja.')
+        line = self.env['account.bank.statement.line'].search([('id', '=', id)])
+        return line.amount if(line) else 0.0
+
+    ''' Get cashBox.transfer '''
+    def confirm_pos_get_casbox_transfer(self,ids):
+        _logger.info('Obtener la transferencia.')
+        transfer = self.env['cash.box.transfer'].search([('id', 'in', ids)])
+        return transfer.amount if(transfer) else 0.0
+
+    ''' Get cashBox.output '''
+    def confirm_pos_get_casbox_output(self,ids):
+        _logger.info('Obtener los retiro de dinero .')
+        output = self.env['cash.box.out'].search([('id', 'in', ids)])
+        return output.amount if(output) else 0.0

+ 148 - 0
static/src/css/style.css

@@ -0,0 +1,148 @@
+.eiru-statement-pos {
+    width: auto;
+    float: left;
+}
+.eiru-statement-pos-print {
+    width: auto;
+    float: left;
+}
+.button-print-pos-confirm {
+    height: 50px;
+    width: 120px;
+    font-size: 20px !important;
+}
+.widget-content.widget-loading-statement-pos {
+    position: absolute;
+    width: 100%;
+    height: 100%;
+    color : #000;
+    display: none;
+    z-index: 1100;
+    background: #8080806b;
+    align-items: center;
+    justify-content: center;
+}
+/**
+      _____  _    ____  _     _____
+     |_   _|/ \  | __ )| |   | ____|
+       | | / _ \ |  _ \| |   |  _|
+       | |/ ___ \| |_) | |___| |___
+       |_/_/   \_\____/|_____|_____|
+ */
+ .statement-pos-table {
+     margin-top: 0px !important;
+ }
+ .expired-account-modal  .modal-head-wrapper-statement-pos {
+     width: 100%;
+ }
+ .expired-account-modal .modal-item-statement-pos {
+     width: 100%;
+     height: 212px;
+     overflow-y: auto;
+ }
+ .expired-account-modal .statement-pos-table table tbody tr {
+     height: 35px;
+ }
+ .expired-account-modal .statement-pos-table table thead tr {
+     height: 40px !important;
+ }
+
+/* [ THEAD ] */
+/*  ID */
+ .expired-account-modal .statement-pos-table table thead tr th:nth-child(1){
+     display: none;
+ }
+ /* Statement */
+ .expired-account-modal .statement-pos-table table thead tr th:nth-child(2){
+    width: 160px;
+    font-size: 11pt;
+    font-weight: bold;
+ }
+ /* amount close */
+ .expired-account-modal .statement-pos-table table thead tr th:nth-child(3){
+    width: 130px;
+    font-size: 11pt;
+    text-align: center;
+    font-weight: bold;
+    text-align: center;
+ }
+ /* amount output */
+ .expired-account-modal .statement-pos-table table thead tr th:nth-child(4){
+    width: 130px;
+    text-align: center;
+    font-size: 11pt;
+    font-weight: bold;
+ }
+ /* statement transfer */
+ .expired-account-modal .statement-pos-table table thead tr th:nth-child(5){
+    width: 158px;
+    text-align: center;
+    font-size: 11pt;
+    font-weight: bold;
+ }
+ /* amount transfer */
+ .expired-account-modal .statement-pos-table table thead tr th:nth-child(6){
+    width: 130px;
+    text-align: center;
+    font-size: 11pt;
+    font-weight: bold;
+ }
+ /* amount Residual */
+ .expired-account-modal .statement-pos-table table thead tr th:nth-child(7){
+    width: 130px;
+    text-align: center;
+    font-size: 11pt;
+    font-weight: bold;
+ }
+
+ /*   [ TBODY ] */
+ .expired-account-modal .statement-pos-table table tbody tr td:nth-child(1){
+     display: none;
+ }
+/* ID */
+ .expired-account-modal .statement-pos-table table tbody tr td:nth-child(2){
+     width: 160px;
+     padding-top: 8px;
+ }
+
+ .expired-account-modal .statement-pos-table table tbody tr td:nth-child(3){
+     width: 130px;
+ }
+ .expired-account-modal .statement-pos-table table tbody tr td:nth-child(4){
+     width: 130px;
+ }
+ .expired-account-modal .statement-pos-table table tbody tr td:nth-child(5){
+     width: 158;
+     padding-top: 6px;
+ }
+ .expired-account-modal .statement-pos-table table tbody tr td:nth-child(6){
+     width: 130px;
+ }
+ .expired-account-modal .statement-pos-table table tbody tr td:nth-child(7){
+     width: 130px;
+ }
+
+.statement-pos-input {
+    padding-left: 1px;
+    padding-right: 5px;
+    padding-top: 10px;
+    width: 105px;
+    margin-top: 2px;
+    text-align: right;
+    font-size: 12px;
+}
+.disable-input{
+    background: #e3e3e3 !important;
+}
+/* header */
+.statement-pos-header{
+    font-size: 12pt;
+    padding-bottom: 10px;
+    padding-top: 10px;
+}
+/* footer */
+.statement-pos-button-footer {
+    font-size: 12pt !important;
+    width: 130px;
+    height: 35px;
+}

+ 455 - 0
static/src/js/eiru_statement_pos-confirm.js

@@ -0,0 +1,455 @@
+(function() {
+    openerp.widgetInstanceStatementPosConfirm = null;
+    openerp.parentInstanceStatementPosConfirm = {};
+    var QWeb = openerp.web.qweb;
+    var instanceWeb = openerp.web;
+
+    openerp.EiruStatementPosConfirm = openerp.Widget.extend({
+        template: 'EiruStatementPos.Confirm',
+        id: undefined,
+        posSession: [],
+        statementConfig: [],
+        statementClose: [],
+
+        /* init */
+        init: function(parent) {
+            this._super(parent);
+        },
+        /* start */
+        start: function () {
+            var self = this
+            this.$el.click(function() {
+                self.fetchInitial();
+            });
+        },
+        /* Actualizar Id de la visat actual  */
+        updateId: function(id) {
+            var self = this;
+            self.id = id;
+            self.$el.css('display','flex');
+            if(!id)
+                self.$el.css('display','none');
+        },
+        /* Reload Page*/
+        reloadPage: function() {
+             openerp.parentInstanceStatementPosConfirm.reload();
+        },
+        /* Description: Función para remover el modal */
+        removeModal: function() {
+            $('.expired-account-modal').remove();
+            $('.modal-backdrop').remove();
+        },
+        /* Método inicial */
+        fetchInitial: function() {
+            var self = this;
+            self.fetchPosSession(self.id).then(function(posSession) {
+                return posSession;
+            }).then(function(posSession) {
+                self.posSession = posSession;
+                return self.fetchPosStatementConfig();
+            }).then(function(statementConfig){
+                self.statementConfig = statementConfig;
+                return self.generateStatemenClose();
+            }).then(function(statementClose){
+                self.statementClose = statementClose;
+                if (statementClose.length) {
+                    return self.showModalStatementClose();
+                }else {
+                    return self.poseSessionClose(self.id);
+                }
+            }).then(function(closePos){
+                self.reloadPage();
+            });
+        },
+        /* GET pos Session */
+        fetchPosSession: function(id) {
+            var posSession = new instanceWeb.Model('pos.session');
+            return posSession.call('eiru_get_pos_session_statement',[id], {
+                context: new instanceWeb.CompoundContext()
+            });
+        },
+        /* Get confihuration Statement Pos */
+        fetchPosStatementConfig: function() {
+            var self = this;
+            var statementConfig = new instanceWeb.Model('account.bank.statement.config');
+            var fields = ['id','pos_journal_permitted','pos_statement_output','pos_statement_transfer'];
+            var domain = [['active', '=', true]];
+            return statementConfig.query(fields).filter(domain).all();
+        },
+        /* Preparar la lista de caja */
+        generateStatemenClose: function() {
+            var self = this;
+            var posConfig = self.statementConfig[0];
+            var pos = self.posSession;
+            var statement = pos.statement;
+            var posClose = [];
+
+            _.each(statement, function(item, index) {
+                /* Caja habilitadas */
+                if (_.contains(posConfig.pos_journal_permitted, item.journalId)) {
+                    var generalStatement = item.statementGeneral
+                    if (generalStatement.length) {
+                        generalStatement.unshift({
+                            'id': '',
+                            'name': ''
+                        });
+                    }
+
+                    posClose.push({
+                        'id': item.id,
+                        'name': item.name +" - "+item.currency[0].symbol,
+                        'amountConfirm': 0,
+                        'amountOutput': 0,
+                        'posStatementOutput': posConfig.pos_statement_output,
+                        'statementTransfer': generalStatement,
+                        'statementSelected': '',
+                        'amountTransfer': 0,
+                        'posStatementTransfer': !!posConfig.pos_statement_transfer && !!generalStatement.length ?posConfig.pos_statement_transfer : false,
+                        'amountResidual': 0,
+                        'currency': item.currency[0],
+                        'casboxDisable': false,
+                    })
+                }
+
+                /* deshabilitada */
+                if (!(_.contains(posConfig.pos_journal_permitted, item.journalId))) {
+                    posClose.push({
+                        'id': item.id,
+                        'name': item.name +" - "+item.currency[0].symbol,
+                        'amountConfirm': item.amount,
+                        'amount': instanceWeb.formatCurrency(item.amount,item.currency[0]),
+                        'amountOutput': 0,
+                        'posStatementOutput': false,
+                        'statementTransfer': [],
+                        'statementSelected': '',
+                        'amountTransfer': 0,
+                        'posStatementTransfer': false,
+                        'amountResidual': 0,
+                        'currency': item.currency[0],
+                        'casboxDisable': true,
+                    })
+                }
+
+            });
+
+            return posClose;
+        },
+        /* Get Statemen Close */
+        getStatmenClose: function(id) {
+            var self = this;
+            return _.filter(self.statementClose, function(item){
+                return item.id === id;
+            });
+        },
+        /* Modal */
+        showModalStatementClose: function() {
+            var self = this;
+            var defer =$.Deferred();
+            var results = true;
+
+            var modal = QWeb.render('EiruStatementPosConfirm.Modal',{
+                'statementClose':self.statementClose
+            });
+
+            $('.openerp_webclient_container').after(modal);
+            $('.expired-account-modal').modal();
+
+            var tableRow = $('.expired-account-modal').find('.table-tbody').find('tr');
+            var buttonGuardar = $('.expired-account-modal').find('.button-guardar');
+
+            /* Keyup */
+            tableRow.keyup(function(e) {
+
+                if (($(e.target).index() !== 0) || (($(e.target).index() === 0) && ($(e.target)[0].className === 'statement-transfer')))
+                    return false;
+
+
+                className =($(e.target)[0].className).split(' ')
+
+                idRow = parseInt(($(e.target).closest('tr').children()[0].textContent).trim());
+                statementConfirm = self.getStatmenClose(idRow).shift();
+                if (!statementConfirm)
+                    return  false;
+                currency = statementConfirm.currency;
+
+
+                var amountConfirm = $($(e.target).closest('tr').children()[2]).find('.amount-confirm');
+                var amountOutput = $($(e.target).closest('tr').children()[3]).find('.amount-output');
+                var amountTransfer =$($(e.target).closest('tr').children()[5]).find('.amount-transfer');
+                var amountResidual = $($(e.target).closest('tr').children()[6]).find('.amount-residual');
+
+
+                /**
+                 * [ Amount Confirm]
+                 * Valor dl cierre de caja
+                 */
+                if ( _.contains(className,'amount-confirm')) {
+                    if (e.key === currency.decimalSeparator && currency.decimalPlaces > 0)
+                        return false ;
+
+                    var amount = instanceWeb.unFormatCurrency(amountConfirm.val());
+                    amount = instanceWeb.formatCurrency(amount, currency);
+
+                    amountConfirm.val(amount);
+                    amountConfirm.css('border-color','#ccc');
+                }
+
+                /**
+                 * [ AMOUNT OUTPUT ]
+                 * Sacar dinero de la caja
+                 */
+                if (_.contains(className, 'amount-output')) {
+                    if (e.key === currency.decimalSeparator && currency.decimalPlaces > 0)
+                        return false ;
+
+                    var confirmAmont = instanceWeb.unFormatCurrency(amountConfirm.val());
+                    var amount = instanceWeb.unFormatCurrency(amountOutput.val());
+                    var transferAmount = instanceWeb.unFormatCurrency(amountTransfer.val());
+
+                    if (amount > (confirmAmont - transferAmount)) {
+                        instanceWeb.notification.do_warn("Atencion", "El valor supera el saldo disponible en la caja");
+                        amount = 0;
+                    }
+                    amount = instanceWeb.formatCurrency(amount, currency);
+
+                    amountOutput.val(amount);
+                    amountOutput.css('border-color','#ccc');
+                }
+
+                /**
+                 * [AMOUNT TRANSFER]
+                 * Valor de la transferencia
+                 */
+                if (_.contains(className, 'amount-transfer')) {
+                    if (e.key === currency.decimalSeparator && currency.decimalPlaces > 0)
+                        return false ;
+
+                    var confirmAmont = instanceWeb.unFormatCurrency(amountConfirm.val());
+                    var outputAmount = instanceWeb.unFormatCurrency(amountOutput.val());
+                    var transferAmount = instanceWeb.unFormatCurrency(amountTransfer.val());
+
+                    if (transferAmount > (confirmAmont - outputAmount)) {
+                        instanceWeb.notification.do_warn("Atencion", "El valor supera el saldo disponible en la caja");
+                        transferAmount = 0;
+                    }
+                    transferAmount = instanceWeb.formatCurrency(transferAmount, currency);
+
+                    amountTransfer.val(transferAmount);
+                    amountTransfer.css('border-color','#ccc');
+                }
+            });
+            /* Focus In */
+            tableRow.focusin(function(e){
+                if (($(e.target).index() !== 0))
+                    return false;
+
+                className =($(e.target)[0].className).split(' ')
+                idRow = parseInt(($(e.target).closest('tr').children()[0].textContent).trim());
+                statementConfirm = self.getStatmenClose(idRow).shift();
+                if (!statementConfirm)
+                    return  false;
+
+                currency = statementConfirm.currency;
+
+
+                if (_.contains(className, 'amount-confirm')) {
+                    var amountConfirm = $($(e.target).closest('tr').children()[2]).find('.amount-confirm');
+                    var amount = instanceWeb.unFormatCurrency(amountConfirm.val());
+                    amount = instanceWeb.formatCurrency(amount, currency);
+                    amountConfirm.val(amount > 0 ?amount : '' );
+                }
+
+            });
+            /* Focus Out */
+            tableRow.focusout(function(e) {
+                if ($(e.target).index() !== 0)
+                    return false;
+
+                className =($(e.target)[0].className).split(' ');
+                idRow = parseInt(($(e.target).closest('tr').children()[0].textContent).trim());
+                statementConfirm = self.getStatmenClose(idRow).shift();
+                if (!statementConfirm)
+                    return  false;
+
+                currency = statementConfirm.currency;
+
+                var amountConfirm = $($(e.target).closest('tr').children()[2]).find('.amount-confirm');
+                var amountOutput = $($(e.target).closest('tr').children()[3]).find('.amount-output');
+                var statementTransfer = $($(e.target).closest('tr').children()[4]).find('.statement-transfer');
+                var amountTransfer =$($(e.target).closest('tr').children()[5]).find('.amount-transfer');
+                var amountResidual = $($(e.target).closest('tr').children()[6]).find('.amount-residual');
+                self.statementClose
+
+                /* amount-confirm */
+                if (_.contains(className,'amount-confirm')) {
+                    var amount = instanceWeb.unFormatCurrency(amountConfirm.val());
+                    var outputAmont = instanceWeb.unFormatCurrency(amountOutput.val());
+                    var transferAmount = instanceWeb.unFormatCurrency(amountTransfer.val());
+
+                    if (amount < (outputAmont + transferAmount)){
+                        amountOutput.val(0);
+                        amountTransfer.val(0);
+                        amountResidual.val(instanceWeb.formatCurrency(amount, currency));
+                        statementConfirm.amountResidual = amount;
+                        statementConfirm.amountOutput = 0;
+                        statementConfirm.amountTransfer = 0;
+                    }else {
+                        amountResidual.val(instanceWeb.formatCurrency((amount - (outputAmont + transferAmount)), currency));
+                        statementConfirm.amountResidual =(amount - (outputAmont + transferAmount));
+
+                    }
+                    statementConfirm.amountConfirm = amount;
+                }
+                /* amount-output */
+                if(_.contains(className, 'amount-output')) {
+                    var amount = instanceWeb.unFormatCurrency(amountConfirm.val());
+                    var outputAmont = instanceWeb.unFormatCurrency(amountOutput.val());
+                    var transferAmount = instanceWeb.unFormatCurrency(amountTransfer.val());
+
+                    statementConfirm.amountOutput = outputAmont;
+                    if ((outputAmont + transferAmount) > amount){
+                        instanceWeb.notification.do_warn("Atencion", "El valor que esta retirando supera  el saldo disponible.");
+                        amountOutput.val(0);
+                        amountTransfer.val(0);
+                        amountResidual.val(instanceWeb.formatCurrency(amount, currency));
+                        statementConfirm.amountResidual = amount;
+                        statementConfirm.amountOutput = 0;
+                        statementConfirm.amountTransfer = 0;
+                        return false;
+                    }
+                    amountResidual.val(instanceWeb.formatCurrency((amount - (outputAmont + transferAmount)), currency));
+                    statementConfirm.amountResidual = (amount - (outputAmont + transferAmount));
+                }
+                /* amount-transfer */
+                if (_.contains(className, 'amount-transfer')) {
+                    var amount = instanceWeb.unFormatCurrency(amountConfirm.val());
+                    var outputAmont = instanceWeb.unFormatCurrency(amountOutput.val());
+                    var transferAmount = instanceWeb.unFormatCurrency(amountTransfer.val());
+
+                    statementConfirm.amountTransfer = transferAmount;
+                    if ((outputAmont + transferAmount) > amount){
+                        instanceWeb.notification.do_warn("Atencion", "El valor que esta retirando supera  el saldo disponible.");
+                        amountOutput.val(0);
+                        amountTransfer.val(0);
+                        amountResidual.val(instanceWeb.formatCurrency(amount, currency));
+
+                        statementConfirm.amountResidual = amount;
+                        statementConfirm.amountOutput = 0;
+                        statementConfirm.amountTransfer = 0;
+
+                        return false;
+                    }
+                    amountResidual.val(instanceWeb.formatCurrency((amount - (outputAmont + transferAmount)), currency));
+                    statementConfirm.amountResidual = (amount - (outputAmont + transferAmount));
+                }
+                /* statement-transfer */
+                if (_.contains(className, 'statement-transfer')) {
+                        var amount = instanceWeb.unFormatCurrency(amountConfirm.val());
+                        var outputAmont = instanceWeb.unFormatCurrency(amountOutput.val());
+                        var transferAmount = instanceWeb.unFormatCurrency(amountTransfer.val());
+
+                        statementConfirm.statementSelected = statementTransfer.val();
+
+                        if (!statementTransfer.val()) {
+                            statementConfirm.statementSelected = '';
+                            statementConfirm.amountTransfer = 0;
+                            statementConfirm.amountResidual = (amount - (outputAmont));
+                        }
+                }
+            });
+
+            buttonGuardar.click(function(e) {
+                var statementPos = []
+
+                _.each(self.statementClose, function(item, index) {
+                    var outputPos = !!item.posStatementOutput && item.amountOutput >0 ? item.posStatementOutput : false;
+                    var transferPos = !!item.posStatementTransfer && !!item.statementSelected.length && item.amountTransfer >0 ?item.posStatementTransfer : false;
+
+                    statementPos.push({
+                        'id': item.id,
+                        'amountConfirm': item.amountConfirm,
+                        'OutputPos': outputPos,
+                        'amountOutput': !!outputPos ? item.amountOutput : 0,
+                        'transferPos':  transferPos,
+                        'statementTransfer': !!transferPos ? parseInt(item.statementSelected) : '',
+                        'amountTransfer': !!transferPos ? item.amountTransfer : 0,
+                    })
+                });
+
+                if (!statementPos.length) {
+                    return false;
+                }
+
+
+                $('.expired-account-modal').find('.widget-content.widget-loading-statement-pos').css('display','flex');
+                self.confirmStatementPos(statementPos).then(function(statementConfirm){
+                    return statementConfirm;
+                }).then(function(statementConfirm) {
+                    if (!statementConfirm.state) {
+                        instanceWeb.notification.do_warn("Atencion", statementConfirm.message);
+                        return false;
+                        $('.expired-account-modal').find('.widget-content.widget-loading-statement-pos').css('display','none');
+                    }
+                    return self.poseSessionClose(self.id);
+                }).then(function(close) {
+                    self.reloadPage();
+                    $('.expired-account-modal').find('.widget-content.widget-loading-statement-pos').css('display','none');
+                    defer.resolve(results);
+                    self.removeModal(e);
+                });
+            });
+
+            /* Cerrar */
+            $('.expired-account-modal').on('hidden.bs.modal', function(e) {
+                results = false;
+                defer.resolve(results);
+                self.removeModal(e);
+            });
+            return defer;
+        },
+        /* Confirm Statement Pos */
+        confirmStatementPos: function(statementPos) {
+            var self = this;
+            var posSession = new instanceWeb.Model('pos.session');
+            return posSession.call('eiru_statement_confirm_pos',[self.id, statementPos], {
+                context: new instanceWeb.CompoundContext()
+            });
+        },
+        /* Account bank Statement  Open*/
+        poseSessionClose: function(id) {
+            var posSession = new instanceWeb.Model('pos.session');
+            return posSession.call('eiru_pos_session_close',[id], {
+                context: new instanceWeb.CompoundContext()
+            });
+        },
+
+    });
+
+    if (openerp.web && openerp.web.FormView) {
+        openerp.web.FormView.include({
+            load_record: function(record) {
+                this._super.apply(this, arguments);
+
+                if (this.model !== 'pos.session')
+                    return;
+
+                openerp.parentInstanceStatementPosConfirm = this;
+
+                if (openerp.widgetInstanceStatementPosConfirm) {
+                    openerp.widgetInstanceStatementPosConfirm.updateId(record.id);
+                    if (this.$el.find('.button-pos-confim').length !== 0 )
+                        return ;
+                }
+
+                if (this.$el.find('.button-pos-confim').length !== 0 )
+                    return;
+
+                openerp.widgetInstanceStatementPosConfirm = new openerp.EiruStatementPosConfirm(this);
+                var element =this.$el.find('.oe_form').find('.eiru-statement-pos');
+
+                openerp.widgetInstanceStatementPosConfirm.appendTo(element[0]);
+                openerp.widgetInstanceStatementPosConfirm.updateId(record.id);
+            }
+        });
+    }
+})();

+ 286 - 0
static/src/js/eiru_statement_pos-confirm_print.js

@@ -0,0 +1,286 @@
+(function() {
+
+    openerp.widgetInstanceStatementPosPrint = null;
+    openerp.parentInstanceStatementPosPrint = {};
+    var QWeb = openerp.web.qweb;
+    var instanceWeb = openerp.web;
+
+    openerp.EiruStatementPosPrint = openerp.Widget.extend({
+        template: 'EiruStatementPos.Print',
+        id: undefined,
+        posStatementConfirm: [],
+        /* init */
+        init: function(parent) {
+            this._super(parent);
+        },
+        /* start */
+        start: function () {
+            var self = this
+            this.$el.click(function() {
+                self.fetchInitial();
+            });
+        },
+        /* Actualizar Id de la visat actual  */
+        updateId: function(id) {
+            var self = this;
+            self.id = id;
+            self.$el.css('display','flex');
+            if(!id)
+                self.$el.css('display','none');
+        },
+        /* Reload Page*/
+        reloadPage: function() {
+             openerp.parentInstanceStatementPosPrint.reload();
+        },
+
+        removeModal: function() {
+            $('.expired-account-modal').remove();
+            $('.modal-backdrop').remove();
+        },
+        /* Método inicial */
+        fetchInitial: function() {
+            var self = this;
+            self.fetchCashboxStatementConfirmPos(self.id).then(function(posStatementConfirm) {
+                return posStatementConfirm;
+            }).then(function(posStatementConfirm) {
+                self.posStatementConfirm = posStatementConfirm;
+                return  self.printSelectedType();
+            });
+        },
+        /* Account bank Statement  Open*/
+        fetchCashboxStatementConfirmPos: function(id) {
+            var statementConfirm = new instanceWeb.Model('pos.session');
+            return statementConfirm.call('confirm_pos_get_statement_print',[id], {
+                context: new instanceWeb.CompoundContext()
+            });
+        },
+        /*print select type */
+        printSelectedType: function(){
+            var self = this;
+            var modal = QWeb.render('ModalStatementUtility.ConfirmPrint');
+            $('.openerp_webclient_container').after(modal);
+            $('.expired-account-modal').modal();
+
+            var printTicket =  $('.expired-account-modal').find('.print-ticket');
+            var printNormal =  $('.expired-account-modal').find('.print-normal');
+
+            /* print Ticket */
+            printTicket.click(function(e){
+                self.drawPdfConfirmStatementTicket();
+                self.removeModal(e);
+            });
+
+            /*print Normal */
+            printNormal.click(function(e){
+                self.drawPdfConfirmStatementNormal();
+                self.removeModal(e);
+            });
+
+            $('.openerp_webclient_container').after(modal);
+            $('.expired-account-modal').modal();
+            $('.expired-account-modal').on('hidden.bs.modal', function(e) {
+                self.removeModal(e);
+            });
+        },
+        /* pdf normal */
+        drawPdfConfirmStatementNormal: function() {
+            var self = this;
+            var pdfDoc = new jsPDF();
+            pdfDoc.page = 1;
+
+            var posStatementConfirm = self.posStatementConfirm[0];
+            if (!posStatementConfirm) {
+                return false
+            }
+
+            var y = 15;
+            var space = 7;
+
+            /*fin */
+            pdfDoc.setFontSize('15');
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.text(104,y, pdfDoc.splitTextToSize(posStatementConfirm.name, 180) , null, null, 'center');
+            y += space;
+            pdfDoc.setFontSize('12');
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.text(30,y, 'Fecha de apertura:');
+            pdfDoc.text(110,y, 'Fecha de cierre:');
+
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.text(70,y, moment(posStatementConfirm.startAt).format('DD-MM-YYYY'));
+            pdfDoc.text(150, y, moment(posStatementConfirm.stopAt).format('DD-MM-YYYY'));
+            /* footer */
+            pdfDoc.setFontSize('10');
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.text(180,290, 'Pagina ' + pdfDoc.page);
+
+            y = 30;
+            _.each(posStatementConfirm.statemnt, function(item, index){
+                if (index > 0 && index < posStatementConfirm.statemnt.length)
+                    y+=65;
+                    if (y > 225) {
+                        pdfDoc.addPage();
+                        pdfDoc.page ++;
+                        y =10
+                        pdfDoc.setFontSize('10');
+                        pdfDoc.setFontStyle('bold');
+                        pdfDoc.text(180,290, 'Pagina ' + pdfDoc.page);
+                    }
+
+                currency = item.currency[0];
+                confirm = item.confirm[0]
+                pdfDoc.setFontSize('12');
+                pdfDoc.setFontStyle('bold');
+                pdfDoc.text(104,y, pdfDoc.splitTextToSize(item.name +" - "+ item.journalName +" - "+currency.localName, 180) , null, null, 'center');
+
+                /* Table */
+                var getColumns = [
+                    { 'title': 'Operación ', 'dataKey': 'ref'},
+                    { 'title': 'Monto', 'dataKey': 'amount'}
+                ]
+
+                rowsPdf = [
+                    {'ref': 'Saldo teórico de cierre', 'amount': instanceWeb.formatCurrency(confirm.amountStatement,currency)},
+                    { 'ref': 'Saldo real de cierre', 'amount': instanceWeb.formatCurrency(confirm.amountConfirm,currency)},
+                    { 'ref': 'Diferencia de cierre', 'amount': instanceWeb.formatCurrency(confirm.amountDifference,currency)},
+                    {'ref': 'Retiro de dinero', 'amount': instanceWeb.formatCurrency(confirm.amountOutput,currency)},
+                    { 'ref': 'Transferencia a caja general ', 'amount': instanceWeb.formatCurrency(confirm.amountTransfer,currency)},
+                    { 'ref': 'Reserva para la próxima apertura', 'amount': instanceWeb.formatCurrency(confirm.amountNextOpen,currency)}
+                ]
+
+                pdfDoc.autoTable(getColumns, rowsPdf, {
+                    theme: 'grid',
+                    startY: y+3,
+                    columnStyles: {
+                        amount : {halign:'right' },
+                    },
+                    margin: { top: 5, horizontal: 20},
+                });
+            })
+            /* FOOTER */
+            y = 280;
+            pdfDoc.setFontSize('12');
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.text(150,y, pdfDoc.splitTextToSize('.......................................................................', 180) , null, null, 'center');
+            y +=5;
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.text(40,y, 'Responsable de la caja ');
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.text(150,y, pdfDoc.splitTextToSize(posStatementConfirm.userName, 180) , null, null, 'center');
+            /* Guardar */
+            pdfDoc.save('RESUME DE CAJA '+posStatementConfirm.name.toUpperCase()+'.pdf');
+            return true;
+        },
+        /* pdf ticket */
+        drawPdfConfirmStatementTicket: function () {
+            var self = this;
+            var rowsPdf = []
+            var pdfDoc = new jsPDF({
+                      orientation: 'p',
+                      unit: 'mm',
+                      format: [76, 297]
+                    })
+
+            var posStatementConfirm = self.posStatementConfirm[0];
+            if (!posStatementConfirm)
+                return false
+
+            var y = 4;
+            var space = 6;
+            y = 4;
+            pdfDoc.setFontSize('11');
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.text(30,y, pdfDoc.splitTextToSize(posStatementConfirm.name, 70) , null, null, 'center');
+
+            y += space;
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.text(4,y, 'Fecha de apertura:');
+            pdfDoc.text(38,y, moment(posStatementConfirm.startAt).format('DD-MM-YYYY'));
+
+            y += space;
+            pdfDoc.text(4,y, 'Fecha de cierre:');
+            pdfDoc.text(38, y, moment(posStatementConfirm.stopAt).format('DD-MM-YYYY'));
+
+            _.each(posStatementConfirm.statemnt, function(item){
+                currency = item.currency[0];
+                confirm = item.confirm[0];
+                rowsPdf.push({
+                    'name': item.name,
+                    'journalName': item.journalName,
+                    'currency': currency.localName,
+                    'confirm': [
+                        {'ref': 'Saldo teórico de cierre', 'amount': instanceWeb.formatCurrency(confirm.amountStatement,currency)},
+                        { 'ref': 'Saldo real de cierre', 'amount': instanceWeb.formatCurrency(confirm.amountConfirm,currency)},
+                        { 'ref': 'Diferencia de cierre', 'amount': instanceWeb.formatCurrency(confirm.amountDifference,currency)},
+                        { 'ref': 'Retiro de dinero', 'amount': instanceWeb.formatCurrency(confirm.amountOutput,currency)},
+                        { 'ref': 'Transferencia a caja general ', 'amount': instanceWeb.formatCurrency(confirm.amountTransfer,currency)},
+                        { 'ref': 'Reserva para la próxima apertura', 'amount': instanceWeb.formatCurrency(confirm.amountNextOpen,currency)}
+                    ]
+                })
+            })
+            _.each(rowsPdf, function(item){
+                y += 10;
+
+                if ((y+72) > 297) {
+                    pdfDoc.addPage();
+                    y =4
+                }
+
+                pdfDoc.text(30,y, pdfDoc.splitTextToSize(item.name, 70) , null, null, 'center');
+                y += 4;
+                pdfDoc.text(30,y, pdfDoc.splitTextToSize(item.journalName +" - "+ item.currency, 70) , null, null, 'center');
+                y += 3;
+                pdfDoc.text(2, y, "================================");
+                _.each(item.confirm, function(item){
+                    y += 5;
+                    pdfDoc.text(3, y, item.ref);
+                    y += 5;
+                    var x = (45 - item.amount.length)
+                    pdfDoc.text(x, y, item.amount);
+                })
+                y += 5;
+                pdfDoc.text(2, y, "================================");
+            });
+        //     /* FOOTER */
+            y += 20;
+            pdfDoc.text(30,y,  pdfDoc.splitTextToSize('.............................................', 70) , null, null, 'center');
+            y+= 5;
+            pdfDoc.text(30,y, pdfDoc.splitTextToSize(posStatementConfirm.userName, 70) , null, null, 'center');
+            y+= 5;
+            pdfDoc.text(30,y, pdfDoc.splitTextToSize('Responsable de la caja ', 70) , null, null, 'center');
+
+            // /* Guardar */
+            pdfDoc.save('RESUME DE CAJA '+posStatementConfirm.name.toUpperCase()+'.pdf');
+            return true;
+        },
+
+    });
+
+    if (openerp.web && openerp.web.FormView) {
+        openerp.web.FormView.include({
+            load_record: function(record) {
+                this._super.apply(this, arguments);
+
+                if (this.model !== 'pos.session')
+                    return;
+
+                openerp.parentInstanceStatementPosPrint = this;
+
+                if (openerp.widgetInstanceStatementPosPrint) {
+                    openerp.widgetInstanceStatementPosPrint.updateId(record.id);
+                    if (this.$el.find('.button-pos-confim-print').length !== 0 )
+                        return ;
+                }
+
+                if (this.$el.find('.button-pos-confim-print').length !== 0 )
+                    return;
+
+                openerp.widgetInstanceStatementPosPrint = new openerp.EiruStatementPosPrint(this);
+                var element =this.$el.find('.oe_form').find('.eiru-statement-pos-print');
+
+                openerp.widgetInstanceStatementPosPrint.appendTo(element[0]);
+                openerp.widgetInstanceStatementPosPrint.updateId(record.id);
+            }
+        });
+    }
+})();

+ 8 - 0
static/src/xml/eiru_statement_pos-confirm.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates xml:space="preserve">
+    <t t-name="EiruStatementPos.Confirm">
+        <button class="button-pos-confim eiru-statement-button oe_button oe_form_button oe_highlight">
+            <span>Validar y contabilizar asiento(s) de cierre</span>
+        </button>
+    </t>
+</templates>

+ 8 - 0
static/src/xml/eiru_statement_pos-confirm_print.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates xml:space="preserve">
+    <t t-name="EiruStatementPos.Print">
+        <button class="button-pos-confim-print eiru-statement-button oe_button oe_form_button oe_highlight">
+            <span> Resumen de cierre. </span>
+        </button>
+    </t>
+</templates>

+ 26 - 0
static/src/xml/modal/modal_eiru_statement_pos-confirm-print.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="EiruStatementPosPrint.Model">
+        <div class="modal in expired-account-modal" tabindex="-1" role="dialog">
+            <div class="modal-dialog modal-sm" role="document">
+                <div class="modal-content openerp">
+                    <div class="modal-header paymnets-invoice-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">×</button>
+                        <h3 class="modal-title"> Resumen de cierre </h3>
+                    </div>
+                    <!-- Body -->
+                    <div class="modal-body">
+                        <div class="row">
+                            <div class="col-xs-6 button-print-group">
+                                <button type="button" class="oe_button oe_form_button oe_highlight button-print-pos-confirm print-ticket">Ticket</button>
+                            </div>
+                            <div class="col-xs-6 button-print-group">
+                                <button type="button" class="oe_button oe_form_button oe_highlight button-print-pos-confirm print-normal">Normal</button>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </t>
+</template>

+ 95 - 0
static/src/xml/modal/modal_eiru_statement_pos-confirm.xml

@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="EiruStatementPosConfirm.Modal">
+        <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-statement-pos">
+                        <i class='fa fa-cog fa-spin fa-3x fa-fw'></i>
+                    </div>
+                    <!-- title  -->
+                    <div class="modal-header statement-pos-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">×</button>
+                        <h3 class="modal-title">Ajuste de cierre de cajas</h3>
+                    </div>
+                    <!-- Body -->
+                    <div class="modal-body">
+                        <!-- Table -->
+                        <div class=" oe_view_manager_body statement-pos-table">
+                            <div class="modal-head-wrapper-statement-pos">
+                                <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">Caja</th>
+                                            <th class="oe_list_header_char oe_sortable">Monto de Cierre</th>
+                                            <th class="oe_list_header_char oe_sortable">Monto del Saque</th>
+                                            <th class="oe_list_header_char oe_sortable">Caja a Transferir</th>
+                                            <th class="oe_list_header_char oe_sortable">Monto a Transferir</th>
+                                            <th class="oe_list_header_char oe_sortable">Saldo</th>
+                                        </tr>
+                                    </thead>
+                                </table>
+                            </div>
+                            <div class="modal-item-statement-pos">
+                                <table class="oe_list_content">
+                                    <tbody class="table-tbody">
+                                        <tr t-foreach="statementClose" t-as="line">
+                                            <!-- ID -->
+                                            <td>
+                                                <t t-esc="line_value.id"/>
+                                            </td>
+                                            <!-- NAME -->
+                                            <td>
+                                                <t t-esc="line_value.name"/>
+                                            </td>
+                                            <!-- AMOUNT Confirm -->
+                                            <td>
+                                                <input type="text" class="statement-pos-input amount-confirm" value='0' t-if="line_value.casboxDisable != true"></input>
+                                                <input type="text" class="statement-pos-input disable-input amount-confirm" disabled="disabled" t-attf-value="{{ line_value.amount }}" t-if="line_value.casboxDisable == true"></input>
+                                            </td>
+                                            <!-- AMOUNT OUTPUT -->
+                                            <td>
+                                                <input type="text" class="statement-pos-input disable-input amount-output" disabled="disabled" value='0' t-if="line_value.posStatementOutput != true"></input>
+                                                <input type="text" class="statement-pos-input amount-output" t-if="line_value.posStatementOutput == true" value='0'></input>
+                                            </td>
+                                            <!-- STATEMENT TRANSFER -->
+                                            <td>
+                                                <select class="statement-transfer" t-if="line_value.posStatementTransfer == true">
+                                                    <t t-foreach="line_value.statementTransfer" t-as="statement">
+                                                        <option t-attf-value="{{ statement_value.id }}" >
+                                                            <t t-esc="statement_value.name"/>
+                                                        </option>
+                                                    </t>
+                                                </select>
+                                                <select t-if="line_value.posStatementTransfer != true" class="disable-input" disabled="disabled" style="width:130px"></select>
+                                            </td>
+                                            <!-- AMOUNT TRANSFER -->
+                                            <td>
+                                                <input type="text" class="statement-pos-input disable-input amount-transfer" value='0' disabled="disabled" t-if="line_value.posStatementTransfer != true"></input>
+                                                <input type="text" class="statement-pos-input amount-transfer" t-if="line_value.posStatementTransfer == true" value='0'></input>
+                                            </td>
+                                            <!-- AMOUNT RESIDUAL -->
+                                            <td>
+                                                <input type="text" class="statement-pos-input disable-input amount-residual" t-if="line_value.casboxDisable != true" disabled="disabled" value='0'></input>
+                                                <input type="text" class="statement-pos-input disable-input amount-residual" t-if="line_value.casboxDisable == true" disabled="disabled" t-attf-value="{{ line_value.amount }}"></input>
+
+                                            </td>
+                                        </tr>
+                                    </tbody>
+                                </table>
+                            </div>
+                        </div>
+
+                    </div>
+                    <!-- Pie de Pagina -->
+                    <div class="modal-footer paymnets-invoice-footer">
+                        <button type="button" class="oe_button oe_form_button oe_highlight statement-pos-button-footer button-guardar">Guardar</button>
+                        <button type="button" class="oe_button oe_form_button oe_link dismmis-modal statement-pos-button-footer" data-dismiss="modal">Salir</button>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </t>
+
+</template>

+ 59 - 0
views/account_bank_config.xml

@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+		<!-- form -->
+        <record id="eiru_account_bank_statement_pos_config_from" model="ir.ui.view">
+            <field name="name">eiru.account.bank.statement.pos.config.from</field>
+            <field name="model">account.bank.statement.config</field>
+            <field name="inherit_id" ref="eiru_account_bank_statement_utility.eiru_account_bank_statement_config_form"/>
+            <field name="arch" type="xml">
+				<!-- Disable Create and edtit -->
+				<form position="attributes">
+					<attribute name="create">0</attribute>
+				</form>
+
+				<notebook>
+					<!-- pos -->
+					<page string="Terminal Punto de Venta.">
+						<notebook>
+							<!-- Cierre de sesión de terminal punto de venta -->
+							<page string="Cierre de sesión de la terminal punto de venta.">
+								<separator string="Configuración de cierre de sesión de la terminal punto de venta." style="font-size: 12pt"/>
+								<group style="margin: 0px" string="Cierre de sesión.">
+									<label for="pos_journal_permitted" string="Métodos de pagos permitidos" style="width: 200px"></label>
+									<field name="pos_journal_permitted" nolabel="1" widget="many2many_tags" options="{'no_create': True}" />
+								</group>
+								<group col="2">
+									<group style="margin: 0px">
+										<label for="pos_statement_output" string="Permitir sacar dinero" style="width: 200px"></label>
+										<field name="pos_statement_output"  style="width: 200px" nolabel="1" />
+									</group>
+
+									<group style="margin: 0px">
+										<label for="pos_statement_transfer" string="Permitir realizar transferencia" style="width: 200px"></label>
+										<field name="pos_statement_transfer"  style="width: 200px" nolabel="1" />
+									</group>
+								</group>
+							</page>
+						</notebook>
+					</page>
+				</notebook>
+            </field>
+        </record>
+
+		<!-- tree -->
+        <record id="eiru_account_bank_statement_pos_config_tree" model="ir.ui.view">
+            <field name="name">eiru.account.bank.statement.pos.config.tree</field>
+            <field name="model">account.bank.statement.config</field>
+            <field name="inherit_id" ref="eiru_account_bank_statement_utility.eiru_account_bank_statement_config_tree"/>
+            <field name="arch" type="xml">
+				<!-- Disable Create and edtit -->
+				<tree position="attributes">
+					<attribute name="create">0</attribute>
+					<attribute name="edit">0</attribute>
+				</tree>
+            </field>
+        </record>
+
+	</data>
+</openerp>

+ 38 - 0
views/statement_pos.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+		<!-- form -->
+        <record id="eiru_account_bank_statement_pos" model="ir.ui.view">
+            <field name="name">eiru.account.bank.statement.pos</field>
+            <field name="model">pos.session</field>
+            <field name="inherit_id" ref="point_of_sale.view_pos_session_form"/>
+            <field name="arch" type="xml">
+				<xpath expr="//button[@name='close']" position="replace">
+					<div class="eiru-statement-pos" attrs="{'invisible' : [('state', '!=', 'opened')]}"></div>
+				</xpath>
+				<field name="state" position="before" >
+					<div class="eiru-statement-pos-print" attrs="{'invisible' : [('state', '!=', 'closed')]}"></div>
+				</field>
+				<!-- Disable Create and edtit -->
+				<form position="attributes">
+					<attribute name="create">0</attribute>
+					<attribute name="edit">0</attribute>
+				</form>
+            </field>
+        </record>
+		<!-- tree -->
+        <record id="eiru_account_bank_statement_pos_tree" model="ir.ui.view">
+            <field name="name">eiru.account.bank.statement.pos.tree</field>
+            <field name="model">pos.session</field>
+            <field name="inherit_id" ref="point_of_sale.view_pos_session_tree"/>
+            <field name="arch" type="xml">
+				<!-- Disable Create and edtit -->
+				<tree position="attributes">
+					<attribute name="create">0</attribute>
+					<attribute name="edit">0</attribute>
+				</tree>
+            </field>
+        </record>
+
+	</data>
+</openerp>

+ 11 - 0
views/templates.xml

@@ -0,0 +1,11 @@
+<openerp>
+    <data>
+        <template id="eiru_account_bank_statement_pos.eiru_assets" name="eiru_account_bank_statement_pos_eiru_assets" inherit_id="eiru_assets.assets">
+            <xpath expr="." position="inside">
+                <link rel="stylesheet" href="/eiru_account_bank_statement_pos/static/src/css/style.css"/>
+                <script type="text/javascript" src="/eiru_account_bank_statement_pos/static/src/js/eiru_statement_pos-confirm.js"/>
+                <script type="text/javascript" src="/eiru_account_bank_statement_pos/static/src/js/eiru_statement_pos-confirm_print.js"/>
+            </xpath>
+        </template>
+    </data>
+</openerp>