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

More reconciliation fixes for spaces, turns out it can be larger than 2. #1013

Merged
merged 3 commits into from
Nov 16, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async def _process_jv_details_feedback(ejv_file, has_errors, line, receipt_numbe
journal_name: str = line[7:17] # {ministry}{ejv_header_model.id:0>8}
ejv_header_model_id = int(journal_name[2:])
# Work around for CAS, they said fix the feedback files.
line = line[:313] + ' ' + line[313:] if line[313:315] == '00' else line
line = _fix_invoice_line(line)
invoice_id = int(line[205:315])
invoice: InvoiceModel = InvoiceModel.find_by_id(invoice_id)
invoice_link: EjvInvoiceLinkModel = db.session.query(EjvInvoiceLinkModel).filter(
Expand Down Expand Up @@ -243,6 +243,15 @@ async def _process_jv_details_feedback(ejv_file, has_errors, line, receipt_numbe
return has_errors


def _fix_invoice_line(line):
"""Work around for CAS, they said fix the feedback files."""
# Check for zeros within 300->315 range. Bump them over with spaces.
if (zero_position := line[300:315].find('0')) > -1:
spaces_to_insert = 15 - zero_position
return line[:300+zero_position] + (' ' * spaces_to_insert) + line[300+zero_position:]
return line


async def _update_invoice_status(invoice):
"""Update status to reversed if its a refund, else to completed."""
if invoice.invoice_status_code in (InvoiceStatus.REFUNDED.value, InvoiceStatus.REFUND_REQUESTED.value):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,19 +526,19 @@ async def test_succesful_payment_ejv_reconciliations(session, app, stan_server,
f'..JD...FI0000000{ejv_header.id}00001........................................................' \
f'...........{pay_line_amount}D.................................................................' \
f'...................................{inv.id} ' \
f' 0000........................' \
f' 0000........................' \
f'............................................................................................' \
f'..................................CGI\n' \
f'..JD...FI0000000{ejv_header.id}00002........................................................' \
f'...........{pay_line_amount}C.................................................................' \
f'...................................{inv.id} ' \
f' 0000........................' \
f' 0000........................' \
f'............................................................................................' \
f'..................................CGI\n' \
f'..JD...FI0000000{ejv_header.id}00003...........................................................' \
f'........{service_fee_amount}D.................................................................' \
f'...................................{inv.id} ' \
f' 0000........................' \
f' 0000........................' \
f'............................................................................................' \
f'..................................CGI\n' \
f'..JD...FI0000000{ejv_header.id}00004........................................................' \
Expand Down