@ -64,6 +64,13 @@ class CamtParser(object):
] ,
] ,
transaction , ' ref '
transaction , ' ref '
)
)
# unique_import_id
self . add_value_from_node (
ns , node , [
' ./ns:Refs/ns:AcctSvcrRef ' ,
] ,
transaction , ' unique_import_id '
)
# remote party values
# remote party values
party_type = ' Dbtr '
party_type = ' Dbtr '
party_type_node = node . xpath (
party_type_node = node . xpath (
@ -75,14 +82,6 @@ class CamtParser(object):
if party_node :
if party_node :
self . add_value_from_node (
self . add_value_from_node (
ns , party_node [ 0 ] , ' ./ns:Nm ' , transaction , ' partner_name ' )
ns , party_node [ 0 ] , ' ./ns:Nm ' , transaction , ' partner_name ' )
self . add_value_from_node (
ns , party_node [ 0 ] , ' ./ns:PstlAdr/ns:Ctry ' , transaction ,
' partner_country '
)
address_node = party_node [ 0 ] . xpath (
' ./ns:PstlAdr/ns:AdrLine ' , namespaces = { ' ns ' : ns } )
if address_node :
transaction [ ' partner_address ' ] = [ address_node [ 0 ] . text ]
# Get remote_account from iban or from domestic account:
# Get remote_account from iban or from domestic account:
account_node = node . xpath (
account_node = node . xpath (
' ./ns:RltdPties/ns: %s Acct/ns:Id ' % party_type ,
' ./ns:RltdPties/ns: %s Acct/ns:Id ' % party_type ,
@ -93,12 +92,6 @@ class CamtParser(object):
' ./ns:IBAN ' , namespaces = { ' ns ' : ns } )
' ./ns:IBAN ' , namespaces = { ' ns ' : ns } )
if iban_node :
if iban_node :
transaction [ ' account_number ' ] = iban_node [ 0 ] . text
transaction [ ' account_number ' ] = iban_node [ 0 ] . text
bic_node = node . xpath (
' ./ns:RltdAgts/ns: %s Agt/ns:FinInstnId/ns:BIC ' % party_type ,
namespaces = { ' ns ' : ns }
)
if bic_node :
transaction [ ' account_bic ' ] = bic_node [ 0 ] . text
else :
else :
self . add_value_from_node (
self . add_value_from_node (
ns , account_node [ 0 ] , ' ./ns:Othr/ns:Id ' , transaction ,
ns , account_node [ 0 ] , ' ./ns:Othr/ns:Id ' , transaction ,
@ -108,16 +101,8 @@ class CamtParser(object):
def parse_transaction ( self , ns , node ) :
def parse_transaction ( self , ns , node ) :
""" Parse transaction (entry) node. """
""" Parse transaction (entry) node. """
transaction = { }
transaction = { }
self . add_value_from_node (
ns , node , ' ./ns:BkTxCd/ns:Prtry/ns:Cd ' , transaction ,
' transfer_type '
)
self . add_value_from_node (
self . add_value_from_node (
ns , node , ' ./ns:BookgDt/ns:Dt ' , transaction , ' date ' )
ns , node , ' ./ns:BookgDt/ns:Dt ' , transaction , ' date ' )
self . add_value_from_node (
ns , node , ' ./ns:BookgDt/ns:Dt ' , transaction , ' execution_date ' )
self . add_value_from_node (
ns , node , ' ./ns:ValDt/ns:Dt ' , transaction , ' value_date ' )
transaction [ ' amount ' ] = self . parse_amount ( ns , node )
transaction [ ' amount ' ] = self . parse_amount ( ns , node )
@ -137,7 +122,6 @@ class CamtParser(object):
] ,
] ,
transaction , ' ref '
transaction , ' ref '
)
)
transaction [ ' data ' ] = etree . tostring ( node )
return transaction
return transaction
def get_balance_amounts ( self , ns , node ) :
def get_balance_amounts ( self , ns , node ) :
@ -185,7 +169,7 @@ class CamtParser(object):
self . add_value_from_node (
self . add_value_from_node (
ns , node , ' ./ns:Id ' , result , ' name ' )
ns , node , ' ./ns:Id ' , result , ' name ' )
self . add_value_from_node (
self . add_value_from_node (
ns , node , ' ./ns:Dt ' , result , ' date ' )
ns , node , ' ./ns:Cre DtTm ' , result , ' date ' )
self . add_value_from_node (
self . add_value_from_node (
ns , node , ' ./ns:Acct/ns:Ccy ' , result , ' currency ' )
ns , node , ' ./ns:Acct/ns:Ccy ' , result , ' currency ' )
result [ ' balance_start ' ] , result [ ' balance_end_real ' ] = (
result [ ' balance_start ' ] , result [ ' balance_end_real ' ] = (