|
@@ -0,0 +1,76 @@
|
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
|
+from openerp import models, fields, tools, api
|
|
|
|
+
|
|
|
|
+class AccountBankStatement(models.Model):
|
|
|
|
+ _inherit = 'account.bank.statement'
|
|
|
|
+
|
|
|
|
+ type_statement = fields.Selection([('normal', 'Normal'),('general', 'General')],'Tipo de Caja ', default="normal", help="Tipo de caja")
|
|
|
|
+
|
|
|
|
+ @api.model
|
|
|
|
+ def get_statement_point_of_sale(self, id):
|
|
|
|
+ accountStatement = self._get_statement(id)
|
|
|
|
+ decimal_precision = self.env['decimal.precision'].precision_get('Account')
|
|
|
|
+
|
|
|
|
+ if (not accountStatement):
|
|
|
|
+ return False;
|
|
|
|
+
|
|
|
|
+ accountStatementLine = self._get_statement_line(accountStatement.id)
|
|
|
|
+
|
|
|
|
+ statementPointOfSale = self._get_statement_point_of_sale(accountStatement)
|
|
|
|
+ statementLine = []
|
|
|
|
+
|
|
|
|
+ for line in statementPointOfSale:
|
|
|
|
+ lineStatement = self.env['account.bank.statement.line'].search([('name', '=', line['name'])])
|
|
|
|
+ if (not lineStatement):
|
|
|
|
+ amount = line['amount']
|
|
|
|
+ statementLine.append([0, False, {
|
|
|
|
+ 'name': line['name'],
|
|
|
|
+ 'ref' : 'Point of sale',
|
|
|
|
+ 'amount': round(float(amount), decimal_precision),
|
|
|
|
+ 'journal_id': accountStatement.journal_id.id,
|
|
|
|
+ 'account_id': accountStatement.journal_id.internal_account_id.id,
|
|
|
|
+ 'statement_id': accountStatement.id,
|
|
|
|
+ 'date': line['date'],
|
|
|
|
+ }])
|
|
|
|
+ line = []
|
|
|
|
+ if (statementLine):
|
|
|
|
+ line = accountStatement.write({'line_ids': statementLine})
|
|
|
|
+
|
|
|
|
+ return line
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ '''
|
|
|
|
+ Get Account Bank Statement
|
|
|
|
+ '''
|
|
|
|
+ def _get_statement(self, id):
|
|
|
|
+ return self.env['account.bank.statement'].browse(id)
|
|
|
|
+
|
|
|
|
+ '''
|
|
|
|
+ Get Account Bank Statement Line
|
|
|
|
+ '''
|
|
|
|
+ def _get_statement_line(self, statementId):
|
|
|
|
+ return self.env['account.bank.statement.line'].search([('statement_id', 'in', [statementId])])
|
|
|
|
+ '''
|
|
|
|
+ Get Account Bank Statement Point of Sale
|
|
|
|
+ '''
|
|
|
|
+ def _get_statement_point_of_sale(self, statement):
|
|
|
|
+ statementPoint = self.env['account.bank.statement'].search([('date','=',statement.date),('journal_id.id', '=',statement.journal_id.id),('period_id.id', '=', statement.period_id.id), ('pos_session_id', '!=', False),('state', '=', 'confirm')], order='id')
|
|
|
|
+ pointSatatement = []
|
|
|
|
+
|
|
|
|
+ for statementP in statementPoint:
|
|
|
|
+ amount = 0.0
|
|
|
|
+ for line in statementP.line_ids:
|
|
|
|
+ amount += line.amount
|
|
|
|
+
|
|
|
|
+ pointSatatement.append({
|
|
|
|
+ 'name': statementP.name,
|
|
|
|
+ 'date': statementP.date,
|
|
|
|
+ 'journalId': statementP.journal_id.id,
|
|
|
|
+ 'periodId': statementP.period_id.id,
|
|
|
|
+ 'userId': statementP.user_id.id,
|
|
|
|
+ 'posSessionId': statementP.pos_session_id.id,
|
|
|
|
+ 'posSessionName': statementP.pos_session_id.name,
|
|
|
|
+ 'amount': amount
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ return pointSatatement
|