mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[IMP] Completed commission extraction from account_statement_base_import.
Removed the last remnants of commission handling from account_statement_base_import and made the newly created account_statement_commission module work properly.
This commit is contained in:
@@ -47,7 +47,6 @@
|
|||||||
in the generated entries and will be useful for reconciliation process
|
in the generated entries and will be useful for reconciliation process
|
||||||
* date : date of the payment
|
* date : date of the payment
|
||||||
* amount : amount paid in the currency of the journal used in the importation profile
|
* amount : amount paid in the currency of the journal used in the importation profile
|
||||||
* commission_amount : amount of the comission for each line
|
|
||||||
* label : the comunication given by the payment office, used as communication in the
|
* label : the comunication given by the payment office, used as communication in the
|
||||||
generated entries.
|
generated entries.
|
||||||
|
|
||||||
|
|||||||
@@ -55,10 +55,6 @@ class CreditPartnerStatementImporter(orm.TransientModel):
|
|||||||
'journal_id': fields.many2one('account.journal',
|
'journal_id': fields.many2one('account.journal',
|
||||||
'Financial journal to use transaction'),
|
'Financial journal to use transaction'),
|
||||||
'file_name': fields.char('File Name', size=128),
|
'file_name': fields.char('File Name', size=128),
|
||||||
'commission_account_id': fields.many2one('account.account',
|
|
||||||
'Commission account'),
|
|
||||||
'commission_analytic_id': fields.many2one('account.analytic.account',
|
|
||||||
'Commission analytic account'),
|
|
||||||
'receivable_account_id': fields.many2one('account.account',
|
'receivable_account_id': fields.many2one('account.account',
|
||||||
'Force Receivable/Payable Account'),
|
'Force Receivable/Payable Account'),
|
||||||
'force_partner_on_bank': fields.boolean(
|
'force_partner_on_bank': fields.boolean(
|
||||||
@@ -80,10 +76,7 @@ class CreditPartnerStatementImporter(orm.TransientModel):
|
|||||||
res = {'value':
|
res = {'value':
|
||||||
{'partner_id': c.partner_id and c.partner_id.id or False,
|
{'partner_id': c.partner_id and c.partner_id.id or False,
|
||||||
'journal_id': c.journal_id and c.journal_id.id or False,
|
'journal_id': c.journal_id and c.journal_id.id or False,
|
||||||
'commission_account_id':
|
|
||||||
c.commission_account_id and c.commission_account_id.id or False,
|
|
||||||
'receivable_account_id': c.receivable_account_id and c.receivable_account_id.id or False,
|
'receivable_account_id': c.receivable_account_id and c.receivable_account_id.id or False,
|
||||||
'commission_a': c.commission_analytic_id and c.commission_analytic_id.id or False,
|
|
||||||
'force_partner_on_bank': c.force_partner_on_bank,
|
'force_partner_on_bank': c.force_partner_on_bank,
|
||||||
'balance_check': c.balance_check,
|
'balance_check': c.balance_check,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@
|
|||||||
<separator string="Import Parameters Summary" colspan="4"/>
|
<separator string="Import Parameters Summary" colspan="4"/>
|
||||||
<field name="partner_id" readonly="1"/>
|
<field name="partner_id" readonly="1"/>
|
||||||
<field name="journal_id" readonly="1"/>
|
<field name="journal_id" readonly="1"/>
|
||||||
<field name="commission_account_id" readonly="1"/>
|
|
||||||
<field name="commission_analytic_id" readonly="1"/>
|
|
||||||
<field name="receivable_account_id" readonly="1"/>
|
<field name="receivable_account_id" readonly="1"/>
|
||||||
<field name="force_partner_on_bank" readonly="1"/>
|
<field name="force_partner_on_bank" readonly="1"/>
|
||||||
<field name="balance_check" readonly="1"/>
|
<field name="balance_check" readonly="1"/>
|
||||||
|
|||||||
22
account_statement_commission/__init__.py
Normal file
22
account_statement_commission/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Author: Joel Grand-Guillaume
|
||||||
|
# Copyright 2011-2012 Camptocamp SA
|
||||||
|
# Copyright 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>)
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
import commission
|
||||||
47
account_statement_commission/__openerp__.py
Normal file
47
account_statement_commission/__openerp__.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Author: Joel Grand-Guillaume
|
||||||
|
# Copyright 2011-2012 Camptocamp SA
|
||||||
|
# Copyright 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>)
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': "Bank statement import - commissions",
|
||||||
|
'version': '1.0',
|
||||||
|
'author': 'Camptocamp',
|
||||||
|
'maintainer': 'Camptocamp',
|
||||||
|
'category': 'Finance',
|
||||||
|
'complexity': 'normal',
|
||||||
|
'depends': [
|
||||||
|
'account_statement_base_import'
|
||||||
|
],
|
||||||
|
'description': """
|
||||||
|
This module brings commission support to bank statement imports. It computes the sum of a commission
|
||||||
|
field on each transaction and creates a statement entry for it.
|
||||||
|
""",
|
||||||
|
'website': 'http://www.camptocamp.com',
|
||||||
|
'data': [
|
||||||
|
"statement_view.xml",
|
||||||
|
"import_statement_view.xml",
|
||||||
|
],
|
||||||
|
'test': [],
|
||||||
|
'installable': True,
|
||||||
|
'images': [],
|
||||||
|
'auto_install': False,
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
import datetime
|
import datetime
|
||||||
from openerp.osv import fields
|
from openerp.osv import orm, fields
|
||||||
from openerp.osv.orm import Model
|
|
||||||
|
|
||||||
class AccountStatementProfil(Model):
|
def float_or_zero(val):
|
||||||
|
return float(val) if val else 0.0
|
||||||
|
|
||||||
|
class AccountStatementProfil(orm.Model):
|
||||||
_inherit = "account.statement.profile"
|
_inherit = "account.statement.profile"
|
||||||
|
|
||||||
def _write_extra_statement_lines(
|
def _write_extra_statement_lines(
|
||||||
@@ -12,7 +14,7 @@ class AccountStatementProfil(Model):
|
|||||||
"""
|
"""
|
||||||
global_commission_amount = 0
|
global_commission_amount = 0
|
||||||
for row in parser.result_row_list:
|
for row in parser.result_row_list:
|
||||||
global_commission_amount += row.get('commission_amount', 0.0)
|
global_commission_amount += float_or_zero(row.get('commission_amount', '0.0'))
|
||||||
if not global_commission_amount:
|
if not global_commission_amount:
|
||||||
return
|
return
|
||||||
partner_id = profile.partner_id and profile.partner_id.id or False
|
partner_id = profile.partner_id and profile.partner_id.id or False
|
||||||
@@ -34,7 +36,7 @@ class AccountStatementProfil(Model):
|
|||||||
statement_line_obj = self.pool.get('account.bank.statement.line')
|
statement_line_obj = self.pool.get('account.bank.statement.line')
|
||||||
statement_line_obj.create(cr, uid, comm_values, context=context)
|
statement_line_obj.create(cr, uid, comm_values, context=context)
|
||||||
|
|
||||||
class AccountStatementLineWithCommission(Model):
|
class AccountStatementLineWithCommission(orm.Model):
|
||||||
_inherit = "account.bank.statement.line"
|
_inherit = "account.bank.statement.line"
|
||||||
_columns = {
|
_columns = {
|
||||||
'commission_amount': fields.sparse(
|
'commission_amount': fields.sparse(
|
||||||
@@ -42,3 +44,25 @@ class AccountStatementLineWithCommission(Model):
|
|||||||
string='Line Commission Amount',
|
string='Line Commission Amount',
|
||||||
serialization_field='additionnal_bank_fields'),
|
serialization_field='additionnal_bank_fields'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CreditPartnerStatementImporter(orm.TransientModel):
|
||||||
|
_inherit = "credit.statement.import"
|
||||||
|
|
||||||
|
_columns = {
|
||||||
|
'commission_account_id': fields.many2one('account.account',
|
||||||
|
'Commission account'),
|
||||||
|
'commission_analytic_id': fields.many2one('account.analytic.account',
|
||||||
|
'Commission analytic account'),
|
||||||
|
}
|
||||||
|
|
||||||
|
def onchange_profile_id(self, cr, uid, ids, profile_id, context=None):
|
||||||
|
res = super(CreditPartnerStatementImporter, self).onchange_profile_id(
|
||||||
|
cr, uid, ids, profile_id, context=context)
|
||||||
|
if profile_id:
|
||||||
|
c = self.pool.get("account.statement.profile").browse(
|
||||||
|
cr, uid, profile_id, context=context)
|
||||||
|
res['value']['commission_account_id'] = \
|
||||||
|
c.commission_account_id and c.commission_account_id.id or False
|
||||||
|
res['value']['commission_a'] = \
|
||||||
|
c.commission_analytic_id and c.commission_analytic_id.id or False
|
||||||
|
return res
|
||||||
18
account_statement_commission/import_statement_view.xml
Normal file
18
account_statement_commission/import_statement_view.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
<record id="statement_importer_view" model="ir.ui.view">
|
||||||
|
<field name="name">credit.statement.import.config.view</field>
|
||||||
|
<field name="model">credit.statement.import</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="inherit_id" ref="account_statement_base_import.statement_importer_view" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="/form/group/field[@name='journal_id']" position="after">
|
||||||
|
<field name="commission_account_id" readonly="1"/>
|
||||||
|
<field name="commission_analytic_id" readonly="1"/>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
Reference in New Issue
Block a user