Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for camt.054 / document type autodetection / minor updates/fixes #6

Closed
Closed
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
41 changes: 37 additions & 4 deletions sepa/definitions/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def address(tag):
'address': ['AdrLine']
}

def party_compat(tag):
## Since version 2019 there is always a new subelement <Pty> after Debtor/Ultimate Deptor and Creditor/Ultimate Creditor.
## Here we try to be compatible with the old and new standards, until we have a better handling of different standards.
party_struct = party(tag)
party_struct['_sorting'].append('Pty')
party_struct['party'] = party('Pty')
return party_struct

def party(tag):
return {
Expand Down Expand Up @@ -91,11 +98,11 @@ def agent(tag):
'_sorting': ['FinInstnId', 'BrnchId'],
'financial_institution': {
'_self': 'FinInstnId',
'_sorting': ['BICFI', 'BIC', 'ClrSysMmdId', 'Nm', 'PstlAdr', 'Othr'],
'_sorting': ['BICFI', 'BIC', 'ClrSysMmbId', 'Nm', 'PstlAdr', 'Othr'],
'bicfi': 'BICFI',
'bic': 'BIC',
'clearing_system_member': {
'_self': 'ClrSysMmdId',
'_self': 'ClrSysMmbId',
'_sorting': ['ClrSysId', 'MmbId'],
'id': code_or_proprietary('ClrSysId'),
'membmer_id': 'MmbId'
Expand All @@ -116,7 +123,7 @@ def agent(tag):
def account(tag):
return {
'_self': tag,
'_sorting': ['Id', 'Tp', 'Ccy', 'Nm', 'Svcr'],
'_sorting': ['Id', 'Tp', 'Ccy', 'Nm', 'Svcr', 'Ownr'],
'id': {
'_self': 'Id',
'_sorting': ['IBAN', 'Othr'],
Expand All @@ -126,5 +133,31 @@ def account(tag):
'type': code_or_proprietary('Tp'),
'currency': 'Ccy',
'name': 'Nm',
'servicer': agent('Svcr')
'servicer': agent('Svcr'),
'owner': party('Ownr')
}

def charges(tag):
return {
'_self': tag,
'_sorting': ['TtlChrgsAndTaxAmt', 'Rcrd'],
'total': 'TtlChrgsAndTaxAmt',
'record': [{
'_self': 'Rcrd',
'_sorting': ['Amt','CdtDbtInd','ChrgInclInd','Tp','Rate','Br','Agt','Tax'],
'amount': amount_field('Amt'),
'credit_debit_indicator': 'CdtDbtInd',
'charge_included_indicator': 'ChrgInclInd',
'type': 'Tp',
'rate': 'Rate',
'charge_bearer_code': 'Br',
'agent': agent('DbtrAgt'),
'tax': {
'_self': 'Tax',
'_sorting': ['Id', 'Rate', 'Amt'],
'id': 'Id',
'rate': 'Rate',
'amount': amount_field('Amt')
},
}],
}
10 changes: 5 additions & 5 deletions sepa/definitions/mandate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .general import code_or_proprietary, party, account, agent
from .general import code_or_proprietary, party, party_compat, account, agent

def mandate_group_header(tag):
return {
Expand Down Expand Up @@ -76,14 +76,14 @@ def mandate(tag):
},
'reason': code_or_proprietary('Rsn'),
'creditor_scheme_identification': party('CdtrSchmeId'),
'creditor': party('Cdtr'),
'creditor': party_compat('Cdtr'),
'creditor_account': account('CdtrAcct'),
'creditor_agent': agent('CdtrAgt'),
'ultimate_creditor': party('UltmtCdtr'),
'debtor': party('Dbtr'),
'ultimate_creditor': party_compat('UltmtCdtr'),
'debtor': party_compat('Dbtr'),
'debtor_account': account('DbtrAcct'),
'debtor_agent': agent('DbtrAgt'),
'ultimate_debtor': party('UltmtDbtr'),
'ultimate_debtor': party_compat('UltmtDbtr'),
'reference': 'MndtRef',
'referred_document': {
'_self': 'RfrdDoc',
Expand Down
25 changes: 25 additions & 0 deletions sepa/definitions/notification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from .general import code_or_proprietary, amount_field, address, party, account, agent, charges
from .statement import pagination, from_to_date, interest_record, transactions_summary, entry

def notification(tag):
return {
'_self': tag,
'_sorting': [
'Id', 'NtfctnPgntn', 'ElctrncSeqNb', 'LglSeqNb', 'CreDtTm', 'FrToDt', 'CpyDplctInd', 'RptgSrc', 'Acct', 'RltdAcct', 'Intrst', 'TxsSummry',
'Ntry', 'AddtlNtfctnInf'
],
'id': 'Id',
'pagination': pagination('NtfctnPgntn'),
'electronic_sequence_number': 'ElctrncSeqNb',
'legal_sequence_number': 'LglSeqNb',
'creation_date_time': 'CreDtTm',
'from_to_date': from_to_date('FrToDt'),
'copy_duplicate_indicator': 'CpyDplctInd',
'reporting_source': code_or_proprietary('RptgSrc'),
'account': account('Acct'),
'related_account': account('RltdAcct'),
'interest': [interest_record('Intrst')],
'transactions_summary': transactions_summary('TxsSummry'),
'entries': [entry('Ntry')],
'additional_information': ['AddtlNtfctnInf']
}
17 changes: 9 additions & 8 deletions sepa/definitions/payment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .general import code_or_proprietary, amount_field, address, party, account, agent
from .general import code_or_proprietary, amount_field, address, party, party_compat, account, agent

def payment_group_header(tag):
return {
Expand Down Expand Up @@ -34,9 +34,10 @@ def transaction(tag):
],
'id': {
'_self': 'PmtId',
'_sorting': ['InstrId', 'EndToEndId'],
'_sorting': ['InstrId', 'EndToEndId', 'UETR'],
'instruction': 'InstrId',
'end_to_end': 'EndToEndId'
'end_to_end': 'EndToEndId',
'end_to_end_uuid': 'UETR',
},
'type': type_information('PmtTpInf'),
'amount': amount_field('InstdAmt'),
Expand Down Expand Up @@ -82,12 +83,12 @@ def transaction(tag):
'pre_notification_id': 'PreNtfctnId',
'pre_notification_date': 'PreNtfctnDt'
},
'ultimate_creditor': party('UltmtCdtr'),
'debtor': party('Dbtr'),
'ultimate_creditor': party_compat('UltmtCdtr'),
'debtor': party_compat('Dbtr'),
'debtor_account': account('DbtrAcct'),
'debtor_agent': agent('DbtrAgt'),
'debtor_agent_account': account('DbtrAgtAcct'),
'ultimate_debtor': party('UltmtDbtr'),
'ultimate_debtor': party_compat('UltmtDbtr'),
'instruction_for_creditor_agent': 'InstrForCdtrAgt',
'purpose': code_or_proprietary('Purp'),
'regulatory_reporting': [{
Expand Down Expand Up @@ -160,11 +161,11 @@ def payment(tag):
'control_sum': 'CtrlSum',
'type': type_information('PmtTpInf'),
'collection_date': 'ReqdColltnDt',
'creditor': party('Cdtr'),
'creditor': party_compat('Cdtr'),
'creditor_account': account('CdtrAcct'),
'creditor_agent': agent('CdtrAgt'),
'creditor_agent_account': account('CdtrAgtAcct'),
'ultimate_creditor': party('UltmtCdtr'),
'ultimate_creditor': party_compat('UltmtCdtr'),
'charge_bearer': 'ChrgBr',
'charges_account': account('ChrgsAcct'),
'charges_account_agent': agent('ChrgsAcctAgt'),
Expand Down
Loading