fortuna_pbb.py
994 Bytes
from opensipkd.string import FixLength
from opensipkd.iso8583.bjb.pbb import Doc
from opensipkd.iso8583.bjb.pbb.structure import (
PAYMENT_CODE,
INVOICE_PROFILE,
)
from . import LogApp
from .fortuna import RE_ISO
class App(LogApp):
conf_name = 'pbb log file last id'
iso8583_class = Doc
bit3_payment_code = PAYMENT_CODE
def parse(self, line): # Override
found = RE_ISO.search(line)
day, month, year, hour, minute, second, milisecond, raw = \
found.groups()
return dict(
day=day, month=month, year=year, hour=hour, minute=minute,
second=second, milisecond=milisecond, raw=raw)
def create_data(self, log_file): # Override
d = super().create_data(log_file)
raw = d['bits']['62']
if raw[:2] == '00':
raw = raw[2:]
profile = FixLength(INVOICE_PROFILE)
profile.set_raw(raw)
d['bits_data'] = {'62': profile.to_dict()}
return d