mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Merge pull request #74 from gurneyalex/7.0-fix-pylint
Refactoring: fix Travis build on 7.0 branch
This commit is contained in:
@@ -1 +1 @@
|
||||
import model
|
||||
from . import model
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
import account_bank_statement_line
|
||||
import account_bank_statement
|
||||
from . import account_bank_statement_line
|
||||
from . import account_bank_statement
|
||||
|
||||
@@ -90,9 +90,6 @@ class AccountBankStatement(orm.Model):
|
||||
defaults['account_id'])),
|
||||
'credit': tax['amount'] < 0 and - tax['amount'] or 0.0,
|
||||
'debit': tax['amount'] > 0 and tax['amount'] or 0.0,
|
||||
'account_id': (
|
||||
tax.get('account_collected_id',
|
||||
defaults['account_id'])),
|
||||
})
|
||||
|
||||
return move_lines, update_move_line
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import sepa
|
||||
import record
|
||||
import banking_import_transaction
|
||||
import account_banking
|
||||
import parsers
|
||||
import wizard
|
||||
import res_partner
|
||||
import res_bank
|
||||
import res_partner_bank
|
||||
from . import sepa
|
||||
from . import record
|
||||
from . import banking_import_transaction
|
||||
from . import account_banking
|
||||
from . import parsers
|
||||
from . import wizard
|
||||
from . import res_partner
|
||||
from . import res_bank
|
||||
from . import res_partner_bank
|
||||
|
||||
@@ -23,11 +23,7 @@ import unicodedata
|
||||
|
||||
__all__ = ['str2date', 'date2str', 'date2date', 'to_swift']
|
||||
|
||||
try:
|
||||
from datetime import datetime
|
||||
datetime.strptime
|
||||
except AttributeError:
|
||||
from mx import DateTime as datetime
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def str2date(datestr, format='%d/%m/%y'):
|
||||
|
||||
@@ -397,7 +397,7 @@ class parser(object):
|
||||
param being a company account is not enforced here either.
|
||||
"""
|
||||
def normalize(account_no):
|
||||
return re.sub('\s', '', account_no)
|
||||
return re.sub(r'\s', '', account_no)
|
||||
|
||||
account = normalize(account)
|
||||
cr.execute(
|
||||
|
||||
@@ -26,22 +26,12 @@ __all__ = [
|
||||
|
||||
__doc__ = '''Ease working with fixed length records in files'''
|
||||
|
||||
import unicodedata
|
||||
from datetime import datetime, date
|
||||
|
||||
# Correct python2.4 issues
|
||||
try:
|
||||
datetime.strptime
|
||||
|
||||
def strpdate(str, format):
|
||||
return datetime.strptime(str, format).date()
|
||||
except AttributeError:
|
||||
import time
|
||||
|
||||
def strpdate(str, format):
|
||||
tm = time.strptime(str, format)
|
||||
return date(tm.tm_year, tm.tm_mon, tm.tm_mday)
|
||||
|
||||
import unicodedata
|
||||
def strpdate(str, format):
|
||||
return datetime.strptime(str, format).date()
|
||||
|
||||
|
||||
class Field(object):
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import iban
|
||||
from . import iban
|
||||
|
||||
|
||||
IBAN = iban.IBAN
|
||||
BBAN = iban.BBAN
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
# deviation to take the warning from SEPA seriously: this is the domain of the
|
||||
# account owning banks. Don't use it, unless you are prepared to loose your
|
||||
# money. It is for heuristic validation purposes only.
|
||||
from __future__ import print_function
|
||||
|
||||
__all__ = ['IBAN', 'BBAN']
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
Define a struct class which behaves like a dict, but allows using
|
||||
object.attr alongside object['attr'].
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
__all__ = ['struct']
|
||||
|
||||
|
||||
|
||||
@@ -21,17 +21,15 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools.translate import _
|
||||
|
||||
"""
|
||||
|
||||
The banking transaction wizard is linked to a button in the statement line
|
||||
tree view. It allows the user to undo the duplicate flag, select between
|
||||
multiple matches or select a manual match.
|
||||
|
||||
"""
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class banking_transaction_wizard(orm.TransientModel):
|
||||
_name = 'banking.transaction.wizard'
|
||||
|
||||
@@ -1 +1 @@
|
||||
import camt
|
||||
from . import camt
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
"""Parser for PATU format files"""
|
||||
import re
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def fixchars(line):
|
||||
@@ -27,111 +30,111 @@ class PatuParser(object):
|
||||
|
||||
recparse = dict()
|
||||
recparse["00"] = (
|
||||
"T(?P<recordid>00)(?P<record_len>\d{3})"
|
||||
"(?P<version>\d{3})(?P<accountnr>\d{14})"
|
||||
"(?P<statementnr>\d{3})(?P<startdate>\d{6})"
|
||||
"(?P<enddate>\d{6})"
|
||||
"(?P<creationdate>\d{6})(?P<creationtime>\d{4})"
|
||||
"(?P<customerid>.{17})(?P<balancedate>\d{6})"
|
||||
"(?P<startingbalance>.{19})"
|
||||
"(?P<itemcount>\d{6})(?P<currency>.{3})"
|
||||
"(?P<accountname>.{30})"
|
||||
"(?P<accountlimit>\d{18})(?P<accountowner>.{35})"
|
||||
"(?P<bankcontact1>.{40})(?P<bankcontact2>.{40})"
|
||||
"(?P<bankcontact3>.{30})(?P<ibanswift>.{30})"
|
||||
r"T(?P<recordid>00)(?P<record_len>\d{3})"
|
||||
r"(?P<version>\d{3})(?P<accountnr>\d{14})"
|
||||
r"(?P<statementnr>\d{3})(?P<startdate>\d{6})"
|
||||
r"(?P<enddate>\d{6})"
|
||||
r"(?P<creationdate>\d{6})(?P<creationtime>\d{4})"
|
||||
r"(?P<customerid>.{17})(?P<balancedate>\d{6})"
|
||||
r"(?P<startingbalance>.{19})"
|
||||
r"(?P<itemcount>\d{6})(?P<currency>.{3})"
|
||||
r"(?P<accountname>.{30})"
|
||||
r"(?P<accountlimit>\d{18})(?P<accountowner>.{35})"
|
||||
r"(?P<bankcontact1>.{40})(?P<bankcontact2>.{40})"
|
||||
r"(?P<bankcontact3>.{30})(?P<ibanswift>.{30})"
|
||||
)
|
||||
recparse["10"] = (
|
||||
"T(?P<recordid>[18]0)(?P<record_len>\d{3})"
|
||||
"(?P<eventid>\d{6})"
|
||||
"(?P<archivalnr>.{18})(?P<recorddate>\d{6})"
|
||||
"(?P<valuedate>\d{6})"
|
||||
"(?P<paymentdate>\d{6})(?P<eventtype>\d)"
|
||||
"(?P<eventcode>.{3})(?P<eventdesc>.{35})"
|
||||
"(?P<amount>.{19})(?P<receiptcode>.)(?P<creationmethod>.)"
|
||||
"(?P<recipientname>.{35})(?P<recipientsource>.)"
|
||||
"(?P<recipientaccount>.{14})(?P<recipientaccountchanged>.)"
|
||||
"(?P<refnr>.{20})"
|
||||
"(?P<formnr>.{8})(?P<eventlevel>.)"
|
||||
r"T(?P<recordid>[18]0)(?P<record_len>\d{3})"
|
||||
r"(?P<eventid>\d{6})"
|
||||
r"(?P<archivalnr>.{18})(?P<recorddate>\d{6})"
|
||||
r"(?P<valuedate>\d{6})"
|
||||
r"(?P<paymentdate>\d{6})(?P<eventtype>\d)"
|
||||
r"(?P<eventcode>.{3})(?P<eventdesc>.{35})"
|
||||
r"(?P<amount>.{19})(?P<receiptcode>.)(?P<creationmethod>.)"
|
||||
r"(?P<recipientname>.{35})(?P<recipientsource>.)"
|
||||
r"(?P<recipientaccount>.{14})(?P<recipientaccountchanged>.)"
|
||||
r"(?P<refnr>.{20})"
|
||||
r"(?P<formnr>.{8})(?P<eventlevel>.)"
|
||||
)
|
||||
recparse["11"] = (
|
||||
"T(?P<recordid>[18]1)(?P<record_len>\d{3})"
|
||||
"(?P<infotype>.{2})"
|
||||
"(?:(?# Match specific info)"
|
||||
"(?<=00)(?P<message>.{35})+"
|
||||
"|"
|
||||
"(?<=01)(?P<transactioncount>\d{8})"
|
||||
"|"
|
||||
"(?<=02)(?P<customerid>.{10})\s(?P<invoicenr>.{15})\s"
|
||||
"(?P<invoicedate>\d{6})"
|
||||
"|"
|
||||
"(?<=03)(?P<cardnumber>.{19})\s(?P<storereference>.{14})"
|
||||
"|"
|
||||
"(?<=04)(?P<origarchiveid>.{18})"
|
||||
"|"
|
||||
"(?<=05)(?P<destinationamount>.{19})\s(?P<currency>.{3})\s"
|
||||
"(?P<exchangerate>.{11})(?P<rateref>.{6})"
|
||||
"|"
|
||||
"(?<=06)(?P<principalinfo1>.{35})(?P<principalinfo2>.{35})"
|
||||
"|"
|
||||
"(?<=07)(?P<bankinfo1>.{35})"
|
||||
"(?P<bankinfo2>.{35})?"
|
||||
"(?P<bankinfo3>.{35})?"
|
||||
"(?P<bankinfo4>.{35})?"
|
||||
"(?P<bankinfo5>.{35})?"
|
||||
"(?P<bankinfo6>.{35})?"
|
||||
"(?P<bankinfo7>.{35})?"
|
||||
"(?P<bankinfo8>.{35})?"
|
||||
"(?P<bankinfo9>.{35})?"
|
||||
"(?P<bankinfo10>.{35})?"
|
||||
"(?P<bankinfo11>.{35})?"
|
||||
"(?P<bankinfo12>.{35})?"
|
||||
"|"
|
||||
"(?<=08)(?P<paymentcode>\d{3})\s(?P<paymentdesc>.{31})"
|
||||
"|"
|
||||
"(?<=09)(?P<recipientname2>.{35})"
|
||||
"|"
|
||||
"(?<=11)(?P<reference>.{35})(?P<recipientiban>.{35})"
|
||||
"(?P<recipientbic>.{35})(?P<recipientnameiban>.{70})"
|
||||
"(?P<sendername>.{70})(?P<senderid>.{35})"
|
||||
"(?P<archivalid>.{70})"
|
||||
")"
|
||||
r"T(?P<recordid>[18]1)(?P<record_len>\d{3})"
|
||||
r"(?P<infotype>.{2})"
|
||||
r"(?:(?# Match specific info)"
|
||||
r"(?<=00)(?P<message>.{35})+"
|
||||
r"|"
|
||||
r"(?<=01)(?P<transactioncount>\d{8})"
|
||||
r"|"
|
||||
r"(?<=02)(?P<customerid>.{10})\s(?P<invoicenr>.{15})\s"
|
||||
r"(?P<invoicedate>\d{6})"
|
||||
r"|"
|
||||
r"(?<=03)(?P<cardnumber>.{19})\s(?P<storereference>.{14})"
|
||||
r"|"
|
||||
r"(?<=04)(?P<origarchiveid>.{18})"
|
||||
r"|"
|
||||
r"(?<=05)(?P<destinationamount>.{19})\s(?P<currency>.{3})\s"
|
||||
r"(?P<exchangerate>.{11})(?P<rateref>.{6})"
|
||||
r"|"
|
||||
r"(?<=06)(?P<principalinfo1>.{35})(?P<principalinfo2>.{35})"
|
||||
r"|"
|
||||
r"(?<=07)(?P<bankinfo1>.{35})"
|
||||
r"(?P<bankinfo2>.{35})?"
|
||||
r"(?P<bankinfo3>.{35})?"
|
||||
r"(?P<bankinfo4>.{35})?"
|
||||
r"(?P<bankinfo5>.{35})?"
|
||||
r"(?P<bankinfo6>.{35})?"
|
||||
r"(?P<bankinfo7>.{35})?"
|
||||
r"(?P<bankinfo8>.{35})?"
|
||||
r"(?P<bankinfo9>.{35})?"
|
||||
r"(?P<bankinfo10>.{35})?"
|
||||
r"(?P<bankinfo11>.{35})?"
|
||||
r"(?P<bankinfo12>.{35})?"
|
||||
r"|"
|
||||
r"(?<=08)(?P<paymentcode>\d{3})\s(?P<paymentdesc>.{31})"
|
||||
r"|"
|
||||
r"(?<=09)(?P<recipientname2>.{35})"
|
||||
r"|"
|
||||
r"(?<=11)(?P<reference>.{35})(?P<recipientiban>.{35})"
|
||||
r"(?P<recipientbic>.{35})(?P<recipientnameiban>.{70})"
|
||||
r"(?P<sendername>.{70})(?P<senderid>.{35})"
|
||||
r"(?P<archivalid>.{70})"
|
||||
r")"
|
||||
)
|
||||
recparse["40"] = (
|
||||
"T(?P<recordid>40)(?P<record_len>\d{3})"
|
||||
"(?P<recorddate>\d{6})(?P<balance>.{19})"
|
||||
"(?P<availablefunds>.{19})"
|
||||
r"T(?P<recordid>40)(?P<record_len>\d{3})"
|
||||
r"(?P<recorddate>\d{6})(?P<balance>.{19})"
|
||||
r"(?P<availablefunds>.{19})"
|
||||
)
|
||||
recparse["50"] = (
|
||||
"T(?P<recordid>50)(?P<record_len>\d{3})"
|
||||
"(?P<period>\d)(?P<perioddate>\d{6})"
|
||||
"(?P<depositcount>\d{8})(?P<depositsum>.{19})"
|
||||
"(?P<withdrawcount>\d{8})(?P<withdrawsum>.{19})"
|
||||
r"T(?P<recordid>50)(?P<record_len>\d{3})"
|
||||
r"(?P<period>\d)(?P<perioddate>\d{6})"
|
||||
r"(?P<depositcount>\d{8})(?P<depositsum>.{19})"
|
||||
r"(?P<withdrawcount>\d{8})(?P<withdrawsum>.{19})"
|
||||
)
|
||||
recparse["60"] = (
|
||||
"T(?P<recordid>60)(?P<record_len>\d{3})"
|
||||
"(?P<bankid>.{3})(?P<specialid>01)"
|
||||
"(?P<interestperiodstart>\d{6})-"
|
||||
"(?P<interestperiodend>\d{6})"
|
||||
"(?P<avgbalanceinfo>.)(?P<avgbalance>.{19})"
|
||||
"(?P<interestinfo>.)(?P<interestrate>\d{7})"
|
||||
"(?P<limitbalanceinfo>.)(?P<avglimitbalance>.{19})"
|
||||
"(?P<limitinterestinfo>.)(?P<limitinterestrate>\d{7})"
|
||||
"(?P<limitusageinfo>.)(?P<limitusage>\d{7})"
|
||||
"(?P<permanentbalanceinfo>.)(?P<permanentbalance>.{19})"
|
||||
"(?P<refinterestinfo>.)(?P<refinterestname>.{35})"
|
||||
"(?P<refinterestrate>\d{7})"
|
||||
"(?P<refcreditinfo>.)(?P<refcreditname>.{35})"
|
||||
"(?P<refcreditrate>\d{7})"
|
||||
r"T(?P<recordid>60)(?P<record_len>\d{3})"
|
||||
r"(?P<bankid>.{3})(?P<specialid>01)"
|
||||
r"(?P<interestperiodstart>\d{6})-"
|
||||
r"(?P<interestperiodend>\d{6})"
|
||||
r"(?P<avgbalanceinfo>.)(?P<avgbalance>.{19})"
|
||||
r"(?P<interestinfo>.)(?P<interestrate>\d{7})"
|
||||
r"(?P<limitbalanceinfo>.)(?P<avglimitbalance>.{19})"
|
||||
r"(?P<limitinterestinfo>.)(?P<limitinterestrate>\d{7})"
|
||||
r"(?P<limitusageinfo>.)(?P<limitusage>\d{7})"
|
||||
r"(?P<permanentbalanceinfo>.)(?P<permanentbalance>.{19})"
|
||||
r"(?P<refinterestinfo>.)(?P<refinterestname>.{35})"
|
||||
r"(?P<refinterestrate>\d{7})"
|
||||
r"(?P<refcreditinfo>.)(?P<refcreditname>.{35})"
|
||||
r"(?P<refcreditrate>\d{7})"
|
||||
)
|
||||
recparse["70"] = (
|
||||
"T(?P<recordid>70)(?P<record_len>\d{3})"
|
||||
"(?P<bankid>\d{3})"
|
||||
"(?P<infoline1>.{80})"
|
||||
"(?P<infoline2>.{80})?"
|
||||
"(?P<infoline3>.{80})?"
|
||||
"(?P<infoline4>.{80})?"
|
||||
"(?P<infoline5>.{80})?"
|
||||
"(?P<infoline6>.{80})?"
|
||||
r"T(?P<recordid>70)(?P<record_len>\d{3})"
|
||||
r"(?P<bankid>\d{3})"
|
||||
r"(?P<infoline1>.{80})"
|
||||
r"(?P<infoline2>.{80})?"
|
||||
r"(?P<infoline3>.{80})?"
|
||||
r"(?P<infoline4>.{80})?"
|
||||
r"(?P<infoline5>.{80})?"
|
||||
r"(?P<infoline6>.{80})?"
|
||||
)
|
||||
for record in recparse:
|
||||
recparse[record] = re.compile(recparse[record])
|
||||
@@ -150,7 +153,7 @@ class PatuParser(object):
|
||||
if matchobj:
|
||||
break
|
||||
if not matchobj:
|
||||
print(" **** failed to match line '%s'" % (line))
|
||||
_logger.warning("failed to match line %r", line)
|
||||
return
|
||||
# Strip strings
|
||||
matchdict = matchobj.groupdict()
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
"""
|
||||
Parser for MT940 format files
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import re
|
||||
import datetime
|
||||
import logging
|
||||
@@ -70,7 +72,6 @@ class MT940(object):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MT940, self).__init__(*args, **kwargs)
|
||||
'state variables'
|
||||
self.current_statement = None
|
||||
'type account_banking.parsers.models.mem_bank_statement'
|
||||
self.current_transaction = None
|
||||
@@ -198,7 +199,7 @@ class MT940(object):
|
||||
transaction.execution_date = str2date(data[:6])
|
||||
transaction.effective_date = str2date(data[:6])
|
||||
transaction.value_date = str2date(data[:6])
|
||||
'...and the rest already is highly bank dependent'
|
||||
# ...and the rest already is highly bank dependent
|
||||
|
||||
def handle_tag_86(self, cr, data):
|
||||
'''details for previous transaction, here most differences between
|
||||
@@ -219,12 +220,12 @@ def main(filename):
|
||||
parser = MT940()
|
||||
parser.parse(None, open(filename, 'r').read())
|
||||
for statement in parser.statements:
|
||||
print '''statement found for %(local_account)s at %(date)s
|
||||
print('''statement found for %(local_account)s at %(date)s
|
||||
with %(local_currency)s%(start_balance)s to %(end_balance)s
|
||||
''' % statement.__dict__
|
||||
''' % statement.__dict__)
|
||||
for transaction in statement.transactions:
|
||||
print '''
|
||||
transaction on %(execution_date)s''' % transaction.__dict__
|
||||
print('''
|
||||
transaction on %(execution_date)s''' % transaction.__dict__)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import abnamro
|
||||
from . import abnamro
|
||||
|
||||
@@ -60,7 +60,7 @@ class transaction_message(object):
|
||||
_('Invalid transaction line: expected %d columns, found '
|
||||
'%d') % (len(self.attrnames), len(values))
|
||||
)
|
||||
''' Strip all values except the blob '''
|
||||
# Strip all values except the blob
|
||||
for (key, val) in zip(self.attrnames, values):
|
||||
self.__dict__[key] = key == 'blob' and val or val.strip()
|
||||
# for lack of a standardized locale function to parse amounts
|
||||
@@ -223,7 +223,7 @@ class transaction(models.mem_bank_transaction):
|
||||
transfer_type = 'GIRO'
|
||||
# field has markup 'GIRO ACCOUNT OWNER'
|
||||
# separated by clusters of space of varying size
|
||||
account_match = re.match('\s*([0-9]+)\s(.*)$', field[5:])
|
||||
account_match = re.match(r'\s*([0-9]+)\s(.*)$', field[5:])
|
||||
if account_match:
|
||||
remote_account = account_match.group(1).zfill(10)
|
||||
remote_owner = account_match.group(2).strip() or ''
|
||||
@@ -245,7 +245,7 @@ class transaction(models.mem_bank_transaction):
|
||||
# format
|
||||
elif field.startswith('MAANDBIJDRAGE ABNAMRO'):
|
||||
transfer_type = 'COSTS'
|
||||
elif re.match("^\s([0-9]+\.){3}[0-9]+\s", field):
|
||||
elif re.match(r"^\s([0-9]+\.){3}[0-9]+\s", field):
|
||||
transfer_type = 'BANK'
|
||||
remote_account = field[1:13].strip().replace('.', '').zfill(10)
|
||||
# column 14 to 31 is either empty or contains the remote owner
|
||||
@@ -325,8 +325,8 @@ class transaction(models.mem_bank_transaction):
|
||||
# but can be any numeric line really
|
||||
for field in fields[1:]:
|
||||
m = re.match(
|
||||
"^\s*((BETALINGSKENM\.)|(ACCEPTGIRO))?\s*([0-9]+"
|
||||
"([ /][0-9]+)*)\s*$",
|
||||
r"^\s*((BETALINGSKENM\.)|(ACCEPTGIRO))?\s*([0-9]+"
|
||||
r"([ /][0-9]+)*)\s*$",
|
||||
field)
|
||||
if m:
|
||||
self.reference = m.group(4)
|
||||
|
||||
@@ -117,7 +117,7 @@ class transaction_message(object):
|
||||
# payment batch done via clieop
|
||||
if (self.transfer_type == 'VZ'
|
||||
and (not self.remote_account or self.remote_account == '0')
|
||||
and (not self.message or re.match('^\s*$', self.message))
|
||||
and (not self.message or re.match(r'^\s*$', self.message))
|
||||
and self.remote_owner.startswith('TOTAAL ')):
|
||||
self.transfer_type = 'PB'
|
||||
self.message = self.remote_owner
|
||||
@@ -127,7 +127,7 @@ class transaction_message(object):
|
||||
and not self.remote_account\
|
||||
and not self.remote_owner\
|
||||
and re.match(
|
||||
'^Verzamel Eurobetaling .* TOTAAL \d+ POSTEN\s*$',
|
||||
r'^Verzamel Eurobetaling .* TOTAAL \d+ POSTEN\s*$',
|
||||
self.message):
|
||||
self.transfer_type = 'PB'
|
||||
else:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import ing
|
||||
from . import ing
|
||||
|
||||
@@ -116,7 +116,7 @@ class transaction(models.mem_bank_transaction):
|
||||
}
|
||||
|
||||
# global expression for matching storno references
|
||||
ref_expr = re.compile('REF[\*:]([0-9A-Z-z_-]+)')
|
||||
ref_expr = re.compile(r'REF[\*:]([0-9A-Z-z_-]+)')
|
||||
# match references for Acceptgiro's through Internet banking
|
||||
kn_expr = re.compile('KN: ([^ ]+)')
|
||||
|
||||
@@ -178,8 +178,8 @@ class transaction(models.mem_bank_transaction):
|
||||
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>.*?)$")
|
||||
r"^\s*(KN:\s*(?P<kn>[^\s]+))?(\s*)"
|
||||
r"(?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')
|
||||
@@ -196,7 +196,7 @@ class transaction(models.mem_bank_transaction):
|
||||
if parts:
|
||||
zip_city = parts.pop(0).strip()
|
||||
zip_match = re.match(
|
||||
"^(?P<zipcode>[^ ]{6})\s+(?P<city>.*?)$", zip_city)
|
||||
r"^(?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')
|
||||
|
||||
@@ -39,8 +39,8 @@ class IngMT940Parser(MT940, parser):
|
||||
code = 'INT_MT940_STRUC'
|
||||
|
||||
tag_61_regex = re.compile(
|
||||
'^(?P<date>\d{6})(?P<sign>[CD])(?P<amount>\d+,\d{2})N(?P<type>.{3})'
|
||||
'(?P<reference>\w{1,16})')
|
||||
r'^(?P<date>\d{6})(?P<sign>[CD])(?P<amount>\d+,\d{2})N(?P<type>.{3})'
|
||||
r'(?P<reference>\w{1,16})')
|
||||
|
||||
def create_transaction(self, cr):
|
||||
return transaction()
|
||||
|
||||
@@ -38,8 +38,8 @@ class RaboMT940Parser(MT940, parser):
|
||||
header_lines = 1
|
||||
|
||||
tag_61_regex = re.compile(
|
||||
'^(?P<date>\d{6})(?P<sign>[CD])(?P<amount>\d+,\d{2})N(?P<type>.{3})'
|
||||
'(?P<reference>\w{1,16})')
|
||||
r'^(?P<date>\d{6})(?P<sign>[CD])(?P<amount>\d+,\d{2})N(?P<type>.{3})'
|
||||
r'(?P<reference>\w{1,16})')
|
||||
|
||||
def parse(self, cr, data):
|
||||
'implements account_banking.parsers.models.parser.parse()'
|
||||
|
||||
@@ -61,7 +61,7 @@ class transaction_message(object):
|
||||
self.__dict__.update(dict(zip(self.attrnames, values)))
|
||||
# for lack of a standardized locale function to parse amounts
|
||||
self.transferred_amount = float(
|
||||
re.sub(',', '.', re.sub('\.', '', self.transferred_amount)))
|
||||
re.sub(',', '.', re.sub(r'\.', '', self.transferred_amount)))
|
||||
if self.debcred == 'Debet':
|
||||
self.transferred_amount = -self.transferred_amount
|
||||
self.execution_date = str2date(self.date, '%d-%m-%Y')
|
||||
|
||||
@@ -1 +1 @@
|
||||
import model
|
||||
from . import model
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import account_payment
|
||||
import payment_line
|
||||
import payment_mode
|
||||
import payment_order_create
|
||||
import banking_import_transaction
|
||||
import banking_transaction_wizard
|
||||
import banking_import_line
|
||||
from . import account_payment
|
||||
from . import payment_line
|
||||
from . import payment_mode
|
||||
from . import payment_order_create
|
||||
from . import banking_import_transaction
|
||||
from . import banking_transaction_wizard
|
||||
from . import banking_import_line
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import test_payment_roundtrip
|
||||
from . import test_payment_roundtrip
|
||||
|
||||
fast_suite = [
|
||||
test_payment_roundtrip,
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import account_banking_uk_hsbc
|
||||
import wizard
|
||||
import hsbc_mt940
|
||||
import hsbc_clientid
|
||||
from . import account_banking_uk_hsbc
|
||||
from . import wizard
|
||||
from . import hsbc_mt940
|
||||
from . import hsbc_clientid
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
##############################################################################
|
||||
# Import of HSBC data in Swift MT940 format
|
||||
#
|
||||
|
||||
from account_banking.parsers import models
|
||||
from mt940_parser import HSBCParser
|
||||
import re
|
||||
import logging
|
||||
|
||||
from account_banking.parsers import models
|
||||
from .mt940_parser import HSBCParser
|
||||
|
||||
bt = models.mem_bank_transaction
|
||||
logger = logging.getLogger('hsbc_mt940')
|
||||
|
||||
@@ -178,10 +178,10 @@ class parser_hsbc_mt940(models.parser):
|
||||
result = []
|
||||
parser = HSBCParser()
|
||||
# Split into statements
|
||||
statements = [st for st in re.split('[\r\n]*(?=:20:)', data)]
|
||||
statements = [st for st in re.split(r'[\r\n]*(?=:20:)', data)]
|
||||
# Split by records
|
||||
statement_list = [
|
||||
re.split('[\r\n ]*(?=:\d\d[\w]?:)', st)
|
||||
re.split(r'[\r\n ]*(?=:\d\d[\w]?:)', st)
|
||||
for st in statements
|
||||
]
|
||||
|
||||
|
||||
@@ -26,27 +26,31 @@ Based on fi_patu's parser
|
||||
"""
|
||||
import re
|
||||
from datetime import datetime
|
||||
import logging
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HSBCParser(object):
|
||||
|
||||
def __init__(self):
|
||||
recparse = dict()
|
||||
patterns = {'ebcdic': "\w/\?:\(\).,'+{} -"}
|
||||
patterns = {'ebcdic': r"\w/\?:\(\).,'+{} -"}
|
||||
|
||||
# MT940 header
|
||||
recparse["20"] = ":(?P<recordid>20):(?P<transref>.{1,16})"
|
||||
recparse["25"] = (":(?P<recordid>25):(?P<sortcode>\d{6})"
|
||||
"(?P<accnum>\d{1,29})")
|
||||
recparse["28"] = ":(?P<recordid>28C?):(?P<statementnr>.{1,8})"
|
||||
recparse["20"] = r":(?P<recordid>20):(?P<transref>.{1,16})"
|
||||
recparse["25"] = (r":(?P<recordid>25):(?P<sortcode>\d{6})"
|
||||
r"(?P<accnum>\d{1,29})")
|
||||
recparse["28"] = r":(?P<recordid>28C?):(?P<statementnr>.{1,8})"
|
||||
|
||||
# Opening balance 60F
|
||||
recparse["60F"] = (":(?P<recordid>60F):(?P<creditmarker>[CD])"
|
||||
"(?P<prevstmtdate>\d{6})(?P<currencycode>.{3})"
|
||||
"(?P<startingbalance>[\d,]{1,15})")
|
||||
recparse["60F"] = (r":(?P<recordid>60F):(?P<creditmarker>[CD])"
|
||||
r"(?P<prevstmtdate>\d{6})(?P<currencycode>.{3})"
|
||||
r"(?P<startingbalance>[\d,]{1,15})")
|
||||
|
||||
# Transaction
|
||||
recparse["61"] = """\
|
||||
recparse["61"] = r"""\
|
||||
:(?P<recordid>61):\
|
||||
(?P<valuedate>\d{6})(?P<bookingdate>\d{4})?\
|
||||
(?P<creditmarker>R?[CD])\
|
||||
@@ -60,19 +64,19 @@ class HSBCParser(object):
|
||||
""" % (patterns)
|
||||
|
||||
# Further info
|
||||
recparse["86"] = (":(?P<recordid>86):"
|
||||
"(?P<infoline1>.{1,80})?"
|
||||
"(?:\n(?P<infoline2>.{1,80}))?"
|
||||
"(?:\n(?P<infoline3>.{1,80}))?"
|
||||
"(?:\n(?P<infoline4>.{1,80}))?"
|
||||
"(?:\n(?P<infoline5>.{1,80}))?")
|
||||
recparse["86"] = (r":(?P<recordid>86):"
|
||||
r"(?P<infoline1>.{1,80})?"
|
||||
r"(?:\n(?P<infoline2>.{1,80}))?"
|
||||
r"(?:\n(?P<infoline3>.{1,80}))?"
|
||||
r"(?:\n(?P<infoline4>.{1,80}))?"
|
||||
r"(?:\n(?P<infoline5>.{1,80}))?")
|
||||
|
||||
# Forward available balance (64) / Closing balance (62F)
|
||||
# / Interim balance (62M)
|
||||
recparse["64"] = (":(?P<recordid>64|62[FM]):"
|
||||
"(?P<creditmarker>[CD])"
|
||||
"(?P<bookingdate>\d{6})(?P<currencycode>.{3})"
|
||||
"(?P<endingbalance>[\d,]{1,15})")
|
||||
recparse["64"] = (r":(?P<recordid>64|62[FM]):"
|
||||
r"(?P<creditmarker>[CD])"
|
||||
r"(?P<bookingdate>\d{6})(?P<currencycode>.{3})"
|
||||
r"(?P<endingbalance>[\d,]{1,15})")
|
||||
|
||||
for record in recparse:
|
||||
recparse[record] = re.compile(recparse[record])
|
||||
@@ -87,7 +91,7 @@ class HSBCParser(object):
|
||||
if matchobj:
|
||||
break
|
||||
if not matchobj:
|
||||
print(" **** failed to match line '%s'" % (line))
|
||||
_logger.warning("failed to match line %r", line)
|
||||
return
|
||||
# Strip strings
|
||||
matchdict = matchobj.groupdict()
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
import base64
|
||||
from datetime import datetime, date
|
||||
from decimal import Decimal
|
||||
import paymul
|
||||
import string
|
||||
import random
|
||||
import logging
|
||||
@@ -32,6 +31,8 @@ from openerp.osv import orm, fields
|
||||
from openerp.tools import ustr
|
||||
from openerp.tools.translate import _
|
||||
|
||||
from . import paymul
|
||||
|
||||
|
||||
def strpdate(arg, format='%Y-%m-%d'):
|
||||
"""shortcut"""
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
import datetime
|
||||
import unittest2 as unittest
|
||||
import paymul
|
||||
from . import paymul
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
import model
|
||||
from . import model
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import account_payment
|
||||
import payment_line
|
||||
import account_move_line
|
||||
import account_invoice
|
||||
import payment_order_create
|
||||
from . import account_payment
|
||||
from . import payment_line
|
||||
from . import account_move_line
|
||||
from . import account_invoice
|
||||
from . import payment_order_create
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm
|
||||
from openerp.tools.translate import _
|
||||
|
||||
"""
|
||||
This module adds support for Direct debit orders as applicable
|
||||
in the Netherlands. Debit orders are advanced in total by the bank.
|
||||
@@ -122,6 +118,9 @@ Two cases need to be distinguisted:
|
||||
open invoices with a matured invoice- or due date.
|
||||
"""
|
||||
|
||||
from openerp.osv import orm
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class account_invoice(orm.Model):
|
||||
_inherit = "account.invoice"
|
||||
|
||||
@@ -1 +1 @@
|
||||
import res_partner_bank
|
||||
from . import res_partner_bank
|
||||
|
||||
@@ -1 +1 @@
|
||||
import model
|
||||
from . import model
|
||||
|
||||
@@ -1 +1 @@
|
||||
import res_partner_bank
|
||||
from . import res_partner_bank
|
||||
|
||||
Reference in New Issue
Block a user