export type VatRate = 'general' | 'reduced' | 'super-reduced';

export const VAT_BASIS_POINTS: Record<VatRate, number> = {
  general: 2100,
  reduced: 1000,
  'super-reduced': 400,
};

export interface VariantPrice {
  variantId: string;
  netUnitAmountCents: number;
  offerCents: number | null;
  costCents: number | null;
  vatRate: VatRate;
  currency: 'EUR';
  createdAt: Date;
  updatedAt: Date;
}

export interface SetVariantPriceCommand {
  variantId: string;
  netUnitAmountCents: number;
  offerCents?: number | null;
  costCents?: number | null;
  vatRate: VatRate;
}

export interface PriceCalculationCommand {
  variantId: string;
  quantity: number;
}

export interface PriceCalculation {
  variantId: string;
  quantity: number;
  currency: 'EUR';
  vatRate: VatRate;
  vatBasisPoints: number;
  netUnitAmountCents: number;
  netSubtotalCents: number;
  vatAmountCents: number;
  totalCents: number;
}

export function calculateVatAmountCents(netSubtotalCents: number, vatRate: VatRate): number {
  return Math.round((netSubtotalCents * VAT_BASIS_POINTS[vatRate]) / 10_000);
}
