import { Organization } from 'fhir/r4'; // Mirrors the server's organization-tax.ts - the server WRITES this exact URL, the plugin READS // it back - so the literal MUST match byte for byte. export const ORGANIZATION_TAX_RATE_EXTENSION_URL = 'https://akashichealthrecords.com/fhir/StructureDefinition/organization-tax-rate'; // Pure reader - org-wide sales-tax rate as a percent (e.g. 8.25). 0 when unset/invalid. Tax is // FROZEN onto each invoice at creation time - this reader is only for the current/live rate // (Platform Manager settings UI, editor breakdown), never for re-deriving an issued invoice's tax. export const getOrganizationTaxRate = (org?: Organization): number => { const value = org?.extension?.find((e) => e.url === ORGANIZATION_TAX_RATE_EXTENSION_URL)?.valueDecimal; return typeof value === 'number' && Number.isFinite(value) ? value : 0; };