package models

import "odoo-go/pkg/orm"

// initAccountAnalytic registers analytic accounting models.
// Mirrors: odoo/addons/analytic/models/analytic_account.py

func initAccountAnalytic() {
	// account.analytic.plan — Analytic Plan
	// Mirrors: odoo/addons/analytic/models/analytic_plan.py
	orm.NewModel("account.analytic.plan", orm.ModelOpts{
		Description: "Analytic Plan",
	}).AddFields(
		orm.Char("name", orm.FieldOpts{String: "Name", Required: true}),
		orm.Many2one("parent_id", "account.analytic.plan", orm.FieldOpts{String: "Parent"}),
		orm.Many2one("company_id", "res.company", orm.FieldOpts{String: "Company"}),
	)

	// account.analytic.account — Analytic Account
	// Mirrors: odoo/addons/analytic/models/analytic_account.py AnalyticAccount
	m := orm.NewModel("account.analytic.account", orm.ModelOpts{
		Description: "Analytic Account",
		Order:       "code, name",
	})
	m.AddFields(
		orm.Char("name", orm.FieldOpts{String: "Name", Required: true}),
		orm.Char("code", orm.FieldOpts{String: "Reference"}),
		orm.Many2one("partner_id", "res.partner", orm.FieldOpts{String: "Customer"}),
		orm.Many2one("company_id", "res.company", orm.FieldOpts{String: "Company"}),
		orm.Boolean("active", orm.FieldOpts{String: "Active", Default: true}),
		orm.Many2one("plan_id", "account.analytic.plan", orm.FieldOpts{String: "Plan"}),
	)

	// account.analytic.line — Analytic Line
	// Mirrors: odoo/addons/analytic/models/analytic_line.py AnalyticLine
	orm.NewModel("account.analytic.line", orm.ModelOpts{
		Description: "Analytic Line",
		Order:       "date desc, id desc",
	}).AddFields(
		orm.Char("name", orm.FieldOpts{String: "Description", Required: true}),
		orm.Date("date", orm.FieldOpts{String: "Date", Required: true}),
		orm.Monetary("amount", orm.FieldOpts{String: "Amount", CurrencyField: "currency_id"}),
		orm.Many2one("account_id", "account.analytic.account", orm.FieldOpts{String: "Analytic Account"}),
		orm.Many2one("move_line_id", "account.move.line", orm.FieldOpts{String: "Journal Item"}),
		orm.Many2one("partner_id", "res.partner", orm.FieldOpts{String: "Partner"}),
		orm.Many2one("company_id", "res.company", orm.FieldOpts{String: "Company"}),
		orm.Many2one("currency_id", "res.currency", orm.FieldOpts{String: "Currency"}),
	)
}
