import type { ChartOfAccounts, AccountGroup, Account, Schema } from "../lib/types";

// ChartOfAccounts fixtures
export const baseDraftCoa = {
  id: "coa-1",
  name: "Standard CoA",
  description: "Standard chart of accounts",
  companyId: "company-1",
  baseCurrencyId: "currency-usd",
  status: "DRAFT",
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies ChartOfAccounts<Schema>;

export const baseActiveCoa = {
  id: "coa-2",
  name: "Active CoA",
  description: "Active chart of accounts",
  companyId: "company-1",
  baseCurrencyId: "currency-usd",
  status: "ACTIVE",
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies ChartOfAccounts<Schema>;

export const baseArchivedCoa = {
  id: "coa-3",
  name: "Archived CoA",
  description: "Archived chart of accounts",
  companyId: "company-1",
  baseCurrencyId: "currency-usd",
  status: "ARCHIVED",
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies ChartOfAccounts<Schema>;

// AccountGroup fixtures
export const baseRootGroup = {
  id: "group-1",
  code: "1000",
  name: "Assets",
  chartOfAccountsId: "coa-2",
  parentAccountGroupId: null,
  sortOrder: 1,
  numberRangeStart: 1000,
  numberRangeEnd: 1999,
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies AccountGroup<Schema>;

export const baseChildGroup = {
  id: "group-2",
  code: "1100",
  name: "Current Assets",
  chartOfAccountsId: "coa-2",
  parentAccountGroupId: "group-1",
  sortOrder: 1,
  numberRangeStart: 1100,
  numberRangeEnd: 1199,
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies AccountGroup<Schema>;

export const baseGrandchildGroup = {
  id: "group-3",
  code: "1110",
  name: "Cash and Equivalents",
  chartOfAccountsId: "coa-2",
  parentAccountGroupId: "group-2",
  sortOrder: 1,
  numberRangeStart: 1110,
  numberRangeEnd: 1119,
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies AccountGroup<Schema>;

export const baseGroupNoRange = {
  id: "group-4",
  code: "2000",
  name: "Liabilities",
  chartOfAccountsId: "coa-2",
  parentAccountGroupId: null,
  sortOrder: 2,
  numberRangeStart: null,
  numberRangeEnd: null,
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies AccountGroup<Schema>;

// Account fixtures
export const baseDraftAccount = {
  id: "account-1",
  code: "1100",
  name: "Cash",
  accountType: "ASSET",
  classification: "REGULAR",
  chartOfAccountsId: "coa-2",
  accountGroupId: null,
  currencyRestriction: null,
  reconciliation: false,
  defaultTaxCode: null,
  tags: null,
  successorAccountId: null,
  hasPostedTransactions: false,
  status: "DRAFT",
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies Account<Schema>;

export const baseActiveAccount = {
  id: "account-2",
  code: "1200",
  name: "Accounts Receivable",
  accountType: "ASSET",
  classification: "RECEIVABLE",
  chartOfAccountsId: "coa-2",
  accountGroupId: "group-2",
  currencyRestriction: null,
  reconciliation: true,
  defaultTaxCode: null,
  tags: null,
  successorAccountId: null,
  hasPostedTransactions: false,
  status: "ACTIVE",
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies Account<Schema>;

export const baseInactiveAccount = {
  id: "account-3",
  code: "1300",
  name: "Old Bank Account",
  accountType: "ASSET",
  classification: "BANK_CASH",
  chartOfAccountsId: "coa-2",
  accountGroupId: null,
  currencyRestriction: null,
  reconciliation: true,
  defaultTaxCode: null,
  tags: null,
  successorAccountId: "account-2",
  hasPostedTransactions: true,
  status: "INACTIVE",
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies Account<Schema>;

export const baseAccountWithPostedTransactions = {
  id: "account-4",
  code: "1400",
  name: "Main Bank",
  accountType: "ASSET",
  classification: "BANK_CASH",
  chartOfAccountsId: "coa-2",
  accountGroupId: null,
  currencyRestriction: null,
  reconciliation: true,
  defaultTaxCode: null,
  tags: null,
  successorAccountId: null,
  hasPostedTransactions: true,
  status: "ACTIVE",
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies Account<Schema>;

export const baseRetainedEarningsAccount = {
  id: "account-5",
  code: "3100",
  name: "Retained Earnings",
  accountType: "EQUITY",
  classification: "RETAINED_EARNINGS",
  chartOfAccountsId: "coa-2",
  accountGroupId: null,
  currencyRestriction: null,
  reconciliation: false,
  defaultTaxCode: null,
  tags: null,
  successorAccountId: null,
  hasPostedTransactions: false,
  status: "ACTIVE",
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
} as const satisfies Account<Schema>;

// Company fixture (for cross-module validation)
export const baseActiveCompany = {
  id: "company-1",
  legalName: "Test Corp",
  baseCurrencyId: "currency-usd",
  status: "ACTIVE",
  taxId: null,
  registrationNumber: null,
  street: "123 Main St",
  city: "New York",
  state: "NY",
  postalCode: "10001",
  country: "US",
  createdAt: new Date("2024-01-01T00:00:00.000Z"),
  updatedAt: null,
};
