package models

import "odoo-go/pkg/orm"

// initChartTemplate registers the German chart of accounts template model
// and defines the structure for loading SKR03/SKR04 seed data.
// Mirrors: odoo/addons/l10n_de/models/template_de_skr03.py
//          odoo/addons/l10n_de/models/template_de_skr04.py
//
// German Standard Charts of Accounts (Standardkontenrahmen):
//
// SKR03 — organized by function (Prozessgliederungsprinzip):
//   0xxx  Anlage- und Kapitalkonten (Fixed assets & capital accounts) — Aktiva
//   1xxx  Finanz- und Privatkonten (Financial & private accounts) — Aktiva
//   2xxx  Abgrenzungskonten (Accrual accounts) — Aktiva
//   3xxx  Wareneingangskonten (Goods received / purchasing accounts) — GuV
//   4xxx  Betriebliche Aufwendungen (Operating expenses) — GuV
//   5xxx  (reserved)
//   6xxx  (reserved)
//   7xxx  Bestände an Erzeugnissen (Inventory of products) — GuV
//   8xxx  Erlöskonten (Revenue accounts) — GuV
//   9xxx  Vortrags- und statistische Konten (Carried-forward & statistical)
//
// SKR04 — organized by the balance sheet / P&L structure (Abschlussgliederungsprinzip):
//   0xxx  Anlagevermögen (Fixed assets) — Aktiva
//   1xxx  Umlaufvermögen (Current assets) — Aktiva
//   2xxx  Eigenkapital (Equity) — Passiva
//   3xxx  Fremdkapital (Liabilities) — Passiva
//   4xxx  Betriebliche Erträge (Operating income) — GuV
//   5xxx  Betriebliche Aufwendungen (Operating expenses, materials) — GuV
//   6xxx  Betriebliche Aufwendungen (Operating expenses, personnel) — GuV
//   7xxx  Weitere Erträge und Aufwendungen (Other income & expenses) — GuV
//   8xxx  (reserved)
//   9xxx  Vortrags- und statistische Konten (Carried-forward & statistical)
func initChartTemplate() {
	// l10n_de.chart.template — Metadata for German chart of accounts templates.
	// In Odoo, chart templates are loaded from data files (XML/CSV).
	// This model holds template metadata; the actual account definitions
	// would be loaded via seed data during module installation.
	m := orm.NewModel("l10n_de.chart.template", orm.ModelOpts{
		Description: "German Chart of Accounts Template",
		Order:       "name",
	})

	m.AddFields(
		orm.Char("name", orm.FieldOpts{String: "Chart Name", Required: true, Translate: true}),
		orm.Selection("chart_type", []orm.SelectionItem{
			{Value: "skr03", Label: "SKR03 (Prozessgliederung)"},
			{Value: "skr04", Label: "SKR04 (Abschlussgliederung)"},
		}, orm.FieldOpts{String: "Chart Type", Required: true}),
		orm.Many2one("company_id", "res.company", orm.FieldOpts{
			String: "Company", Index: true,
		}),
		orm.Many2one("currency_id", "res.currency", orm.FieldOpts{String: "Currency"}),
		orm.Boolean("visible", orm.FieldOpts{String: "Can be Visible", Default: true}),
	)
}

// LoadSKR03 would load the SKR03 chart of accounts as seed data.
// In a full implementation, this reads account definitions and creates
// account.account records for the installing company.
//
// SKR03 key account ranges:
//   0100-0499  Immaterielle Vermögensgegenstände (Intangible assets)
//   0500-0899  Sachanlagen (Tangible fixed assets)
//   0900-0999  Finanzanlagen (Financial assets)
//   1000-1099  Kasse (Cash)
//   1200-1299  Bankkonten (Bank accounts)
//   1400-1499  Forderungen aus Lieferungen (Trade receivables)
//   1600-1699  Sonstige Forderungen (Other receivables)
//   1700-1799  Verbindlichkeiten aus Lieferungen (Trade payables)
//   1800-1899  Umsatzsteuer / Vorsteuer (VAT accounts)
//   3000-3999  Wareneingang (Goods received)
//   4000-4999  Betriebliche Aufwendungen (Operating expenses)
//   8000-8999  Erlöse (Revenue)
func LoadSKR03() {
	// Seed data loading would be implemented here.
	// Typically reads from embedded CSV/XML data files and calls
	// orm create operations for account.account records.
}

// LoadSKR04 would load the SKR04 chart of accounts as seed data.
// SKR04 follows the balance sheet structure more closely.
//
// SKR04 key account ranges:
//   0100-0199  Immaterielle Vermögensgegenstände (Intangible assets)
//   0200-0499  Sachanlagen (Tangible fixed assets)
//   0500-0699  Finanzanlagen (Financial assets)
//   1000-1099  Kasse (Cash)
//   1200-1299  Bankkonten (Bank accounts)
//   1400-1499  Forderungen aus Lieferungen (Trade receivables)
//   2000-2999  Eigenkapital (Equity)
//   3000-3999  Fremdkapital (Liabilities)
//   4000-4999  Betriebliche Erträge (Operating income)
//   5000-6999  Betriebliche Aufwendungen (Operating expenses)
//   7000-7999  Weitere Erträge/Aufwendungen (Other income/expenses)
func LoadSKR04() {
	// Seed data loading would be implemented here.
}
