Skip to content

Year End Closing Wizard Documentation

Overview

The Year End Closing wizard model (year.end) creates the year-end closing journal entry that transfers income and expense account balances to retained earnings. This is an essential part of the accounting year-end close process.


Model Information

Model Name: year.end Display Name: Year End Transient: Yes Key Fields: None (transient model)

Features

  • ✅ Transient model (temporary data)
  • ❌ Audit logging enabled (_audit_log)
  • ❌ Multi-company support (company_id)
  • ✅ Auto-calculates year-end date from settings
  • ✅ Voids and replaces existing entries
  • ✅ Supports tracking dimensions

Key Fields Reference

All Fields

Field Type Required Description
date Date Year end date
journal_id Many2One Journal for closing entry

Default Values

_defaults = {
    "date": _get_date,  # Calculated from settings
}

The default date is calculated from Settings: - Uses year_end_month and year_end_day from settings - Applies to current year


API Methods

1. Get Date

Method: _get_date(context)

Calculates default year-end date from settings.

Example:

# If settings: year_end_month=12, year_end_day=31
# Returns: "2024-12-31" (for current year)


2. Create Entry

Method: create_entry(ids, context={})

Creates the year-end closing journal entry.

Process: 1. Calculates date range (year before closing date) 2. Finds all income/expense accounts: - revenue - other_income - cost_sales - expense - other_expense 3. For each account with balance: - Creates line to zero out balance 4. Creates offsetting line to retained earnings 5. Voids existing closing entry if present 6. Posts the new entry

Settings Required: - retained_earnings_account_id: Target account for net income - year_end_track_id: Optional tracking dimension - year_end_track2_id: Optional secondary tracking

Returns: Navigation to journal entry view with flash message

Raises: - Exception("Retained earnings account not found") - Exception("Failed to generate journal number")


Model Relationship Description
account.journal Many2One (journal_id) Closing journal
account.move Created Closing entry
settings Reference Configuration

Account Types Closed

Account Type Direction
revenue Debit (to zero credit balance)
other_income Debit (to zero credit balance)
cost_sales Credit (to zero debit balance)
expense Credit (to zero debit balance)
other_expense Credit (to zero debit balance)

Common Use Cases

Use Case 1: Create Year-End Entry

# Create wizard
wiz_id = get_model("year.end").create({
    "date": "2024-12-31",
    "journal_id": closing_journal_id,
})

# Create closing entry
result = get_model("year.end").create_entry([wiz_id])

# Navigate to created entry
move_id = result["next"]["active_id"]

Use Case 2: Re-run Year-End

# If corrections needed, re-run wizard
# Existing entry for same journal/date is voided automatically

wiz_id = get_model("year.end").create({
    "date": "2024-12-31",
    "journal_id": closing_journal_id,
})

result = get_model("year.end").create_entry([wiz_id])
# Previous entry voided, new entry created

Year-End Closing Flow

1. Configure Settings
   ├─ retained_earnings_account_id
   ├─ year_end_month / year_end_day
   └─ year_end_track_id (optional)
2. Run Year-End Wizard
   ├─ Select/confirm closing date
   └─ Select closing journal
3. System Creates Closing Entry
   ├─ Debit revenue accounts
   ├─ Credit expense accounts
   └─ Debit/Credit retained earnings (net)
4. Entry Posted
5. Income/Expense accounts show zero balance

Journal Entry Structure

Year-End Closing Entry (example):
─────────────────────────────────────────────
Description: Year-end closing entry for 2024

  Sales Revenue              Dr  1,000,000
  Other Income               Dr     50,000
  Cost of Sales                  Cr   600,000
  Operating Expenses             Cr   300,000
  Other Expenses                 Cr    50,000
  Retained Earnings              Cr   100,000
─────────────────────────────────────────────
  Net Income transferred to Retained Earnings

Best Practices

1. Verify Before Closing

# Run trial balance first
# Ensure all reconciliations complete
# Review account balances

2. Use Dedicated Journal

# Create specific journal for year-end
# Makes entries easy to identify

3. Document Closing Date

# Configure year_end_month/day in Settings
# Ensures consistent closing dates

Troubleshooting

"Retained earnings account not found"

Cause: retained_earnings_account_id not set in Settings Solution: Configure retained earnings account in Settings

"Failed to generate journal number"

Cause: Journal sequence not configured Solution: Check journal sequence settings

"Entry already exists"

Cause: Normal - system voids and replaces Solution: Previous entry automatically voided


Testing Examples

Unit Test: Year-End Entry

def test_year_end_entry():
    # Create test accounts with balances
    # ...

    # Run year-end wizard
    wiz_id = get_model("year.end").create({
        "date": "2024-12-31",
        "journal_id": journal_id,
    })

    result = get_model("year.end").create_entry([wiz_id])

    # Verify entry created
    move_id = result["next"]["active_id"]
    move = get_model("account.move").browse([move_id])[0]
    assert move.state == "posted"

    # Verify income/expense accounts zeroed
    # ...

Security Considerations

Permission Model

  • Restricted to accounting administrators
  • Year-end close is critical operation

Audit Trail

  • Journal entry provides audit trail
  • Void of previous entry logged

Configuration Requirements

Setting Location Description
retained_earnings_account_id Settings Target equity account
year_end_month Settings Closing month (1-12)
year_end_day Settings Closing day (1-31)
year_end_track_id Settings Optional tracking
year_end_track2_id Settings Optional tracking 2

Version History

Last Updated: December 2024 Model Version: year_end.py Framework: Netforce


Additional Resources

  • Journal Entry Documentation: account.move
  • Account Documentation: account.account
  • Settings Documentation: settings

This documentation is generated for developer onboarding and reference purposes.