mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
Simpler variable names
Rename method
This commit is contained in:
@@ -176,70 +176,69 @@ class AccountPaymentOrder(models.Model):
|
||||
|
||||
@api.model
|
||||
def generate_group_header_block(self, parent_node, gen_args):
|
||||
group_header_1_0 = etree.SubElement(parent_node, 'GrpHdr')
|
||||
message_identification_1_1 = etree.SubElement(
|
||||
group_header_1_0, 'MsgId')
|
||||
message_identification_1_1.text = self._prepare_field(
|
||||
group_header = etree.SubElement(parent_node, 'GrpHdr')
|
||||
message_identification = etree.SubElement(
|
||||
group_header, 'MsgId')
|
||||
message_identification.text = self._prepare_field(
|
||||
'Message Identification',
|
||||
'self.name',
|
||||
{'self': self}, 35, gen_args=gen_args)
|
||||
creation_date_time_1_2 = etree.SubElement(group_header_1_0, 'CreDtTm')
|
||||
creation_date_time_1_2.text = datetime.strftime(
|
||||
creation_date_time = etree.SubElement(group_header, 'CreDtTm')
|
||||
creation_date_time.text = datetime.strftime(
|
||||
datetime.today(), '%Y-%m-%dT%H:%M:%S')
|
||||
if gen_args.get('pain_flavor') == 'pain.001.001.02':
|
||||
# batch_booking is in "Group header" with pain.001.001.02
|
||||
# and in "Payment info" in pain.001.001.03/04
|
||||
batch_booking = etree.SubElement(group_header_1_0, 'BtchBookg')
|
||||
batch_booking = etree.SubElement(group_header, 'BtchBookg')
|
||||
batch_booking.text = unicode(self.batch_booking).lower()
|
||||
nb_of_transactions_1_6 = etree.SubElement(
|
||||
group_header_1_0, 'NbOfTxs')
|
||||
control_sum_1_7 = etree.SubElement(group_header_1_0, 'CtrlSum')
|
||||
nb_of_transactions = etree.SubElement(
|
||||
group_header, 'NbOfTxs')
|
||||
control_sum = etree.SubElement(group_header, 'CtrlSum')
|
||||
# Grpg removed in pain.001.001.03
|
||||
if gen_args.get('pain_flavor') == 'pain.001.001.02':
|
||||
grouping = etree.SubElement(group_header_1_0, 'Grpg')
|
||||
grouping = etree.SubElement(group_header, 'Grpg')
|
||||
grouping.text = 'GRPD'
|
||||
self.generate_initiating_party_block(group_header_1_0, gen_args)
|
||||
return group_header_1_0, nb_of_transactions_1_6, control_sum_1_7
|
||||
self.generate_initiating_party_block(group_header, gen_args)
|
||||
return group_header, nb_of_transactions, control_sum
|
||||
|
||||
@api.model
|
||||
def generate_start_payment_info_block(
|
||||
self, parent_node, payment_info_ident,
|
||||
priority, local_instrument, sequence_type, requested_date,
|
||||
eval_ctx, gen_args):
|
||||
payment_info_2_0 = etree.SubElement(parent_node, 'PmtInf')
|
||||
payment_info_identification_2_1 = etree.SubElement(
|
||||
payment_info_2_0, 'PmtInfId')
|
||||
payment_info_identification_2_1.text = self._prepare_field(
|
||||
payment_info = etree.SubElement(parent_node, 'PmtInf')
|
||||
payment_info_identification = etree.SubElement(
|
||||
payment_info, 'PmtInfId')
|
||||
payment_info_identification.text = self._prepare_field(
|
||||
'Payment Information Identification',
|
||||
payment_info_ident, eval_ctx, 35, gen_args=gen_args)
|
||||
payment_method_2_2 = etree.SubElement(payment_info_2_0, 'PmtMtd')
|
||||
payment_method_2_2.text = gen_args['payment_method']
|
||||
nb_of_transactions_2_4 = False
|
||||
control_sum_2_5 = False
|
||||
payment_method = etree.SubElement(payment_info, 'PmtMtd')
|
||||
payment_method.text = gen_args['payment_method']
|
||||
nb_of_transactions = False
|
||||
control_sum = False
|
||||
if gen_args.get('pain_flavor') != 'pain.001.001.02':
|
||||
batch_booking_2_3 = etree.SubElement(payment_info_2_0, 'BtchBookg')
|
||||
batch_booking_2_3.text = unicode(self.batch_booking).lower()
|
||||
batch_booking = etree.SubElement(payment_info, 'BtchBookg')
|
||||
batch_booking.text = unicode(self.batch_booking).lower()
|
||||
# The "SEPA Customer-to-bank
|
||||
# Implementation guidelines" for SCT and SDD says that control sum
|
||||
# and nb_of_transactions should be present
|
||||
# at both "group header" level and "payment info" level
|
||||
nb_of_transactions_2_4 = etree.SubElement(
|
||||
payment_info_2_0, 'NbOfTxs')
|
||||
control_sum_2_5 = etree.SubElement(payment_info_2_0, 'CtrlSum')
|
||||
payment_type_info_2_6 = etree.SubElement(
|
||||
payment_info_2_0, 'PmtTpInf')
|
||||
nb_of_transactions = etree.SubElement(
|
||||
payment_info, 'NbOfTxs')
|
||||
control_sum = etree.SubElement(payment_info, 'CtrlSum')
|
||||
payment_type_info = etree.SubElement(
|
||||
payment_info, 'PmtTpInf')
|
||||
if priority and gen_args['payment_method'] != 'DD':
|
||||
instruction_priority_2_7 = etree.SubElement(
|
||||
payment_type_info_2_6, 'InstrPrty')
|
||||
instruction_priority_2_7.text = priority
|
||||
instruction_priority = etree.SubElement(
|
||||
payment_type_info, 'InstrPrty')
|
||||
instruction_priority.text = priority
|
||||
if self.sepa:
|
||||
service_level_2_8 = etree.SubElement(
|
||||
payment_type_info_2_6, 'SvcLvl')
|
||||
service_level_code_2_9 = etree.SubElement(service_level_2_8, 'Cd')
|
||||
service_level_code_2_9.text = 'SEPA'
|
||||
service_level = etree.SubElement(payment_type_info, 'SvcLvl')
|
||||
service_level_code = etree.SubElement(service_level, 'Cd')
|
||||
service_level_code.text = 'SEPA'
|
||||
if local_instrument:
|
||||
local_instrument_root = etree.SubElement(
|
||||
payment_type_info_2_6, 'LclInstrm')
|
||||
payment_type_info, 'LclInstrm')
|
||||
if gen_args.get('local_instrument_type') == 'proprietary':
|
||||
local_instr_value = etree.SubElement(
|
||||
local_instrument_root, 'Prtry')
|
||||
@@ -248,18 +247,18 @@ class AccountPaymentOrder(models.Model):
|
||||
local_instrument_root, 'Cd')
|
||||
local_instr_value.text = local_instrument
|
||||
if sequence_type:
|
||||
sequence_type_2_14 = etree.SubElement(
|
||||
payment_type_info_2_6, 'SeqTp')
|
||||
sequence_type_2_14.text = sequence_type
|
||||
sequence_type_node = etree.SubElement(
|
||||
payment_type_info, 'SeqTp')
|
||||
sequence_type_node.text = sequence_type
|
||||
|
||||
if gen_args['payment_method'] == 'DD':
|
||||
request_date_tag = 'ReqdColltnDt'
|
||||
else:
|
||||
request_date_tag = 'ReqdExctnDt'
|
||||
requested_date_2_17 = etree.SubElement(
|
||||
payment_info_2_0, request_date_tag)
|
||||
requested_date_2_17.text = requested_date
|
||||
return payment_info_2_0, nb_of_transactions_2_4, control_sum_2_5
|
||||
requested_date_node = etree.SubElement(
|
||||
payment_info, request_date_tag)
|
||||
requested_date_node.text = requested_date
|
||||
return payment_info, nb_of_transactions, control_sum
|
||||
|
||||
@api.model
|
||||
def _must_have_initiating_party(self, gen_args):
|
||||
@@ -273,8 +272,8 @@ class AccountPaymentOrder(models.Model):
|
||||
'Company Name',
|
||||
'self.company_partner_bank_id.partner_id.name',
|
||||
{'self': self}, gen_args.get('name_maxsize'), gen_args=gen_args)
|
||||
initiating_party_1_8 = etree.SubElement(parent_node, 'InitgPty')
|
||||
initiating_party_name = etree.SubElement(initiating_party_1_8, 'Nm')
|
||||
initiating_party = etree.SubElement(parent_node, 'InitgPty')
|
||||
initiating_party_name = etree.SubElement(initiating_party, 'Nm')
|
||||
initiating_party_name.text = my_company_name
|
||||
initiating_party_identifier = (
|
||||
self.payment_mode_id.initiating_party_identifier or
|
||||
@@ -285,7 +284,7 @@ class AccountPaymentOrder(models.Model):
|
||||
# in pain.008.001.02.ch.01.xsd files they use
|
||||
# initiating_party_identifier but not initiating_party_issuer
|
||||
if initiating_party_identifier:
|
||||
iniparty_id = etree.SubElement(initiating_party_1_8, 'Id')
|
||||
iniparty_id = etree.SubElement(initiating_party, 'Id')
|
||||
iniparty_org_id = etree.SubElement(iniparty_id, 'OrgId')
|
||||
iniparty_org_other = etree.SubElement(iniparty_org_id, 'Othr')
|
||||
iniparty_org_other_id = etree.SubElement(iniparty_org_other, 'Id')
|
||||
@@ -340,7 +339,7 @@ class AccountPaymentOrder(models.Model):
|
||||
return True
|
||||
|
||||
@api.model
|
||||
def generate_party_bank_account(
|
||||
def generate_party_acc_number(
|
||||
self, parent_node, party_type, order, partner_bank, gen_args,
|
||||
bank_line=None):
|
||||
party_account = etree.SubElement(
|
||||
@@ -403,7 +402,7 @@ class AccountPaymentOrder(models.Model):
|
||||
'Address Line2', "partner.zip + ' ' + partner.city",
|
||||
{'partner': partner}, 70, gen_args=gen_args)
|
||||
|
||||
self.generate_party_bank_account(
|
||||
self.generate_party_acc_number(
|
||||
parent_node, party_type, order, partner_bank, gen_args,
|
||||
bank_line=bank_line)
|
||||
|
||||
@@ -415,51 +414,52 @@ class AccountPaymentOrder(models.Model):
|
||||
|
||||
@api.model
|
||||
def generate_remittance_info_block(self, parent_node, line, gen_args):
|
||||
remittance_info_2_91 = etree.SubElement(
|
||||
remittance_info = etree.SubElement(
|
||||
parent_node, 'RmtInf')
|
||||
if line.communication_type == 'normal':
|
||||
remittance_info_unstructured_2_99 = etree.SubElement(
|
||||
remittance_info_2_91, 'Ustrd')
|
||||
remittance_info_unstructured_2_99.text = \
|
||||
remittance_info_unstructured = etree.SubElement(
|
||||
remittance_info, 'Ustrd')
|
||||
remittance_info_unstructured.text = \
|
||||
self._prepare_field(
|
||||
'Remittance Unstructured Information',
|
||||
'line.communication', {'line': line}, 140,
|
||||
gen_args=gen_args)
|
||||
else:
|
||||
remittance_info_structured_2_100 = etree.SubElement(
|
||||
remittance_info_2_91, 'Strd')
|
||||
creditor_ref_information_2_120 = etree.SubElement(
|
||||
remittance_info_structured_2_100, 'CdtrRefInf')
|
||||
remittance_info_structured = etree.SubElement(
|
||||
remittance_info, 'Strd')
|
||||
creditor_ref_information = etree.SubElement(
|
||||
remittance_info_structured, 'CdtrRefInf')
|
||||
if gen_args.get('pain_flavor') == 'pain.001.001.02':
|
||||
creditor_ref_info_type_2_121 = etree.SubElement(
|
||||
creditor_ref_information_2_120, 'CdtrRefTp')
|
||||
creditor_ref_info_type_code_2_123 = etree.SubElement(
|
||||
creditor_ref_info_type_2_121, 'Cd')
|
||||
creditor_ref_info_type_code_2_123.text = 'SCOR'
|
||||
creditor_ref_info_type_issuer_2_125 = etree.SubElement(
|
||||
creditor_ref_info_type_2_121, 'Issr')
|
||||
creditor_ref_info_type_issuer_2_125.text = \
|
||||
creditor_ref_info_type = etree.SubElement(
|
||||
creditor_ref_information, 'CdtrRefTp')
|
||||
creditor_ref_info_type_code = etree.SubElement(
|
||||
creditor_ref_info_type, 'Cd')
|
||||
creditor_ref_info_type_code.text = 'SCOR'
|
||||
# SCOR means "Structured Communication Reference"
|
||||
creditor_ref_info_type_issuer = etree.SubElement(
|
||||
creditor_ref_info_type, 'Issr')
|
||||
creditor_ref_info_type_issuer.text = \
|
||||
line.communication_type
|
||||
creditor_reference_2_126 = etree.SubElement(
|
||||
creditor_ref_information_2_120, 'CdtrRef')
|
||||
creditor_reference = etree.SubElement(
|
||||
creditor_ref_information, 'CdtrRef')
|
||||
else:
|
||||
if gen_args.get('structured_remittance_issuer', True):
|
||||
creditor_ref_info_type_2_121 = etree.SubElement(
|
||||
creditor_ref_information_2_120, 'Tp')
|
||||
creditor_ref_info_type_or_2_122 = etree.SubElement(
|
||||
creditor_ref_info_type_2_121, 'CdOrPrtry')
|
||||
creditor_ref_info_type_code_2_123 = etree.SubElement(
|
||||
creditor_ref_info_type_or_2_122, 'Cd')
|
||||
creditor_ref_info_type_code_2_123.text = 'SCOR'
|
||||
creditor_ref_info_type_issuer_2_125 = etree.SubElement(
|
||||
creditor_ref_info_type_2_121, 'Issr')
|
||||
creditor_ref_info_type_issuer_2_125.text = \
|
||||
creditor_ref_info_type = etree.SubElement(
|
||||
creditor_ref_information, 'Tp')
|
||||
creditor_ref_info_type_or = etree.SubElement(
|
||||
creditor_ref_info_type, 'CdOrPrtry')
|
||||
creditor_ref_info_type_code = etree.SubElement(
|
||||
creditor_ref_info_type_or, 'Cd')
|
||||
creditor_ref_info_type_code.text = 'SCOR'
|
||||
creditor_ref_info_type_issuer = etree.SubElement(
|
||||
creditor_ref_info_type, 'Issr')
|
||||
creditor_ref_info_type_issuer.text = \
|
||||
line.communication_type
|
||||
|
||||
creditor_reference_2_126 = etree.SubElement(
|
||||
creditor_ref_information_2_120, 'Ref')
|
||||
creditor_reference = etree.SubElement(
|
||||
creditor_ref_information, 'Ref')
|
||||
|
||||
creditor_reference_2_126.text = \
|
||||
creditor_reference.text = \
|
||||
self._prepare_field(
|
||||
'Creditor Structured Reference',
|
||||
'line.communication', {'line': line}, 35,
|
||||
|
||||
@@ -76,10 +76,10 @@ class AccountPaymentOrder(models.Model):
|
||||
xml_root = etree.Element('Document', nsmap=nsmap, attrib=attrib)
|
||||
pain_root = etree.SubElement(xml_root, root_xml_tag)
|
||||
# A. Group header
|
||||
group_header_1_0, nb_of_transactions_1_6, control_sum_1_7 = \
|
||||
group_header, nb_of_transactions_a, control_sum_a = \
|
||||
self.generate_group_header_block(pain_root, gen_args)
|
||||
transactions_count_1_6 = 0
|
||||
amount_control_sum_1_7 = 0.0
|
||||
transactions_count_a = 0
|
||||
amount_control_sum_a = 0.0
|
||||
lines_per_group = {}
|
||||
# key = (requested_date, priority, local_instrument)
|
||||
# values = list of lines as object
|
||||
@@ -98,7 +98,7 @@ class AccountPaymentOrder(models.Model):
|
||||
for (requested_date, priority, local_instrument), lines in\
|
||||
lines_per_group.items():
|
||||
# B. Payment info
|
||||
payment_info_2_0, nb_of_transactions_2_4, control_sum_2_5 = \
|
||||
payment_info, nb_of_transactions_b, control_sum_b = \
|
||||
self.generate_start_payment_info_block(
|
||||
pain_root,
|
||||
"self.name + '-' "
|
||||
@@ -111,56 +111,56 @@ class AccountPaymentOrder(models.Model):
|
||||
'local_instrument': local_instrument or 'NOinstr',
|
||||
}, gen_args)
|
||||
self.generate_party_block(
|
||||
payment_info_2_0, 'Dbtr', 'B',
|
||||
payment_info, 'Dbtr', 'B',
|
||||
self.company_partner_bank_id, gen_args)
|
||||
charge_bearer_2_24 = etree.SubElement(payment_info_2_0, 'ChrgBr')
|
||||
charge_bearer = etree.SubElement(payment_info, 'ChrgBr')
|
||||
if self.sepa:
|
||||
charge_bearer = 'SLEV'
|
||||
charge_bearer_text = 'SLEV'
|
||||
else:
|
||||
charge_bearer = self.charge_bearer
|
||||
charge_bearer_2_24.text = charge_bearer
|
||||
transactions_count_2_4 = 0
|
||||
amount_control_sum_2_5 = 0.0
|
||||
charge_bearer_text = self.charge_bearer
|
||||
charge_bearer.text = charge_bearer_text
|
||||
transactions_count_b = 0
|
||||
amount_control_sum_b = 0.0
|
||||
for line in lines:
|
||||
transactions_count_1_6 += 1
|
||||
transactions_count_2_4 += 1
|
||||
transactions_count_a += 1
|
||||
transactions_count_b += 1
|
||||
# C. Credit Transfer Transaction Info
|
||||
credit_transfer_transaction_info_2_27 = etree.SubElement(
|
||||
payment_info_2_0, 'CdtTrfTxInf')
|
||||
payment_identification_2_28 = etree.SubElement(
|
||||
credit_transfer_transaction_info_2_27, 'PmtId')
|
||||
end2end_identification_2_30 = etree.SubElement(
|
||||
payment_identification_2_28, 'EndToEndId')
|
||||
end2end_identification_2_30.text = self._prepare_field(
|
||||
credit_transfer_transaction_info = etree.SubElement(
|
||||
payment_info, 'CdtTrfTxInf')
|
||||
payment_identification = etree.SubElement(
|
||||
credit_transfer_transaction_info, 'PmtId')
|
||||
end2end_identification = etree.SubElement(
|
||||
payment_identification, 'EndToEndId')
|
||||
end2end_identification.text = self._prepare_field(
|
||||
'End to End Identification', 'line.name',
|
||||
{'line': line}, 35, gen_args=gen_args)
|
||||
currency_name = self._prepare_field(
|
||||
'Currency Code', 'line.currency_id.name',
|
||||
{'line': line}, 3, gen_args=gen_args)
|
||||
amount_2_42 = etree.SubElement(
|
||||
credit_transfer_transaction_info_2_27, 'Amt')
|
||||
instructed_amount_2_43 = etree.SubElement(
|
||||
amount_2_42, 'InstdAmt', Ccy=currency_name)
|
||||
instructed_amount_2_43.text = '%.2f' % line.amount_currency
|
||||
amount_control_sum_1_7 += line.amount_currency
|
||||
amount_control_sum_2_5 += line.amount_currency
|
||||
amount = etree.SubElement(
|
||||
credit_transfer_transaction_info, 'Amt')
|
||||
instructed_amount = etree.SubElement(
|
||||
amount, 'InstdAmt', Ccy=currency_name)
|
||||
instructed_amount.text = '%.2f' % line.amount_currency
|
||||
amount_control_sum_a += line.amount_currency
|
||||
amount_control_sum_b += line.amount_currency
|
||||
if not line.partner_bank_id:
|
||||
raise UserError(
|
||||
_("Bank account is missing on the bank payment line "
|
||||
"of partner '%s' (reference '%s').")
|
||||
% (line.partner_id.name, line.name))
|
||||
self.generate_party_block(
|
||||
credit_transfer_transaction_info_2_27, 'Cdtr',
|
||||
credit_transfer_transaction_info, 'Cdtr',
|
||||
'C', line.partner_bank_id, gen_args, line)
|
||||
self.generate_remittance_info_block(
|
||||
credit_transfer_transaction_info_2_27, line, gen_args)
|
||||
credit_transfer_transaction_info, line, gen_args)
|
||||
if not pain_flavor.startswith('pain.001.001.02'):
|
||||
nb_of_transactions_2_4.text = unicode(transactions_count_2_4)
|
||||
control_sum_2_5.text = '%.2f' % amount_control_sum_2_5
|
||||
nb_of_transactions_b.text = unicode(transactions_count_b)
|
||||
control_sum_b.text = '%.2f' % amount_control_sum_b
|
||||
if not pain_flavor.startswith('pain.001.001.02'):
|
||||
nb_of_transactions_1_6.text = unicode(transactions_count_1_6)
|
||||
control_sum_1_7.text = '%.2f' % amount_control_sum_1_7
|
||||
nb_of_transactions_a.text = unicode(transactions_count_a)
|
||||
control_sum_a.text = '%.2f' % amount_control_sum_a
|
||||
else:
|
||||
nb_of_transactions_1_6.text = unicode(transactions_count_1_6)
|
||||
control_sum_1_7.text = '%.2f' % amount_control_sum_1_7
|
||||
nb_of_transactions_a.text = unicode(transactions_count_a)
|
||||
control_sum_a.text = '%.2f' % amount_control_sum_a
|
||||
return self.finalize_sepa_file_creation(xml_root, gen_args)
|
||||
|
||||
@@ -81,15 +81,15 @@ class AccountPaymentOrder(models.Model):
|
||||
xml_root = etree.Element('Document', nsmap=nsmap, attrib=attrib)
|
||||
pain_root = etree.SubElement(xml_root, root_xml_tag)
|
||||
# A. Group header
|
||||
group_header_1_0, nb_of_transactions_1_6, control_sum_1_7 = \
|
||||
group_header, nb_of_transactions_a, control_sum_a = \
|
||||
self.generate_group_header_block(pain_root, gen_args)
|
||||
transactions_count_1_6 = 0
|
||||
amount_control_sum_1_7 = 0.0
|
||||
transactions_count_a = 0
|
||||
amount_control_sum_a = 0.0
|
||||
lines_per_group = {}
|
||||
# key = (requested_date, priority, sequence type)
|
||||
# value = list of lines as objects
|
||||
for line in self.bank_line_ids:
|
||||
transactions_count_1_6 += 1
|
||||
transactions_count_a += 1
|
||||
priority = line.priority
|
||||
# The field line.date is the requested payment date
|
||||
# taking into account the 'date_prefered' setting
|
||||
@@ -138,7 +138,7 @@ class AccountPaymentOrder(models.Model):
|
||||
for (requested_date, priority, sequence_type, scheme), lines in \
|
||||
lines_per_group.items():
|
||||
# B. Payment info
|
||||
payment_info_2_0, nb_of_transactions_2_4, control_sum_2_5 = \
|
||||
payment_info, nb_of_transactions_b, control_sum_b = \
|
||||
self.generate_start_payment_info_block(
|
||||
pain_root,
|
||||
"self.name + '-' + "
|
||||
@@ -152,80 +152,80 @@ class AccountPaymentOrder(models.Model):
|
||||
}, gen_args)
|
||||
|
||||
self.generate_party_block(
|
||||
payment_info_2_0, 'Cdtr', 'B',
|
||||
payment_info, 'Cdtr', 'B',
|
||||
self.company_partner_bank_id, gen_args)
|
||||
charge_bearer_2_24 = etree.SubElement(payment_info_2_0, 'ChrgBr')
|
||||
charge_bearer = etree.SubElement(payment_info, 'ChrgBr')
|
||||
if self.sepa:
|
||||
charge_bearer = 'SLEV'
|
||||
charge_bearer_text = 'SLEV'
|
||||
else:
|
||||
charge_bearer = self.charge_bearer
|
||||
charge_bearer_2_24.text = charge_bearer
|
||||
creditor_scheme_identification_2_27 = etree.SubElement(
|
||||
payment_info_2_0, 'CdtrSchmeId')
|
||||
charge_bearer_text = self.charge_bearer
|
||||
charge_bearer.text = charge_bearer_text
|
||||
creditor_scheme_identification = etree.SubElement(
|
||||
payment_info, 'CdtrSchmeId')
|
||||
self.generate_creditor_scheme_identification(
|
||||
creditor_scheme_identification_2_27,
|
||||
creditor_scheme_identification,
|
||||
'self.payment_mode_id.sepa_creditor_identifier or '
|
||||
'self.company_id.sepa_creditor_identifier',
|
||||
'SEPA Creditor Identifier', {'self': self}, 'SEPA', gen_args)
|
||||
transactions_count_2_4 = 0
|
||||
amount_control_sum_2_5 = 0.0
|
||||
transactions_count_b = 0
|
||||
amount_control_sum_b = 0.0
|
||||
for line in lines:
|
||||
transactions_count_2_4 += 1
|
||||
transactions_count_b += 1
|
||||
# C. Direct Debit Transaction Info
|
||||
dd_transaction_info_2_28 = etree.SubElement(
|
||||
payment_info_2_0, 'DrctDbtTxInf')
|
||||
payment_identification_2_29 = etree.SubElement(
|
||||
dd_transaction_info_2_28, 'PmtId')
|
||||
dd_transaction_info = etree.SubElement(
|
||||
payment_info, 'DrctDbtTxInf')
|
||||
payment_identification = etree.SubElement(
|
||||
dd_transaction_info, 'PmtId')
|
||||
if pain_flavor == 'pain.008.001.02.ch.01':
|
||||
instruction_identification = etree.SubElement(
|
||||
payment_identification_2_29, 'InstrId')
|
||||
payment_identification, 'InstrId')
|
||||
instruction_identification.text = self._prepare_field(
|
||||
'Intruction Identification', 'line.name',
|
||||
{'line': line}, 35, gen_args=gen_args)
|
||||
end2end_identification_2_31 = etree.SubElement(
|
||||
payment_identification_2_29, 'EndToEndId')
|
||||
end2end_identification_2_31.text = self._prepare_field(
|
||||
end2end_identification = etree.SubElement(
|
||||
payment_identification, 'EndToEndId')
|
||||
end2end_identification.text = self._prepare_field(
|
||||
'End to End Identification', 'line.name',
|
||||
{'line': line}, 35, gen_args=gen_args)
|
||||
currency_name = self._prepare_field(
|
||||
'Currency Code', 'line.currency_id.name',
|
||||
{'line': line}, 3, gen_args=gen_args)
|
||||
instructed_amount_2_44 = etree.SubElement(
|
||||
dd_transaction_info_2_28, 'InstdAmt', Ccy=currency_name)
|
||||
instructed_amount_2_44.text = '%.2f' % line.amount_currency
|
||||
amount_control_sum_1_7 += line.amount_currency
|
||||
amount_control_sum_2_5 += line.amount_currency
|
||||
dd_transaction_2_46 = etree.SubElement(
|
||||
dd_transaction_info_2_28, 'DrctDbtTx')
|
||||
mandate_related_info_2_47 = etree.SubElement(
|
||||
dd_transaction_2_46, 'MndtRltdInf')
|
||||
mandate_identification_2_48 = etree.SubElement(
|
||||
mandate_related_info_2_47, 'MndtId')
|
||||
mandate_identification_2_48.text = self._prepare_field(
|
||||
instructed_amount = etree.SubElement(
|
||||
dd_transaction_info, 'InstdAmt', Ccy=currency_name)
|
||||
instructed_amount.text = '%.2f' % line.amount_currency
|
||||
amount_control_sum_a += line.amount_currency
|
||||
amount_control_sum_b += line.amount_currency
|
||||
dd_transaction = etree.SubElement(
|
||||
dd_transaction_info, 'DrctDbtTx')
|
||||
mandate_related_info = etree.SubElement(
|
||||
dd_transaction, 'MndtRltdInf')
|
||||
mandate_identification = etree.SubElement(
|
||||
mandate_related_info, 'MndtId')
|
||||
mandate_identification.text = self._prepare_field(
|
||||
'Unique Mandate Reference',
|
||||
'line.mandate_id.unique_mandate_reference',
|
||||
{'line': line}, 35, gen_args=gen_args)
|
||||
mandate_signature_date_2_49 = etree.SubElement(
|
||||
mandate_related_info_2_47, 'DtOfSgntr')
|
||||
mandate_signature_date_2_49.text = self._prepare_field(
|
||||
mandate_signature_date = etree.SubElement(
|
||||
mandate_related_info, 'DtOfSgntr')
|
||||
mandate_signature_date.text = self._prepare_field(
|
||||
'Mandate Signature Date',
|
||||
'line.mandate_id.signature_date',
|
||||
{'line': line}, 10, gen_args=gen_args)
|
||||
if sequence_type == 'FRST' and line.mandate_id.last_debit_date:
|
||||
previous_bank = self._get_previous_bank(line)
|
||||
if previous_bank:
|
||||
amendment_indicator_2_50 = etree.SubElement(
|
||||
mandate_related_info_2_47, 'AmdmntInd')
|
||||
amendment_indicator_2_50.text = 'true'
|
||||
amendment_info_details_2_51 = etree.SubElement(
|
||||
mandate_related_info_2_47, 'AmdmntInfDtls')
|
||||
amendment_indicator = etree.SubElement(
|
||||
mandate_related_info, 'AmdmntInd')
|
||||
amendment_indicator.text = 'true'
|
||||
amendment_info_details = etree.SubElement(
|
||||
mandate_related_info, 'AmdmntInfDtls')
|
||||
if (
|
||||
previous_bank.bank_bic ==
|
||||
line.partner_bank_id.bank_bic):
|
||||
ori_debtor_account_2_57 = etree.SubElement(
|
||||
amendment_info_details_2_51, 'OrgnlDbtrAcct')
|
||||
ori_debtor_account = etree.SubElement(
|
||||
amendment_info_details, 'OrgnlDbtrAcct')
|
||||
ori_debtor_account_id = etree.SubElement(
|
||||
ori_debtor_account_2_57, 'Id')
|
||||
ori_debtor_account, 'Id')
|
||||
ori_debtor_account_iban = etree.SubElement(
|
||||
ori_debtor_account_id, 'IBAN')
|
||||
ori_debtor_account_iban.text = self._validate_iban(
|
||||
@@ -235,10 +235,10 @@ class AccountPaymentOrder(models.Model):
|
||||
{'previous_bank': previous_bank},
|
||||
gen_args=gen_args))
|
||||
else:
|
||||
ori_debtor_agent_2_58 = etree.SubElement(
|
||||
amendment_info_details_2_51, 'OrgnlDbtrAgt')
|
||||
ori_debtor_agent = etree.SubElement(
|
||||
amendment_info_details, 'OrgnlDbtrAgt')
|
||||
ori_debtor_agent_institution = etree.SubElement(
|
||||
ori_debtor_agent_2_58, 'FinInstnId')
|
||||
ori_debtor_agent, 'FinInstnId')
|
||||
ori_debtor_agent_bic = etree.SubElement(
|
||||
ori_debtor_agent_institution, bic_xml_tag)
|
||||
ori_debtor_agent_bic.text = self._prepare_field(
|
||||
@@ -254,16 +254,16 @@ class AccountPaymentOrder(models.Model):
|
||||
# SMNDA = Same Mandate New Debtor Agent
|
||||
|
||||
self.generate_party_block(
|
||||
dd_transaction_info_2_28, 'Dbtr', 'C',
|
||||
dd_transaction_info, 'Dbtr', 'C',
|
||||
line.partner_bank_id, gen_args, line)
|
||||
|
||||
self.generate_remittance_info_block(
|
||||
dd_transaction_info_2_28, line, gen_args)
|
||||
dd_transaction_info, line, gen_args)
|
||||
|
||||
nb_of_transactions_2_4.text = unicode(transactions_count_2_4)
|
||||
control_sum_2_5.text = '%.2f' % amount_control_sum_2_5
|
||||
nb_of_transactions_1_6.text = unicode(transactions_count_1_6)
|
||||
control_sum_1_7.text = '%.2f' % amount_control_sum_1_7
|
||||
nb_of_transactions_b.text = unicode(transactions_count_b)
|
||||
control_sum_b.text = '%.2f' % amount_control_sum_b
|
||||
nb_of_transactions_a.text = unicode(transactions_count_a)
|
||||
control_sum_a.text = '%.2f' % amount_control_sum_a
|
||||
|
||||
return self.finalize_sepa_file_creation(
|
||||
xml_root, gen_args)
|
||||
|
||||
Reference in New Issue
Block a user