@final-commerce/common 2.8.1-online.3 → 2.8.1-online.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -481,12 +481,6 @@ declare enum ShippingZoneError {
481
481
  MISSING_NAME = "MISSING_NAME"
482
482
  }
483
483
 
484
- declare enum TaxProductType {
485
- STANDARD = "standard",
486
- BASIC_FOOD = "basic_food",
487
- CHILDRENS_CLOTHING = "childrens_clothing",
488
- EXEMPT = "exempt"
489
- }
490
484
  declare enum TaxRegistrationKind {
491
485
  GST_HST = "GST_HST",
492
486
  PST = "PST",
@@ -502,7 +496,8 @@ declare enum OutOfProvinceTaxes {
502
496
  }
503
497
  declare enum TaxWarningCode {
504
498
  NOT_REGISTERED = "NOT_REGISTERED",
505
- NO_RULES_FOR_PLACE = "NO_RULES_FOR_PLACE"
499
+ NO_RULES_FOR_PLACE = "NO_RULES_FOR_PLACE",
500
+ NO_TABLE = "NO_TABLE"
506
501
  }
507
502
 
508
503
  interface CurrencyConfig {
@@ -1873,7 +1868,63 @@ interface TaxRegistration {
1873
1868
  number?: string | null;
1874
1869
  from?: string | null;
1875
1870
  }
1876
- declare const TAX_REGISTRATION_PLACES: Readonly<Record<TaxRegistrationKind, readonly string[]>>;
1871
+
1872
+ declare const STANDARD_TAX_TYPE = "standard";
1873
+ type AutomaticTaxRowStatus = 'confirmed' | 'to_confirm';
1874
+ interface AutomaticTaxTypeRow {
1875
+ key: string;
1876
+ name: string;
1877
+ description?: string | null;
1878
+ sortOrder: number;
1879
+ active: boolean;
1880
+ }
1881
+ interface AutomaticTaxPart {
1882
+ code: string;
1883
+ name: string;
1884
+ rate: string;
1885
+ level: 'federal' | 'provincial';
1886
+ }
1887
+ interface AutomaticTaxRateRow {
1888
+ code: string;
1889
+ name: string;
1890
+ kind: TaxRegistrationKind | `${TaxRegistrationKind}`;
1891
+ places: string[];
1892
+ rate: string;
1893
+ from?: string | null;
1894
+ to?: string | null;
1895
+ order: number;
1896
+ compound: boolean;
1897
+ registrationPlace: string;
1898
+ harmonized: boolean;
1899
+ parts?: AutomaticTaxPart[] | null;
1900
+ sourceUrl?: string | null;
1901
+ status: AutomaticTaxRowStatus;
1902
+ }
1903
+ interface AutomaticTaxRuleRow {
1904
+ taxType: string;
1905
+ codes: string[];
1906
+ rate: string;
1907
+ from?: string | null;
1908
+ to?: string | null;
1909
+ sourceUrl?: string | null;
1910
+ status: AutomaticTaxRowStatus;
1911
+ note?: string | null;
1912
+ }
1913
+ interface AutomaticTaxTable {
1914
+ version: string;
1915
+ types: AutomaticTaxTypeRow[];
1916
+ rates: AutomaticTaxRateRow[];
1917
+ rules: AutomaticTaxRuleRow[];
1918
+ }
1919
+ declare function automaticTaxTableVersion(table: Omit<AutomaticTaxTable, 'version'>): string;
1920
+ declare function buildAutomaticTaxTable(rows: {
1921
+ types: readonly AutomaticTaxTypeRow[];
1922
+ rates: readonly AutomaticTaxRateRow[];
1923
+ rules: readonly AutomaticTaxRuleRow[];
1924
+ }): AutomaticTaxTable;
1925
+ declare function registrationPlacesByKind(rates: readonly AutomaticTaxRateRow[]): ReadonlyMap<string, readonly string[]>;
1926
+
1927
+ declare function sha1Hex(text: string): string;
1877
1928
 
1878
1929
  interface CurrencyRate {
1879
1930
  rate: number;
@@ -1943,4 +1994,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
1943
1994
  }];
1944
1995
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
1945
1996
 
1946
- export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderWriteStrategy, OtherFixedRates, OutOfProvinceTaxes, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, TAX_REGISTRATION_PLACES, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, TaxProductType, type TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
1997
+ export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, AttributeType, type AutomaticTaxPart, type AutomaticTaxRateRow, type AutomaticTaxRowStatus, type AutomaticTaxRuleRow, type AutomaticTaxTable, type AutomaticTaxTypeRow, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderWriteStrategy, OtherFixedRates, OutOfProvinceTaxes, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, STANDARD_TAX_TYPE, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, assertUnitSane, automaticTaxTableVersion, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAutomaticTaxTable, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, registrationPlacesByKind, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, sha1Hex, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.d.ts CHANGED
@@ -481,12 +481,6 @@ declare enum ShippingZoneError {
481
481
  MISSING_NAME = "MISSING_NAME"
482
482
  }
483
483
 
484
- declare enum TaxProductType {
485
- STANDARD = "standard",
486
- BASIC_FOOD = "basic_food",
487
- CHILDRENS_CLOTHING = "childrens_clothing",
488
- EXEMPT = "exempt"
489
- }
490
484
  declare enum TaxRegistrationKind {
491
485
  GST_HST = "GST_HST",
492
486
  PST = "PST",
@@ -502,7 +496,8 @@ declare enum OutOfProvinceTaxes {
502
496
  }
503
497
  declare enum TaxWarningCode {
504
498
  NOT_REGISTERED = "NOT_REGISTERED",
505
- NO_RULES_FOR_PLACE = "NO_RULES_FOR_PLACE"
499
+ NO_RULES_FOR_PLACE = "NO_RULES_FOR_PLACE",
500
+ NO_TABLE = "NO_TABLE"
506
501
  }
507
502
 
508
503
  interface CurrencyConfig {
@@ -1873,7 +1868,63 @@ interface TaxRegistration {
1873
1868
  number?: string | null;
1874
1869
  from?: string | null;
1875
1870
  }
1876
- declare const TAX_REGISTRATION_PLACES: Readonly<Record<TaxRegistrationKind, readonly string[]>>;
1871
+
1872
+ declare const STANDARD_TAX_TYPE = "standard";
1873
+ type AutomaticTaxRowStatus = 'confirmed' | 'to_confirm';
1874
+ interface AutomaticTaxTypeRow {
1875
+ key: string;
1876
+ name: string;
1877
+ description?: string | null;
1878
+ sortOrder: number;
1879
+ active: boolean;
1880
+ }
1881
+ interface AutomaticTaxPart {
1882
+ code: string;
1883
+ name: string;
1884
+ rate: string;
1885
+ level: 'federal' | 'provincial';
1886
+ }
1887
+ interface AutomaticTaxRateRow {
1888
+ code: string;
1889
+ name: string;
1890
+ kind: TaxRegistrationKind | `${TaxRegistrationKind}`;
1891
+ places: string[];
1892
+ rate: string;
1893
+ from?: string | null;
1894
+ to?: string | null;
1895
+ order: number;
1896
+ compound: boolean;
1897
+ registrationPlace: string;
1898
+ harmonized: boolean;
1899
+ parts?: AutomaticTaxPart[] | null;
1900
+ sourceUrl?: string | null;
1901
+ status: AutomaticTaxRowStatus;
1902
+ }
1903
+ interface AutomaticTaxRuleRow {
1904
+ taxType: string;
1905
+ codes: string[];
1906
+ rate: string;
1907
+ from?: string | null;
1908
+ to?: string | null;
1909
+ sourceUrl?: string | null;
1910
+ status: AutomaticTaxRowStatus;
1911
+ note?: string | null;
1912
+ }
1913
+ interface AutomaticTaxTable {
1914
+ version: string;
1915
+ types: AutomaticTaxTypeRow[];
1916
+ rates: AutomaticTaxRateRow[];
1917
+ rules: AutomaticTaxRuleRow[];
1918
+ }
1919
+ declare function automaticTaxTableVersion(table: Omit<AutomaticTaxTable, 'version'>): string;
1920
+ declare function buildAutomaticTaxTable(rows: {
1921
+ types: readonly AutomaticTaxTypeRow[];
1922
+ rates: readonly AutomaticTaxRateRow[];
1923
+ rules: readonly AutomaticTaxRuleRow[];
1924
+ }): AutomaticTaxTable;
1925
+ declare function registrationPlacesByKind(rates: readonly AutomaticTaxRateRow[]): ReadonlyMap<string, readonly string[]>;
1926
+
1927
+ declare function sha1Hex(text: string): string;
1877
1928
 
1878
1929
  interface CurrencyRate {
1879
1930
  rate: number;
@@ -1943,4 +1994,4 @@ declare const EXPENSE_DEFAULT_CATEGORIES: readonly [{
1943
1994
  }];
1944
1995
  type ExpenseDefaultCategoryKey = (typeof EXPENSE_DEFAULT_CATEGORIES)[number]['key'];
1945
1996
 
1946
- export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, AttributeType, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderWriteStrategy, OtherFixedRates, OutOfProvinceTaxes, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, TAX_REGISTRATION_PLACES, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, TaxProductType, type TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, assertUnitSane, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
1997
+ export { ADYEN_JOB_TITLE_ASSOCIATION_TYPES, ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES, ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES, ADYEN_ROLLOUT_COUNTRY_CODES, ADYEN_STORE_STATE_PROVINCE_COUNTRIES, ADYEN_TAX_NUMBER_FORMATS, ADYEN_TAX_NUMBER_MIN_LENGTH, AFFIRM_COUNTRY_CODES, AFFIRM_PRICE_PLANS, type AddressLike, type AdyenBnplSettings, type AdyenBnplSkippedStore, type AdyenBnplUpdateResult, type AffirmPricePlan, type Amount, AttributeType, type AutomaticTaxPart, type AutomaticTaxRateRow, type AutomaticTaxRowStatus, type AutomaticTaxRuleRow, type AutomaticTaxTable, type AutomaticTaxTypeRow, type AvailabilityInput, type AvailabilitySlot, type AvailableTransition, BNPL_METHOD_STATUS, BNPL_SKIP_REASON, type BnplMethodStatus, type BnplSkipReason, type BookingOccupancy, BookingRatePeriod, type BookingResourceInput, BookingResourceKind, BookingResourceStatus, BookingRulesError, type BookingRulesInput, BookingType, type BusyWindow, CANADA_PROVINCES, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, type CategoryModifierRow, type CategoryRow, CompanyType, type CompositeAvailabilityRows, type CompositeMakeable, type CompositeMakeableRow, type CompositePriceItem, type CompositePricePart, type CompositeReservationOrder, type CompositeShelf, type CompositeStockPart, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CountryOption, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_HOLD_MINUTES, DEFAULT_RESOLVED_CONFIG, DEFAULT_UNIT_ID, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, DualWriteStrategy, EUFixedRates, EUROPE, EVERYWHERE_KEY, EXPENSE_DEFAULT_CATEGORIES, EXPENSE_NAME_MAX_LENGTH, EXPENSE_PAYMENT_METHOD_PRESETS, type EndOfSessionReport, type ExpenseDefaultCategoryKey, ExtensionCategory, FINANCIAL_INVARIANTS, FULFILLMENT_STATES, type FailedCondition, type FeesBreakdown, FeesCustomBillingStatus, type FeesTuple, type FinancialInvariant, type FragmentParam, type FragmentValidationResult, type FulfillmentState, type FulfillmentStateDefinition, type FulfillmentTransitionPath, type GetAvailableTransitionsParams, type GetAvailableTransitionsResponse, type GetOrderDisplayStateParams, type GetOrderDisplayStateResponse, type GetOrderStateConfigParams, type GetOrderStateConfigResponse, type GetStateConfigFragmentParams, type GetStateConfigFragmentResponse, type GridSlot, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LegacyWriteStrategy, LibraryItemType, type LineStockMove, MAX_PRECISION, type Measurable, type MeasurementBase, type MeasurementUnit, type MeasurementUnitFamily, MenuProject, type ModifierChoiceRow, type ModifierRow, type ModifiersBreakdown, type ModifiersTuple, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, type NormalizedAddress, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForInCart, type OrderLikeForLegacyInference, type OrderLineItem, type OrderMutationData, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderReservationForContext, type OrderStateEventPayload, type OrderStateWritable, type OrderStatusDefinition, type OrderStatusValidationError, type OrderWriteStrategy, OtherFixedRates, OutOfProvinceTaxes, OwnerType, PATH_MODES, PAYMENT_CHANNELS, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, type PaymentChannel, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, type PlanWindowInput, Platform, type PoolDrawing, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, ProcessorType, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, type Province, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ReservationStatus, ResidualPaymentMethod, ResidualStatus, type ResolveInputs, type ResolveShippingInput, type ResolveTemplateResult, type ResourceAvailability, ResourceAvailabilityState, type ResourceInWindow, type ResourcePresenceRow, STANDARD_TAX_TYPE, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, SYSTEM_FAMILIES, SYSTEM_FAMILY_IDS, SYSTEM_UNITS, SYSTEM_UNIT_IDS, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, ShippingChannel, ShippingNoOptionReason, type ShippingOptionRule, ShippingOptionType, type ShippingPlace, type ShippingPriceTier, type ShippingQuoteOption, ShippingRateType, type ShippingResolution, ShippingZoneError, ShippingZoneKind, type ShippingZoneProblem, type ShippingZoneRule, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StockLine, type StockLineComponent, type StockReservationLink, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, type TaxRegistration, TaxRegistrationKind, TaxSource, TaxWarningCode, type TaxesTuple, TimePeriod, type TipEntry, type TipsBreakdown, type TipsTuple, TopMetericsSort, type TransitionBlockedBy, type TransitionConditionSet, type TransitionOrderStateParams, type TransitionOrderStateResponse, type TransitionPath, type TransitionRequest, type TransitionResult, UserTypes, type WeeklyHours, addAmounts, addressPlaceKeys, adyenLegalEntityRequiresStateOrProvince, adyenRequiresJobTitle, adyenStoreRequiresStateOrProvince, adyenSupportsTaxNumberAbsent, adyenTaxNumberFormat, amountToString, ancestorChain, assertUnitSane, automaticTaxTableVersion, availableIn, baseFor, baseFulfillmentDefinitions, baseOf, basePaymentDefinitions, buildAutomaticTaxTable, buildAvailability, buildGrid, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, cheapestCompositeItem, cheapestCompositePrice, compositeItemCost, compositeItemUnavailable, compositeMakeable, compositeModifierMismatches, compositeReservationMismatches, compositeVariantInStock, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, deriveFamilyCode, deriveUnitId, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, extendPrice, extendPriceFor, formatCurrency, formatInUnit, formatMinorUnitsToString, formatQuantity, fromBase, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, hasInCartFlag, hasSellableChoice, holdExpiresAt, inferStatesFromLegacyStatus, isAdyenRolloutCountry, isAffirmCountry, isAffirmPricePlan, isChoiceAvailableAtOutlet, isConditionOperator, isFulfillmentState, isInCart, isPaymentState, isSupportedCurrency, isSystemFamilyCode, isValidQuantity, isWhole, lineStockMoves, listCountries, listProvinces, mapToLegacyStatus, maxPrecisionFor, mergeFragment, modifiersSellable, multiplyAmount, normalizeAddress, normalizeCityKey, normalizeCountry, normalizeMongoIdString, normalizePostCode, normalizeProvince, occupancyIn, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, placeKey, planWindow, poolDemand, poolOf, poolShortfall, poolStockAt, postCodeMatchesProvince, presentAt, priceForTotal, provincesForPostCode, registrationPlacesByKind, removeFragment, resolveFamily, resolveModifiersForProduct, resolveShipping, resolveTemplate, resolveUnit, roundToPrecision, sameFamily, setOrderState, sha1Hex, shopDayKey, shopDayRange, signReportForDisplay, slotsForWindow, stringifyMinorUnits, subtractAmounts, toBase, toMinorUnits, validateConfig, validateFragmentCompatibility, validateOrderStatuses, validateShippingZone, violatesFinancialInvariant, windowEndsAt, withinPresence };
package/dist/index.js CHANGED
@@ -102,6 +102,7 @@ __export(index_exports, {
102
102
  ResidualPaymentMethod: () => ResidualPaymentMethod,
103
103
  ResidualStatus: () => ResidualStatus,
104
104
  ResourceAvailabilityState: () => ResourceAvailabilityState,
105
+ STANDARD_TAX_TYPE: () => STANDARD_TAX_TYPE,
105
106
  STATE_SCHEMA: () => STATE_SCHEMA,
106
107
  STRIPE_SUPPORTED_COUNTRIES: () => STRIPE_SUPPORTED_COUNTRIES,
107
108
  SYSTEM_FAMILIES: () => SYSTEM_FAMILIES,
@@ -117,8 +118,6 @@ __export(index_exports, {
117
118
  StationStatus: () => StationStatus,
118
119
  StripeCurrencyCode: () => StripeCurrencyCode,
119
120
  StripeStatus: () => StripeStatus,
120
- TAX_REGISTRATION_PLACES: () => TAX_REGISTRATION_PLACES,
121
- TaxProductType: () => TaxProductType,
122
121
  TaxRegistrationKind: () => TaxRegistrationKind,
123
122
  TaxSource: () => TaxSource,
124
123
  TaxWarningCode: () => TaxWarningCode,
@@ -135,11 +134,13 @@ __export(index_exports, {
135
134
  amountToString: () => amountToString,
136
135
  ancestorChain: () => ancestorChain,
137
136
  assertUnitSane: () => assertUnitSane,
137
+ automaticTaxTableVersion: () => automaticTaxTableVersion,
138
138
  availableIn: () => availableIn,
139
139
  baseFor: () => baseFor,
140
140
  baseFulfillmentDefinitions: () => baseFulfillmentDefinitions,
141
141
  baseOf: () => baseOf,
142
142
  basePaymentDefinitions: () => basePaymentDefinitions,
143
+ buildAutomaticTaxTable: () => buildAutomaticTaxTable,
143
144
  buildAvailability: () => buildAvailability,
144
145
  buildGrid: () => buildGrid,
145
146
  buildOrderContext: () => buildOrderContext,
@@ -233,6 +234,7 @@ __export(index_exports, {
233
234
  presentAt: () => presentAt,
234
235
  priceForTotal: () => priceForTotal,
235
236
  provincesForPostCode: () => provincesForPostCode,
237
+ registrationPlacesByKind: () => registrationPlacesByKind,
236
238
  removeFragment: () => removeFragment,
237
239
  resolveFamily: () => resolveFamily,
238
240
  resolveModifiersForProduct: () => resolveModifiersForProduct,
@@ -242,6 +244,7 @@ __export(index_exports, {
242
244
  roundToPrecision: () => roundToPrecision,
243
245
  sameFamily: () => sameFamily,
244
246
  setOrderState: () => setOrderState,
247
+ sha1Hex: () => sha1Hex,
245
248
  shopDayKey: () => shopDayKey,
246
249
  shopDayRange: () => shopDayRange,
247
250
  signReportForDisplay: () => signReportForDisplay,
@@ -794,13 +797,6 @@ var ShippingZoneError = /* @__PURE__ */ ((ShippingZoneError2) => {
794
797
  })(ShippingZoneError || {});
795
798
 
796
799
  // enums/tax.enum.ts
797
- var TaxProductType = /* @__PURE__ */ ((TaxProductType2) => {
798
- TaxProductType2["STANDARD"] = "standard";
799
- TaxProductType2["BASIC_FOOD"] = "basic_food";
800
- TaxProductType2["CHILDRENS_CLOTHING"] = "childrens_clothing";
801
- TaxProductType2["EXEMPT"] = "exempt";
802
- return TaxProductType2;
803
- })(TaxProductType || {});
804
800
  var TaxRegistrationKind = /* @__PURE__ */ ((TaxRegistrationKind2) => {
805
801
  TaxRegistrationKind2["GST_HST"] = "GST_HST";
806
802
  TaxRegistrationKind2["PST"] = "PST";
@@ -820,6 +816,7 @@ var OutOfProvinceTaxes = /* @__PURE__ */ ((OutOfProvinceTaxes2) => {
820
816
  var TaxWarningCode = /* @__PURE__ */ ((TaxWarningCode2) => {
821
817
  TaxWarningCode2["NOT_REGISTERED"] = "NOT_REGISTERED";
822
818
  TaxWarningCode2["NO_RULES_FOR_PLACE"] = "NO_RULES_FOR_PLACE";
819
+ TaxWarningCode2["NO_TABLE"] = "NO_TABLE";
823
820
  return TaxWarningCode2;
824
821
  })(TaxWarningCode || {});
825
822
 
@@ -4258,12 +4255,146 @@ function tiersAreValid(option) {
4258
4255
  return tiers.every((tier) => Number.isInteger(tier.from) && tier.from > 0 && isAmount(tier.price)) && new Set(froms).size === froms.length;
4259
4256
  }
4260
4257
 
4261
- // tax/registrations.ts
4262
- var TAX_REGISTRATION_PLACES = {
4263
- ["GST_HST" /* GST_HST */]: ["CA"],
4264
- ["PST" /* PST */]: ["CA-BC", "CA-SK", "CA-MB"],
4265
- ["QST" /* QST */]: ["CA-QC"]
4266
- };
4258
+ // tax/sha1.ts
4259
+ function utf8Bytes(text) {
4260
+ const bytes = [];
4261
+ for (const char of text) {
4262
+ const cp = char.codePointAt(0);
4263
+ if (cp < 128) bytes.push(cp);
4264
+ else if (cp < 2048) bytes.push(192 | cp >> 6, 128 | cp & 63);
4265
+ else if (cp < 65536) bytes.push(224 | cp >> 12, 128 | cp >> 6 & 63, 128 | cp & 63);
4266
+ else bytes.push(240 | cp >> 18, 128 | cp >> 12 & 63, 128 | cp >> 6 & 63, 128 | cp & 63);
4267
+ }
4268
+ return bytes;
4269
+ }
4270
+ var rotl = (x, n) => x << n | x >>> 32 - n;
4271
+ function sha1Hex(text) {
4272
+ const bytes = utf8Bytes(text);
4273
+ const bitLength = bytes.length * 8;
4274
+ bytes.push(128);
4275
+ while (bytes.length % 64 !== 56) bytes.push(0);
4276
+ const high = Math.floor(bitLength / 4294967296);
4277
+ for (const word of [high, bitLength >>> 0])
4278
+ bytes.push(word >>> 24 & 255, word >>> 16 & 255, word >>> 8 & 255, word & 255);
4279
+ const h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
4280
+ const w = new Array(80);
4281
+ for (let offset = 0; offset < bytes.length; offset += 64) {
4282
+ for (let i = 0; i < 16; i++) {
4283
+ const j = offset + i * 4;
4284
+ w[i] = bytes[j] << 24 | bytes[j + 1] << 16 | bytes[j + 2] << 8 | bytes[j + 3];
4285
+ }
4286
+ for (let i = 16; i < 80; i++) w[i] = rotl(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
4287
+ let [a, b, c, d, e] = h;
4288
+ for (let i = 0; i < 80; i++) {
4289
+ const [f, k] = i < 20 ? [b & c | ~b & d, 1518500249] : i < 40 ? [b ^ c ^ d, 1859775393] : i < 60 ? [b & c | b & d | c & d, 2400959708] : [b ^ c ^ d, 3395469782];
4290
+ const t = rotl(a, 5) + f + e + k + w[i] | 0;
4291
+ e = d;
4292
+ d = c;
4293
+ c = rotl(b, 30);
4294
+ b = a;
4295
+ a = t;
4296
+ }
4297
+ h[0] = h[0] + a | 0;
4298
+ h[1] = h[1] + b | 0;
4299
+ h[2] = h[2] + c | 0;
4300
+ h[3] = h[3] + d | 0;
4301
+ h[4] = h[4] + e | 0;
4302
+ }
4303
+ return h.map((x) => (x >>> 0).toString(16).padStart(8, "0")).join("");
4304
+ }
4305
+
4306
+ // tax/table.ts
4307
+ var STANDARD_TAX_TYPE = "standard";
4308
+ var TYPE_FIELDS = ["key", "name", "description", "sortOrder", "active"];
4309
+ var RATE_FIELDS = [
4310
+ "code",
4311
+ "name",
4312
+ "kind",
4313
+ "places",
4314
+ "rate",
4315
+ "from",
4316
+ "to",
4317
+ "order",
4318
+ "compound",
4319
+ "registrationPlace",
4320
+ "harmonized",
4321
+ "parts",
4322
+ "sourceUrl",
4323
+ "status"
4324
+ ];
4325
+ var RULE_FIELDS = ["taxType", "codes", "rate", "from", "to", "sourceUrl", "status", "note"];
4326
+ function canonical(row, fields) {
4327
+ return JSON.stringify(fields.map((field) => row[field] ?? null));
4328
+ }
4329
+ var sortedCanonical = (rows, fields) => rows.map((row) => canonical(row, fields)).sort();
4330
+ function automaticTaxTableVersion(table) {
4331
+ return sha1Hex(
4332
+ JSON.stringify([
4333
+ sortedCanonical(table.types, TYPE_FIELDS),
4334
+ sortedCanonical(table.rates, RATE_FIELDS),
4335
+ sortedCanonical(table.rules, RULE_FIELDS)
4336
+ ])
4337
+ );
4338
+ }
4339
+ var toTypeRow = ({ key, name, description, sortOrder, active }) => ({
4340
+ key,
4341
+ name,
4342
+ description,
4343
+ sortOrder,
4344
+ active
4345
+ });
4346
+ var toRateRow = (rate) => ({
4347
+ code: rate.code,
4348
+ name: rate.name,
4349
+ kind: rate.kind,
4350
+ places: rate.places,
4351
+ rate: rate.rate,
4352
+ from: rate.from,
4353
+ to: rate.to,
4354
+ order: rate.order,
4355
+ compound: rate.compound,
4356
+ registrationPlace: rate.registrationPlace,
4357
+ harmonized: rate.harmonized,
4358
+ parts: rate.parts?.map(({ code, name, rate: partRate, level }) => ({ code, name, rate: partRate, level })),
4359
+ sourceUrl: rate.sourceUrl,
4360
+ status: rate.status
4361
+ });
4362
+ var toRuleRow = ({
4363
+ taxType,
4364
+ codes: codes2,
4365
+ rate,
4366
+ from,
4367
+ to,
4368
+ sourceUrl,
4369
+ status,
4370
+ note
4371
+ }) => ({
4372
+ taxType,
4373
+ codes: codes2,
4374
+ rate,
4375
+ from,
4376
+ to,
4377
+ sourceUrl,
4378
+ status,
4379
+ note
4380
+ });
4381
+ function buildAutomaticTaxTable(rows) {
4382
+ const table = {
4383
+ types: [...rows.types].sort((a, b) => a.sortOrder - b.sortOrder).map(toTypeRow),
4384
+ rates: rows.rates.map(toRateRow),
4385
+ rules: rows.rules.map(toRuleRow)
4386
+ };
4387
+ return { version: automaticTaxTableVersion(table), ...table };
4388
+ }
4389
+ function registrationPlacesByKind(rates) {
4390
+ const places = /* @__PURE__ */ new Map();
4391
+ for (const rate of rates) {
4392
+ const list = places.get(rate.kind) ?? [];
4393
+ if (!list.includes(rate.registrationPlace)) list.push(rate.registrationPlace);
4394
+ places.set(rate.kind, list);
4395
+ }
4396
+ return places;
4397
+ }
4267
4398
 
4268
4399
  // constants/adyen.constants.ts
4269
4400
  var ADYEN_ROLLOUT_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
@@ -4443,6 +4574,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4443
4574
  ResidualPaymentMethod,
4444
4575
  ResidualStatus,
4445
4576
  ResourceAvailabilityState,
4577
+ STANDARD_TAX_TYPE,
4446
4578
  STATE_SCHEMA,
4447
4579
  STRIPE_SUPPORTED_COUNTRIES,
4448
4580
  SYSTEM_FAMILIES,
@@ -4458,8 +4590,6 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4458
4590
  StationStatus,
4459
4591
  StripeCurrencyCode,
4460
4592
  StripeStatus,
4461
- TAX_REGISTRATION_PLACES,
4462
- TaxProductType,
4463
4593
  TaxRegistrationKind,
4464
4594
  TaxSource,
4465
4595
  TaxWarningCode,
@@ -4476,11 +4606,13 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4476
4606
  amountToString,
4477
4607
  ancestorChain,
4478
4608
  assertUnitSane,
4609
+ automaticTaxTableVersion,
4479
4610
  availableIn,
4480
4611
  baseFor,
4481
4612
  baseFulfillmentDefinitions,
4482
4613
  baseOf,
4483
4614
  basePaymentDefinitions,
4615
+ buildAutomaticTaxTable,
4484
4616
  buildAvailability,
4485
4617
  buildGrid,
4486
4618
  buildOrderContext,
@@ -4574,6 +4706,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4574
4706
  presentAt,
4575
4707
  priceForTotal,
4576
4708
  provincesForPostCode,
4709
+ registrationPlacesByKind,
4577
4710
  removeFragment,
4578
4711
  resolveFamily,
4579
4712
  resolveModifiersForProduct,
@@ -4583,6 +4716,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
4583
4716
  roundToPrecision,
4584
4717
  sameFamily,
4585
4718
  setOrderState,
4719
+ sha1Hex,
4586
4720
  shopDayKey,
4587
4721
  shopDayRange,
4588
4722
  signReportForDisplay,