diff --git a/report-api/report-templates/generic_footer.html b/report-api/report-templates/generic_footer.html index 8f028fe2..bfc48d5c 100644 --- a/report-api/report-templates/generic_footer.html +++ b/report-api/report-templates/generic_footer.html @@ -33,7 +33,7 @@ {% endif %} {% endif %} {% endif %} - {% elif statement and statement.is_interim_statement %} + {% elif statement and statement.isInterimStatement %} Interim Account Statement #{{statement.id}} {% elif statement %} Account Statement #{{statement.id}} diff --git a/report-api/report-templates/statement_details.html b/report-api/report-templates/statement_details.html index eb3e53d8..184ff2ab 100644 --- a/report-api/report-templates/statement_details.html +++ b/report-api/report-templates/statement_details.html @@ -4,34 +4,6 @@
Account Number: {{ account.id }}
- {% if not summary_header_text and groupedInvoices %} - {% if payment_method == 'PAD' %} -
Pre-Authorized Debit Totals: ${{ '%.2f' % data.totals_summary }}
-
Amount Owing: ${{ '%.2f' % data.due_summary }}
- {% elif payment_method == 'ONLINE_BANKING' %} -
Online Banking Totals: ${{ '%.2f' % data.totals_summary }}
- {% elif payment_method in ['DIRECT_PAY', 'CC'] %} -
Credit Card Totals: ${{ '%.2f' % data.totals_summary }}
- {% elif payment_method == 'DRAWDOWN' %} -
BC OnLine Totals: ${{ '%.2f' % data.totals_summary }}
- {% elif payment_method == 'EJV' %} -
Electronic Journal Voucher Totals: ${{ '%.2f' % data.totals_summary }}
- {% endif %} - {% if eft_payment %} -
EFT Totals: ${{ '%.2f' % data.totals_summary }}
-
Amount Owing: ${{ '%.2f' % data.due_summary }}
- {% if statementSummary.dueDate %} -
Payment Due Date: {{ statementSummary.dueDate }}
- {% endif %} - {% else %} -
Amount Paid: ${{ '%.2f' % data.paid_summary }}
- {% endif %} - {% if statement.is_interim_statement and payment_method == 'EFT' %} -
Payment Received Date: - {{ statementSummary.latestStatementPaymentDate }} -
- {% endif %} - {% endif %}
Statement Number: {{statement.id}}
diff --git a/report-api/report-templates/statement_header.html b/report-api/report-templates/statement_header.html index 7885e086..3ea603e0 100644 --- a/report-api/report-templates/statement_header.html +++ b/report-api/report-templates/statement_header.html @@ -25,7 +25,7 @@ {% if is_payment_instructions %}
BC Registries And Online Services
- {% elif statement.from_date or statement.to_date %} + {% elif statement.fromDate or statement.toDate %}
{{ statement.duration }}
@@ -36,7 +36,7 @@ {% if not is_payment_instructions %} -
{{ account.name|upper }}
+
ACCOUNT NAME: {{ account.name|upper }}
diff --git a/report-api/report-templates/statement_report.html b/report-api/report-templates/statement_report.html index 7f61e76e..88aafcd0 100644 --- a/report-api/report-templates/statement_report.html +++ b/report-api/report-templates/statement_report.html @@ -67,6 +67,15 @@ width: 100%; } + .statement-totals{ + border: 3px solid #e2e7ed; + margin-top: 20px; + border-collapse: separate; + border-spacing: 0 0; + padding-top: 15px; + padding-bottom: 15px; + } + .wordmark { font-family: Georgia, 'Times New Roman', Times, serif; } @@ -276,12 +285,17 @@ .transaction-table { margin: 0px 24px 16px; width: 690px; + border-bottom: 1px solid #bcbec5; } .transaction-table thead tr, .transaction-table tbody tr { line-height: 3; font-size: 12px; + border-top: 1px solid #bcbec5; + } + .transaction-table tbody tr.no-top-border { + border-top: transparent; border-bottom: 1px solid #bcbec5; } @@ -324,12 +338,43 @@ border-bottom: 1px solid #b3bac3; } - .total-elements_no_border { + .total-elements-top-border { + margin: 10px 24px 0 24px; + padding: 10px 0; + font-size: 14px; + border-top: 1px solid #b3bac3; + } + + .total-elements-bottom-border { + margin: 0px 24px; + font-size: 14px; + padding-bottom: 10px; + border-bottom: 2px solid #b3bac3; + } + + .total-elements-no-border { margin: 0px 24px; font-size: 14px; border-bottom: none; } + .transaction-summary-row { + margin: 0px 24px; + padding: 10px 0; + font-size: 14px; + border-bottom: 2px solid #b3bac3; + } + + .total-elements-last-row { + margin: 0px 24px; + padding: 0 0 10px 0; + border: none; + } + + .statement-subline{ + margin-left: 60px; + } + .total-elements-price { float: right; font-family: 'BCSans-Regular', sans-serif; @@ -414,36 +459,36 @@ - {% for data in groupedInvoices %} - {% set payment_method = data.payment_method %} - {% set transactions = data.transactions %} - {% set total_paid = data.total_paid %} - {% set latest_payment_date = data.latest_payment_date if 'latest_payment_date' in data else None %} - {% set due_date = data.due_date if 'due_date' in data else None %} - {% set eft_payment = payment_method == 'EFT' %} - {% set statement_header_text = data.statement_header_text %} - {% set include_service_provided = data.include_service_provided %} -
- {% include 'report-templates/statement_header.html' with context %} -
- - {% include 'report-templates/statement_details.html' with context %} - {% include 'report-templates/statement_transactions.html' with context %} - {% endfor %} - {% if not groupedInvoices %} + {% if not groupedInvoices or groupedInvoices|length == 0 %}
{% include 'report-templates/statement_header.html' %}
{% include 'report-templates/statement_details.html' %} {% include 'report-templates/statement_transactions.html' %} - {% endif %} + {% else %} + {% for data in groupedInvoices %} + {% set payment_method = data.paymentMethod %} + {% set transactions = data.transactions %} + {% set total_paid = data.total_paid %} + {% set latest_payment_date = data.latestPaymentDate if 'latest_payment_date' in data else None %} + {% set due_date = data.dueDate if 'due_date' in data else None %} + {% set eft_payment = payment_method == 'EFT' %} + {% set statement_header_text = data.statementHeaderText %} + {% set include_service_provided = data.includeServiceProvided %} +
+ {% include 'report-templates/statement_header.html' with context %} +
+ {% include 'report-templates/statement_details.html' with context %} + {% include 'report-templates/statement_transactions.html' with context %} + {% endfor %} + {% endif %} {% for data in groupedInvoices %} - {% if hasPaymentInstructions and data.payment_method == 'EFT' %} + {% if hasPaymentInstructions and data.paymentMethod == 'EFT' %} {% set payment_method = 'EFT' %} {% set is_payment_instructions = true %} -
+
{% include 'report-templates/statement_header.html' %}

Payment Instructions

diff --git a/report-api/report-templates/statement_transactions.html b/report-api/report-templates/statement_transactions.html index adc73845..875feb90 100644 --- a/report-api/report-templates/statement_transactions.html +++ b/report-api/report-templates/statement_transactions.html @@ -1,168 +1,143 @@
- - - - - - - -
-
- Transactions -
-
-
- Number of Transactions: {{ transactions|length }} -
-
- {% if transactions %} - - - - - - - - - - - {% for row in transactions %} +
Product PurchasedFolioDateFeeService FeeGSTTotal
+ {% if payment_method in ['EFT', 'PAD'] %} - - - - - - - + - {% endfor %} -
- {% for product in row.products %} -
{{ product }}
- {% endfor %} - {% if row.details %} -
- {% for detail in row.details %} -
{{ detail }}
- {% endfor %} -
- {% endif %} -
{{ row.folio }}{{ row.created_on }}${{ row.fee }}${{ row.service_fee }}${{ row.gst }} - ${{ row.total }} - {% if row.status_code == 'APPROVED' %} -
(Pending) - {% endif %} -
+
Previous Statement
+
- {% endif %} - + + + + + + + + + + {% endif %} - {% if data and data.refunds_total %} + {% if data and data.countedRefund != '0.00' and payment_method != 'PAD' %} + {% set refund_label = 'Credits received' + if payment_method in ['ONLINE_BANKING'] + else 'Refunds received' %} + + + + {% endif %} + {% if data and data.creditsApplied and data.creditsApplied != "0.00" %} {% endif %} - {% if data and data.credits_total %} + {% if payment_method == 'PAD' %} + + + {% endif %} + {% if payment_method == 'EFT' %} - {% if payment_method == 'EFT' %} - - + - - - - - {% if statementSummary.cancelledTransactions %} - - - - {% endif %} - - {% if statement.is_interim_statement %} + {% endif %} + + + {% endif %} + {% if payment_method == 'EFT' %} + {% if statement.isInterimStatement %} {% endif %} - - - {% else %} - - - - {% if payment_method == 'DIRECT_PAY' or payment_method == 'CC' or payment_method == 'EFT' or payment_method == 'ONLINE_BANKING' %} + {% if payment_method == 'DIRECT_PAY' or payment_method == 'CC' or payment_method == 'ONLINE_BANKING' %} {% endif %} {% endif %} - {% if payment_method == 'PAD' %} - {% if data.due_summary %} + {% if payment_method in ['DIRECT_PAY', 'CC'] %} + + + + {% elif payment_method == 'ONLINE_BANKING' %} + + + + {% elif payment_method == 'DRAWDOWN' %} + + + + {% endif %} +
+
+ Previous Balance: + ${{ statementSummary.lastStatementTotal if statementSummary.lastStatementTotal else '0.00' }} +
+
+
+ Payments received ({{ statementSummary.latestStatementPaymentDate or statement.duration }}) + {{ '$0.00' if not statementSummary.lastStatementPaidAmount or statementSummary.lastStatementPaidAmount == '0.00' else '-$' + statementSummary.lastStatementPaidAmount }} +
+
+
+ Balance Forward (From {{ statement.toDate }}): + ${{ statementSummary.balanceForward }} +
+
-
- {% if payment_method == 'PAD' %} - Pre-Authorized Debit Totals - {% elif payment_method == 'ONLINE_BANKING' %} - Online Banking Totals - {% elif payment_method == 'CC' or pm == 'DIRECT_PAY' %} - Credit Card Totals - {% elif payment_method == 'DRAWDOWN' %} - BC OnLine Totals - {% elif payment_method == 'EJV' %} - Electronic Journal Voucher Totals - {% elif payment_method == 'EFT' %} - Electronic Funds Transfer Totals - {% else %} - Totals - {% endif %} -
+
Current Statement
-
+
Fees: - ${{ '%.2f' % (data.fees_total if data else 0.0) }} + ${{ data.fees if data else '0.0' }}
-
+
Service Fees: - ${{ '%.2f' % (data.service_fees_total if data else 0.0) }} + ${{ data.serviceFees if data else '0.0' }}
-
- GST: - ${{ '%.2f' % (data.gst_total if data else 0.0) }} +
+ GST (Reg Number 107864738): + ${{ data.gst if data else '0.0' }}
+
+ {{ refund_label }} (from {{ statement.duration }}): + {{ '$0.00' if not data or data.countedRefund == '0.00' else '-$' + data.countedRefund }} +
+
-
- Refunds Received: - ${{ '%.2f' % (data.refunds_total if data else 0.0) }} +
+ Credits applied (from {{statement.duration}}): + {{ '$0.00' if not data or data.creditsApplied == '0.00' else '-$' + data.creditsApplied }}
-
- Credits Received: - ${{ '%.2f' % (data.credits_total if data else 0.0) }} +
+ Current Statement Total: + ${{ data.totals if data else '0.0' }}
+
+ Pre-Authorized Debit Amount Processed: + {{ '$0.00' if not data or data.paid == '0.00' else '-$' + data.paid }} +
+
-
- Total: - ${{ '%.2f' % (data.totals_summary if data else 0.0) }} +
+ Current Statement Total: + ${{ data.totals if data else '0.0' }}
-
- Last Statement Total: - ${{ statementSummary.lastStatementTotal }} + {% endif %} + {% if data.due and payment_method in ['EFT', 'PAD'] %} +
+
+ Total Amount Due: + ${{ data.due }} +
+ {% if payment_method == 'EFT' %} +
+ Payment Due Date: + {{ data.dueDate }}
-
-
- Payment Received for Last Statement: - -${{ statementSummary.lastStatementPaidAmount }} + {% else %} +
+ Will be withdrawn within 1-3 business days after the transaction date.
-
-
- Cancelled Transactions: - -${{ statementSummary.cancelledTransactions }} -
-
Total Amount Paid: - ${{ data.paid_summary }} + ${{ data.paid }}
{% if statementSummary.latestStatementPaymentDate %}
Paid on {{ statementSummary.latestStatementPaymentDate }}
@@ -170,70 +145,193 @@
-
- Total Amount Owing: - ${{ '%.2f' % data.due_summary }} -
- {% if not statement.is_interim_statement %} -
Payment Due Date: {{ statementSummary.dueDate }}
- {% endif %} -
-
- Amount Paid: - ${{ '%.2f' % (data.paid_summary if data else 0.0) }} -
-
Total Amount Due: - ${{ '%.2f' % (data.due_summary if data else 0.0) }} + ${{ data.due if data else '0.0' }}
+
+ CREDIT CARD TOTAL: + ${{ data.totals if data else '0.0' }} +
+
+ Fees charged to credit card +
+
+
+ ONLINE BANKING TOTAL: + ${{ data.totals if data else '0.0' }} +
+
+ Fees paid by online banking +
+
+
+ BC ONLINE TOTAL: + ${{ data.totals if data else '0.0' }} +
+
+ Fees for BC Registries and Online Services are deducted from the BC Online account. +
+
+ + + + + + + +
+
+ Transactions from {{ statement.duration }} +
+
+
+ Number of Transactions: {{ transactions|length }} +
+
+ {% if transactions %} + + + + + + + + + + + {% for row in transactions %} - - - {% endif %} - {% if statementSummary.lastPADStatementPaidAmount %} - - + + + + + + {% if row.appliedCredits %} + + + + + + + + + {% endif %} - {% endif %} + {% set status_text = { + 'CANCELLED': 'Service Cancelled', + 'REFUNDED': 'Refunded', + 'CREDITED': 'Credited', + 'PARTIALLY_REFUNDED': 'Partially Refunded', + 'PARTIALLY_CREDITED': 'Partially Credited' + } %} + {% if row.statusCode in status_text %} + + + + + + + + + + {% endif %} + {% endfor %} +
Product PurchasedFolioDateFeeService FeeGSTTotal
-
- Total Amount Owing: - ${{ '%.2f' % data.due_summary }} -
+
+ {% for product in row.products %} +
{{ product }}
+ {% endfor %} + {% if row.details %} +
+ {% for detail in row.details %} +
{{ detail }}
+ {% endfor %} +
+ {% endif %}
-
- Payment Received for Pending Transactions on Last Statement: - -${{ '%.2f' % statementSummary.lastPADStatementPaidAmount }} -
+
{{ row.folio }}{{ row.createdOn }}${{ row.fee }}${{ row.serviceFee }}${{ row.gst }} + ${{ row.total }} + {% if row.statusCode == 'APPROVED' and payment_method == 'PAD' %} +
(Pending) + {% endif %}
+
Account Credit Applied
+
+ {% if row.isFullAppliedCredits %} +
{{ '$0.00' if row.fee == '0.00' else '-$' + row.fee }}
+ {% else %} +
{{ '$0.00' if row.appliedCreditsAmount == '0.00' else '-$' + row.appliedCreditsAmount }}
+ {% endif %} +
+ {% if row.isFullAppliedCredits %} +
{{ '$0.00' if row.serviceFee == '0.00' else '-$' + row.serviceFee }}
+ {% endif %} +
+ {% if row.isFullAppliedCredits %} +
{{ '$0.00' if row.gst == '0.00' else '-$' + row.gst }}
+ {% endif %} +
+
{{ '$0.00' if row.appliedCreditsAmount == '0.00' else '-$' + row.appliedCreditsAmount }}
+
+ {% for product in row.products %} +
{{ product }} ({{ status_text[row.statusCode] }})
+ {% endfor %} + {% if row.details %} +
+ {% for detail in row.details %} +
{{ detail }}
+ {% endfor %} +
+ {% endif %} + {% if row.statusCode in ['REFUNDED', 'CREDITED', 'PARTIALLY_REFUNDED', 'PARTIALLY_CREDITED'] %} +
Refund Transaction ID: {{ row.refundId }}
+ {% endif %} +
{{ row.folio }}{{ row.refundDate }}{{ '$0.00' if row.refundFee == '0.00' else '-$' + row.refundFee }}{{ '$0.00' if row.refundServiceFee == '0.00' else '-$' + row.refundServiceFee }}{{ '$0.00' if row.refundGst == '0.00' else '-$' + row.refundGst }}{{ '$0.00' if row.refundTotal == '0.00' else '-$' + row.refundTotal }}
+ + +
+ Current Statement Total: + ${{ data.totals if data else '0.0' }} +
+ + + {% endif %} + {% if include_service_provided and payment_method == 'PAD' %} {% endif %} - {% if include_service_provided and payment_method in ('ONLINE_BANKING', 'CC', 'BCOL', 'DRAWDOWN', 'DIRECT_PAY', 'INTERNAL') %} + {% if payment_method in ('ONLINE_BANKING', 'CC', 'BCOL', 'DRAWDOWN', 'DIRECT_PAY', 'INTERNAL') %}

This statement lists only the products and services provided. To view the status of all transactions, please refer to the transaction page in your account settings.

-

The 'Total Amount Owing' indicates the amount that will be automatically debited from your PAD bank account within 1-3 business days. Please ensure sufficient funds are available. If a payment fails, a non-sufficient funds (NSF) fee of $30.00 may be applied for each failed attempt.

+

The 'Pre-Authorized Debit Amount' indicates the amount that will be automatically debited from your PAD bank account within 1-3 business days. Please ensure sufficient funds are available. If a payment fails, a non-sufficient funds (NSF) fee of $30.00 may be applied for each failed attempt.

diff --git a/report-api/src/api/services/chunk_report_service.py b/report-api/src/api/services/chunk_report_service.py index 78db2825..b9cb208b 100644 --- a/report-api/src/api/services/chunk_report_service.py +++ b/report-api/src/api/services/chunk_report_service.py @@ -83,7 +83,7 @@ def _build_chunk_html( chunk_info: 'ChunkReportService.ChunkInfo', ) -> str: chunk_vars = template_vars.copy() - chunk_vars['groupedInvoices'] = [invoice_copy] + chunk_vars['grouped_invoices'] = [invoice_copy] chunk_vars['_chunk_info'] = asdict(chunk_info) sanitized_name = sanitize_template_name(template_name) @@ -144,7 +144,7 @@ def create_chunk_report( if chunk_size is None: chunk_size = 500 # the optimal chunk size is 500 after testing - grouped_invoices = template_vars.get('groupedInvoices', []) + grouped_invoices = template_vars.get('grouped_invoices', []) temp_files: List[str] = [] # Build all chunk HTMLs ahead of time (keep order id) diff --git a/report-api/src/api/services/report_service.py b/report-api/src/api/services/report_service.py index 415d8adf..28198e65 100644 --- a/report-api/src/api/services/report_service.py +++ b/report-api/src/api/services/report_service.py @@ -64,9 +64,9 @@ def _finalize_pdf( html_out: str, generate_page_number: bool, ) -> bytes: - """Route to chunk only when statement_report has groupedInvoices; else render directly.""" + """Route to chunk only when statement_report has grouped_invoices; else render directly.""" is_statement = 'statement_report' in (template_name or '') - has_grouped_invoices = bool((template_args or {}).get('groupedInvoices')) + has_grouped_invoices = bool((template_args or {}).get('grouped_invoices')) if is_statement and has_grouped_invoices: return ChunkReportService.create_chunk_report( diff --git a/report-api/tests/unit/api/test_reports.py b/report-api/tests/unit/api/test_reports.py index 873ce610..c4eaa773 100644 --- a/report-api/tests/unit/api/test_reports.py +++ b/report-api/tests/unit/api/test_reports.py @@ -194,7 +194,7 @@ def test_statement_grouped_invoices(client, jwt, app, monkeypatch): data = { 'template': _inline_tpl(), 'templateVars': { - 'groupedInvoices': [{'transactions': [1]}], + 'grouped_invoices': [{'transactions': [1]}], 'reportName': 'statement_report', }, 'reportName': 'statement_report',