Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tfsoffice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from tfsoffice.client import Client # noqa

__title__ = 'tfsoffice'
__version__ = '0.1.9998'
__version__ = '0.1.9999'
__copyright__ = 'Copyright 2017 Dataselskapet AS'
__author__ = 'rune@loyning.net'
__all__ = ['Client', ]
Expand Down
8 changes: 8 additions & 0 deletions tfsoffice/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ class Client:
'TransactionService.asmx?WSDL',
}

_client_information = {}
_country_code = ''

def __init__(self, username, password, applicationid, identityid=None, token_id=None, faults=True, **options): # noqa
"""
Initialize a Client object with session, optional auth handler, and options
Expand All @@ -140,6 +143,7 @@ def __init__(self, username, password, applicationid, identityid=None, token_id=
self._faults = faults
self._clients = {}
self._headers = None
self._username = username

if 'session_id' in options:
session_id = options['session_id']
Expand Down Expand Up @@ -182,6 +186,10 @@ def __init__(self, username, password, applicationid, identityid=None, token_id=
for name, Klass in list(RESOURCE_CLASSES.items()):
setattr(self, name, Klass(self))

# load client information to get country code
self._client_information = self.client.get_client_information()
self._country_code = self._client_information.get('Country') or ''

def _authenticate(
self,
username,
Expand Down
18 changes: 18 additions & 0 deletions tfsoffice/resources/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,24 @@ def create_bundlelist(self, data):
[e for e in entries if e.get('stamp_no', None) == stamp_no]
)

# get bank details about the vendor
customer_ids = list(set([e['customer_id'] for e in entries]))
giro_numbers = list(set([e['giro_number'] for e in entries]))

if self._client._country_code.upper() == 'SE' and customer_ids and giro_numbers:
# load vendor to get payment info from CRM
vendor = self._client.companies.find_by_id(customer_ids[0])

# if giro number does not match value in CRM - change it
if vendor.get('BankAccountNo') != giro_numbers[0]:
stored_value = vendor.get('BankAccountNo').replace('-', '')
giro_number = giro_numbers[0].replace('-', '')

if stored_value == giro_number:
for e in entries:
e['bankaccount'] = vendor.get('BankAccountNo')
print(entries)

#
# Add CurrencyRate to entries
#
Expand Down