@zeniai/client-epic-state 5.1.41-betaAK0 → 5.1.41-betaAK2

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 (21) hide show
  1. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerPayload.d.ts +1 -0
  2. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerPayload.js +1 -0
  3. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerState.d.ts +1 -0
  4. package/lib/esm/entity/invoicing/invoicingCustomer/invoicingCustomerPayload.js +1 -0
  5. package/lib/esm/index.js +1 -1
  6. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.js +8 -24
  7. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +26 -2
  8. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig.js +2 -15
  9. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +8 -2
  10. package/lib/index.d.ts +1 -1
  11. package/lib/index.js +6 -5
  12. package/lib/view/addressView/addressViewState.d.ts +1 -1
  13. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.d.ts +6 -4
  14. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.js +8 -24
  15. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +2 -0
  16. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +25 -1
  17. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +4 -11
  18. package/lib/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig.d.ts +2 -0
  19. package/lib/view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig.js +3 -16
  20. package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +8 -2
  21. package/package.json +1 -1
@@ -6,6 +6,7 @@ export interface InvoicingCustomerPayload {
6
6
  arr?: number;
7
7
  auto_collection?: 'on' | 'off';
8
8
  billing_address?: InvoicingBillingAddressPayload;
9
+ billing_address_id?: string;
9
10
  card_status?: 'no_card' | 'valid' | 'expiring' | 'expired';
10
11
  company?: string;
11
12
  consolidated_invoicing?: boolean;
@@ -16,6 +16,7 @@ const mapInvoicingCustomerPayloadToState = (payload) => {
16
16
  : undefined,
17
17
  autoCollection: payload.auto_collection,
18
18
  billingAddress: payload.billing_address,
19
+ billingAddressId: payload.billing_address_id,
19
20
  cardStatus: payload.card_status,
20
21
  company: payload.company,
21
22
  consolidatedInvoicing: payload.consolidated_invoicing,
@@ -8,6 +8,7 @@ export interface InvoicingCustomer {
8
8
  arr?: Amount;
9
9
  autoCollection?: 'on' | 'off';
10
10
  billingAddress?: InvoicingBillingAddressPayload;
11
+ billingAddressId?: ID;
11
12
  cardStatus?: 'no_card' | 'valid' | 'expiring' | 'expired';
12
13
  company?: string;
13
14
  consolidatedInvoicing?: boolean;
@@ -13,6 +13,7 @@ export const mapInvoicingCustomerPayloadToState = (payload) => {
13
13
  : undefined,
14
14
  autoCollection: payload.auto_collection,
15
15
  billingAddress: payload.billing_address,
16
+ billingAddressId: payload.billing_address_id,
16
17
  cardStatus: payload.card_status,
17
18
  company: payload.company,
18
19
  consolidatedInvoicing: payload.consolidated_invoicing,
package/lib/esm/index.js CHANGED
@@ -725,7 +725,7 @@ export { getInvoicingAuditLogFetchState, getInvoicingAuditLogFilters, getInvoici
725
725
  export { getCreateInvoiceFetchState, getCreateInvoiceFormView, getCreatedInvoiceId, } from './view/invoicing/createInvoice/createInvoiceSelector';
726
726
  export { getRecordPaymentFetchState, getRecordedTransactionId, } from './view/invoicing/recordPayment/recordPaymentSelector';
727
727
  export { resetEditInvoicingCustomerDetailView, submitInvoicingCustomerForm, submitInvoicingCustomerFormFailure, submitInvoicingCustomerFormSuccess, updateInvoicingCustomerFormDraft, } from './view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer';
728
- export { INVOICING_CUSTOMER_TYPE_VALUES, INVOICING_NET_TERM_DAY_VALUES, INVOICING_TAXABILITY_VALUES, entityToInvoicingCustomerFormLocalData, initialInvoicingCustomerFormLocalData, } from './view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig';
728
+ export { INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE, INVOICING_CUSTOMER_TYPE_VALUES, INVOICING_NET_TERM_DAY_VALUES, INVOICING_TAXABILITY_VALUES, entityToInvoicingCustomerFormLocalData, initialInvoicingCustomerFormLocalData, } from './view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig';
729
729
  export { getInvoicingCustomerFormView } from './view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector';
730
730
  export { fetchInvoicingSubscriptionFormPage, resetEditInvoicingSubscriptionDetailView, saveInvoicingSubscription, } from './view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer';
731
731
  export { getEditInvoicingSubscriptionDetailViewState, getInvoicingSubscriptionFormView, } from './view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector';
@@ -1,24 +1,16 @@
1
+ import { toAddressUpdatableInfoPayload } from '../../addressView/addressViewPayload';
1
2
  const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
2
3
  /**
3
- * Build the create/update customer request body from the form draft. Owns the
4
- * trimming and billing-address assembly that previously lived in
5
- * web-components, so the presentational form no longer shapes the API payload.
4
+ * Build the create/update customer request body from the form draft. The
5
+ * billing address is sent as an object (captured via the shared Address
6
+ * screen); the backend creates it and returns its id — same pattern as the
7
+ * vendor save flow.
6
8
  */
7
- export const localDataToSaveInvoicingCustomerPayload = (localData) => {
9
+ export const localDataToSaveInvoicingCustomerPayload = (localData, billingAddress) => {
8
10
  const firstName = trimOrUndefined(localData.firstName);
9
11
  const lastName = trimOrUndefined(localData.lastName);
10
12
  const company = trimOrUndefined(localData.company);
11
13
  const netTerm = localData.netTermDays.trim();
12
- const addressFields = {
13
- city: trimOrUndefined(localData.billingCity),
14
- country: trimOrUndefined(localData.billingCountry),
15
- line1: trimOrUndefined(localData.billingLine1),
16
- line2: trimOrUndefined(localData.billingLine2),
17
- phone: trimOrUndefined(localData.billingPhone),
18
- state_code: trimOrUndefined(localData.billingState),
19
- zip: trimOrUndefined(localData.billingZip),
20
- };
21
- const hasAddress = Object.values(addressFields).some((part) => part != null);
22
14
  return {
23
15
  auto_collection: localData.autoCollection ? 'on' : 'off',
24
16
  company,
@@ -32,16 +24,8 @@ export const localDataToSaveInvoicingCustomerPayload = (localData) => {
32
24
  taxability: localData.taxability,
33
25
  vat_number: trimOrUndefined(localData.vatNumber),
34
26
  ...(netTerm !== '' ? { net_term_days: Number(netTerm) } : {}),
35
- ...(hasAddress
36
- ? {
37
- billing_address: {
38
- ...addressFields,
39
- company,
40
- first_name: firstName,
41
- last_name: lastName,
42
- validation_status: 'not_validated',
43
- },
44
- }
27
+ ...(billingAddress != null
28
+ ? { billing_address: toAddressUpdatableInfoPayload(billingAddress) }
45
29
  : {}),
46
30
  };
47
31
  };
@@ -1,5 +1,15 @@
1
1
  import { getInvoicingCustomerById } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector';
2
- import { INVOICING_CUSTOMER_TYPE_VALUES, INVOICING_NET_TERM_DAY_VALUES, INVOICING_TAXABILITY_VALUES, entityToInvoicingCustomerFormLocalData, } from './invoicingCustomerFormConfig';
2
+ import { getFormattedAddress } from '../../addressView/addressViewSelector';
3
+ import { INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE, INVOICING_CUSTOMER_TYPE_VALUES, INVOICING_NET_TERM_DAY_VALUES, INVOICING_TAXABILITY_VALUES, entityToInvoicingCustomerFormLocalData, } from './invoicingCustomerFormConfig';
4
+ const formatInvoicingBillingAddress = (address) => [
5
+ address.line1,
6
+ address.line2,
7
+ address.city,
8
+ `${address.state_code ?? ''} ${address.zip ?? ''}`.trim(),
9
+ address.country,
10
+ ]
11
+ .filter((part) => part != null && part !== '')
12
+ .join(', ');
3
13
  /**
4
14
  * Bundled view for the customer create/edit form. Exposes the draft `localData`
5
15
  * (seeded from the existing customer entity in edit mode until the user edits),
@@ -10,16 +20,30 @@ import { INVOICING_CUSTOMER_TYPE_VALUES, INVOICING_NET_TERM_DAY_VALUES, INVOICIN
10
20
  export const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
11
21
  const { editDraftById, error, fetchState, newCustomerDraft, savedCustomerId } = state.editInvoicingCustomerDetailViewState;
12
22
  const mode = invoicingCustomerID != null ? 'edit' : 'create';
23
+ const customer = invoicingCustomerID != null
24
+ ? getInvoicingCustomerById(state.invoicingCustomerState, invoicingCustomerID)
25
+ : undefined;
13
26
  const localData = invoicingCustomerID != null
14
27
  ? (editDraftById[invoicingCustomerID] ??
15
- entityToInvoicingCustomerFormLocalData(getInvoicingCustomerById(state.invoicingCustomerState, invoicingCustomerID)))
28
+ entityToInvoicingCustomerFormLocalData(customer))
16
29
  : newCustomerDraft;
30
+ // Billing address is captured via the shared Address screen: prefer a
31
+ // freshly-saved address, else the customer's existing one.
32
+ const newAddress = state.addressViewState.newAddressState?.[INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE];
33
+ const billingAddressId = newAddress?.newAddressId ?? customer?.billingAddressId;
34
+ const billingAddressLabel = newAddress?.addressToCreate != null
35
+ ? getFormattedAddress(newAddress.addressToCreate)
36
+ : customer?.billingAddress != null
37
+ ? formatInvoicingBillingAddress(customer.billingAddress)
38
+ : undefined;
17
39
  return {
18
40
  customerTypeValues: [...INVOICING_CUSTOMER_TYPE_VALUES],
19
41
  localData,
20
42
  mode,
21
43
  netTermDayValues: [...INVOICING_NET_TERM_DAY_VALUES],
22
44
  taxabilityValues: [...INVOICING_TAXABILITY_VALUES],
45
+ billingAddressId,
46
+ billingAddressLabel,
23
47
  savedCustomerId,
24
48
  fetchState,
25
49
  error,
@@ -1,3 +1,5 @@
1
+ /** `AddressType` key used when the customer form opens the shared Address screen. */
2
+ export const INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE = 'invoicing_customer_billing_address';
1
3
  /**
2
4
  * Canonical option value sets for the customer form. CES owns the values;
3
5
  * web-components maps each value to a localized label (same split as the
@@ -17,13 +19,6 @@ export const INVOICING_NET_TERM_DAY_VALUES = [
17
19
  ];
18
20
  export const initialInvoicingCustomerFormLocalData = {
19
21
  autoCollection: true,
20
- billingCity: '',
21
- billingCountry: '',
22
- billingLine1: '',
23
- billingLine2: '',
24
- billingPhone: '',
25
- billingState: '',
26
- billingZip: '',
27
22
  company: '',
28
23
  customerType: 'business',
29
24
  email: '',
@@ -41,16 +36,8 @@ export const entityToInvoicingCustomerFormLocalData = (customer) => {
41
36
  if (customer == null) {
42
37
  return { ...initialInvoicingCustomerFormLocalData };
43
38
  }
44
- const address = customer.billingAddress;
45
39
  return {
46
40
  autoCollection: (customer.autoCollection ?? 'on') === 'on',
47
- billingCity: address?.city ?? '',
48
- billingCountry: address?.country ?? '',
49
- billingLine1: address?.line1 ?? '',
50
- billingLine2: address?.line2 ?? '',
51
- billingPhone: address?.phone ?? '',
52
- billingState: address?.state_code ?? '',
53
- billingZip: address?.zip ?? '',
54
41
  company: customer.company ?? '',
55
42
  customerType: customer.customerType ?? 'business',
56
43
  email: customer.email ?? '',
@@ -3,13 +3,19 @@ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { updateInvoicingCustomers } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerReducer';
4
4
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
5
  import { localDataToSaveInvoicingCustomerPayload, } from './editInvoicingCustomerDetailViewPayload';
6
+ import { INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE } from './invoicingCustomerFormConfig';
6
7
  import { submitInvoicingCustomerForm, submitInvoicingCustomerFormFailure, submitInvoicingCustomerFormSuccess, } from './editInvoicingCustomerDetailViewReducer';
7
8
  export const saveInvoicingCustomerEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(submitInvoicingCustomerForm.match), mergeMap((action) => {
8
9
  const { id } = action.payload;
9
- const viewState = state$.value.editInvoicingCustomerDetailViewState;
10
+ const rootState = state$.value;
11
+ const viewState = rootState.editInvoicingCustomerDetailViewState;
10
12
  const localData = (id != null ? viewState.editDraftById[id] : viewState.newCustomerDraft) ??
11
13
  viewState.newCustomerDraft;
12
- const data = localDataToSaveInvoicingCustomerPayload(localData);
14
+ // Billing address captured via the shared Address screen is sent as an
15
+ // object in the payload; the backend creates it and returns its id
16
+ // (same pattern as the vendor save flow).
17
+ const billingAddress = rootState.addressViewState.newAddressState?.[INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE]?.addressToCreate;
18
+ const data = localDataToSaveInvoicingCustomerPayload(localData, billingAddress);
13
19
  const baseUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;
14
20
  const request$ = id != null
15
21
  ? zeniAPI.putAndGetJSON(`${baseUrl}/customers/${encodeURIComponent(id)}`, { ...data })
package/lib/index.d.ts CHANGED
@@ -1041,7 +1041,7 @@ export { getRecordPaymentFetchState, getRecordedTransactionId, } from './view/in
1041
1041
  export { resetEditInvoicingCustomerDetailView, submitInvoicingCustomerForm, submitInvoicingCustomerFormFailure, submitInvoicingCustomerFormSuccess, updateInvoicingCustomerFormDraft, } from './view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer';
1042
1042
  export type { SubmitInvoicingCustomerFormPayload, UpdateInvoicingCustomerFormDraftPayload, } from './view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer';
1043
1043
  export type { InvoicingCustomerFormLocalData } from './view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState';
1044
- export { INVOICING_CUSTOMER_TYPE_VALUES, INVOICING_NET_TERM_DAY_VALUES, INVOICING_TAXABILITY_VALUES, entityToInvoicingCustomerFormLocalData, initialInvoicingCustomerFormLocalData, } from './view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig';
1044
+ export { INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE, INVOICING_CUSTOMER_TYPE_VALUES, INVOICING_NET_TERM_DAY_VALUES, INVOICING_TAXABILITY_VALUES, entityToInvoicingCustomerFormLocalData, initialInvoicingCustomerFormLocalData, } from './view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig';
1045
1045
  export { getInvoicingCustomerFormView } from './view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector';
1046
1046
  export type { InvoicingCustomerFormView } from './view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector';
1047
1047
  export { fetchInvoicingSubscriptionFormPage, resetEditInvoicingSubscriptionDetailView, saveInvoicingSubscription, } from './view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer';
package/lib/index.js CHANGED
@@ -77,11 +77,11 @@ exports.toCardPolicyEditFormDraft = exports.toBulkCreateCardPolicyTemplateError
77
77
  exports.updateArchiveCardPolicyFetchStatus = exports.prependCardPolicyTemplateIds = exports.fetchCardPolicyList = exports.clearCardPolicyList = 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 = exports.toMccCategoryLike = exports.CARD_POLICY_LIMIT_ROW_ID_TRANSACTION = exports.CARD_POLICY_LIMIT_ROW_ID_REQUIRE_RECEIPT = exports.getManualCardPolicyFormDraft = exports.getLastCreatedCardPolicyTemplateIds = exports.getLastCreatedCardPolicyTemplateId = exports.getLastCreateCardPolicyTemplateErrors = exports.getLastCreateCardPolicySourceChatSessionId = exports.getCreateCardPolicyTemplateRequestState = exports.getAiCardPolicyFormDraft = exports.updateManualCardPolicyFormDraft = exports.updateCreateCardPolicyTemplateRequestState = exports.updateAiCardPolicyFormDraftFromUploadPlan = exports.updateAiCardPolicyFormDraft = exports.seedManualCardPolicyFormDraft = exports.seedAiCardPolicyFormDraft = exports.createCardPolicyTemplates = exports.clearManualCardPolicyFormDraft = exports.clearCreateCardPolicy = exports.clearAiCardPolicyFormDraft = exports.applyExtractedPolicyToManualCardPolicyDraft = exports.applyExtractedPolicyToAiCardPolicyDraft = exports.toUpdateCardPolicyTemplateRequestBody = exports.toExtractedCardPolicyRules = exports.toCreateCardPolicyTemplatesRequestBody = exports.toCreateCardPolicyTemplateRequestBody = exports.toCardPolicyVendorSearchOption = exports.toCardPolicyTemplateList = exports.toCardPolicyTemplate = exports.toCardPolicyStats = void 0;
78
78
  exports.saveAutoSweepSettings = exports.clearAutoSweepFlow = exports.fetchCashManagementOverviewPage = exports.fetchCashManagementBanner = 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 = 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.clearCardPolicyDetail = exports.getCardPolicyTemplateIds = exports.getCardPolicyListView = exports.getCardPolicyListFetchState = exports.getArchiveCardPolicyFetchState = exports.updateCardPolicyListFetchStatus = void 0;
79
79
  exports.submitInvoicingCustomerFormFailure = exports.submitInvoicingCustomerForm = exports.resetEditInvoicingCustomerDetailView = exports.getRecordedTransactionId = exports.getRecordPaymentFetchState = exports.getCreatedInvoiceId = exports.getCreateInvoiceFormView = exports.getCreateInvoiceFetchState = exports.getInvoicingAuditLogNextCursor = exports.getInvoicingAuditLogItems = exports.getInvoicingAuditLogHasMore = exports.getInvoicingAuditLogFilters = exports.getInvoicingAuditLogFetchState = exports.fetchInvoicingAuditLog = exports.clearInvoicingAuditView = exports.getInvoicingOverview = exports.buildPeriodOptions = exports.fetchInvoicingOverview = exports.clearInvoicingOverview = exports.resetRecordPayment = exports.recordPayment = exports.resetCreateInvoice = exports.createInvoice = exports.getInvoiceDetail = exports.fetchInvoiceDetail = exports.clearAllInvoiceDetail = exports.getInvoiceListView = exports.INVOICING_INVOICE_TABS = exports.ALL_INVOICING_INVOICE_TAB_IDS = exports.updateInvoiceListFilters = exports.fetchInvoiceListPage = exports.fetchInvoiceList = exports.fetchInvoiceKPIs = exports.fetchInvoiceCounts = exports.clearInvoiceList = exports.getInvoicesByIds = exports.getInvoiceById = exports.updateInvoices = exports.removeInvoice = exports.clearAllInvoices = exports.getCashManagementOverviewBanner = exports.getCashManagementOverview = exports.bufferAmountToRisk = exports.RISK_BUFFER_AMOUNT = exports.getAutoSweepFlow = exports.updateCashManagementSettingsFetchStatus = exports.updateCashManagementSettings = exports.updateAutoSweepSettingsFetchStatus = exports.updateAutoSweepRisk = exports.updateAutoSweepDraft = void 0;
80
- exports.retryInvoicingMigration = exports.connectInvoicingChargebee = exports.clearAllInvoicingDataImportActions = exports.getInvoicingMigrationSessionsFetchState = exports.getInvoicingMigrationSessions = exports.getInvoicingMigrationSessionById = exports.getInvoicingDataImportStatusRows = exports.getInvoicingDataImportStatusFetchState = exports.getInvoicingActiveMigrationSessionId = exports.setInvoicingActiveMigrationSessionId = exports.fetchInvoicingMigrationSessions = exports.fetchInvoicingMigrationSession = exports.fetchInvoicingDataImportStatus = exports.clearInvoicingDataImportView = exports.getInvoicingPaymentActionState = exports.runInvoicingPaymentAction = exports.clearInvoicingPaymentAction = exports.getInvoicingDunningActionState = exports.runInvoicingDunningAction = exports.clearInvoicingDunningAction = exports.getInvoicingSubscriptionActionState = exports.runInvoicingSubscriptionAction = exports.clearInvoicingSubscriptionAction = exports.getInvoicingInvoiceActionState = exports.updateInvoicingInvoice = exports.runInvoicingInvoiceAction = exports.clearInvoicingInvoiceAction = exports.getInvoicingCouponFormView = exports.getEditInvoicingCouponDetailViewState = exports.saveInvoicingCoupon = exports.resetEditInvoicingCouponDetailView = exports.getSavedInvoicingCatalogItemKind = exports.getSavedInvoicingCatalogItemId = exports.getInvoicingCatalogItemFormView = exports.getEditInvoicingCatalogItemDetailViewState = exports.saveInvoicingCatalogItem = exports.resetEditInvoicingCatalogItemDetailView = exports.getInvoicingSubscriptionFormView = exports.getEditInvoicingSubscriptionDetailViewState = exports.saveInvoicingSubscription = exports.resetEditInvoicingSubscriptionDetailView = exports.fetchInvoicingSubscriptionFormPage = exports.getInvoicingCustomerFormView = exports.initialInvoicingCustomerFormLocalData = exports.entityToInvoicingCustomerFormLocalData = exports.INVOICING_TAXABILITY_VALUES = exports.INVOICING_NET_TERM_DAY_VALUES = exports.INVOICING_CUSTOMER_TYPE_VALUES = exports.updateInvoicingCustomerFormDraft = exports.submitInvoicingCustomerFormSuccess = void 0;
81
- exports.fetchInvoicingSubscriptionDetail = exports.clearInvoicingSubscriptionDetailView = exports.getInvoicingSubscriptionListView = exports.INVOICING_SUBSCRIPTION_TABS = exports.INVOICING_SUBSCRIPTION_COLUMNS = exports.ALL_INVOICING_SUBSCRIPTION_TAB_IDS = exports.ALL_INVOICING_SUBSCRIPTION_SORT_KEYS = exports.updateInvoicingSubscriptionFilters = exports.fetchInvoicingSubscriptionListPage = exports.fetchInvoicingSubscriptionList = exports.fetchInvoicingSubscriptionCounts = exports.clearInvoicingSubscriptionListView = exports.updateInvoicingSubscriptions = exports.removeInvoicingSubscription = exports.clearAllInvoicingSubscriptions = exports.getInvoicingSetupIntentFetchState = exports.getInvoicingSetupIntent = exports.getInvoicingSentPaymentLinkMagicUrl = exports.getInvoicingSentPaymentLinkEmail = exports.getInvoicingPlaidLinkTokenFetchState = exports.getInvoicingPlaidLinkToken = exports.getInvoicingPaymentMethodSaveState = exports.getInvoicingPaymentLinkSendState = exports.sendInvoicingPaymentLink = exports.saveInvoicingPaymentMethod = exports.resetInvoicingCustomerPaymentMethod = exports.fetchInvoicingPlaidLinkToken = exports.createInvoicingSetupIntent = exports.getInvoicingCustomerDetail = exports.fetchInvoicingCustomerDetailPage = exports.fetchInvoicingCustomerDetail = exports.clearInvoicingCustomerDetailView = exports.getInvoicingCustomerListView = exports.INVOICING_CUSTOMER_TABS = exports.INVOICING_CUSTOMER_COLUMNS = exports.ALL_INVOICING_CUSTOMER_TAB_IDS = exports.ALL_INVOICING_CUSTOMER_SORT_KEYS = exports.updateInvoicingCustomerFilters = exports.fetchInvoicingCustomerListPage = exports.fetchInvoicingCustomerList = exports.fetchInvoicingCustomerCounts = exports.clearInvoicingCustomerListView = exports.updateInvoicingCustomers = exports.removeInvoicingCustomer = exports.clearAllInvoicingCustomers = exports.INVOICING_LIST_PAGE_SIZE = exports.getInvoicingDataImportActionState = exports.uploadInvoicingMigrationFiles = exports.startInvoicingMigration = exports.rollbackInvoicingMigration = void 0;
82
- exports.getInvoicingCouponListFilters = exports.getInvoicingCouponListFetchState = exports.getInvoicingCouponCounts = exports.INVOICING_COUPON_TABS = exports.INVOICING_COUPON_COLUMNS = exports.ALL_INVOICING_COUPON_TAB_IDS = exports.ALL_INVOICING_COUPON_SORT_KEYS = exports.updateInvoicingCouponFilters = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.fetchInvoicingCouponCounts = exports.clearInvoicingCouponView = exports.updateInvoicingCoupons = exports.removeInvoicingCoupon = exports.clearAllInvoicingCoupons = exports.getInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteById = exports.fetchInvoicingCreditNoteDetail = exports.clearInvoicingCreditNoteDetailView = exports.getInvoicingCreditNoteListView = exports.INVOICING_CREDIT_NOTE_TABS = exports.INVOICING_CREDIT_NOTE_COLUMNS = exports.ALL_INVOICING_CREDIT_NOTE_TAB_IDS = exports.ALL_INVOICING_CREDIT_NOTE_SORT_KEYS = exports.updateInvoicingCreditNoteFilters = exports.fetchInvoicingCreditNoteListPage = exports.fetchInvoicingCreditNoteList = exports.fetchInvoicingCreditNoteCounts = exports.clearInvoicingCreditNoteListView = exports.updateInvoicingCreditNotes = exports.removeInvoicingCreditNote = exports.clearAllInvoicingCreditNotes = exports.getInvoicingTransactionDetail = exports.getInvoicingTransactionById = exports.fetchInvoicingTransactionDetail = exports.clearInvoicingTransactionDetailView = exports.getInvoicingTransactionListView = exports.INVOICING_TRANSACTION_TABS = exports.INVOICING_TRANSACTION_COLUMNS = exports.ALL_INVOICING_TRANSACTION_TAB_IDS = exports.ALL_INVOICING_TRANSACTION_SORT_KEYS = exports.updateInvoicingTransactionFilters = exports.fetchInvoicingTransactionListPage = exports.fetchInvoicingTransactionList = exports.clearInvoicingTransactionListView = exports.updateInvoicingTransactions = exports.removeInvoicingTransaction = exports.clearAllInvoicingTransactions = exports.getInvoicingSubscriptionDetail = exports.getInvoicingSubscriptionById = void 0;
83
- exports.fetchInvoicingSettings = exports.disconnectInvoicingStripe = exports.connectInvoicingStripe = exports.clearInvoicingSettings = exports.getInvoicingProductById = exports.getInvoicingPlanById = exports.getInvoicingCatalogItemDetail = exports.fetchInvoicingCatalogItemDetail = exports.clearInvoicingCatalogItemDetailView = exports.getInvoicingCatalogListView = exports.INVOICING_PRODUCT_COLUMNS = exports.ALL_INVOICING_PRODUCT_SORT_KEYS = exports.updateInvoicingCatalogProductFilters = exports.updateInvoicingCatalogPlanFilters = exports.fetchInvoicingCatalogProductList = exports.fetchInvoicingCatalogPlanList = exports.fetchInvoicingCatalogListPage = exports.fetchInvoicingCatalogCounts = exports.clearInvoicingCatalogListView = exports.updateInvoicingProducts = exports.removeInvoicingProduct = exports.clearAllInvoicingProducts = exports.updateInvoicingPlans = exports.removeInvoicingPlan = exports.clearAllInvoicingPlans = exports.getInvoicingDunningCaseDetail = exports.getInvoicingDunningCaseById = exports.fetchInvoicingDunningCaseDetail = exports.clearInvoicingDunningCaseDetailView = exports.getInvoicingDunningCaseListView = exports.INVOICING_DUNNING_CASE_TABS = exports.INVOICING_DUNNING_CASE_COLUMNS = exports.ALL_INVOICING_DUNNING_CASE_TAB_IDS = exports.ALL_INVOICING_DUNNING_CASE_SORT_KEYS = exports.updateInvoicingDunningCaseFilters = exports.fetchInvoicingDunningCaseListPage = exports.fetchInvoicingDunningCaseList = exports.fetchInvoicingDunningCaseCounts = exports.clearInvoicingDunningCaseListView = exports.updateInvoicingDunningCases = exports.removeInvoicingDunningCase = exports.clearAllInvoicingDunningCases = exports.getInvoicingCouponDetail = exports.fetchInvoicingCouponDetail = exports.clearInvoicingCouponDetailView = exports.getInvoicingCouponById = exports.getInvoicingCouponListView = exports.getInvoicingCouponListNextCursor = exports.getInvoicingCouponListItems = exports.getInvoicingCouponListHasMore = void 0;
84
- exports.isStripeConnectedFromSettings = exports.getInvoicingStripeConnectState = exports.getInvoicingSettingsSaveState = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = exports.updateInvoicingSettings = exports.saveInvoicingSettings = exports.resetSaveInvoicingSettings = void 0;
80
+ exports.connectInvoicingChargebee = exports.clearAllInvoicingDataImportActions = exports.getInvoicingMigrationSessionsFetchState = exports.getInvoicingMigrationSessions = exports.getInvoicingMigrationSessionById = exports.getInvoicingDataImportStatusRows = exports.getInvoicingDataImportStatusFetchState = exports.getInvoicingActiveMigrationSessionId = exports.setInvoicingActiveMigrationSessionId = exports.fetchInvoicingMigrationSessions = exports.fetchInvoicingMigrationSession = exports.fetchInvoicingDataImportStatus = exports.clearInvoicingDataImportView = exports.getInvoicingPaymentActionState = exports.runInvoicingPaymentAction = exports.clearInvoicingPaymentAction = exports.getInvoicingDunningActionState = exports.runInvoicingDunningAction = exports.clearInvoicingDunningAction = exports.getInvoicingSubscriptionActionState = exports.runInvoicingSubscriptionAction = exports.clearInvoicingSubscriptionAction = exports.getInvoicingInvoiceActionState = exports.updateInvoicingInvoice = exports.runInvoicingInvoiceAction = exports.clearInvoicingInvoiceAction = exports.getInvoicingCouponFormView = exports.getEditInvoicingCouponDetailViewState = exports.saveInvoicingCoupon = exports.resetEditInvoicingCouponDetailView = exports.getSavedInvoicingCatalogItemKind = exports.getSavedInvoicingCatalogItemId = exports.getInvoicingCatalogItemFormView = exports.getEditInvoicingCatalogItemDetailViewState = exports.saveInvoicingCatalogItem = exports.resetEditInvoicingCatalogItemDetailView = exports.getInvoicingSubscriptionFormView = exports.getEditInvoicingSubscriptionDetailViewState = exports.saveInvoicingSubscription = exports.resetEditInvoicingSubscriptionDetailView = exports.fetchInvoicingSubscriptionFormPage = exports.getInvoicingCustomerFormView = exports.initialInvoicingCustomerFormLocalData = exports.entityToInvoicingCustomerFormLocalData = exports.INVOICING_TAXABILITY_VALUES = exports.INVOICING_NET_TERM_DAY_VALUES = exports.INVOICING_CUSTOMER_TYPE_VALUES = exports.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE = exports.updateInvoicingCustomerFormDraft = exports.submitInvoicingCustomerFormSuccess = void 0;
81
+ exports.clearInvoicingSubscriptionDetailView = exports.getInvoicingSubscriptionListView = exports.INVOICING_SUBSCRIPTION_TABS = exports.INVOICING_SUBSCRIPTION_COLUMNS = exports.ALL_INVOICING_SUBSCRIPTION_TAB_IDS = exports.ALL_INVOICING_SUBSCRIPTION_SORT_KEYS = exports.updateInvoicingSubscriptionFilters = exports.fetchInvoicingSubscriptionListPage = exports.fetchInvoicingSubscriptionList = exports.fetchInvoicingSubscriptionCounts = exports.clearInvoicingSubscriptionListView = exports.updateInvoicingSubscriptions = exports.removeInvoicingSubscription = exports.clearAllInvoicingSubscriptions = exports.getInvoicingSetupIntentFetchState = exports.getInvoicingSetupIntent = exports.getInvoicingSentPaymentLinkMagicUrl = exports.getInvoicingSentPaymentLinkEmail = exports.getInvoicingPlaidLinkTokenFetchState = exports.getInvoicingPlaidLinkToken = exports.getInvoicingPaymentMethodSaveState = exports.getInvoicingPaymentLinkSendState = exports.sendInvoicingPaymentLink = exports.saveInvoicingPaymentMethod = exports.resetInvoicingCustomerPaymentMethod = exports.fetchInvoicingPlaidLinkToken = exports.createInvoicingSetupIntent = exports.getInvoicingCustomerDetail = exports.fetchInvoicingCustomerDetailPage = exports.fetchInvoicingCustomerDetail = exports.clearInvoicingCustomerDetailView = exports.getInvoicingCustomerListView = exports.INVOICING_CUSTOMER_TABS = exports.INVOICING_CUSTOMER_COLUMNS = exports.ALL_INVOICING_CUSTOMER_TAB_IDS = exports.ALL_INVOICING_CUSTOMER_SORT_KEYS = exports.updateInvoicingCustomerFilters = exports.fetchInvoicingCustomerListPage = exports.fetchInvoicingCustomerList = exports.fetchInvoicingCustomerCounts = exports.clearInvoicingCustomerListView = exports.updateInvoicingCustomers = exports.removeInvoicingCustomer = exports.clearAllInvoicingCustomers = exports.INVOICING_LIST_PAGE_SIZE = exports.getInvoicingDataImportActionState = exports.uploadInvoicingMigrationFiles = exports.startInvoicingMigration = exports.rollbackInvoicingMigration = exports.retryInvoicingMigration = void 0;
82
+ exports.getInvoicingCouponListFetchState = exports.getInvoicingCouponCounts = exports.INVOICING_COUPON_TABS = exports.INVOICING_COUPON_COLUMNS = exports.ALL_INVOICING_COUPON_TAB_IDS = exports.ALL_INVOICING_COUPON_SORT_KEYS = exports.updateInvoicingCouponFilters = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.fetchInvoicingCouponCounts = exports.clearInvoicingCouponView = exports.updateInvoicingCoupons = exports.removeInvoicingCoupon = exports.clearAllInvoicingCoupons = exports.getInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteById = exports.fetchInvoicingCreditNoteDetail = exports.clearInvoicingCreditNoteDetailView = exports.getInvoicingCreditNoteListView = exports.INVOICING_CREDIT_NOTE_TABS = exports.INVOICING_CREDIT_NOTE_COLUMNS = exports.ALL_INVOICING_CREDIT_NOTE_TAB_IDS = exports.ALL_INVOICING_CREDIT_NOTE_SORT_KEYS = exports.updateInvoicingCreditNoteFilters = exports.fetchInvoicingCreditNoteListPage = exports.fetchInvoicingCreditNoteList = exports.fetchInvoicingCreditNoteCounts = exports.clearInvoicingCreditNoteListView = exports.updateInvoicingCreditNotes = exports.removeInvoicingCreditNote = exports.clearAllInvoicingCreditNotes = exports.getInvoicingTransactionDetail = exports.getInvoicingTransactionById = exports.fetchInvoicingTransactionDetail = exports.clearInvoicingTransactionDetailView = exports.getInvoicingTransactionListView = exports.INVOICING_TRANSACTION_TABS = exports.INVOICING_TRANSACTION_COLUMNS = exports.ALL_INVOICING_TRANSACTION_TAB_IDS = exports.ALL_INVOICING_TRANSACTION_SORT_KEYS = exports.updateInvoicingTransactionFilters = exports.fetchInvoicingTransactionListPage = exports.fetchInvoicingTransactionList = exports.clearInvoicingTransactionListView = exports.updateInvoicingTransactions = exports.removeInvoicingTransaction = exports.clearAllInvoicingTransactions = exports.getInvoicingSubscriptionDetail = exports.getInvoicingSubscriptionById = exports.fetchInvoicingSubscriptionDetail = void 0;
83
+ exports.disconnectInvoicingStripe = exports.connectInvoicingStripe = exports.clearInvoicingSettings = exports.getInvoicingProductById = exports.getInvoicingPlanById = exports.getInvoicingCatalogItemDetail = exports.fetchInvoicingCatalogItemDetail = exports.clearInvoicingCatalogItemDetailView = exports.getInvoicingCatalogListView = exports.INVOICING_PRODUCT_COLUMNS = exports.ALL_INVOICING_PRODUCT_SORT_KEYS = exports.updateInvoicingCatalogProductFilters = exports.updateInvoicingCatalogPlanFilters = exports.fetchInvoicingCatalogProductList = exports.fetchInvoicingCatalogPlanList = exports.fetchInvoicingCatalogListPage = exports.fetchInvoicingCatalogCounts = exports.clearInvoicingCatalogListView = exports.updateInvoicingProducts = exports.removeInvoicingProduct = exports.clearAllInvoicingProducts = exports.updateInvoicingPlans = exports.removeInvoicingPlan = exports.clearAllInvoicingPlans = exports.getInvoicingDunningCaseDetail = exports.getInvoicingDunningCaseById = exports.fetchInvoicingDunningCaseDetail = exports.clearInvoicingDunningCaseDetailView = exports.getInvoicingDunningCaseListView = exports.INVOICING_DUNNING_CASE_TABS = exports.INVOICING_DUNNING_CASE_COLUMNS = exports.ALL_INVOICING_DUNNING_CASE_TAB_IDS = exports.ALL_INVOICING_DUNNING_CASE_SORT_KEYS = exports.updateInvoicingDunningCaseFilters = exports.fetchInvoicingDunningCaseListPage = exports.fetchInvoicingDunningCaseList = exports.fetchInvoicingDunningCaseCounts = exports.clearInvoicingDunningCaseListView = exports.updateInvoicingDunningCases = exports.removeInvoicingDunningCase = exports.clearAllInvoicingDunningCases = exports.getInvoicingCouponDetail = exports.fetchInvoicingCouponDetail = exports.clearInvoicingCouponDetailView = exports.getInvoicingCouponById = exports.getInvoicingCouponListView = exports.getInvoicingCouponListNextCursor = exports.getInvoicingCouponListItems = exports.getInvoicingCouponListHasMore = exports.getInvoicingCouponListFilters = void 0;
84
+ exports.isStripeConnectedFromSettings = exports.getInvoicingStripeConnectState = exports.getInvoicingSettingsSaveState = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = exports.updateInvoicingSettings = exports.saveInvoicingSettings = exports.resetSaveInvoicingSettings = exports.fetchInvoicingSettings = void 0;
85
85
  const allowedValue_1 = require("./commonStateTypes/allowedValue");
86
86
  Object.defineProperty(exports, "isAllowedValueWithCode", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithCode; } });
87
87
  Object.defineProperty(exports, "isAllowedValueWithID", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithID; } });
@@ -2670,6 +2670,7 @@ Object.defineProperty(exports, "submitInvoicingCustomerFormFailure", { enumerabl
2670
2670
  Object.defineProperty(exports, "submitInvoicingCustomerFormSuccess", { enumerable: true, get: function () { return editInvoicingCustomerDetailViewReducer_1.submitInvoicingCustomerFormSuccess; } });
2671
2671
  Object.defineProperty(exports, "updateInvoicingCustomerFormDraft", { enumerable: true, get: function () { return editInvoicingCustomerDetailViewReducer_1.updateInvoicingCustomerFormDraft; } });
2672
2672
  var invoicingCustomerFormConfig_1 = require("./view/invoicing/editInvoicingCustomerDetailView/invoicingCustomerFormConfig");
2673
+ Object.defineProperty(exports, "INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE", { enumerable: true, get: function () { return invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE; } });
2673
2674
  Object.defineProperty(exports, "INVOICING_CUSTOMER_TYPE_VALUES", { enumerable: true, get: function () { return invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_TYPE_VALUES; } });
2674
2675
  Object.defineProperty(exports, "INVOICING_NET_TERM_DAY_VALUES", { enumerable: true, get: function () { return invoicingCustomerFormConfig_1.INVOICING_NET_TERM_DAY_VALUES; } });
2675
2676
  Object.defineProperty(exports, "INVOICING_TAXABILITY_VALUES", { enumerable: true, get: function () { return invoicingCustomerFormConfig_1.INVOICING_TAXABILITY_VALUES; } });
@@ -2,7 +2,7 @@ import { FetchStateAndError, ID } from '../../commonStateTypes/common';
2
2
  import { Address } from '../../entity/address/addressState';
3
3
  import { OfficerType } from '../companyView/types/companyPassport/companyUsersLocalData';
4
4
  export type AddressUpdatableInfo = Omit<Address, 'updateTime' | 'createTime' | 'addressId'>;
5
- export type AddressType = 'company_address' | 'company_registered_address' | `officer_${OfficerType}_address` | 'vendor_address' | 'user_address' | `credit_custom_shipping_${ID}_address` | `debit_custom_shipping_${ID}_address` | `subscription_billing_address`;
5
+ export type AddressType = 'company_address' | 'company_registered_address' | `officer_${OfficerType}_address` | 'vendor_address' | 'user_address' | `credit_custom_shipping_${ID}_address` | `debit_custom_shipping_${ID}_address` | `subscription_billing_address` | `invoicing_customer_billing_address`;
6
6
  export interface NewAddressData {
7
7
  addressToCreate: AddressUpdatableInfo;
8
8
  addressType: AddressType;
@@ -1,10 +1,12 @@
1
1
  import { InvoicingCustomerPayload } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerPayload';
2
2
  import { ZeniAPIResponse } from '../../../responsePayload';
3
+ import { AddressUpdatableInfo } from '../../addressView/addressViewState';
3
4
  import { InvoicingCustomerFormLocalData } from './editInvoicingCustomerDetailViewState';
4
5
  export type SaveInvoicingCustomerResponse = ZeniAPIResponse<InvoicingCustomerPayload>;
5
6
  /**
6
- * Build the create/update customer request body from the form draft. Owns the
7
- * trimming and billing-address assembly that previously lived in
8
- * web-components, so the presentational form no longer shapes the API payload.
7
+ * Build the create/update customer request body from the form draft. The
8
+ * billing address is sent as an object (captured via the shared Address
9
+ * screen); the backend creates it and returns its id — same pattern as the
10
+ * vendor save flow.
9
11
  */
10
- export declare const localDataToSaveInvoicingCustomerPayload: (localData: InvoicingCustomerFormLocalData) => Record<string, unknown>;
12
+ export declare const localDataToSaveInvoicingCustomerPayload: (localData: InvoicingCustomerFormLocalData, billingAddress?: AddressUpdatableInfo) => Record<string, unknown>;
@@ -1,27 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.localDataToSaveInvoicingCustomerPayload = void 0;
4
+ const addressViewPayload_1 = require("../../addressView/addressViewPayload");
4
5
  const trimOrUndefined = (value) => value.trim() !== '' ? value.trim() : undefined;
5
6
  /**
6
- * Build the create/update customer request body from the form draft. Owns the
7
- * trimming and billing-address assembly that previously lived in
8
- * web-components, so the presentational form no longer shapes the API payload.
7
+ * Build the create/update customer request body from the form draft. The
8
+ * billing address is sent as an object (captured via the shared Address
9
+ * screen); the backend creates it and returns its id — same pattern as the
10
+ * vendor save flow.
9
11
  */
10
- const localDataToSaveInvoicingCustomerPayload = (localData) => {
12
+ const localDataToSaveInvoicingCustomerPayload = (localData, billingAddress) => {
11
13
  const firstName = trimOrUndefined(localData.firstName);
12
14
  const lastName = trimOrUndefined(localData.lastName);
13
15
  const company = trimOrUndefined(localData.company);
14
16
  const netTerm = localData.netTermDays.trim();
15
- const addressFields = {
16
- city: trimOrUndefined(localData.billingCity),
17
- country: trimOrUndefined(localData.billingCountry),
18
- line1: trimOrUndefined(localData.billingLine1),
19
- line2: trimOrUndefined(localData.billingLine2),
20
- phone: trimOrUndefined(localData.billingPhone),
21
- state_code: trimOrUndefined(localData.billingState),
22
- zip: trimOrUndefined(localData.billingZip),
23
- };
24
- const hasAddress = Object.values(addressFields).some((part) => part != null);
25
17
  return {
26
18
  auto_collection: localData.autoCollection ? 'on' : 'off',
27
19
  company,
@@ -35,16 +27,8 @@ const localDataToSaveInvoicingCustomerPayload = (localData) => {
35
27
  taxability: localData.taxability,
36
28
  vat_number: trimOrUndefined(localData.vatNumber),
37
29
  ...(netTerm !== '' ? { net_term_days: Number(netTerm) } : {}),
38
- ...(hasAddress
39
- ? {
40
- billing_address: {
41
- ...addressFields,
42
- company,
43
- first_name: firstName,
44
- last_name: lastName,
45
- validation_status: 'not_validated',
46
- },
47
- }
30
+ ...(billingAddress != null
31
+ ? { billing_address: (0, addressViewPayload_1.toAddressUpdatableInfoPayload)(billingAddress) }
48
32
  : {}),
49
33
  };
50
34
  };
@@ -8,6 +8,8 @@ export interface InvoicingCustomerFormView extends SelectorView {
8
8
  mode: 'create' | 'edit';
9
9
  netTermDayValues: string[];
10
10
  taxabilityValues: string[];
11
+ billingAddressId?: ID;
12
+ billingAddressLabel?: string;
11
13
  savedCustomerId?: ID;
12
14
  }
13
15
  /**
@@ -2,7 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInvoicingCustomerFormView = void 0;
4
4
  const invoicingCustomerSelector_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
5
+ const addressViewSelector_1 = require("../../addressView/addressViewSelector");
5
6
  const invoicingCustomerFormConfig_1 = require("./invoicingCustomerFormConfig");
7
+ const formatInvoicingBillingAddress = (address) => [
8
+ address.line1,
9
+ address.line2,
10
+ address.city,
11
+ `${address.state_code ?? ''} ${address.zip ?? ''}`.trim(),
12
+ address.country,
13
+ ]
14
+ .filter((part) => part != null && part !== '')
15
+ .join(', ');
6
16
  /**
7
17
  * Bundled view for the customer create/edit form. Exposes the draft `localData`
8
18
  * (seeded from the existing customer entity in edit mode until the user edits),
@@ -13,16 +23,30 @@ const invoicingCustomerFormConfig_1 = require("./invoicingCustomerFormConfig");
13
23
  const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
14
24
  const { editDraftById, error, fetchState, newCustomerDraft, savedCustomerId } = state.editInvoicingCustomerDetailViewState;
15
25
  const mode = invoicingCustomerID != null ? 'edit' : 'create';
26
+ const customer = invoicingCustomerID != null
27
+ ? (0, invoicingCustomerSelector_1.getInvoicingCustomerById)(state.invoicingCustomerState, invoicingCustomerID)
28
+ : undefined;
16
29
  const localData = invoicingCustomerID != null
17
30
  ? (editDraftById[invoicingCustomerID] ??
18
- (0, invoicingCustomerFormConfig_1.entityToInvoicingCustomerFormLocalData)((0, invoicingCustomerSelector_1.getInvoicingCustomerById)(state.invoicingCustomerState, invoicingCustomerID)))
31
+ (0, invoicingCustomerFormConfig_1.entityToInvoicingCustomerFormLocalData)(customer))
19
32
  : newCustomerDraft;
33
+ // Billing address is captured via the shared Address screen: prefer a
34
+ // freshly-saved address, else the customer's existing one.
35
+ const newAddress = state.addressViewState.newAddressState?.[invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE];
36
+ const billingAddressId = newAddress?.newAddressId ?? customer?.billingAddressId;
37
+ const billingAddressLabel = newAddress?.addressToCreate != null
38
+ ? (0, addressViewSelector_1.getFormattedAddress)(newAddress.addressToCreate)
39
+ : customer?.billingAddress != null
40
+ ? formatInvoicingBillingAddress(customer.billingAddress)
41
+ : undefined;
20
42
  return {
21
43
  customerTypeValues: [...invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_TYPE_VALUES],
22
44
  localData,
23
45
  mode,
24
46
  netTermDayValues: [...invoicingCustomerFormConfig_1.INVOICING_NET_TERM_DAY_VALUES],
25
47
  taxabilityValues: [...invoicingCustomerFormConfig_1.INVOICING_TAXABILITY_VALUES],
48
+ billingAddressId,
49
+ billingAddressLabel,
26
50
  savedCustomerId,
27
51
  fetchState,
28
52
  error,
@@ -1,20 +1,13 @@
1
1
  import { FetchedState, ID } from '../../../commonStateTypes/common';
2
2
  /**
3
3
  * Draft form state for the create/edit customer form. Held in CES so the form
4
- * flows its data from here (mirrors the bill-pay / reimbursement pattern).
5
- * Address is kept canonical (`billingLine1`/`billingLine2`); the presentational
6
- * form is free to split street/suite in its own UI and collapse into these on
7
- * submit.
4
+ * flows its data from here (mirrors the bill-pay / reimbursement pattern). The
5
+ * billing address is NOT part of this draft — it is captured via the shared
6
+ * Address screen (`addressView`) and threaded into the save payload as
7
+ * `billing_address_id` by the save epic.
8
8
  */
9
9
  export interface InvoicingCustomerFormLocalData {
10
10
  autoCollection: boolean;
11
- billingCity: string;
12
- billingCountry: string;
13
- billingLine1: string;
14
- billingLine2: string;
15
- billingPhone: string;
16
- billingState: string;
17
- billingZip: string;
18
11
  company: string;
19
12
  customerType: string;
20
13
  email: string;
@@ -1,5 +1,7 @@
1
1
  import { InvoicingCustomer } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerState';
2
2
  import { InvoicingCustomerFormLocalData } from './editInvoicingCustomerDetailViewState';
3
+ /** `AddressType` key used when the customer form opens the shared Address screen. */
4
+ export declare const INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE: "invoicing_customer_billing_address";
3
5
  /**
4
6
  * Canonical option value sets for the customer form. CES owns the values;
5
7
  * web-components maps each value to a localized label (same split as the
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.entityToInvoicingCustomerFormLocalData = exports.initialInvoicingCustomerFormLocalData = exports.INVOICING_NET_TERM_DAY_VALUES = exports.INVOICING_TAXABILITY_VALUES = exports.INVOICING_CUSTOMER_TYPE_VALUES = void 0;
3
+ exports.entityToInvoicingCustomerFormLocalData = exports.initialInvoicingCustomerFormLocalData = exports.INVOICING_NET_TERM_DAY_VALUES = exports.INVOICING_TAXABILITY_VALUES = exports.INVOICING_CUSTOMER_TYPE_VALUES = exports.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE = void 0;
4
+ /** `AddressType` key used when the customer form opens the shared Address screen. */
5
+ exports.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE = 'invoicing_customer_billing_address';
4
6
  /**
5
7
  * Canonical option value sets for the customer form. CES owns the values;
6
8
  * web-components maps each value to a localized label (same split as the
@@ -20,13 +22,6 @@ exports.INVOICING_NET_TERM_DAY_VALUES = [
20
22
  ];
21
23
  exports.initialInvoicingCustomerFormLocalData = {
22
24
  autoCollection: true,
23
- billingCity: '',
24
- billingCountry: '',
25
- billingLine1: '',
26
- billingLine2: '',
27
- billingPhone: '',
28
- billingState: '',
29
- billingZip: '',
30
25
  company: '',
31
26
  customerType: 'business',
32
27
  email: '',
@@ -44,16 +39,8 @@ const entityToInvoicingCustomerFormLocalData = (customer) => {
44
39
  if (customer == null) {
45
40
  return { ...exports.initialInvoicingCustomerFormLocalData };
46
41
  }
47
- const address = customer.billingAddress;
48
42
  return {
49
43
  autoCollection: (customer.autoCollection ?? 'on') === 'on',
50
- billingCity: address?.city ?? '',
51
- billingCountry: address?.country ?? '',
52
- billingLine1: address?.line1 ?? '',
53
- billingLine2: address?.line2 ?? '',
54
- billingPhone: address?.phone ?? '',
55
- billingState: address?.state_code ?? '',
56
- billingZip: address?.zip ?? '',
57
44
  company: customer.company ?? '',
58
45
  customerType: customer.customerType ?? 'business',
59
46
  email: customer.email ?? '',
@@ -6,13 +6,19 @@ const operators_1 = require("rxjs/operators");
6
6
  const invoicingCustomerReducer_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerReducer");
7
7
  const responsePayload_1 = require("../../../responsePayload");
8
8
  const editInvoicingCustomerDetailViewPayload_1 = require("./editInvoicingCustomerDetailViewPayload");
9
+ const invoicingCustomerFormConfig_1 = require("./invoicingCustomerFormConfig");
9
10
  const editInvoicingCustomerDetailViewReducer_1 = require("./editInvoicingCustomerDetailViewReducer");
10
11
  const saveInvoicingCustomerEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(editInvoicingCustomerDetailViewReducer_1.submitInvoicingCustomerForm.match), (0, operators_1.mergeMap)((action) => {
11
12
  const { id } = action.payload;
12
- const viewState = state$.value.editInvoicingCustomerDetailViewState;
13
+ const rootState = state$.value;
14
+ const viewState = rootState.editInvoicingCustomerDetailViewState;
13
15
  const localData = (id != null ? viewState.editDraftById[id] : viewState.newCustomerDraft) ??
14
16
  viewState.newCustomerDraft;
15
- const data = (0, editInvoicingCustomerDetailViewPayload_1.localDataToSaveInvoicingCustomerPayload)(localData);
17
+ // Billing address captured via the shared Address screen is sent as an
18
+ // object in the payload; the backend creates it and returns its id
19
+ // (same pattern as the vendor save flow).
20
+ const billingAddress = rootState.addressViewState.newAddressState?.[invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE]?.addressToCreate;
21
+ const data = (0, editInvoicingCustomerDetailViewPayload_1.localDataToSaveInvoicingCustomerPayload)(localData, billingAddress);
16
22
  const baseUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;
17
23
  const request$ = id != null
18
24
  ? zeniAPI.putAndGetJSON(`${baseUrl}/customers/${encodeURIComponent(id)}`, { ...data })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.41-betaAK0",
3
+ "version": "5.1.41-betaAK2",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",