mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MRG] Merged with target branch
This commit is contained in:
@@ -1181,7 +1181,7 @@ class banking_import_transaction(orm.Model):
|
||||
not(transaction.move_currency_amount is False)):
|
||||
res[transaction.id] = (
|
||||
transaction.move_currency_amount -
|
||||
transaction.transferred_amount
|
||||
transaction.statement_line_id.amount
|
||||
)
|
||||
return res
|
||||
|
||||
@@ -1738,10 +1738,14 @@ class account_bank_statement_line(orm.Model):
|
||||
(statement_line_data['name'] or '') + _(' (split)'))
|
||||
statement_line_data['import_transaction_id'] = transaction_id
|
||||
statement_line_data['parent_id'] = this.id
|
||||
statement_line_id = self.create(
|
||||
cr, uid, statement_line_data, context=context)
|
||||
|
||||
child_statement_ids.append(
|
||||
self.create(cr, uid, statement_line_data,
|
||||
context=context))
|
||||
child_statement_ids.append(statement_line_id)
|
||||
transaction_pool.write(
|
||||
cr, uid, transaction_id, {
|
||||
'statement_line_id': statement_line_id,
|
||||
}, context=context)
|
||||
this.write({'amount': this.amount - amount})
|
||||
|
||||
return child_statement_ids
|
||||
|
||||
@@ -2,27 +2,17 @@
|
||||
#
|
||||
# Copyright (C) 2013 Therp BV (<http://therp.nl>).
|
||||
#
|
||||
# All other contributions are (C) by their respective contributors
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
# WARNING: This program as such is intended to be used by professional
|
||||
# programmers who take the whole responsability of assessing all potential
|
||||
# consequences resulting from its eventual inadequacies and bugs
|
||||
# End users who are looking for a ready-to-use solution with commercial
|
||||
# garantees and support are strongly adviced to contract EduSense BV
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# 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 General Public License for more details.
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# 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/>.
|
||||
#
|
||||
############################################################################*/
|
||||
|
||||
@@ -98,8 +98,6 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
# The following fields get never written
|
||||
# they are just triggers for manual matching
|
||||
# which populates regular fields on the transaction
|
||||
manual_invoice_id = vals.pop('manual_invoice_id', False)
|
||||
manual_move_line_id = vals.pop('manual_move_line_id', False)
|
||||
manual_invoice_ids = vals.pop('manual_invoice_ids', [])
|
||||
manual_move_line_ids = vals.pop('manual_move_line_ids', [])
|
||||
|
||||
@@ -145,17 +143,17 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
_("No entry found for the selected invoice. " +
|
||||
"Try manual reconciliation."))
|
||||
|
||||
if manual_move_line_id or manual_invoice_id \
|
||||
or manual_move_line_ids or manual_invoice_ids:
|
||||
if manual_move_line_ids or manual_invoice_ids:
|
||||
move_line_obj = self.pool.get('account.move.line')
|
||||
invoice_obj = self.pool.get('account.invoice')
|
||||
statement_line_obj = self.pool.get('account.bank.statement.line')
|
||||
manual_invoice_ids = (
|
||||
([manual_invoice_id] if manual_invoice_id else []) +
|
||||
# Rewrite *2many directive notation
|
||||
if manual_invoice_ids:
|
||||
manual_invoice_ids = (
|
||||
[i[1] for i in manual_invoice_ids if i[0]==4] +
|
||||
[j for i in manual_invoice_ids if i[0]==6 for j in i[2]])
|
||||
manual_move_line_ids = (
|
||||
([manual_move_line_id] if manual_move_line_id else []) +
|
||||
if manual_move_line_ids:
|
||||
manual_move_line_ids = (
|
||||
[i[1] for i in manual_move_line_ids if i[0]==4] +
|
||||
[j for i in manual_move_line_ids if i[0]==6 for j in i[2]])
|
||||
for wiz in self.browse(cr, uid, ids, context=context):
|
||||
@@ -202,7 +200,7 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
|
||||
if len(todo) > 0:
|
||||
statement_line_id = wiz.statement_line_id.split_off(
|
||||
move_line.credit or move_line.debit)[0]
|
||||
move_line.debit or -move_line.credit)[0]
|
||||
transaction_id = statement_line_obj.browse(
|
||||
cr,
|
||||
uid,
|
||||
@@ -266,7 +264,12 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
account_id = setting.default_debit_account_id and setting.default_debit_account_id.id
|
||||
statement_pool.write(cr, uid, wiz.statement_line_id.id, {'account_id':account_id})
|
||||
|
||||
wiz.write({'partner_id': False})
|
||||
# Restore partner id from the bank account or else reset
|
||||
partner_id = False
|
||||
if (wiz.statement_line_id.partner_bank_id and
|
||||
wiz.statement_line_id.partner_bank_id.partner_id):
|
||||
partner_id = wiz.statement_line_id.partner_bank_id.partner_id.id
|
||||
wiz.write({'partner_id': partner_id})
|
||||
|
||||
if wiz.statement_line_id:
|
||||
#delete splits causing an unsplit if this is a split
|
||||
@@ -370,12 +373,12 @@ class banking_transaction_wizard(orm.TransientModel):
|
||||
'manual_invoice_ids': fields.many2many(
|
||||
'account.invoice',
|
||||
'banking_transaction_wizard_account_invoice_rel',
|
||||
'wizard_id', 'invoice_id', string='Match following invoices',
|
||||
'wizard_id', 'invoice_id', string='Match one or more invoices',
|
||||
domain=[('reconciled', '=', False)]),
|
||||
'manual_move_line_ids': fields.many2many(
|
||||
'account.move.line',
|
||||
'banking_transaction_wizard_account_move_line_rel',
|
||||
'wizard_id', 'move_line_id', string='Or match this entries',
|
||||
'wizard_id', 'move_line_id', string='Or match one or more entries',
|
||||
domain=[('account_id.reconcile', '=', True),
|
||||
('reconcile_id', '=', False)]),
|
||||
'payment_option': fields.related('import_transaction_id','payment_option', string='Payment Difference', type='selection', required=True,
|
||||
|
||||
@@ -81,35 +81,9 @@
|
||||
name="trigger_match"
|
||||
type="object"
|
||||
string="Match again"/>
|
||||
<!-- Manual selection -->
|
||||
</page>
|
||||
<!-- Manual selection -->
|
||||
<page string="Manual match">
|
||||
<field name="manual_invoice_id"
|
||||
context="{'search_default_partner_id': partner_id}"
|
||||
/>
|
||||
<!--
|
||||
Specify alternative tree_view_ref as a
|
||||
workaround for lp:1073521 in OpenERP 6.1
|
||||
Need to also define 'view_mode' to prevent
|
||||
an instant editable tree view
|
||||
reconstruction by account.move.line's
|
||||
fields_view_get().
|
||||
Both are not needed in OpenERP 6.0 or 7.0.
|
||||
-->
|
||||
<field name="manual_move_line_id"
|
||||
context="{
|
||||
'search_default_partner_id': partner_id,
|
||||
'tree_view_ref': 'account.view_move_line_tax_tree',
|
||||
'view_mode': 'yes'
|
||||
}"
|
||||
/>
|
||||
<newline/>
|
||||
<button colspan="1"
|
||||
name="trigger_write"
|
||||
type="object"
|
||||
string="Match"/>
|
||||
</page>
|
||||
<page string="Multiple manual matches" attrs="{'invisible': ['|', ('match_type', '!=', False), ('statement_line_parent_id', '!=', False)]}">
|
||||
<field name="manual_invoice_ids" colspan="4"
|
||||
context="{'search_default_partner_id': partner_id}"
|
||||
/>
|
||||
@@ -145,7 +119,7 @@
|
||||
</notebook>
|
||||
<group colspan="2">
|
||||
<separator/>
|
||||
<button icon="gtk-ok" string="Done" special="cancel"/>
|
||||
<button icon="gtk-ok" string="Close" special="cancel"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
|
||||
@@ -90,6 +90,7 @@ class transaction(models.mem_bank_transaction):
|
||||
'INTL': bt.ORDER, # international order
|
||||
'UNKN': bt.ORDER, # everything else
|
||||
'SEPA': bt.ORDER,
|
||||
'PAYB': bt.PAYMENT_BATCH,
|
||||
}
|
||||
|
||||
def __init__(self, line, *args, **kwargs):
|
||||
@@ -116,7 +117,7 @@ class transaction(models.mem_bank_transaction):
|
||||
elif not self.execution_date:
|
||||
self.error_message = "No execution date"
|
||||
elif not self.remote_account and self.transfer_type not in [
|
||||
'BEA', 'GEA', 'COSTS', 'UNKN',
|
||||
'BEA', 'GEA', 'COSTS', 'UNKN', 'PAYB',
|
||||
]:
|
||||
self.error_message = _('No remote account for transaction type '
|
||||
'%s') % self.transfer_type
|
||||
@@ -246,6 +247,8 @@ class transaction(models.mem_bank_transaction):
|
||||
remote_owner = field[14:32].strip()
|
||||
elif re.match("^EL[0-9]{13}I", field):
|
||||
transfer_type = 'INTL'
|
||||
elif field.startswith("TOTAAL BETALINGEN"):
|
||||
transfer_type = 'PAYB'
|
||||
return (transfer_type, remote_account, remote_owner)
|
||||
|
||||
fields = split_blob(self.blob)
|
||||
|
||||
@@ -77,6 +77,7 @@ class transaction_message(object):
|
||||
# Normalize basic account numbers
|
||||
self.remote_account = self.remote_account.replace('.', '').zfill(10)
|
||||
self.local_account = self.local_account.replace('.', '').zfill(10)
|
||||
|
||||
|
||||
class transaction(models.mem_bank_transaction):
|
||||
'''
|
||||
@@ -114,6 +115,8 @@ class transaction(models.mem_bank_transaction):
|
||||
|
||||
# global expression for matching storno references
|
||||
ref_expr = re.compile('REF[\*:]([0-9A-Z-z_-]+)')
|
||||
# match references for Acceptgiro's through Internet banking
|
||||
kn_expr = re.compile('KN: ([^ ]+)')
|
||||
|
||||
def __init__(self, line, *args, **kwargs):
|
||||
'''
|
||||
@@ -149,6 +152,58 @@ class transaction(models.mem_bank_transaction):
|
||||
self.reference = res.group(1)
|
||||
self.storno_retry = True
|
||||
self.remote_owner = False
|
||||
if self.transfer_type == 'GT':
|
||||
res = self.kn_expr.search(self.message)
|
||||
if res:
|
||||
self.reference = res.group(1)
|
||||
if self.transfer_type == 'AC':
|
||||
self.parse_acceptgiro()
|
||||
if self.message and not self.reference:
|
||||
self.reference = self.message
|
||||
|
||||
def parse_acceptgiro(self):
|
||||
"""
|
||||
Entries of type 'Acceptgiro' can contain the reference
|
||||
in the 'name' column, as well as full address information
|
||||
in the 'message' column'
|
||||
"""
|
||||
reference = ''
|
||||
street = False
|
||||
zipcode = False
|
||||
street = False
|
||||
before = False
|
||||
if self.remote_owner.startswith('KN: '):
|
||||
self.reference = self.remote_owner[4:]
|
||||
self.remote_owner = ''
|
||||
if 'KN: ' in self.message:
|
||||
index = self.message.index('KN: ')
|
||||
before = self.message[:index]
|
||||
self.message = self.message[index:]
|
||||
expression = (
|
||||
"^\s*(KN:\s*(?P<kn>[^\s]+))?(\s*)"
|
||||
"(?P<navr>NAVR:\s*[^\s]+)?(\s*)(?P<after>.*?)$")
|
||||
msg_match = re.match(expression, self.message)
|
||||
after = msg_match.group('after')
|
||||
kn = msg_match.group('kn')
|
||||
navr = msg_match.group('navr')
|
||||
if kn:
|
||||
self.reference = kn[4:]
|
||||
self.message = 'Acceptgiro %s' % (navr or '')
|
||||
if after:
|
||||
parts = [after[i:i+33] for i in range(0, len(after), 33)]
|
||||
if parts and not self.remote_owner:
|
||||
self.remote_owner = parts.pop(0).strip()
|
||||
if parts:
|
||||
self.remote_owner_address = [parts.pop(0).strip()]
|
||||
if parts:
|
||||
zip_city = parts.pop(0).strip()
|
||||
zip_match = re.match(
|
||||
"^(?P<zipcode>[^ ]{6})\s+(?P<city>.*?)$", zip_city)
|
||||
if zip_match:
|
||||
self.remote_owner_postalcode = zip_match.group('zipcode')
|
||||
self.remote_owner_city = zip_match.group('city')
|
||||
if before and not self.remote_owner_city:
|
||||
self.remote_owner_city = before.strip()
|
||||
|
||||
def is_valid(self):
|
||||
if not self.error_message:
|
||||
|
||||
@@ -165,8 +165,12 @@ class payment_order_create(orm.TransientModel):
|
||||
# customer invoice number (in the case of debit order)
|
||||
communication = line.invoice.number.replace('/', '')
|
||||
state = 'structured'
|
||||
if communication != line.ref:
|
||||
if line.invoice.number != line.ref:
|
||||
communication2 = line.ref
|
||||
else:
|
||||
state = 'normal'
|
||||
communication2 = line.ref
|
||||
|
||||
# support debit orders when enabled
|
||||
if (payment.payment_order_type == 'debit' and
|
||||
'amount_to_receive' in line):
|
||||
|
||||
Reference in New Issue
Block a user