export interface TaxParty {
  country: string
}

type SupplyType = 'goods' | 'services' | 'digital'
type TaxTreatment = 'standard' | 'zero_rated' | 'exempt'

interface ResolveTaxabilityInput {
  supplier: TaxParty
  customer: TaxParty
  supplyType: SupplyType
}

interface TaxabilityResolution {
  treatment: TaxTreatment
  reason: string
}

const IL_COUNTRY = 'IL'

export function resolveTaxability(input: ResolveTaxabilityInput): TaxabilityResolution {
  if (input.supplier.country === IL_COUNTRY && input.customer.country === IL_COUNTRY) {
    return {
      treatment: 'standard',
      reason: 'supplier and customer are both in IL',
    }
  }

  if (input.supplier.country === IL_COUNTRY && input.customer.country !== IL_COUNTRY) {
    return {
      treatment: 'zero_rated',
      reason: 'supplier is in IL and customer is outside IL',
    }
  }

  return {
    treatment: 'standard',
    reason: 'no v1 taxability override applies',
  }
}
