@zeniai/client-epic-state 5.2.72 → 5.2.74-betaAK0

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.
Files changed (28) hide show
  1. package/lib/entity/invoicing/coupon/couponSelector.d.ts +1 -0
  2. package/lib/entity/invoicing/coupon/couponSelector.js +5 -0
  3. package/lib/epic.d.ts +2 -1
  4. package/lib/epic.js +2 -0
  5. package/lib/esm/entity/invoicing/coupon/couponSelector.js +4 -0
  6. package/lib/esm/epic.js +2 -0
  7. package/lib/esm/index.js +1 -1
  8. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +55 -0
  9. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +35 -1
  10. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +80 -2
  11. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionEstimateEpic.js +49 -0
  12. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +18 -13
  13. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/updateOnboardingCustomerViewEpic.js +2 -2
  14. package/lib/index.d.ts +3 -3
  15. package/lib/index.js +7 -5
  16. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.d.ts +46 -1
  17. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +57 -1
  18. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +10 -2
  19. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +36 -2
  20. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +21 -1
  21. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +83 -3
  22. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +58 -0
  23. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionEstimateEpic.d.ts +7 -0
  24. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionEstimateEpic.js +53 -0
  25. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts +8 -0
  26. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +21 -14
  27. package/lib/view/onboardingView/customerView/epic/customerDetails/updateOnboardingCustomerViewEpic.js +2 -2
  28. package/package.json +1 -26
package/lib/index.js CHANGED
@@ -81,11 +81,11 @@ exports.toMccCategoryLike = exports.CARD_POLICY_LIMIT_ROW_ID_TRANSACTION = expor
81
81
  exports.fetchAutoTransferRuleHistory = exports.deleteAutoTransferRule = exports.updateAutoTransferRule = exports.createAutoTransferRule = exports.fetchAutoTransferRules = exports.getTreasuryTaxLetters = exports.fetchTreasuryTaxLetterList = exports.getTreasuryStatements = exports.fetchTreasuryStatementList = exports.getTreasuryTransferMoney = exports.clearTreasuryTransferMoney = exports.updateTreasuryTransferMoneyLocalData = exports.executeTreasuryTransferMoney = exports.getTreasuryDetail = exports.updateTreasuryTransactionListUIState = exports.fetchTreasuryTransactionList = exports.fetchTreasuryOverviewDetail = exports.getUpdateCardPolicyFetchState = exports.getCardPolicyFormDraft = exports.getCardPolicyDetailView = exports.getCardPolicyDetailFetchState = exports.updateCardPolicyFormDraft = exports.updateCardPolicyFetchStatus = exports.updateCardPolicyDetailFetchStatus = exports.updateCardPolicy = exports.fetchCardPolicyDetail = exports.getCardPolicyTemplateIds = exports.getCardPolicyListView = exports.getCardPolicyListFetchState = exports.getArchiveCardPolicyFetchState = exports.updateCardPolicyListFetchStatus = exports.updateArchiveCardPolicyFetchStatus = exports.prependCardPolicyTemplateIds = exports.fetchCardPolicyList = exports.archiveCardPolicy = exports.toManualCardPolicyTemplateRequestFromDraft = exports.toBulkCardPolicyTemplateRequestsFromDraft = exports.toCardPolicyTemplateRequestFromDraft = exports.applyAiCardPolicyFormDraftUpdate = exports.deriveAiPolicyReviewRowsFromInputs = exports.buildManualCardPolicyFormDraftSeed = exports.buildUploadReviewRows = exports.buildEmptyLimitRows = exports.buildAiCardPolicyFormDraftSeed = exports.toVendorChipFieldValue = exports.toMccCategoryChipFieldValue = exports.buildVendorChipId = exports.buildMccCategoryChipId = exports.VENDOR_CHIP_ID_PREFIX = exports.MCC_CHIP_ID_PREFIX = void 0;
82
82
  exports.resetCreateInvoice = exports.fetchCreateInvoiceFormPage = exports.createInvoice = exports.getInvoiceDetail = exports.fetchInvoiceDetailPage = exports.fetchInvoiceDetail = exports.getInvoiceListView = exports.ALL_INVOICING_INVOICE_TAB_IDS = exports.updateInvoiceListFilters = exports.setInvoiceActiveTab = exports.fetchInvoiceListPage = exports.fetchInvoiceList = exports.fetchInvoiceKPIs = exports.fetchInvoiceCounts = exports.getInvoicesByIds = exports.getInvoiceById = exports.updateInvoices = exports.removeInvoice = exports.mapAuditLogEntry = exports.toAuditLogEntityRouteOption = exports.isInvoicingEntityLinkable = exports.buildInvoicingEntityPath = exports.toInvoicingDiscountLifecycleActionOption = exports.toInvoicingDiscountLifecycleAction = exports.toInvoicingCatalogProductLifecycleActionOption = exports.toInvoicingCatalogItemLifecycleActionOption = exports.toInvoicingCatalogProductLifecycleAction = exports.toInvoicingCatalogItemLifecycleAction = exports.toInvoicingSubscriptionLifecycleActionOption = exports.toInvoicingSubscriptionLifecycleAction = exports.toInvoicingDunningAction = exports.INVOICING_DISCOUNT_LIFECYCLE_ACTIONS = exports.INVOICING_CATALOG_PRODUCT_LIFECYCLE_ACTIONS = exports.INVOICING_CATALOG_ITEM_LIFECYCLE_ACTIONS = exports.INVOICING_SUBSCRIPTION_LIFECYCLE_ACTIONS = exports.INVOICING_DUNNING_ACTIONS = exports.toKycProvidedDocumentTypeFromAllowed = exports.toKycProvidedDocumentType = exports.DEFAULT_SESSION_CONFIG = exports.SessionManager = exports.getTransactionActivityLogView = exports.fetchTransactionActivityLog = exports.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = exports.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = exports.getAutoTransferRuleHistory = exports.getAutoTransferRuleById = exports.getAutoTransferRules = exports.clearRuleUpdateLocalData = exports.updateRuleLocalData = exports.fetchAutoTransferReviewDetail = void 0;
83
83
  exports.entityToInvoicingCustomerFormLocalData = exports.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE = exports.updateInvoicingCustomerFormDraft = exports.submitInvoicingCustomerFormSuccess = exports.submitInvoicingCustomerFormFailure = exports.submitInvoicingCustomerForm = exports.resetEditInvoicingCustomerDetailView = exports.initializeInvoicingCustomerAddress = exports.getRecordPaymentView = exports.getRecordPaymentInvoiceOptions = exports.getRecordPaymentFormView = exports.getCreateInvoiceFormView = exports.getInvoicingAuditView = exports.fetchInvoicingAuditLog = exports.getInvoicingOverview = exports.buildPeriodOptions = exports.fetchInvoicingOverview = exports.clearInvoicingOverview = exports.initialRecordPaymentFormLocalData = exports.localDataToRecordPaymentPayload = exports.localDataToInvoiceRecordPaymentBody = exports.initializeRecordPaymentDraftFromInvoice = exports.getCreateCreditNoteView = exports.getCreateCreditNoteFormView = exports.initialCreateCreditNoteFormLocalData = exports.localDataToCreateCreditNotePayload = exports.updateCreateCreditNoteFormDraft = exports.submitCreateCreditNote = exports.resetCreateCreditNote = exports.createCreditNoteSuccess = exports.createCreditNoteFailure = exports.getIssueCreditNoteView = exports.initialIssueCreditNoteFormLocalData = exports.localDataToIssueCreditNotePayload = exports.initializeIssueCreditNoteDraftFromInvoice = exports.computeIssueCreditNoteTotal = exports.updateIssueCreditNoteFormDraft = exports.submitIssueCreditNote = exports.resetIssueCreditNote = exports.issueCreditNoteSuccess = exports.issueCreditNoteFailure = exports.initializeIssueCreditNoteDraft = exports.updateRecordPaymentFormDraft = exports.submitRecordPayment = exports.initializeRecordPaymentDraft = exports.resetRecordPayment = exports.initialInvoicingCreateInvoiceFormLocalData = exports.createInvoiceFormLocalDataToRequest = exports.blankInvoicingCreateInvoiceLineItem = exports.updateInvoicingCreateInvoiceFormDraft = void 0;
84
- exports.runInvoicingSubscriptionAction = exports.runInvoicingDiscountAction = exports.runInvoicingCatalogProductAction = exports.runInvoicingCatalogPlanAction = exports.fetchInvoicingCatalogItemDetailPage = exports.shouldDefaultAdjustmentCreditNote = exports.isBackdatedInvoiceDate = exports.buildVoidInvoiceSubmitBody = exports.updateInvoicingInvoice = exports.runInvoicingInvoiceAction = exports.getInvoicingCouponFormView = exports.getEditInvoicingCouponDetailViewState = exports.initialInvoicingCouponFormLocalData = exports.entityToInvoicingCouponFormLocalData = exports.updateInvoicingCouponFormDraft = exports.submitInvoicingCouponForm = exports.saveInvoicingCoupon = exports.resetEditInvoicingCouponDetailView = exports.fetchInvoicingCouponDetailPage = exports.getSavedInvoicingCatalogItemKind = exports.getSavedInvoicingCatalogItemId = exports.getInvoicingCatalogItemFormView = exports.getInvoicingApplicableCatalogItemOptions = exports.isTieredCatalogPricingModel = exports.initialInvoicingCatalogItemFormLocalData = exports.invoicingProductToCatalogItemFormSubFamily = exports.entityToInvoicingCatalogItemFormLocalData = exports.blankInvoicingCatalogTier = exports.blankInvoicingCatalogSubFamily = exports.INVOICING_CATALOG_TIER_TYPE_VALUES = exports.INVOICING_CATALOG_PRORATION_VALUES = exports.INVOICING_CATALOG_PRICING_MODEL_VALUES = exports.INVOICING_CATALOG_APPLICABILITY_VALUES = exports.updateInvoicingCatalogItemFormDraft = exports.submitInvoicingCatalogItemForm = exports.resetEditInvoicingCatalogItemDetailView = exports.getInvoicingSubscriptionFormView = exports.getEditInvoicingSubscriptionDetailViewState = exports.toInvoicingSubscriptionQuantity = exports.invoicingSubscriptionTodayIso = exports.initialInvoicingSubscriptionFormLocalData = exports.entityToInvoicingSubscriptionFormLocalData = exports.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE = exports.updateInvoicingSubscriptionFormDraft = exports.submitInvoicingSubscriptionForm = exports.resetEditInvoicingSubscriptionDetailView = exports.initializeInvoicingSubscriptionAddress = exports.fetchInvoicingSubscriptionFormPage = exports.getInvoicingCustomerFormView = exports.initialInvoicingCustomerFormLocalData = void 0;
85
- exports.ALL_INVOICING_SUBSCRIPTION_SORT_KEYS = exports.updateInvoicingSubscriptionFilters = exports.setInvoicingSubscriptionActiveTab = exports.fetchInvoicingSubscriptionListPage = exports.fetchInvoicingSubscriptionList = exports.fetchInvoicingSubscriptionCounts = exports.updateInvoicingSubscriptions = exports.removeInvoicingSubscription = exports.resetPromotionalCreditAction = exports.submitAddPromotionalCredits = exports.getInvoicingSetupIntentFetchState = exports.getInvoicingSetupIntent = exports.getInvoicingSentPaymentLinkMagicUrl = exports.getInvoicingSentPaymentLinkEmail = exports.getInvoicingPlaidLinkToken = exports.getInvoicingPaymentMethodSaveState = exports.getInvoicingPaymentLinkSendState = exports.sendInvoicingPaymentLink = exports.saveInvoicingPaymentMethod = exports.resetInvoicingCustomerPaymentMethod = exports.fetchInvoicingPlaidLinkToken = exports.createInvoicingSetupIntent = exports.fetchInvoicingPaymentLinkEmailPreviewPage = exports.fetchInvoicingCustomerDetailPage = exports.fetchInvoicingCustomerDetail = exports.getInvoicingCustomerListView = exports.INVOICING_CUSTOMER_COLUMNS = exports.ALL_INVOICING_CUSTOMER_TAB_IDS = exports.ALL_INVOICING_CUSTOMER_SORT_KEYS = exports.updateInvoicingCustomerFilters = exports.setInvoicingCustomerActiveTab = exports.fetchInvoicingCustomerListPage = exports.fetchInvoicingCustomerList = exports.fetchInvoicingCustomerCounts = exports.updateInvoicingCustomers = exports.removeInvoicingCustomer = exports.INVOICING_LIST_PAGE_SIZE = exports.uploadInvoicingMigrationFiles = exports.startInvoicingMigration = exports.rollbackInvoicingMigration = exports.retryInvoicingMigration = exports.connectInvoicingChargebee = exports.getInvoicingDataImportView = exports.setInvoicingActiveMigrationSessionId = exports.fetchInvoicingMigrationSessions = exports.fetchInvoicingMigrationSession = exports.fetchInvoicingMigrationDiagnostics = exports.fetchInvoicingDataImportStatus = exports.runInvoicingPaymentAction = exports.runInvoicingDunningAction = void 0;
86
- exports.getInvoicingCouponListView = exports.getInvoicingCouponListNextCursor = exports.getInvoicingCouponListItems = exports.getInvoicingCouponListHasMore = exports.getInvoicingCouponListFilters = exports.getInvoicingCouponListFetchState = exports.getInvoicingCouponCounts = exports.INVOICING_COUPON_COLUMNS = exports.ALL_INVOICING_COUPON_TAB_IDS = exports.ALL_INVOICING_COUPON_SORT_KEYS = exports.updateInvoicingCouponFilters = exports.setInvoicingCouponActiveTab = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.fetchInvoicingCouponCounts = exports.updateInvoicingCoupons = exports.removeInvoicingCoupon = exports.getInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteById = exports.fetchInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteListView = exports.INVOICING_CREDIT_NOTE_COLUMNS = exports.ALL_INVOICING_CREDIT_NOTE_TAB_IDS = exports.ALL_INVOICING_CREDIT_NOTE_SORT_KEYS = exports.updateInvoicingCreditNoteFilters = exports.setInvoicingCreditNoteActiveTab = exports.fetchInvoicingCreditNoteListPage = exports.fetchInvoicingCreditNoteList = exports.fetchInvoicingCreditNoteCounts = exports.updateInvoicingCreditNotes = exports.removeInvoicingCreditNote = exports.getInvoicingTransactionDetail = exports.getInvoicingTransactionById = exports.fetchInvoicingTransactionDetail = exports.getInvoicingTransactionListView = exports.INVOICING_TRANSACTION_COLUMNS = exports.ALL_INVOICING_TRANSACTION_TAB_IDS = exports.ALL_INVOICING_TRANSACTION_SORT_KEYS = exports.updateInvoicingTransactionFilters = exports.setInvoicingTransactionActiveTab = exports.fetchInvoicingTransactionListPage = exports.fetchInvoicingTransactionList = exports.updateInvoicingTransactions = exports.removeInvoicingTransaction = exports.getInvoicingSubscriptionById = exports.fetchInvoicingSubscriptionDetailPage = exports.fetchInvoicingSubscriptionDetail = exports.getInvoicingSubscriptionListView = exports.INVOICING_SUBSCRIPTION_COLUMNS = exports.ALL_INVOICING_SUBSCRIPTION_TAB_IDS = void 0;
87
- exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = exports.getInvoicingQboSettingsFormView = exports.getInvoicingBrandingFormView = exports.updateInvoicingSettings = exports.updateInvoicingQboSettingsDraft = exports.updateInvoicingBrandingFormDraft = exports.submitInvoicingQboSettings = exports.submitInvoicingBrandingForm = exports.saveInvoicingSettings = exports.resetSaveInvoicingSettings = exports.resetInvoicingQboSettingsDraft = exports.resetInvoicingBrandingFormDraft = exports.fetchInvoicingSettings = exports.disconnectInvoicingStripe = exports.connectInvoicingStripe = exports.getLowestInvoicingCatalogPricePointAmount = exports.getInvoicingCatalogItemById = exports.fetchInvoicingCatalogItemDetail = exports.getInvoicingCatalogListView = exports.updateInvoicingCatalogProductFilters = exports.updateInvoicingCatalogPlanFilters = exports.fetchInvoicingCatalogProductList = exports.fetchInvoicingCatalogPlanList = exports.fetchInvoicingCatalogListPage = exports.fetchInvoicingCatalogCounts = exports.updateInvoicingCatalogItems = exports.removeInvoicingCatalogItem = exports.mergeInvoicingCatalogPricePoint = exports.getInvoicingDunningEmailPreview = exports.getInvoicingDunningCaseDetail = exports.getInvoicingDunningCaseById = exports.invalidateInvoicingDunningEmailPreview = exports.fetchInvoicingDunningEmailPreviewPage = exports.fetchInvoicingDunningCaseDetailPage = exports.fetchInvoicingDunningCaseDetail = exports.clearInvoicingDunningCaseDetailView = exports.getInvoicingDunningCaseListView = exports.INVOICING_DUNNING_CASE_COLUMNS = exports.ALL_INVOICING_DUNNING_CASE_TAB_IDS = exports.ALL_INVOICING_DUNNING_CASE_SORT_KEYS = exports.updateInvoicingDunningCaseFilters = exports.setInvoicingDunningCaseActiveTab = exports.fetchInvoicingDunningCaseListPage = exports.fetchInvoicingDunningCaseList = exports.fetchInvoicingDunningCaseCounts = exports.updateInvoicingDunningCases = exports.removeInvoicingDunningCase = exports.fetchInvoicingCouponDetail = exports.getInvoicingCouponById = void 0;
88
- exports.isPendingReviewAccrual = exports.isManuallyReversedAccrual = exports.isAutoReversedAccrual = exports.getExpenseAutomationActualMatchingView = exports.getExpenseAutomationActualMatchingMatchView = exports.parseActualMatchingMatchId = exports.getCloseMatchAfterUndoMatchId = exports.getCloseMatchAfterUndo = exports.getCloseMatchAfterIgnoreMatchId = exports.getActualMatchingMatchModalConfirmStatus = exports.getActualMatchingReversalDate = exports.getActualMatchingAmount = exports.isPendingReviewRow = exports.isRenderableOneTimeAccrual = exports.isOneTimeAccrualRow = exports.isExistingTabRow = exports.isAiAccountantSchedule = exports.isAccruedScheduleRow = exports.getJEScheduleRowType = exports.getExpenseAutomationJEOneTimeAccrualDetailView = exports.getInvoicingOnboardingGateView = exports.getInvoicingConfigView = exports.updateInvoicingConfig = exports.resetInvoicingConfigActionStates = exports.fetchInvoicingConfig = exports.enableInvoicing = exports.acceptInvoicingTerms = exports.toInvoicingQboCustomerMatchingMode = exports.toInvoicingNamedOptionsByKey = exports.getInvoicingQboAccountMappingId = exports.INVOICING_QBO_CUSTOMER_MATCHING_MODES = exports.getInvoicingQboView = exports.invoicingAccountsForQboAccountTypes = exports.startInvoicingQboBackfill = exports.retryInvoicingQboSyncTask = exports.fetchInvoicingQboSyncHealth = exports.fetchInvoicingQboConnection = exports.fetchInvoicingAccountingPickers = exports.isStripeConnectedFromSettings = exports.initialInvoicingBrandingFormLocalData = exports.entityToInvoicingBrandingFormLocalData = exports.INVOICING_BUSINESS_ADDRESS_TYPE = exports.invoicingQboSettingsLocalDataToPayload = exports.initialInvoicingQboSettingsLocalData = exports.entityToInvoicingQboSettingsLocalData = exports.getInvoicingSettingsView = exports.getInvoicingSettingsHubView = void 0;
84
+ exports.runInvoicingCatalogProductAction = exports.runInvoicingCatalogPlanAction = exports.fetchInvoicingCatalogItemDetailPage = exports.shouldDefaultAdjustmentCreditNote = exports.isBackdatedInvoiceDate = exports.buildVoidInvoiceSubmitBody = exports.updateInvoicingInvoice = exports.runInvoicingInvoiceAction = exports.getInvoicingCouponFormView = exports.getEditInvoicingCouponDetailViewState = exports.initialInvoicingCouponFormLocalData = exports.entityToInvoicingCouponFormLocalData = exports.updateInvoicingCouponFormDraft = exports.submitInvoicingCouponForm = exports.saveInvoicingCoupon = exports.resetEditInvoicingCouponDetailView = exports.fetchInvoicingCouponDetailPage = exports.getSavedInvoicingCatalogItemKind = exports.getSavedInvoicingCatalogItemId = exports.getInvoicingCatalogItemFormView = exports.getInvoicingApplicableCatalogItemOptions = exports.isTieredCatalogPricingModel = exports.initialInvoicingCatalogItemFormLocalData = exports.invoicingProductToCatalogItemFormSubFamily = exports.entityToInvoicingCatalogItemFormLocalData = exports.blankInvoicingCatalogTier = exports.blankInvoicingCatalogSubFamily = exports.INVOICING_CATALOG_TIER_TYPE_VALUES = exports.INVOICING_CATALOG_PRORATION_VALUES = exports.INVOICING_CATALOG_PRICING_MODEL_VALUES = exports.INVOICING_CATALOG_APPLICABILITY_VALUES = exports.updateInvoicingCatalogItemFormDraft = exports.submitInvoicingCatalogItemForm = exports.resetEditInvoicingCatalogItemDetailView = exports.getInvoicingSubscriptionFormView = exports.getEditInvoicingSubscriptionDetailViewState = exports.toInvoicingSubscriptionQuantity = exports.invoicingSubscriptionTodayIso = exports.initialInvoicingSubscriptionFormLocalData = exports.entityToInvoicingSubscriptionFormLocalData = exports.INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE = exports.updateInvoicingSubscriptionFormDraft = exports.submitInvoicingSubscriptionForm = exports.resetEditInvoicingSubscriptionDetailView = exports.initializeInvoicingSubscriptionAddress = exports.fetchInvoicingSubscriptionFormPage = exports.fetchInvoicingSubscriptionEstimate = exports.clearInvoicingSubscriptionEstimate = exports.getInvoicingCustomerFormView = exports.initialInvoicingCustomerFormLocalData = void 0;
85
+ exports.setInvoicingSubscriptionActiveTab = exports.fetchInvoicingSubscriptionListPage = exports.fetchInvoicingSubscriptionList = exports.fetchInvoicingSubscriptionCounts = exports.updateInvoicingSubscriptions = exports.removeInvoicingSubscription = exports.resetPromotionalCreditAction = exports.submitAddPromotionalCredits = exports.getInvoicingSetupIntentFetchState = exports.getInvoicingSetupIntent = exports.getInvoicingSentPaymentLinkMagicUrl = exports.getInvoicingSentPaymentLinkEmail = exports.getInvoicingPlaidLinkToken = exports.getInvoicingPaymentMethodSaveState = exports.getInvoicingPaymentLinkSendState = exports.sendInvoicingPaymentLink = exports.saveInvoicingPaymentMethod = exports.resetInvoicingCustomerPaymentMethod = exports.fetchInvoicingPlaidLinkToken = exports.createInvoicingSetupIntent = exports.fetchInvoicingPaymentLinkEmailPreviewPage = exports.fetchInvoicingCustomerDetailPage = exports.fetchInvoicingCustomerDetail = exports.getInvoicingCustomerListView = exports.INVOICING_CUSTOMER_COLUMNS = exports.ALL_INVOICING_CUSTOMER_TAB_IDS = exports.ALL_INVOICING_CUSTOMER_SORT_KEYS = exports.updateInvoicingCustomerFilters = exports.setInvoicingCustomerActiveTab = exports.fetchInvoicingCustomerListPage = exports.fetchInvoicingCustomerList = exports.fetchInvoicingCustomerCounts = exports.updateInvoicingCustomers = exports.removeInvoicingCustomer = exports.INVOICING_LIST_PAGE_SIZE = exports.uploadInvoicingMigrationFiles = exports.startInvoicingMigration = exports.rollbackInvoicingMigration = exports.retryInvoicingMigration = exports.connectInvoicingChargebee = exports.getInvoicingDataImportView = exports.setInvoicingActiveMigrationSessionId = exports.fetchInvoicingMigrationSessions = exports.fetchInvoicingMigrationSession = exports.fetchInvoicingMigrationDiagnostics = exports.fetchInvoicingDataImportStatus = exports.runInvoicingPaymentAction = exports.runInvoicingDunningAction = exports.runInvoicingSubscriptionAction = exports.runInvoicingDiscountAction = void 0;
86
+ exports.getInvoicingCouponListItems = exports.getInvoicingCouponListHasMore = exports.getInvoicingCouponListFilters = exports.getInvoicingCouponListFetchState = exports.getInvoicingCouponCounts = exports.INVOICING_COUPON_COLUMNS = exports.ALL_INVOICING_COUPON_TAB_IDS = exports.ALL_INVOICING_COUPON_SORT_KEYS = exports.updateInvoicingCouponFilters = exports.setInvoicingCouponActiveTab = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.fetchInvoicingCouponCounts = exports.updateInvoicingCoupons = exports.removeInvoicingCoupon = exports.getInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteById = exports.fetchInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteListView = exports.INVOICING_CREDIT_NOTE_COLUMNS = exports.ALL_INVOICING_CREDIT_NOTE_TAB_IDS = exports.ALL_INVOICING_CREDIT_NOTE_SORT_KEYS = exports.updateInvoicingCreditNoteFilters = exports.setInvoicingCreditNoteActiveTab = exports.fetchInvoicingCreditNoteListPage = exports.fetchInvoicingCreditNoteList = exports.fetchInvoicingCreditNoteCounts = exports.updateInvoicingCreditNotes = exports.removeInvoicingCreditNote = exports.getInvoicingTransactionDetail = exports.getInvoicingTransactionById = exports.fetchInvoicingTransactionDetail = exports.getInvoicingTransactionListView = exports.INVOICING_TRANSACTION_COLUMNS = exports.ALL_INVOICING_TRANSACTION_TAB_IDS = exports.ALL_INVOICING_TRANSACTION_SORT_KEYS = exports.updateInvoicingTransactionFilters = exports.setInvoicingTransactionActiveTab = exports.fetchInvoicingTransactionListPage = exports.fetchInvoicingTransactionList = exports.updateInvoicingTransactions = exports.removeInvoicingTransaction = exports.getInvoicingSubscriptionById = exports.fetchInvoicingSubscriptionDetailPage = exports.fetchInvoicingSubscriptionDetail = exports.getInvoicingSubscriptionListView = exports.INVOICING_SUBSCRIPTION_COLUMNS = exports.ALL_INVOICING_SUBSCRIPTION_TAB_IDS = exports.ALL_INVOICING_SUBSCRIPTION_SORT_KEYS = exports.updateInvoicingSubscriptionFilters = void 0;
87
+ exports.getInvoicingQboSettingsFormView = exports.getInvoicingBrandingFormView = exports.updateInvoicingSettings = exports.updateInvoicingQboSettingsDraft = exports.updateInvoicingBrandingFormDraft = exports.submitInvoicingQboSettings = exports.submitInvoicingBrandingForm = exports.saveInvoicingSettings = exports.resetSaveInvoicingSettings = exports.resetInvoicingQboSettingsDraft = exports.resetInvoicingBrandingFormDraft = exports.fetchInvoicingSettings = exports.disconnectInvoicingStripe = exports.connectInvoicingStripe = exports.getLowestInvoicingCatalogPricePointAmount = exports.getInvoicingCatalogItemById = exports.fetchInvoicingCatalogItemDetail = exports.getInvoicingCatalogListView = exports.updateInvoicingCatalogProductFilters = exports.updateInvoicingCatalogPlanFilters = exports.fetchInvoicingCatalogProductList = exports.fetchInvoicingCatalogPlanList = exports.fetchInvoicingCatalogListPage = exports.fetchInvoicingCatalogCounts = exports.updateInvoicingCatalogItems = exports.removeInvoicingCatalogItem = exports.mergeInvoicingCatalogPricePoint = exports.getInvoicingDunningEmailPreview = exports.getInvoicingDunningCaseDetail = exports.getInvoicingDunningCaseById = exports.invalidateInvoicingDunningEmailPreview = exports.fetchInvoicingDunningEmailPreviewPage = exports.fetchInvoicingDunningCaseDetailPage = exports.fetchInvoicingDunningCaseDetail = exports.clearInvoicingDunningCaseDetailView = exports.getInvoicingDunningCaseListView = exports.INVOICING_DUNNING_CASE_COLUMNS = exports.ALL_INVOICING_DUNNING_CASE_TAB_IDS = exports.ALL_INVOICING_DUNNING_CASE_SORT_KEYS = exports.updateInvoicingDunningCaseFilters = exports.setInvoicingDunningCaseActiveTab = exports.fetchInvoicingDunningCaseListPage = exports.fetchInvoicingDunningCaseList = exports.fetchInvoicingDunningCaseCounts = exports.updateInvoicingDunningCases = exports.removeInvoicingDunningCase = exports.fetchInvoicingCouponDetail = exports.getInvoicingCouponById = exports.getInvoicingCouponListView = exports.getInvoicingCouponListNextCursor = void 0;
88
+ exports.isPendingReviewAccrual = exports.isManuallyReversedAccrual = exports.isAutoReversedAccrual = exports.getExpenseAutomationActualMatchingView = exports.getExpenseAutomationActualMatchingMatchView = exports.parseActualMatchingMatchId = exports.getCloseMatchAfterUndoMatchId = exports.getCloseMatchAfterUndo = exports.getCloseMatchAfterIgnoreMatchId = exports.getActualMatchingMatchModalConfirmStatus = exports.getActualMatchingReversalDate = exports.getActualMatchingAmount = exports.isPendingReviewRow = exports.isRenderableOneTimeAccrual = exports.isOneTimeAccrualRow = exports.isExistingTabRow = exports.isAiAccountantSchedule = exports.isAccruedScheduleRow = exports.getJEScheduleRowType = exports.getExpenseAutomationJEOneTimeAccrualDetailView = exports.getInvoicingOnboardingGateView = exports.getInvoicingConfigView = exports.updateInvoicingConfig = exports.resetInvoicingConfigActionStates = exports.fetchInvoicingConfig = exports.enableInvoicing = exports.acceptInvoicingTerms = exports.toInvoicingQboCustomerMatchingMode = exports.toInvoicingNamedOptionsByKey = exports.getInvoicingQboAccountMappingId = exports.INVOICING_QBO_CUSTOMER_MATCHING_MODES = exports.getInvoicingQboView = exports.invoicingAccountsForQboAccountTypes = exports.startInvoicingQboBackfill = exports.retryInvoicingQboSyncTask = exports.fetchInvoicingQboSyncHealth = exports.fetchInvoicingQboConnection = exports.fetchInvoicingAccountingPickers = exports.isStripeConnectedFromSettings = exports.initialInvoicingBrandingFormLocalData = exports.entityToInvoicingBrandingFormLocalData = exports.INVOICING_BUSINESS_ADDRESS_TYPE = exports.invoicingQboSettingsLocalDataToPayload = exports.initialInvoicingQboSettingsLocalData = exports.entityToInvoicingQboSettingsLocalData = exports.getInvoicingSettingsView = exports.getInvoicingSettingsHubView = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = void 0;
89
89
  const allowedValue_1 = require("./commonStateTypes/allowedValue");
90
90
  Object.defineProperty(exports, "isAllowedValueWithCode", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithCode; } });
91
91
  Object.defineProperty(exports, "isAllowedValueWithID", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithID; } });
@@ -2915,6 +2915,8 @@ Object.defineProperty(exports, "initialInvoicingCustomerFormLocalData", { enumer
2915
2915
  var editInvoicingCustomerDetailViewSelector_1 = require("./view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector");
2916
2916
  Object.defineProperty(exports, "getInvoicingCustomerFormView", { enumerable: true, get: function () { return editInvoicingCustomerDetailViewSelector_1.getInvoicingCustomerFormView; } });
2917
2917
  var editInvoicingSubscriptionDetailViewReducer_1 = require("./view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer");
2918
+ Object.defineProperty(exports, "clearInvoicingSubscriptionEstimate", { enumerable: true, get: function () { return editInvoicingSubscriptionDetailViewReducer_1.clearInvoicingSubscriptionEstimate; } });
2919
+ Object.defineProperty(exports, "fetchInvoicingSubscriptionEstimate", { enumerable: true, get: function () { return editInvoicingSubscriptionDetailViewReducer_1.fetchInvoicingSubscriptionEstimate; } });
2918
2920
  Object.defineProperty(exports, "fetchInvoicingSubscriptionFormPage", { enumerable: true, get: function () { return editInvoicingSubscriptionDetailViewReducer_1.fetchInvoicingSubscriptionFormPage; } });
2919
2921
  Object.defineProperty(exports, "initializeInvoicingSubscriptionAddress", { enumerable: true, get: function () { return editInvoicingSubscriptionDetailViewReducer_1.initializeInvoicingSubscriptionAddress; } });
2920
2922
  Object.defineProperty(exports, "resetEditInvoicingSubscriptionDetailView", { enumerable: true, get: function () { return editInvoicingSubscriptionDetailViewReducer_1.resetEditInvoicingSubscriptionDetailView; } });
@@ -1,7 +1,7 @@
1
1
  import { InvoicingSubscriptionPayload } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload';
2
2
  import { ZeniAPIResponse } from '../../../responsePayload';
3
3
  import { AddressUpdatableInfo } from '../../addressView/addressViewState';
4
- import { InvoicingSubscriptionFormLocalData } from './editInvoicingSubscriptionDetailViewState';
4
+ import { InvoicingSubscriptionEstimate, InvoicingSubscriptionFormLocalData } from './editInvoicingSubscriptionDetailViewState';
5
5
  export type SaveInvoicingSubscriptionResponse = ZeniAPIResponse<InvoicingSubscriptionPayload>;
6
6
  /**
7
7
  * Build the create/update subscription request body from the form draft. The
@@ -74,3 +74,48 @@ export type ScheduleChargeBody = {
74
74
  };
75
75
  export type InvoicingSubscriptionActionBody = ApplyCouponBody | RemoveCouponBody | AddChargesBody | PauseSubscriptionBody | CancelSubscriptionBody | ChangePlanBody | ChangeTermEndBody | ScheduleChargeBody | Record<string, never>;
76
76
  export type InvoicingSubscriptionDetailResponse = ZeniAPIResponse<InvoicingSubscriptionPayload>;
77
+ interface InvoicingSubscriptionEstimateLineItemPayload {
78
+ amount: number;
79
+ description: string;
80
+ discount_amount: number;
81
+ quantity: number;
82
+ unit_amount: number;
83
+ date_from?: string;
84
+ date_to?: string;
85
+ tax_amount?: number | null;
86
+ }
87
+ interface InvoicingSubscriptionInvoiceEstimatePayload {
88
+ amount_due: number;
89
+ coupon_discount_total: number;
90
+ credits_applied: number;
91
+ gross_sub_total: number;
92
+ line_items: InvoicingSubscriptionEstimateLineItemPayload[];
93
+ promotional_credits_applied: number;
94
+ sub_total: number;
95
+ tax: number | null;
96
+ total: number;
97
+ due_date?: string;
98
+ invoice_date?: string;
99
+ }
100
+ export interface InvoicingSubscriptionEstimatePayload {
101
+ currency_code: string;
102
+ currency_symbol: string;
103
+ invoice_estimate: InvoicingSubscriptionInvoiceEstimatePayload | null;
104
+ next_invoice_estimate: InvoicingSubscriptionInvoiceEstimatePayload | null;
105
+ proration_estimate: {
106
+ document_type: string;
107
+ invoice_estimate: InvoicingSubscriptionInvoiceEstimatePayload | null;
108
+ net: number;
109
+ } | null;
110
+ reason: string;
111
+ subscription_estimate: {
112
+ becomes_non_renewing_after_this_term?: boolean;
113
+ current_term_end?: string;
114
+ current_term_start?: string;
115
+ next_billing_at?: string | null;
116
+ } | null;
117
+ will_be_invoiced: boolean;
118
+ }
119
+ export type InvoicingSubscriptionEstimateResponse = ZeniAPIResponse<InvoicingSubscriptionEstimatePayload>;
120
+ export declare const mapInvoicingSubscriptionEstimatePayloadToState: (payload: InvoicingSubscriptionEstimatePayload) => InvoicingSubscriptionEstimate;
121
+ export {};
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.localDataToSaveInvoicingSubscriptionPayload = void 0;
3
+ exports.mapInvoicingSubscriptionEstimatePayloadToState = exports.localDataToSaveInvoicingSubscriptionPayload = void 0;
4
+ const amount_1 = require("../../../commonStateTypes/amount");
5
+ const zeniDayJS_1 = require("../../../zeniDayJS");
4
6
  const addressViewPayload_1 = require("../../addressView/addressViewPayload");
5
7
  const invoicingSubscriptionFormConfig_1 = require("./invoicingSubscriptionFormConfig");
6
8
  /**
@@ -60,3 +62,57 @@ const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingAddress)
60
62
  };
61
63
  };
62
64
  exports.localDataToSaveInvoicingSubscriptionPayload = localDataToSaveInvoicingSubscriptionPayload;
65
+ const toEstimateDate = (value) => value != null && value !== '' ? (0, zeniDayJS_1.date)(value) : undefined;
66
+ const mapInvoiceEstimate = (payload, money) => payload == null
67
+ ? undefined
68
+ : {
69
+ amountDue: money(payload.amount_due),
70
+ couponDiscountTotal: money(payload.coupon_discount_total),
71
+ creditsApplied: money(payload.credits_applied),
72
+ dueDate: toEstimateDate(payload.due_date),
73
+ grossSubTotal: money(payload.gross_sub_total),
74
+ invoiceDate: toEstimateDate(payload.invoice_date),
75
+ lineItems: payload.line_items.map((lineItem) => ({
76
+ amount: money(lineItem.amount),
77
+ dateFrom: toEstimateDate(lineItem.date_from),
78
+ dateTo: toEstimateDate(lineItem.date_to),
79
+ description: lineItem.description,
80
+ discountAmount: money(lineItem.discount_amount),
81
+ quantity: lineItem.quantity,
82
+ taxAmount: lineItem.tax_amount != null
83
+ ? money(lineItem.tax_amount)
84
+ : undefined,
85
+ unitAmount: money(lineItem.unit_amount),
86
+ })),
87
+ promotionalCreditsApplied: money(payload.promotional_credits_applied),
88
+ subTotal: money(payload.sub_total),
89
+ tax: payload.tax != null ? money(payload.tax) : undefined,
90
+ total: money(payload.total),
91
+ };
92
+ const mapInvoicingSubscriptionEstimatePayloadToState = (payload) => {
93
+ const money = (amount) => (0, amount_1.toAmount)(amount, payload.currency_code, payload.currency_symbol);
94
+ const term = payload.subscription_estimate;
95
+ const proration = payload.proration_estimate;
96
+ return {
97
+ invoice: mapInvoiceEstimate(payload.invoice_estimate, money),
98
+ nextInvoice: mapInvoiceEstimate(payload.next_invoice_estimate, money),
99
+ proration: proration != null
100
+ ? {
101
+ documentType: proration.document_type,
102
+ invoice: mapInvoiceEstimate(proration.invoice_estimate, money),
103
+ net: money(proration.net),
104
+ }
105
+ : undefined,
106
+ reason: payload.reason,
107
+ term: term != null
108
+ ? {
109
+ becomesNonRenewing: term.becomes_non_renewing_after_this_term === true,
110
+ currentTermEnd: toEstimateDate(term.current_term_end),
111
+ currentTermStart: toEstimateDate(term.current_term_start),
112
+ nextBillingAt: toEstimateDate(term.next_billing_at),
113
+ }
114
+ : undefined,
115
+ willBeInvoiced: payload.will_be_invoiced,
116
+ };
117
+ };
118
+ exports.mapInvoicingSubscriptionEstimatePayloadToState = mapInvoicingSubscriptionEstimatePayloadToState;
@@ -1,7 +1,7 @@
1
1
  import { ID } from '../../../commonStateTypes/common';
2
2
  import { ZeniAPIStatus } from '../../../responsePayload';
3
3
  import { InvoicingSubscriptionActionBody } from './editInvoicingSubscriptionDetailViewPayload';
4
- import { EditInvoicingSubscriptionDetailViewState, InvoicingSubscriptionFormLocalData } from './editInvoicingSubscriptionDetailViewState';
4
+ import { EditInvoicingSubscriptionDetailViewState, InvoicingSubscriptionEstimate, InvoicingSubscriptionFormLocalData } from './editInvoicingSubscriptionDetailViewState';
5
5
  /** Push the full form draft into CES (edit tree when `id` is present). */
6
6
  export interface UpdateInvoicingSubscriptionFormDraftPayload {
7
7
  localData: InvoicingSubscriptionFormLocalData;
@@ -59,6 +59,14 @@ export declare const runInvoicingSubscriptionAction: import("@reduxjs/toolkit").
59
59
  id?: ID;
60
60
  } | undefined, "editInvoicingSubscriptionDetailView/resetEditInvoicingSubscriptionDetailView">, initializeInvoicingSubscriptionAddress: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InitializeInvoicingSubscriptionAddressPayload], InitializeInvoicingSubscriptionAddressPayload, "editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddress", never, never>, claimInvoicingSubscriptionShippingAddress: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
61
61
  id: ID;
62
- }, "editInvoicingSubscriptionDetailView/claimInvoicingSubscriptionShippingAddress">, syncInvoicingSubscriptionCoupons: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SyncInvoicingSubscriptionCouponsPayload], SyncInvoicingSubscriptionCouponsPayload, "editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCoupons", never, never>;
62
+ }, "editInvoicingSubscriptionDetailView/claimInvoicingSubscriptionShippingAddress">, syncInvoicingSubscriptionCoupons: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SyncInvoicingSubscriptionCouponsPayload], SyncInvoicingSubscriptionCouponsPayload, "editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCoupons", never, never>, fetchInvoicingSubscriptionEstimate: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
63
+ id?: ID;
64
+ }, "editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionEstimate">, updateInvoicingSubscriptionEstimate: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
65
+ estimate: InvoicingSubscriptionEstimate;
66
+ id?: ID;
67
+ }, "editInvoicingSubscriptionDetailView/updateInvoicingSubscriptionEstimate">, updateInvoicingSubscriptionEstimateFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
68
+ status: ZeniAPIStatus;
69
+ id?: ID;
70
+ }, "editInvoicingSubscriptionDetailView/updateInvoicingSubscriptionEstimateFailure">, clearInvoicingSubscriptionEstimate: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"editInvoicingSubscriptionDetailView/clearInvoicingSubscriptionEstimate">;
63
71
  declare const _default: import("redux").Reducer<EditInvoicingSubscriptionDetailViewState>;
64
72
  export default _default;
@@ -1,15 +1,19 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.syncInvoicingSubscriptionCoupons = exports.claimInvoicingSubscriptionShippingAddress = exports.initializeInvoicingSubscriptionAddress = exports.resetEditInvoicingSubscriptionDetailView = exports.submitInvoicingSubscriptionFormFailure = exports.submitInvoicingSubscriptionFormSuccess = exports.submitInvoicingSubscriptionForm = exports.updateInvoicingSubscriptionFormDraft = exports.updateInvoicingSubscriptionDetailFailure = exports.updateInvoicingSubscriptionDetail = exports.seedInvoicingSubscriptionFormDraft = exports.fetchInvoicingSubscriptionFormPage = exports.fetchInvoicingSubscriptionDetailPage = exports.fetchInvoicingSubscriptionDetail = exports.runInvoicingSubscriptionActionSuccess = exports.runInvoicingSubscriptionActionFailure = exports.runInvoicingSubscriptionAction = exports.initialState = void 0;
4
+ exports.clearInvoicingSubscriptionEstimate = exports.updateInvoicingSubscriptionEstimateFailure = exports.updateInvoicingSubscriptionEstimate = exports.fetchInvoicingSubscriptionEstimate = exports.syncInvoicingSubscriptionCoupons = exports.claimInvoicingSubscriptionShippingAddress = exports.initializeInvoicingSubscriptionAddress = exports.resetEditInvoicingSubscriptionDetailView = exports.submitInvoicingSubscriptionFormFailure = exports.submitInvoicingSubscriptionFormSuccess = exports.submitInvoicingSubscriptionForm = exports.updateInvoicingSubscriptionFormDraft = exports.updateInvoicingSubscriptionDetailFailure = exports.updateInvoicingSubscriptionDetail = exports.seedInvoicingSubscriptionFormDraft = exports.fetchInvoicingSubscriptionFormPage = exports.fetchInvoicingSubscriptionDetailPage = exports.fetchInvoicingSubscriptionDetail = exports.runInvoicingSubscriptionActionSuccess = exports.runInvoicingSubscriptionActionFailure = exports.runInvoicingSubscriptionAction = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const rootActions_1 = require("../../../rootActions");
7
7
  const invoicingFormDraft_1 = require("../invoicingFormDraft");
8
8
  const invoicingSubscriptionFormConfig_1 = require("./invoicingSubscriptionFormConfig");
9
+ const initialEstimateState = {
10
+ fetchState: { fetchState: 'Not-Started', error: undefined },
11
+ };
9
12
  exports.initialState = {
10
13
  fetchState: 'Not-Started',
11
14
  error: undefined,
12
15
  editDraftById: {},
16
+ estimateState: initialEstimateState,
13
17
  actionStateById: {},
14
18
  recordStateById: {},
15
19
  shippingAddressOwnerId: undefined,
@@ -23,6 +27,36 @@ const editInvoicingSubscriptionDetailView = (0, toolkit_1.createSlice)({
23
27
  name: 'editInvoicingSubscriptionDetailView',
24
28
  initialState: exports.initialState,
25
29
  reducers: {
30
+ // What saving the draft would bill (no id: create); see the estimate epic.
31
+ fetchInvoicingSubscriptionEstimate(draft, action) {
32
+ draft.estimateState = {
33
+ fetchState: { fetchState: 'In-Progress', error: undefined },
34
+ subscriptionId: action.payload.id,
35
+ };
36
+ },
37
+ // Dropped when the dialog has since moved to another subscription.
38
+ updateInvoicingSubscriptionEstimate(draft, action) {
39
+ if (draft.estimateState.subscriptionId !== action.payload.id) {
40
+ return;
41
+ }
42
+ draft.estimateState.estimate = action.payload.estimate;
43
+ draft.estimateState.fetchState = {
44
+ fetchState: 'Completed',
45
+ error: undefined,
46
+ };
47
+ },
48
+ updateInvoicingSubscriptionEstimateFailure(draft, action) {
49
+ if (draft.estimateState.subscriptionId !== action.payload.id) {
50
+ return;
51
+ }
52
+ draft.estimateState.fetchState = {
53
+ fetchState: 'Error',
54
+ error: action.payload.status,
55
+ };
56
+ },
57
+ clearInvoicingSubscriptionEstimate(draft) {
58
+ draft.estimateState = initialEstimateState;
59
+ },
26
60
  runInvoicingSubscriptionAction(draft, action) {
27
61
  draft.actionStateById[action.payload.id] = {
28
62
  fetchState: 'In-Progress',
@@ -162,5 +196,5 @@ const editInvoicingSubscriptionDetailView = (0, toolkit_1.createSlice)({
162
196
  });
163
197
  },
164
198
  });
165
- _a = editInvoicingSubscriptionDetailView.actions, exports.runInvoicingSubscriptionAction = _a.runInvoicingSubscriptionAction, exports.runInvoicingSubscriptionActionFailure = _a.runInvoicingSubscriptionActionFailure, exports.runInvoicingSubscriptionActionSuccess = _a.runInvoicingSubscriptionActionSuccess, exports.fetchInvoicingSubscriptionDetail = _a.fetchInvoicingSubscriptionDetail, exports.fetchInvoicingSubscriptionDetailPage = _a.fetchInvoicingSubscriptionDetailPage, exports.fetchInvoicingSubscriptionFormPage = _a.fetchInvoicingSubscriptionFormPage, exports.seedInvoicingSubscriptionFormDraft = _a.seedInvoicingSubscriptionFormDraft, exports.updateInvoicingSubscriptionDetail = _a.updateInvoicingSubscriptionDetail, exports.updateInvoicingSubscriptionDetailFailure = _a.updateInvoicingSubscriptionDetailFailure, exports.updateInvoicingSubscriptionFormDraft = _a.updateInvoicingSubscriptionFormDraft, exports.submitInvoicingSubscriptionForm = _a.submitInvoicingSubscriptionForm, exports.submitInvoicingSubscriptionFormSuccess = _a.submitInvoicingSubscriptionFormSuccess, exports.submitInvoicingSubscriptionFormFailure = _a.submitInvoicingSubscriptionFormFailure, exports.resetEditInvoicingSubscriptionDetailView = _a.resetEditInvoicingSubscriptionDetailView, exports.initializeInvoicingSubscriptionAddress = _a.initializeInvoicingSubscriptionAddress, exports.claimInvoicingSubscriptionShippingAddress = _a.claimInvoicingSubscriptionShippingAddress, exports.syncInvoicingSubscriptionCoupons = _a.syncInvoicingSubscriptionCoupons;
199
+ _a = editInvoicingSubscriptionDetailView.actions, exports.runInvoicingSubscriptionAction = _a.runInvoicingSubscriptionAction, exports.runInvoicingSubscriptionActionFailure = _a.runInvoicingSubscriptionActionFailure, exports.runInvoicingSubscriptionActionSuccess = _a.runInvoicingSubscriptionActionSuccess, exports.fetchInvoicingSubscriptionDetail = _a.fetchInvoicingSubscriptionDetail, exports.fetchInvoicingSubscriptionDetailPage = _a.fetchInvoicingSubscriptionDetailPage, exports.fetchInvoicingSubscriptionFormPage = _a.fetchInvoicingSubscriptionFormPage, exports.seedInvoicingSubscriptionFormDraft = _a.seedInvoicingSubscriptionFormDraft, exports.updateInvoicingSubscriptionDetail = _a.updateInvoicingSubscriptionDetail, exports.updateInvoicingSubscriptionDetailFailure = _a.updateInvoicingSubscriptionDetailFailure, exports.updateInvoicingSubscriptionFormDraft = _a.updateInvoicingSubscriptionFormDraft, exports.submitInvoicingSubscriptionForm = _a.submitInvoicingSubscriptionForm, exports.submitInvoicingSubscriptionFormSuccess = _a.submitInvoicingSubscriptionFormSuccess, exports.submitInvoicingSubscriptionFormFailure = _a.submitInvoicingSubscriptionFormFailure, exports.resetEditInvoicingSubscriptionDetailView = _a.resetEditInvoicingSubscriptionDetailView, exports.initializeInvoicingSubscriptionAddress = _a.initializeInvoicingSubscriptionAddress, exports.claimInvoicingSubscriptionShippingAddress = _a.claimInvoicingSubscriptionShippingAddress, exports.syncInvoicingSubscriptionCoupons = _a.syncInvoicingSubscriptionCoupons, exports.fetchInvoicingSubscriptionEstimate = _a.fetchInvoicingSubscriptionEstimate, exports.updateInvoicingSubscriptionEstimate = _a.updateInvoicingSubscriptionEstimate, exports.updateInvoicingSubscriptionEstimateFailure = _a.updateInvoicingSubscriptionEstimateFailure, exports.clearInvoicingSubscriptionEstimate = _a.clearInvoicingSubscriptionEstimate;
166
200
  exports.default = editInvoicingSubscriptionDetailView.reducer;
@@ -5,7 +5,8 @@ import { InvoicingCatalogPricePoint } from '../../../entity/invoicing/invoicingC
5
5
  import { InvoicingFieldHelpByCode, InvoicingNamedOption, InvoicingSubscriptionLifecycleActionOption } from '../../../entity/invoicing/invoicingCommonPayload';
6
6
  import { InvoicingSubscription } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionState';
7
7
  import { RootState } from '../../../rootStateTypes';
8
- import { InvoicingSubscriptionFormLocalData } from './editInvoicingSubscriptionDetailViewState';
8
+ import { ZeniDate } from '../../../zeniDayJS';
9
+ import { InvoicingSubscriptionEstimateState, InvoicingSubscriptionFormLocalData, InvoicingSubscriptionInvoiceEstimate } from './editInvoicingSubscriptionDetailViewState';
9
10
  /**
10
11
  * Bundled view for the subscription create/edit form's save concern: the save
11
12
  * fetch state/error, the id of the subscription last saved, and — when an
@@ -29,6 +30,22 @@ export interface EditInvoicingSubscriptionDetailView extends SelectorView {
29
30
  * `{label, value}` records, so this stays free of any web-components
30
31
  * dependency while leaving the screen nothing to derive.
31
32
  */
33
+ export type InvoicingSubscriptionEstimateKind = 'invoice_now' | 'later_invoice' | 'proration_credit' | 'proration_invoice' | 'reason_only';
34
+ export interface InvoicingSubscriptionEstimateView {
35
+ /** A later invoice quotes today's credit balances, which can change by then. */
36
+ creditsMayChange: boolean;
37
+ fetchState: FetchStateAndError;
38
+ nonRenewing: boolean;
39
+ /** The one invoice to show, whichever estimate it came from. */
40
+ invoice?: InvoicingSubscriptionInvoiceEstimate;
41
+ kind?: InvoicingSubscriptionEstimateKind;
42
+ nextBillingAt?: ZeniDate;
43
+ reason?: string;
44
+ storeCredit?: Amount;
45
+ termEnd?: ZeniDate;
46
+ termStart?: ZeniDate;
47
+ }
48
+ export declare const toInvoicingSubscriptionEstimateView: ({ estimate, fetchState, subscriptionId }: InvoicingSubscriptionEstimateState, invoicingSubscriptionID?: ID) => InvoicingSubscriptionEstimateView;
32
49
  export interface InvoicingSubscriptionFormView extends SelectorView {
33
50
  /** Lifecycle action in flight, folded in from the record view. */
34
51
  actionState: FetchStateAndError;
@@ -43,6 +60,8 @@ export interface InvoicingSubscriptionFormView extends SelectorView {
43
60
  charges: InvoicingSubscriptionOption[];
44
61
  coupons: InvoicingSubscriptionOption[];
45
62
  customers: InvoicingSubscriptionOption[];
63
+ /** The review dialog's cost estimate for saving this draft. */
64
+ estimate: InvoicingSubscriptionEstimateView;
46
65
  fieldHelp: InvoicingFieldHelpByCode;
47
66
  /**
48
67
  * True while the subscription being edited is still on its way to the form.
@@ -108,6 +127,7 @@ export declare const getEditInvoicingSubscriptionDetailViewState: (state: RootSt
108
127
  * page's inline edit narrow their pickers by the same rule.
109
128
  */
110
129
  export declare const getInvoicingItemsAllowedForPlan: (products: InvoicingCatalogPricePoint[], plan: InvoicingCatalogPricePoint | undefined) => InvoicingCatalogPricePoint[];
130
+ export declare const isInvoicingAddonPeriodCompatible: (addon: InvoicingCatalogPricePoint, plan: InvoicingCatalogPricePoint | undefined) => boolean;
111
131
  /**
112
132
  * One entry in a subscription-form picker, ready for the screen to render.
113
133
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInvoicingSubscriptionFormView = exports.getInvoicingItemsAllowedForPlan = exports.getEditInvoicingSubscriptionDetailViewState = void 0;
3
+ exports.getInvoicingSubscriptionFormView = exports.isInvoicingAddonPeriodCompatible = exports.getInvoicingItemsAllowedForPlan = exports.getEditInvoicingSubscriptionDetailViewState = exports.toInvoicingSubscriptionEstimateView = void 0;
4
4
  const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
5
5
  const addressSelector_1 = require("../../../entity/address/addressSelector");
6
6
  const invoicingSubscriptionSelector_1 = require("../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector");
@@ -12,6 +12,58 @@ const invoicingCustomerListViewSelector_1 = require("../invoicingCustomerListVie
12
12
  const invoicingFormDraft_1 = require("../invoicingFormDraft");
13
13
  const invoicingSubscriptionFormConfig_1 = require("./invoicingSubscriptionFormConfig");
14
14
  const invoicingSubscriptionFormConfig_2 = require("./invoicingSubscriptionFormConfig");
15
+ const notStartedEstimateView = {
16
+ creditsMayChange: false,
17
+ fetchState: { fetchState: 'Not-Started', error: undefined },
18
+ nonRenewing: false,
19
+ };
20
+ const toInvoicingSubscriptionEstimateView = ({ estimate, fetchState, subscriptionId }, invoicingSubscriptionID) => {
21
+ // A slot asked for another subscription is not this form's estimate.
22
+ if (subscriptionId !== invoicingSubscriptionID) {
23
+ return notStartedEstimateView;
24
+ }
25
+ if (estimate == null) {
26
+ return { ...notStartedEstimateView, fetchState };
27
+ }
28
+ const { invoice, nextInvoice, proration, reason, term } = estimate;
29
+ const base = {
30
+ fetchState,
31
+ nonRenewing: term?.becomesNonRenewing === true,
32
+ nextBillingAt: term?.nextBillingAt,
33
+ reason: reason !== '' ? reason : undefined,
34
+ termEnd: term?.currentTermEnd,
35
+ termStart: term?.currentTermStart,
36
+ };
37
+ if (proration?.documentType === 'invoice' && proration.invoice != null) {
38
+ return {
39
+ ...base,
40
+ creditsMayChange: false,
41
+ invoice: proration.invoice,
42
+ kind: 'proration_invoice',
43
+ };
44
+ }
45
+ if (proration?.documentType === 'credit_note') {
46
+ return {
47
+ ...base,
48
+ creditsMayChange: false,
49
+ kind: 'proration_credit',
50
+ storeCredit: { ...proration.net, amount: Math.abs(proration.net.amount) },
51
+ };
52
+ }
53
+ if (estimate.willBeInvoiced && invoice != null) {
54
+ return { ...base, creditsMayChange: false, invoice, kind: 'invoice_now' };
55
+ }
56
+ if (nextInvoice != null) {
57
+ return {
58
+ ...base,
59
+ creditsMayChange: true,
60
+ invoice: nextInvoice,
61
+ kind: 'later_invoice',
62
+ };
63
+ }
64
+ return { ...base, creditsMayChange: false, kind: 'reason_only' };
65
+ };
66
+ exports.toInvoicingSubscriptionEstimateView = toInvoicingSubscriptionEstimateView;
15
67
  const getEditInvoicingSubscriptionDetailViewState = (state, invoicingSubscriptionID) => {
16
68
  const { error, fetchState, savedSubscriptionId } = state.editInvoicingSubscriptionDetailViewState;
17
69
  const { subscriptionCommercialEditAllowedFromStatuses, subscriptionLifecycleActionOptions, subscriptionMetadataEditAllowedFromStatuses, } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
@@ -91,6 +143,28 @@ const getInvoicingItemsAllowedForPlan = (products, plan) => {
91
143
  return products.filter((product) => product.itemID != null && allowedItemIDs.includes(product.itemID));
92
144
  };
93
145
  exports.getInvoicingItemsAllowedForPlan = getInvoicingItemsAllowedForPlan;
146
+ // Years count as months so they compare; any other unit only meets itself.
147
+ const billingPeriodInCommonUnit = (pricePoint) => {
148
+ const { period, periodUnit } = pricePoint;
149
+ if (period == null || periodUnit == null || periodUnit === '') {
150
+ return undefined;
151
+ }
152
+ return periodUnit === 'year'
153
+ ? { count: period * 12, unit: 'month' }
154
+ : { count: period, unit: periodUnit };
155
+ };
156
+ // The add-on's period must divide the plan's (create 422s otherwise); fails open when they cannot be compared.
157
+ const isInvoicingAddonPeriodCompatible = (addon, plan) => {
158
+ const addonPeriod = billingPeriodInCommonUnit(addon);
159
+ const planPeriod = plan != null ? billingPeriodInCommonUnit(plan) : undefined;
160
+ if (addonPeriod == null ||
161
+ planPeriod == null ||
162
+ addonPeriod.unit !== planPeriod.unit) {
163
+ return true;
164
+ }
165
+ return addonPeriod.count > 0 && planPeriod.count % addonPeriod.count === 0;
166
+ };
167
+ exports.isInvoicingAddonPeriodCompatible = isInvoicingAddonPeriodCompatible;
94
168
  /**
95
169
  * A price row can only be subscribed by its price code, so one without a code
96
170
  * is not an option the form can offer.
@@ -154,7 +228,7 @@ const toInvoicingCustomerOption = (customer) => ({
154
228
  value: customer.id,
155
229
  });
156
230
  const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID) => {
157
- const { editDraftById, error, fetchState, newSubscriptionDraft, savedSubscriptionId, } = state.editInvoicingSubscriptionDetailViewState;
231
+ const { editDraftById, error, estimateState, fetchState, newSubscriptionDraft, savedSubscriptionId, } = state.editInvoicingSubscriptionDetailViewState;
158
232
  const mode = invoicingSubscriptionID != null ? 'edit' : 'create';
159
233
  const subscription = invoicingSubscriptionID != null
160
234
  ? (0, invoicingSubscriptionSelector_1.getInvoicingSubscriptionById)(state.invoicingSubscriptionState, invoicingSubscriptionID)
@@ -179,7 +253,12 @@ const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID) => {
179
253
  // pickers offer only those: subscription create rejects the rest with a 422,
180
254
  // and an option that can only fail is not a choice. The applicability rides
181
255
  // on the price rows already in the store, so this is a join, not a refetch.
182
- const allowedCatalogPrices = (0, exports.getInvoicingItemsAllowedForPlan)((0, invoicingCatalogListViewSelector_1.getInvoicingCatalogPrices)(catalogListView.products), planPrices.find((plan) => plan.priceCode === localData.planPriceCode)).filter(hasInvoicingPriceCode);
256
+ const selectedPlanPrice = planPrices.find((plan) => plan.priceCode === localData.planPriceCode);
257
+ // Add-ons also have to bill on the plan's cadence; charges are one-time.
258
+ const allowedCatalogPrices = (0, exports.getInvoicingItemsAllowedForPlan)((0, invoicingCatalogListViewSelector_1.getInvoicingCatalogPrices)(catalogListView.products), selectedPlanPrice)
259
+ .filter(hasInvoicingPriceCode)
260
+ .filter((product) => product.itemType !== 'addon' ||
261
+ (0, exports.isInvoicingAddonPeriodCompatible)(product, selectedPlanPrice));
183
262
  const catalogItemOptionsOfType = (itemType) => allowedCatalogPrices
184
263
  .filter((product) => product.itemType === itemType)
185
264
  .map(toInvoicingCatalogItemOption);
@@ -203,6 +282,7 @@ const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID) => {
203
282
  subscriptionMetadataEditAllowedFromStatuses: configState.subscriptionMetadataEditAllowedFromStatuses,
204
283
  recordState,
205
284
  isFormLoading: (0, invoicingFormDraft_1.isInvoicingFormDraftPending)(editDraftById, invoicingSubscriptionID),
285
+ estimate: (0, exports.toInvoicingSubscriptionEstimateView)(estimateState, invoicingSubscriptionID),
206
286
  fieldHelp: (0, invoicingConfigViewSelector_1.invoicingFieldHelpForGroup)(state, 'subscription'),
207
287
  addons: catalogItemOptionsOfType('addon'),
208
288
  charges: catalogItemOptionsOfType('charge'),
@@ -1,5 +1,6 @@
1
1
  import { Amount } from '../../../commonStateTypes/amount';
2
2
  import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
3
+ import { ZeniDate } from '../../../zeniDayJS';
3
4
  import { InvoicingFormDraftById } from '../invoicingFormDraft';
4
5
  /**
5
6
  * Draft form state for the create/edit subscription form. Held in CES so the
@@ -39,10 +40,67 @@ export interface InvoicingSubscriptionFormLocalData {
39
40
  /** Unset until the user enters one, so an explicit 0 stays distinguishable. */
40
41
  setupFee?: Amount;
41
42
  }
43
+ export interface InvoicingSubscriptionEstimateLineItem {
44
+ amount: Amount;
45
+ description: string;
46
+ discountAmount: Amount;
47
+ quantity: number;
48
+ unitAmount: Amount;
49
+ dateFrom?: ZeniDate;
50
+ dateTo?: ZeniDate;
51
+ taxAmount?: Amount;
52
+ }
53
+ /** An invoice the save would raise now, or the next one it would raise later. */
54
+ export interface InvoicingSubscriptionInvoiceEstimate {
55
+ amountDue: Amount;
56
+ couponDiscountTotal: Amount;
57
+ /** Refundable credits plus excess payments; promotional credits are separate. */
58
+ creditsApplied: Amount;
59
+ grossSubTotal: Amount;
60
+ lineItems: InvoicingSubscriptionEstimateLineItem[];
61
+ promotionalCreditsApplied: Amount;
62
+ /** After coupons and promotional credits. */
63
+ subTotal: Amount;
64
+ total: Amount;
65
+ dueDate?: ZeniDate;
66
+ invoiceDate?: ZeniDate;
67
+ /** Absent when the tax quote failed on a later invoice; Save still succeeds. */
68
+ tax?: Amount;
69
+ }
70
+ export interface InvoicingSubscriptionProrationEstimate {
71
+ /** `invoice`, `credit_note`, or `none` when the change nets to zero. */
72
+ documentType: string;
73
+ net: Amount;
74
+ invoice?: InvoicingSubscriptionInvoiceEstimate;
75
+ }
76
+ export interface InvoicingSubscriptionTermEstimate {
77
+ becomesNonRenewing: boolean;
78
+ currentTermEnd?: ZeniDate;
79
+ currentTermStart?: ZeniDate;
80
+ nextBillingAt?: ZeniDate;
81
+ }
82
+ /** What a save would bill, from `POST /subscriptions[/{id}]/estimate`. */
83
+ export interface InvoicingSubscriptionEstimate {
84
+ /** The service's sentence for why nothing is invoiced now; empty otherwise. */
85
+ reason: string;
86
+ willBeInvoiced: boolean;
87
+ invoice?: InvoicingSubscriptionInvoiceEstimate;
88
+ nextInvoice?: InvoicingSubscriptionInvoiceEstimate;
89
+ proration?: InvoicingSubscriptionProrationEstimate;
90
+ term?: InvoicingSubscriptionTermEstimate;
91
+ }
92
+ export interface InvoicingSubscriptionEstimateState {
93
+ fetchState: FetchStateAndError;
94
+ estimate?: InvoicingSubscriptionEstimate;
95
+ /** The subscription the estimate was asked for; absent for a new one. */
96
+ subscriptionId?: ID;
97
+ }
42
98
  export interface EditInvoicingSubscriptionDetailViewState extends FetchedState {
43
99
  /** Lifecycle action fetch state per subscription id. */
44
100
  actionStateById: Record<ID, FetchStateAndError>;
45
101
  editDraftById: InvoicingFormDraftById<InvoicingSubscriptionFormLocalData>;
102
+ /** The cost estimate shown before a save; nothing is saved by asking. */
103
+ estimateState: InvoicingSubscriptionEstimateState;
46
104
  newSubscriptionDraft: InvoicingSubscriptionFormLocalData;
47
105
  /** Detail-load state per subscription id. */
48
106
  recordStateById: Record<ID, FetchStateAndError>;
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../rootStateTypes';
4
+ import { ZeniAPI } from '../../../zeniAPI';
5
+ import { fetchInvoicingSubscriptionEstimate, updateInvoicingSubscriptionEstimate, updateInvoicingSubscriptionEstimateFailure } from './editInvoicingSubscriptionDetailViewReducer';
6
+ export type ActionType = ReturnType<typeof fetchInvoicingSubscriptionEstimate> | ReturnType<typeof updateInvoicingSubscriptionEstimate> | ReturnType<typeof updateInvoicingSubscriptionEstimateFailure>;
7
+ export declare const fetchInvoicingSubscriptionEstimateEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchInvoicingSubscriptionEstimateEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const couponSelector_1 = require("../../../entity/invoicing/coupon/couponSelector");
7
+ const responsePayload_1 = require("../../../responsePayload");
8
+ const editInvoicingSubscriptionDetailViewPayload_1 = require("./editInvoicingSubscriptionDetailViewPayload");
9
+ const editInvoicingSubscriptionDetailViewReducer_1 = require("./editInvoicingSubscriptionDetailViewReducer");
10
+ const saveInvoicingSubscriptionEpic_1 = require("./saveInvoicingSubscriptionEpic");
11
+ // Posts Save's exact body; a changed coupon rides along as `coupons` (Save syncs it after the PUT).
12
+ const fetchInvoicingSubscriptionEstimateEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(editInvoicingSubscriptionDetailViewReducer_1.fetchInvoicingSubscriptionEstimate.match), (0, operators_1.switchMap)((action) => {
13
+ const { id } = action.payload;
14
+ const { data, localData, previousCouponCode } = (0, saveInvoicingSubscriptionEpic_1.invoicingSubscriptionSaveRequest)(state$.value, id);
15
+ const couponCode = localData.couponId;
16
+ const coupon = (0, couponSelector_1.getInvoicingCouponByCode)(state$.value.invoicingCouponState, couponCode);
17
+ const body = id != null &&
18
+ (0, saveInvoicingSubscriptionEpic_1.isInvoicingSubscriptionCouponChanged)(previousCouponCode, couponCode)
19
+ ? {
20
+ ...data,
21
+ coupons: couponCode !== ''
22
+ ? [
23
+ {
24
+ applied_count: 0,
25
+ apply_till: null,
26
+ coupon_code: couponCode,
27
+ coupon_id: coupon?.id ?? couponCode,
28
+ },
29
+ ]
30
+ : [],
31
+ }
32
+ : data;
33
+ const baseUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/subscriptions`;
34
+ const url = id != null
35
+ ? `${baseUrl}/${encodeURIComponent(id)}/estimate`
36
+ : `${baseUrl}/estimate`;
37
+ return zeniAPI
38
+ .postAndGetJSON(url, body)
39
+ .pipe((0, operators_1.map)((response) => (0, responsePayload_1.isSuccessResponse)(response) && response.data != null
40
+ ? (0, editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionEstimate)({
41
+ estimate: (0, editInvoicingSubscriptionDetailViewPayload_1.mapInvoicingSubscriptionEstimatePayloadToState)(response.data),
42
+ id,
43
+ })
44
+ : (0, editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionEstimateFailure)({
45
+ id,
46
+ status: response.status,
47
+ })), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, editInvoicingSubscriptionDetailViewReducer_1.updateInvoicingSubscriptionEstimateFailure)({
48
+ id,
49
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Subscription estimate REST API call errored out ' +
50
+ JSON.stringify(error)),
51
+ }))));
52
+ }));
53
+ exports.fetchInvoicingSubscriptionEstimateEpic = fetchInvoicingSubscriptionEstimateEpic;