@final-commerce/common 1.1.4-beta.5 → 1.2.4-beta.2

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
@@ -218,7 +218,8 @@ declare enum InventorySpecificActionType {
218
218
  SALE = "SALE",
219
219
  TRANSFER = "TRANSFER",
220
220
  BULK_RECOUNT = "BULK_RECOUNT",
221
- APPLIED_FROM_WOO = "APPLIED_FROM_WOO"
221
+ APPLIED_FROM_WOO = "APPLIED_FROM_WOO",
222
+ PO_RECEIVED = "PO_RECEIVED"
222
223
  }
223
224
  declare enum ExtensionCategory {
224
225
  SYNC = "sync",
@@ -391,6 +392,12 @@ declare enum ProductStatus {
391
392
  DRAFT = "draft"
392
393
  }
393
394
 
395
+ declare enum PaymentProcessor {
396
+ STRIPE = "stripe",
397
+ ADYEN = "adyen",
398
+ EXTERNAL = "external"
399
+ }
400
+
394
401
  interface CurrencyConfig {
395
402
  minorUnits: number;
396
403
  symbol: string;
@@ -619,6 +626,19 @@ declare function getMinorUnits(currency: CurrencyCode): number;
619
626
  declare function createAmount(value: string | number | null | undefined, currency: CurrencyCode): Amount | undefined;
620
627
  declare function amountToString(amount: Amount | undefined | null): string;
621
628
 
629
+ type MoneyInput = number | string | null | undefined;
630
+ declare function getTotalCollected(amountPaid: MoneyInput, tipTotal: MoneyInput): number;
631
+ declare function getPaymentLegTotal(amount: MoneyInput, tipAmount: MoneyInput): number;
632
+ declare function getCashAmountDue(amount: MoneyInput, cashRounding: MoneyInput): number;
633
+ interface SettlementBuckets {
634
+ cardTotal?: MoneyInput;
635
+ cashTotal?: MoneyInput;
636
+ customTotal?: MoneyInput;
637
+ }
638
+ declare function getSettlementTotal(payments: SettlementBuckets | undefined | null, tipTotal: MoneyInput): number;
639
+ declare function getLineSubtotal(price: MoneyInput, quantity: MoneyInput): number;
640
+ declare function getGoodsPortion(total: MoneyInput, totalTax: MoneyInput): number;
641
+
622
642
  declare function getPricingRegionFromCountry(countryCode?: string): PricingRegionEnum;
623
643
  declare const NORTH_AMERICA: Set<string>;
624
644
  declare const EUROPE: Set<string>;
@@ -899,7 +919,6 @@ declare const DEFAULT_CONFIG: StoredStateConfig;
899
919
  declare function buildResolvedConfig(config: StoredStateConfig): StateConfig;
900
920
  declare const DEFAULT_RESOLVED_CONFIG: StateConfig;
901
921
 
902
- declare const POS_CROSS_AXIS_RULES: readonly CrossAxisRule[];
903
922
  declare const POS_VALID_INITIAL_STATES: readonly StatePair[];
904
923
  declare function buildPosPresetConfig(companyId?: string): StoredStateConfig;
905
924
 
@@ -1059,4 +1078,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
1059
1078
  declare const OtherFixedRates: Record<string, CurrencyRate>;
1060
1079
  declare const COUNTRY_CURRENCIES: Record<string, string>;
1061
1080
 
1062
- export { type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, EUFixedRates, EUROPE, type EndOfSessionReport, 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, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LibraryItemType, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_CROSS_AXIS_RULES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, 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, addAmounts, amountToString, baseFulfillmentDefinitions, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, formatCurrency, formatMinorUnitsToString, fromMinorUnits, generateMongoID, getAvailableTransitions, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getMinorUnitMultiplier, getMinorUnits, getPricingRegionFromCountry, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
1081
+ export { type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, EUFixedRates, EUROPE, type EndOfSessionReport, 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, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LibraryItemType, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, 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, addAmounts, amountToString, baseFulfillmentDefinitions, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, formatCurrency, formatMinorUnitsToString, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
package/dist/index.d.ts CHANGED
@@ -218,7 +218,8 @@ declare enum InventorySpecificActionType {
218
218
  SALE = "SALE",
219
219
  TRANSFER = "TRANSFER",
220
220
  BULK_RECOUNT = "BULK_RECOUNT",
221
- APPLIED_FROM_WOO = "APPLIED_FROM_WOO"
221
+ APPLIED_FROM_WOO = "APPLIED_FROM_WOO",
222
+ PO_RECEIVED = "PO_RECEIVED"
222
223
  }
223
224
  declare enum ExtensionCategory {
224
225
  SYNC = "sync",
@@ -391,6 +392,12 @@ declare enum ProductStatus {
391
392
  DRAFT = "draft"
392
393
  }
393
394
 
395
+ declare enum PaymentProcessor {
396
+ STRIPE = "stripe",
397
+ ADYEN = "adyen",
398
+ EXTERNAL = "external"
399
+ }
400
+
394
401
  interface CurrencyConfig {
395
402
  minorUnits: number;
396
403
  symbol: string;
@@ -619,6 +626,19 @@ declare function getMinorUnits(currency: CurrencyCode): number;
619
626
  declare function createAmount(value: string | number | null | undefined, currency: CurrencyCode): Amount | undefined;
620
627
  declare function amountToString(amount: Amount | undefined | null): string;
621
628
 
629
+ type MoneyInput = number | string | null | undefined;
630
+ declare function getTotalCollected(amountPaid: MoneyInput, tipTotal: MoneyInput): number;
631
+ declare function getPaymentLegTotal(amount: MoneyInput, tipAmount: MoneyInput): number;
632
+ declare function getCashAmountDue(amount: MoneyInput, cashRounding: MoneyInput): number;
633
+ interface SettlementBuckets {
634
+ cardTotal?: MoneyInput;
635
+ cashTotal?: MoneyInput;
636
+ customTotal?: MoneyInput;
637
+ }
638
+ declare function getSettlementTotal(payments: SettlementBuckets | undefined | null, tipTotal: MoneyInput): number;
639
+ declare function getLineSubtotal(price: MoneyInput, quantity: MoneyInput): number;
640
+ declare function getGoodsPortion(total: MoneyInput, totalTax: MoneyInput): number;
641
+
622
642
  declare function getPricingRegionFromCountry(countryCode?: string): PricingRegionEnum;
623
643
  declare const NORTH_AMERICA: Set<string>;
624
644
  declare const EUROPE: Set<string>;
@@ -899,7 +919,6 @@ declare const DEFAULT_CONFIG: StoredStateConfig;
899
919
  declare function buildResolvedConfig(config: StoredStateConfig): StateConfig;
900
920
  declare const DEFAULT_RESOLVED_CONFIG: StateConfig;
901
921
 
902
- declare const POS_CROSS_AXIS_RULES: readonly CrossAxisRule[];
903
922
  declare const POS_VALID_INITIAL_STATES: readonly StatePair[];
904
923
  declare function buildPosPresetConfig(companyId?: string): StoredStateConfig;
905
924
 
@@ -1059,4 +1078,4 @@ declare const EUFixedRates: Record<string, CurrencyRate>;
1059
1078
  declare const OtherFixedRates: Record<string, CurrencyRate>;
1060
1079
  declare const COUNTRY_CURRENCIES: Record<string, string>;
1061
1080
 
1062
- export { type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, EUFixedRates, EUROPE, type EndOfSessionReport, 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, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LibraryItemType, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_CROSS_AXIS_RULES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, 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, addAmounts, amountToString, baseFulfillmentDefinitions, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, formatCurrency, formatMinorUnitsToString, fromMinorUnits, generateMongoID, getAvailableTransitions, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getMinorUnitMultiplier, getMinorUnits, getPricingRegionFromCountry, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
1081
+ export { type Amount, AttributeType, type AvailableTransition, CONDITION_OPERATORS, COUNTRY_CURRENCIES, CURRENCY_CONFIG, type CartDiscountBucket, type CartFeeBucket, type CashDrawer, type CashRoundingTuple, CompanyType, type Condition, type ConditionGroup, type ConditionOperator, type ConfigUpdatedPayload, type ConfigValidationError, type ConfigValidationResult, type ConfigValidationWarning, type CrossAxisRequires, type CrossAxisRule, type CrossAxisTrigger, CurrencyCode, type CurrencyConfig, type CurrencyRate, CustomTableAvailability, CustomerPlatform, DEFAULT_CONFIG, DEFAULT_CROSS_AXIS_RULES, DEFAULT_DISPLAY_STATE_MAP, DEFAULT_RESOLVED_CONFIG, type DeleteStateConfigFragmentParams, type DeleteStateConfigFragmentResponse, type DiscountsBreakdown, type DiscountsTuple, type DisplayStateResult, type DisplayStateRule, EUFixedRates, EUROPE, type EndOfSessionReport, 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, InventoryBaseActionEnum, type InventoryBaseActionType, InventorySpecificActionType, InvoiceStatus, LibraryItemType, MenuProject, NAFixedRates, NORTH_AMERICA, NonRevenueItemType, ORDER_STATE_ACTIONS, ORDER_STATE_EVENTS, ORDER_STATE_TOPIC, type OrderContext, type OrderLikeForContext, type OrderLikeForLegacyInference, type OrderLineItem, type OrderPaymentMethod, OrderPlatform, type OrderRefund, type OrderStateEventPayload, type OrderStateWritable, OtherFixedRates, OwnerType, PATH_MODES, PAYMENT_STATES, POS_VALID_INITIAL_STATES, type PathMode, PaymentMethod, PaymentProcessor, type PaymentState, type PaymentStateDefinition, type PaymentTransitionPath, Platform, PreviewImageMode, PricingLevel, PricingPlanEnum, PricingRegionEnum, type ProductDiscountBucket, type ProductFeeBucket, ProductStatus, ProductType, PublicationAvailability, type PublicationConfig, PublicationStatus, REGION_MAPPING, REPORT_NEGATE_PATHS, ReceiptSendChannel, ReceiptType, type RefundsBreakdown, ResidualPaymentMethod, ResidualStatus, type ResolveTemplateResult, STATE_SCHEMA, STRIPE_SUPPORTED_COUNTRIES, type SalesSummary, type SaveStateConfigFragmentParams, type SaveStateConfigFragmentResponse, type SettlementBreakdown, type SettlementBuckets, type SettlementCardSection, type SettlementCashSection, type SettlementCustomEntry, type SplitPayment, type SplitPaymentPayment, type StaffSales, type StaffSalesEntry, type StateConfig, type StateConfigFragment, type StateDefinition, type StatePair, type StateSchema, type StateTransitionBlockedPayload, type StateTransitionCompletedPayload, StationStatus, type StoredStateConfig, StripeCurrencyCode, StripeStatus, type TaxBreakdown, type TaxBreakdownRateEntry, type TaxBreakdownSection, type TaxBreakdownSubtotal, 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, addAmounts, amountToString, baseFulfillmentDefinitions, basePaymentDefinitions, buildOrderContext, buildPosPresetConfig, buildResolvedConfig, calculatePercentage, canTransition, conditionSummary, convertFixedFeeToLocalCurrency, createAmount, crossAxisRuleApplies, deriveDisplayState, displayRuleMatchesPair, divideAmount, evaluateCondition, evaluateConditionSet, formatCurrency, formatMinorUnitsToString, fromMinorUnits, generateMongoID, getAvailableTransitions, getCashAmountDue, getCountriesByRegion, getCurrencyConfig, getCurrentISODate, getFinancialInvariantViolations, getGoodsPortion, getLineSubtotal, getMinorUnitMultiplier, getMinorUnits, getPaymentLegTotal, getPricingRegionFromCountry, getSettlementTotal, getTotalCollected, inferStatesFromLegacyStatus, isConditionOperator, isFulfillmentState, isPaymentState, isSupportedCurrency, mapToLegacyStatus, mergeFragment, multiplyAmount, normalizeMongoIdString, parseAmountToMinorUnits, parseCurrencyCode, parseStripeCurrencyCode, removeFragment, resolveTemplate, setOrderState, signReportForDisplay, stringifyMinorUnits, subtractAmounts, toMinorUnits, validateConfig, validateFragmentCompatibility, violatesFinancialInvariant };
package/dist/index.js CHANGED
@@ -53,9 +53,9 @@ __export(index_exports, {
53
53
  OwnerType: () => OwnerType,
54
54
  PATH_MODES: () => PATH_MODES,
55
55
  PAYMENT_STATES: () => PAYMENT_STATES,
56
- POS_CROSS_AXIS_RULES: () => POS_CROSS_AXIS_RULES,
57
56
  POS_VALID_INITIAL_STATES: () => POS_VALID_INITIAL_STATES,
58
57
  PaymentMethod: () => PaymentMethod,
58
+ PaymentProcessor: () => PaymentProcessor,
59
59
  Platform: () => Platform,
60
60
  PreviewImageMode: () => PreviewImageMode,
61
61
  PricingLevel: () => PricingLevel,
@@ -102,13 +102,19 @@ __export(index_exports, {
102
102
  fromMinorUnits: () => fromMinorUnits,
103
103
  generateMongoID: () => generateMongoID,
104
104
  getAvailableTransitions: () => getAvailableTransitions,
105
+ getCashAmountDue: () => getCashAmountDue,
105
106
  getCountriesByRegion: () => getCountriesByRegion,
106
107
  getCurrencyConfig: () => getCurrencyConfig,
107
108
  getCurrentISODate: () => getCurrentISODate,
108
109
  getFinancialInvariantViolations: () => getFinancialInvariantViolations,
110
+ getGoodsPortion: () => getGoodsPortion,
111
+ getLineSubtotal: () => getLineSubtotal,
109
112
  getMinorUnitMultiplier: () => getMinorUnitMultiplier,
110
113
  getMinorUnits: () => getMinorUnits,
114
+ getPaymentLegTotal: () => getPaymentLegTotal,
111
115
  getPricingRegionFromCountry: () => getPricingRegionFromCountry,
116
+ getSettlementTotal: () => getSettlementTotal,
117
+ getTotalCollected: () => getTotalCollected,
112
118
  inferStatesFromLegacyStatus: () => inferStatesFromLegacyStatus,
113
119
  isConditionOperator: () => isConditionOperator,
114
120
  isFulfillmentState: () => isFulfillmentState,
@@ -367,6 +373,7 @@ var InventorySpecificActionType = /* @__PURE__ */ ((InventorySpecificActionType2
367
373
  InventorySpecificActionType2["TRANSFER"] = "TRANSFER";
368
374
  InventorySpecificActionType2["BULK_RECOUNT"] = "BULK_RECOUNT";
369
375
  InventorySpecificActionType2["APPLIED_FROM_WOO"] = "APPLIED_FROM_WOO";
376
+ InventorySpecificActionType2["PO_RECEIVED"] = "PO_RECEIVED";
370
377
  return InventorySpecificActionType2;
371
378
  })(InventorySpecificActionType || {});
372
379
  var ExtensionCategory = /* @__PURE__ */ ((ExtensionCategory2) => {
@@ -561,6 +568,14 @@ var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
561
568
  return ProductStatus2;
562
569
  })(ProductStatus || {});
563
570
 
571
+ // enums/payments.enum.ts
572
+ var PaymentProcessor = /* @__PURE__ */ ((PaymentProcessor2) => {
573
+ PaymentProcessor2["STRIPE"] = "stripe";
574
+ PaymentProcessor2["ADYEN"] = "adyen";
575
+ PaymentProcessor2["EXTERNAL"] = "external";
576
+ return PaymentProcessor2;
577
+ })(PaymentProcessor || {});
578
+
564
579
  // utils/currency.util.ts
565
580
  var CURRENCY_CONFIG = {
566
581
  // Major currencies with 2 decimal places
@@ -844,6 +859,29 @@ function amountToString(amount) {
844
859
  return majorValue.toFixed(amount.minorUnits);
845
860
  }
846
861
 
862
+ // utils/order-totals.util.ts
863
+ function toMinorUnits2(value) {
864
+ return Number(value) || 0;
865
+ }
866
+ function getTotalCollected(amountPaid, tipTotal) {
867
+ return toMinorUnits2(amountPaid) + toMinorUnits2(tipTotal);
868
+ }
869
+ function getPaymentLegTotal(amount, tipAmount) {
870
+ return toMinorUnits2(amount) + toMinorUnits2(tipAmount);
871
+ }
872
+ function getCashAmountDue(amount, cashRounding) {
873
+ return toMinorUnits2(amount) - toMinorUnits2(cashRounding);
874
+ }
875
+ function getSettlementTotal(payments, tipTotal) {
876
+ return toMinorUnits2(payments?.cardTotal) + toMinorUnits2(payments?.cashTotal) + toMinorUnits2(payments?.customTotal) + toMinorUnits2(tipTotal);
877
+ }
878
+ function getLineSubtotal(price, quantity) {
879
+ return toMinorUnits2(price) * toMinorUnits2(quantity);
880
+ }
881
+ function getGoodsPortion(total, totalTax) {
882
+ return toMinorUnits2(total) - toMinorUnits2(totalTax);
883
+ }
884
+
847
885
  // constants/pricing.constants.ts
848
886
  var REGION_MAPPING = {
849
887
  // North America
@@ -1093,7 +1131,8 @@ var REPORT_NEGATE_PATHS = /* @__PURE__ */ new Set([
1093
1131
  "taxBreakdown.refunds.total.tax",
1094
1132
  // Refunds breakdown — reductions and naturally-signed entries
1095
1133
  "refundsBreakdown.discountsReversed",
1096
- "refundsBreakdown.cashRoundingRefund",
1134
+ // 2026 AUG10, cashRoundingRefund is showing as natural sign
1135
+ // 'refundsBreakdown.cashRoundingRefund',
1097
1136
  // Fees breakdown — refunded magnitudes are money flowing back out
1098
1137
  "feesBreakdown.productFee.refundedProductFees",
1099
1138
  "feesBreakdown.cartFee.refundedCartFees",
@@ -1402,7 +1441,7 @@ var DEFAULT_CONFIG = {
1402
1441
  fulfillmentPaths: [],
1403
1442
  paymentPathMode: "permissive",
1404
1443
  fulfillmentPathMode: "permissive",
1405
- crossAxisRules: [...DEFAULT_CROSS_AXIS_RULES],
1444
+ crossAxisRules: [],
1406
1445
  transitionConditions: [],
1407
1446
  validInitialStates: [{ payment: "unpaid", fulfillment: "draft" }],
1408
1447
  displayStateMap: [...DEFAULT_DISPLAY_STATE_MAP],
@@ -1419,19 +1458,6 @@ function buildResolvedConfig(config) {
1419
1458
  var DEFAULT_RESOLVED_CONFIG = buildResolvedConfig(DEFAULT_CONFIG);
1420
1459
 
1421
1460
  // order-state-machine/pos-preset.ts
1422
- var POS_CROSS_AXIS_RULES = [
1423
- {
1424
- id: "pos-pay-requires-open-fulfillment",
1425
- label: "Payments only on open fulfillment states",
1426
- description: "POS payments are only valid on orders whose fulfillment is open (draft / pending / on_hold) or auto-fulfilled in lock-step (fulfilled). Returned / cancelled / in-progress fulfillment must use refund flows instead.",
1427
- enabled: true,
1428
- trigger: { axis: "payment", to: ["payment_pending", "paid", "partially_paid"] },
1429
- requires: {
1430
- axis: "fulfillment",
1431
- states: ["draft", "pending", "on_hold", "fulfilled"]
1432
- }
1433
- }
1434
- ];
1435
1461
  var POS_VALID_INITIAL_STATES = [
1436
1462
  { payment: "unpaid", fulfillment: "draft" },
1437
1463
  { payment: "unpaid", fulfillment: "on_hold" },
@@ -1446,7 +1472,7 @@ function buildPosPresetConfig(companyId) {
1446
1472
  _id: "pos-preset",
1447
1473
  companyId: companyId ?? DEFAULT_CONFIG.companyId,
1448
1474
  name: "POS Preset",
1449
- crossAxisRules: [...DEFAULT_CROSS_AXIS_RULES, ...POS_CROSS_AXIS_RULES],
1475
+ crossAxisRules: [],
1450
1476
  validInitialStates: [...POS_VALID_INITIAL_STATES],
1451
1477
  displayStateMap: [...DEFAULT_DISPLAY_STATE_MAP]
1452
1478
  };
@@ -2620,9 +2646,9 @@ var ORDER_STATE_EVENTS = {
2620
2646
  OwnerType,
2621
2647
  PATH_MODES,
2622
2648
  PAYMENT_STATES,
2623
- POS_CROSS_AXIS_RULES,
2624
2649
  POS_VALID_INITIAL_STATES,
2625
2650
  PaymentMethod,
2651
+ PaymentProcessor,
2626
2652
  Platform,
2627
2653
  PreviewImageMode,
2628
2654
  PricingLevel,
@@ -2669,13 +2695,19 @@ var ORDER_STATE_EVENTS = {
2669
2695
  fromMinorUnits,
2670
2696
  generateMongoID,
2671
2697
  getAvailableTransitions,
2698
+ getCashAmountDue,
2672
2699
  getCountriesByRegion,
2673
2700
  getCurrencyConfig,
2674
2701
  getCurrentISODate,
2675
2702
  getFinancialInvariantViolations,
2703
+ getGoodsPortion,
2704
+ getLineSubtotal,
2676
2705
  getMinorUnitMultiplier,
2677
2706
  getMinorUnits,
2707
+ getPaymentLegTotal,
2678
2708
  getPricingRegionFromCountry,
2709
+ getSettlementTotal,
2710
+ getTotalCollected,
2679
2711
  inferStatesFromLegacyStatus,
2680
2712
  isConditionOperator,
2681
2713
  isFulfillmentState,