Coverage for jbank/management/commands/wsedi_exec.py : 0%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import logging
2import pytz
3from django.core.management.base import CommandParser
4from jutil.command import SafeCommand
5from jbank.helpers import parse_start_and_end_date
6from jbank.models import WsEdiConnection
7from jbank.wsedi import wsedi_execute
10logger = logging.getLogger(__name__)
13class Command(SafeCommand):
14 help = """
15 Executes WS-EDI command using direct bank connection.
16 """
18 def add_arguments(self, parser: CommandParser):
19 parser.add_argument('--ws', type=int, default=1)
20 parser.add_argument('--cmd', type=str, default='DownloadFileList')
21 parser.add_argument('--file-reference', type=str)
22 parser.add_argument('--file-type', type=str)
23 parser.add_argument('--start-date', type=str)
24 parser.add_argument('--end-date', type=str)
26 def do(self, *args, **options):
27 ws = WsEdiConnection.objects.get(id=options['ws'])
28 assert isinstance(ws, WsEdiConnection)
29 if ws and not ws.enabled:
30 logger.info('WS connection %s not enabled, exiting', ws)
31 return
33 start_date, end_date = parse_start_and_end_date(pytz.timezone('Europe/Helsinki'), **options)
34 cmd = options['cmd']
35 file_reference = options['file_reference']
36 file_type = options['file_type']
37 wsedi_execute(ws, command=cmd, file_reference=file_reference, file_type=file_type, start_date=start_date, end_date=end_date, verbose=True)