NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import logging
from jsonschema import validate
from jsonschema.exceptions import ValidationError
import json
required = ['BankReference',
'DESCRIPTION',
'WIRE_TYPE',
'PayMeth',
'IN_OUT',
'MSGID',
'TYPE',
'TemplateID',
'IMAD',
'OMAD',
'SNDBKABA',
'SNDBKNAME',
'RCVBKABA',
'RCVBKNAME',
'ORGID',
'ORG',
'BNF',
'OBI',
'RCVBKINFO',
'IBKINFO',
'BBKINFO',
'BNFINFO',
'BBI',
'RFB',
'CREATE_OPERATOR',
'VERIFY_OPERATOR',
'PNRM_TIME',
]

advice_schema = {
'type': 'object',
'properties': {
'AdviceReference': {'type': 'string'},
'BankReference': {'type': 'string'},
'TranDate': {'type': 'string'},
'DESCRIPTION': {'type': 'string'},
'WIRE_TYPE': {'type': 'string'},
'PayMeth': {'type': 'string'},
'IN_OUT': {'type': 'string'},
'MSGID': {'type': 'string'},
'TYPE': {'type': 'string'},
'TemplateID': {'type': 'string'},
'IMAD': {'type': 'string'},
'OMAD': {'type': 'string'},
'SNDBKABA': {'type': 'string'},
'SNDBKNAME': {'type': 'string'},
'RCVBKABA': {'type': 'string'},
'RCVBKNAME': {'type': 'string'},
'ORGID': {'type': 'string'},
'ORG': {'type': 'string'},
'BNF': {'type': 'string'},
'OBI': {'type': 'string'},
'RCVBKINFO': {'type': 'string'},
'IBKINFO': {'type': 'string'},
'BBKINFO': {'type': 'string'},
'BNFINFO': {'type': 'string'},
'BBI': {'type': 'string'},
'RFB': {'type': 'string'},
'CREATE_OPERATOR': {'type': 'string'},
'VERIFY_OPERATOR': {'type': 'string'},
'PNRM_TIME': {'type': 'string'}
},
'additionalProperties': False,
'required': required,
'unevaluatedProperties': False
}


def valid_advice(wire_advice) -> bool:
if not isinstance(wire_advice, dict) or wire_advice is None or not wire_advice:
return False
try:
validate(instance=wire_advice, schema=advice_schema)
return True
except ValidationError as ve:
print(f"Invalid JSON Schema: {ve}")
logging.info(f"Invalid JSON Schema: {ve}")
return False


class Advice(object):
def __init__(self, wireAdvice: dict) -> None:
super().__init__()

self.AdviceReference = wireAdvice['AdviceReference']
self.BankReference = wireAdvice['BankReference']
self.TranDate = wireAdvice['TranDate']
self.DESCRIPTION = wireAdvice['DESCRIPTION']
self.WIRE_TYPE = wireAdvice['WIRE_TYPE']
self.PayMeth = wireAdvice['PayMeth']
self.IN_OUT = wireAdvice['IN_OUT']
self.MSGID = wireAdvice['MSGID']
self.TYPE = wireAdvice['TYPE']
self.TemplateID = wireAdvice['TemplateID']
self.IMAD = wireAdvice['IMAD']
self.OMAD = wireAdvice['OMAD']
self.SNDBKABA = wireAdvice['SNDBKABA']
self.SNDBKNAME = wireAdvice['SNDBKNAME']
self.RCVBKABA = wireAdvice['RCVBKABA']
self.RCVBKNAME = wireAdvice['RCVBKNAME']
self.ORGID = wireAdvice['ORGID']
self.ORG = wireAdvice['ORG']
self.BNF = wireAdvice['BNF']
self.OBI = wireAdvice['OBI']
self.RCVBKINFO = wireAdvice['RCVBKINFO']
self.IBKINFO = wireAdvice['IBKINFO']
self.BBKINFO = wireAdvice['BBKINFO']
self.BNFINFO = wireAdvice['BNFINFO']
self.BBI = wireAdvice['BBI']
self.RFB = wireAdvice['RFB']
self.CREATE_OPERATOR = wireAdvice['CREATE_OPERATOR']
self.VERIFY_OPERATOR = wireAdvice['VERIFY_OPERATOR']
self.PNRM_TIME = wireAdvice['PNRM_TIME']

def get_dict(self):
return self.__dict__

def get_json_str(self):
return json.dumps(self.__dict__, indent=4)



















import logging
from jsonschema import validate
from jsonschema.exceptions import ValidationError
from datetime import datetime
import json
import uuid
required = ['AccountNo',
'TranDate',
'PostDate',
'Amount',
'BankReference',
'BAITypeCode',
'AdviceReference']

transaction_info_schema = {
'type': 'object',
'properties': {
'BankCode': {'type': 'string'},
'AccountNo': {'type': 'string'},
'TranId': {'type': 'string'},
'TranDate': {'type': 'string'},
'PostDate': {'type': 'string'},
'ValueDate': {'type': 'string'},
'debitCreditIndicator': {'type': 'string'},
'Amount': {'type': 'number'},
'BankReference': {'type': 'string'},
'currencyCode': {'type': 'string'},
'TransactionDetail': {'type': 'string'},
'BAITypeCode': {'type': 'string'},
'timestamp': {'type': 'string'},
'TransactionCode': {'type': 'string'},
'Source': {'type': 'string'},
'AdviceReference': {'type': 'string'},
'RecordStatus': {'type': 'string'},
'chequeNumber': {'type': 'string'},
'DNARefNumber': {'type': 'string'}
},
'additionalProperties': False,
'required': required,
'unevaluatedProperties': False
}


def valid_transaction_info(transaction_info) -> bool:
if not isinstance(transaction_info, dict) or transaction_info is None or not transaction_info:
return False
try:
validate(instance=transaction_info, schema=transaction_info_schema)
return True
except ValidationError as ve:
print(f"Invalid JSON Schema: {ve}")
logging.info(f"Invalid JSON Schema: {ve}")
return False


class TransactionInfo(object):
def __init__(self, transactionInfo: dict) -> None:
super().__init__()

self.BankCode = "1235"
self.AccountNo = transactionInfo['Account']
self.TranId = uuid.uuid1().hex
self.TranDate = transactionInfo['TranDate']
self.PostDate = str(datetime.now())
self.Amount = transactionInfo['Amount']
self.BankReference = transactionInfo['BankReference']
self.BAITypeCode = transactionInfo['WIRE_TYPE']
self.AdviceReference = transactionInfo['AdviceReference']
self.TransactionDetail = transactionInfo['DESCRIPTION']
self.timestamp = str(datetime.now())
if 'ValueDate' in transactionInfo.keys():
self.ValueDate = transactionInfo['ValueDate']
else:
self.ValueDate = str(datetime.now())
if 'debitCreditIndicator' in transactionInfo.keys():
self.debitCreditIndicator = transactionInfo['debitCreditIndicator']
else:
self.debitCreditIndicator = ''
if 'currencyCode' in transactionInfo.keys():
self.currencyCode = transactionInfo['currencyCode']
else:
self.currencyCode = ''
if 'TransactionCode' in transactionInfo.keys():
self.TransactionCode = transactionInfo['TransactionCode']
else:
self.TransactionCode = ''
if 'Source' in transactionInfo.keys():
self.Source = transactionInfo['Source']
else:
self.Source = ''
if 'RecordStatus' in transactionInfo.keys():
self.RecordStatus = transactionInfo['RecordStatus']
else:
self.RecordStatus = 'READY'
if 'chequeNumber' in transactionInfo.keys():
self.chequeNumber = transactionInfo['chequeNumber']
else:
self.chequeNumber = ''
if 'DNARefNumber' in transactionInfo.keys():
self.DNARefNumber = transactionInfo['DNARefNumber']
else:
self.DNARefNumber = ''

def get_dict(self):
return self.__dict__

def get_json_str(self):
return json.dumps(self.__dict__, indent=4)
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.