Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

1.5 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

type CountryProfile = {
  eori?: boolean;
  registrationNumber?: boolean;
};

const COUNTRY_PROFILES: Record<string, CountryProfile> = {
  AT: { eori: true },
  BE: { eori: true },
  BG: { eori: true },
  HR: { eori: true },
  CY: { eori: true },
  CZ: { eori: true },
  DK: { eori: true },
  EE: { eori: true },
  FI: { eori: true },
  FR: { eori: true },
  DE: { eori: true },
  GB: { eori: true, registrationNumber: true },
  GR: { eori: true },
  HU: { eori: true },
  IE: { eori: true },
  IT: { eori: true },
  LV: { eori: true },
  LT: { eori: true },
  LU: { eori: true },
  MT: { eori: true },
  NL: { eori: true },
  PL: { eori: true },
  PT: { eori: true },
  RO: { eori: true },
  SK: { eori: true },
  SI: { eori: true },
  ES: { eori: true },
  SE: { eori: true }
};

export function getCountryProfile(
  countryCode: string | null | undefined
): CountryProfile | undefined {
  if (!countryCode) return undefined;
  return COUNTRY_PROFILES[countryCode.toUpperCase()];
}

export function isEoriCountry(countryCode: string | null | undefined): boolean {
  return getCountryProfile(countryCode)?.eori === true;
}

export function isRegistrationNumberCountry(
  countryCode: string | null | undefined
): boolean {
  return getCountryProfile(countryCode)?.registrationNumber === true;
}