Skip to content

Commit

Permalink
18730 - Add invoice id to description, because it doesn't show up in …
Browse files Browse the repository at this point in the history
…flow thr… (#1327)

* Add invoice id to description, because it doesn't show up in flow through.

* Add in extra space

* Enhance disbursements and EJV to include invoice ids
  • Loading branch information
seeker25 authored Nov 23, 2023
1 parent c645340 commit c671f95
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions jobs/payment-jobs/tasks/ejv_partner_distribution_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,19 @@ def _create_ejv_file_for_partner(cls, batch_type: str): # pylint:disable=too-ma
is_reversal = InvoiceModel.find_by_id(line.invoice_id).invoice_status_code in \
(InvoiceStatus.REFUNDED.value, InvoiceStatus.REFUND_REQUESTED.value)

invoice_number = f'#{line.invoice_id}'
description = disbursement_desc[:-len(invoice_number)] + invoice_number
description = f'{description[:100]:<100}'
ejv_content = '{}{}'.format(ejv_content, # pylint:disable=consider-using-f-string
cls.get_jv_line(batch_type, credit_distribution, disbursement_desc,
cls.get_jv_line(batch_type, credit_distribution, description,
effective_date, flow_through, journal_name, line.total,
line_number, 'C' if not is_reversal else 'D'))
line_number += 1
control_total += 1

# Add a line here for debit too
ejv_content = '{}{}'.format(ejv_content, # pylint:disable=consider-using-f-string
cls.get_jv_line(batch_type, debit_distribution, disbursement_desc,
cls.get_jv_line(batch_type, debit_distribution, description,
effective_date, flow_through, journal_name, line.total,
line_number, 'D' if not is_reversal else 'C'))

Expand Down
11 changes: 7 additions & 4 deletions jobs/payment-jobs/tasks/ejv_payment_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def _create_ejv_file_for_gov_account(cls, batch_type: str): # pylint:disable=to
inv_ref.status_code = InvoiceReferenceStatus.CANCELLED.value

line_items = inv.payment_line_items
invoice_number = f'#{inv.id}'
description = disbursement_desc[:-len(invoice_number)] + invoice_number
description = f'{description[:100]:<100}'

for line in line_items:
# Line can have 2 distribution, 1 for the total and another one for service fees.
Expand All @@ -126,7 +129,7 @@ def _create_ejv_file_for_gov_account(cls, batch_type: str): # pylint:disable=to
control_total += 1
# If it's normal payment then the Line distribution goes as Credit,
# else it goes as Debit as we need to debit the fund from BC registry GL.
account_jv = account_jv + cls.get_jv_line(batch_type, line_distribution, disbursement_desc,
account_jv = account_jv + cls.get_jv_line(batch_type, line_distribution, description,
effective_date, flow_through, journal_name,
line.total,
line_number, 'C' if not is_jv_reversal else 'D')
Expand All @@ -136,7 +139,7 @@ def _create_ejv_file_for_gov_account(cls, batch_type: str): # pylint:disable=to
control_total += 1
# If it's normal payment then the Gov account GL goes as Debit,
# else it goes as Credit as we need to credit the fund back to ministry.
account_jv = account_jv + cls.get_jv_line(batch_type, debit_distribution, disbursement_desc,
account_jv = account_jv + cls.get_jv_line(batch_type, debit_distribution, description,
effective_date, flow_through, journal_name,
line.total,
line_number, 'D' if not is_jv_reversal else 'C')
Expand All @@ -150,15 +153,15 @@ def _create_ejv_file_for_gov_account(cls, batch_type: str): # pylint:disable=to
line_number += 1
control_total += 1
account_jv = account_jv + cls.get_jv_line(batch_type, service_fee_distribution,
disbursement_desc,
description,
effective_date, flow_through, journal_name,
line.service_fees,
line_number, 'C' if not is_jv_reversal else 'D')

# Debit from GOV ACCOUNT GL
line_number += 1
control_total += 1
account_jv = account_jv + cls.get_jv_line(batch_type, debit_distribution, disbursement_desc,
account_jv = account_jv + cls.get_jv_line(batch_type, debit_distribution, description,
effective_date, flow_through, journal_name,
line.service_fees,
line_number, 'D' if not is_jv_reversal else 'C')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def _set_invoice_jv_reversal(invoice: InvoiceModel, is_reversal: bool):
else:
invoice.invoice_status_code = InvoiceStatus.PAID.value
invoice.payment_date = datetime.now()
invoice.paid = invoice.total


def _fix_invoice_line(line):
Expand Down

0 comments on commit c671f95

Please sign in to comment.