{% extends "ui/templates/base/layout.html" %} {% block content %}

Accounting · Phase 21A v2

Opening Balance Review & Correction

Summary-first review of previous-year closing balances against current-year openings. Only Balance Sheet ledgers and Stock Items are checked; revenue, expense, purchase and sales ledgers are excluded. Matched and new zero-balance masters stay out of the main review; actionable differences retain the existing controlled Tally correction workflow.

{% if message %}
{{ message }}
{% endif %} {% if error %}
{{ error }}
{% endif %}
{% if selected_client %} {% set prev = previous_mirror_status.mirror if previous_mirror_status and previous_mirror_status.mirror else {} %} {% set curr = current_mirror_status.mirror if current_mirror_status and current_mirror_status.mirror else {} %}
Previous FY Mirror · FY {{ previous_fy }}
{{ 'Ready' if prev.ready else 'Mirror required' }}
{% if prev.ready %}
{{ prev.company.company_name }} · {{ prev.counts.voucher }} vouchers
{{ previous_mirror_status.mirror_db_path or prev.path or '' }}
{% endif %}
Current FY Mirror · FY {{ current_fy }}
{{ 'Ready' if curr.ready else 'Mirror required' }}
{% if curr.ready %}
{{ curr.company.company_name }} · {{ curr.counts.voucher }} vouchers
{{ current_mirror_status.mirror_db_path or curr.path or '' }}
{% endif %}
{% endif %}
{% if selected_client and runs %}

Comparison Runs

{% for run in runs %} {% endfor %}
RunPrevious YearCurrent YearLedgersStock Items
#{{ run.id }} {{ run.previous_company_name }} {{ run.current_company_name }} {{ run.ledger_count }} {{ run.stock_item_count }} Open Summary
{% endif %} {% if selected_run %}
Download Excel Report {% if analysis_run_id %}Download PDF{% endif %}

Run #{{ selected_run.id }}

{{ selected_run.previous_company_name }} closing → {{ selected_run.current_company_name }} opening

Summary
{% if tab=='summary' %}

Ledger Opening Summary

Matched records are summarized only. Click a category when you need its detailed report.

Stock Opening Summary

Quantity, value and unit exceptions are separated so the reviewer sees only the issue that needs attention.

Ledger Differences — Action Required

Only ledgers with an actual previous-closing/current-opening difference are shown here.

Open detailed report
{% for item in ledger_action_rows %} {% else %} {% endfor %}
ApplyPrevious LedgerPY ClosingCurrent LedgerCY OpeningDifferenceMatchCorrection
{{ item.previous_name }}
{{ item.previous_group }}
{{ '%.2f'|format(item.previous_closing_balance) }}
{{ item.current_name }}
{{ item.current_group }}
{{ '%.2f'|format(item.current_opening_balance) }} {{ '%.2f'|format(0 if item.difference|abs < 0.005 else item.difference) }} {{ item.match_method|replace('_',' ')|title }} · {{ item.confidence }}% {{ item.correction_status|replace('_',' ')|title }}{% if item.correction_note %}
{{ item.correction_note }}
{% endif %}
No Ledger opening differences require action.
{% if summary.ledgers.difference > ledger_action_rows|length %}
Showing the first {{ ledger_action_rows|length }} differences here. Open the detailed report to review the remaining rows.
{% endif %}

Stock Opening Differences — Action Required

Quantity/value differences can be selected for correction. Unit differences are shown but remain blocked.

Open stock details
{% for item in stock_action_rows %} {% else %} {% endfor %}
ApplyPrevious Stock ItemPY ClosingCurrent Stock ItemCY OpeningDifferenceStatusCorrection
{% if item.match_status != 'unit_difference' and item.previous_unit|lower == item.current_unit|lower %}{% else %}Blocked{% endif %}
{{ item.previous_name }}
{{ item.previous_group }} · HSN {{ item.previous_hsn or '-' }}
{{ item.previous_closing_qty }} {{ item.previous_unit }}
₹{{ '%.2f'|format(item.previous_closing_value) }}
{{ item.current_name }}
{{ item.current_group }} · HSN {{ item.current_hsn or '-' }}
{{ item.current_opening_qty }} {{ item.current_unit }}
₹{{ '%.2f'|format(item.current_opening_value) }}
Qty {{ 0 if item.quantity_difference|abs < 0.000001 else item.quantity_difference }}
Value ₹{{ '%.2f'|format(0 if item.value_difference|abs < 0.005 else item.value_difference) }}
{{ item.match_status|replace('_',' ')|title }}
{{ item.match_method|replace('_',' ')|title }} · {{ item.confidence }}%
{{ item.correction_status|replace('_',' ')|title }}{% if item.correction_note %}
{{ item.correction_note }}
{% endif %}
No Stock Item opening differences require action.
{% if ledger_action_rows or stock_action_rows %}

Apply selected safe corrections directly to current-year Tally

Existing safeguards are unchanged: current openings are rechecked immediately before write and every altered master is re-read from Tally afterward.

{% endif %}
{% elif tab=='ledgers' %}

Ledger Detailed Report

{{ status_filter|replace('_',' ')|title }} · {{ detail_total }} row(s). This detailed list is opened only on demand.

{% for value,label in [('matched','Matched'),('difference','Differences'),('missing_in_current_year','Missing'),('new_in_current_year','New')] %} {{ label }} {% endfor %} Back to Summary
{% if status_filter=='new_in_current_year' %}
{% if show_zero_new %} Zero-balance new Ledgers are currently visible. Hide zero-balance new Ledgers {% else %} Zero-balance new Ledgers are hidden by default. Show them {% endif %}
{% endif %}
{% for item in ledgers %} {% else %}{% endfor %}
ApplyPrevious LedgerPY ClosingCurrent LedgerCY OpeningDifferenceStatusCorrection
{% if item.match_status=='difference' %}{% else %}—{% endif %}
{{ item.previous_name or '—' }}
{{ item.previous_group }}
{{ '%.2f'|format(item.previous_closing_balance) }}
{{ item.current_name or '—' }}
{{ item.current_group }}
{{ '%.2f'|format(item.current_opening_balance) }} {{ '%.2f'|format(0 if item.difference|abs < 0.005 else item.difference) }} {{ item.match_status|replace('_',' ')|title }}{% if item.match_method %}
{{ item.match_method|replace('_',' ')|title }} · {{ item.confidence }}%
{% endif %}
{{ item.correction_status|replace('_',' ')|title }}{% if item.correction_note %}
{{ item.correction_note }}
{% endif %}
No Ledger rows for this category.
{% if status_filter=='difference' and ledgers %}
{% endif %}
{% if pages > 1 %}
Page {{ page }} of {{ pages }}
{% if page>1 %}Previous{% endif %} {% if pageNext{% endif %}
{% endif %}
{% elif tab=='stock' %}

Stock Item Detailed Report

{{ status_filter|replace('_',' ')|title }} · {{ detail_total }} row(s).

{% for value,label in [('matched','Matched'),('quantity_difference','Qty Difference'),('value_difference','Value Difference'),('quantity_and_value_difference','Qty + Value'),('unit_difference','Unit Difference'),('missing_in_current_year','Missing'),('new_in_current_year','New')] %} {{ label }} {% endfor %} Back to Summary
{% if status_filter=='new_in_current_year' %}
{% if show_zero_new %} Zero-balance new Stock Items are currently visible. Hide zero-balance new Stock Items {% else %} Zero-balance new Stock Items are hidden by default. Show them {% endif %}
{% endif %}
{% for item in stocks %} {% else %}{% endfor %}
ApplyPrevious Stock ItemPY ClosingCurrent Stock ItemCY OpeningDifferenceStatusCorrection
{% if item.match_status in ['quantity_difference','value_difference','quantity_and_value_difference'] and item.previous_unit|lower == item.current_unit|lower %}{% else %}—{% endif %}
{{ item.previous_name or '—' }}
{{ item.previous_group }} · HSN {{ item.previous_hsn or '-' }}
{{ item.previous_closing_qty }} {{ item.previous_unit }}
₹{{ '%.2f'|format(item.previous_closing_value) }}
{{ item.current_name or '—' }}
{{ item.current_group }} · HSN {{ item.current_hsn or '-' }}
{{ item.current_opening_qty }} {{ item.current_unit }}
₹{{ '%.2f'|format(item.current_opening_value) }}
Qty {{ 0 if item.quantity_difference|abs < 0.000001 else item.quantity_difference }}
Value ₹{{ '%.2f'|format(0 if item.value_difference|abs < 0.005 else item.value_difference) }}
{{ item.match_status|replace('_',' ')|title }}{% if item.match_method %}
{{ item.match_method|replace('_',' ')|title }} · {{ item.confidence }}%
{% endif %}
{{ item.correction_status|replace('_',' ')|title }}{% if item.correction_note %}
{{ item.correction_note }}
{% endif %}
No Stock Item rows for this category.
{% if status_filter in ['quantity_difference','value_difference','quantity_and_value_difference'] and stocks %}
{% endif %}
{% if pages > 1 %}
Page {{ page }} of {{ pages }}
{% if page>1 %}Previous{% endif %} {% if pageNext{% endif %}
{% endif %}
{% endif %} {% endif %}
{% endblock %}