@zeniai/client-epic-state 5.1.50-betaAK1 → 5.1.50-betaAK3

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 (73) hide show
  1. package/lib/entity/invoicing/invoice/invoicePayload.d.ts +10 -3
  2. package/lib/entity/invoicing/invoice/invoicePayload.js +16 -3
  3. package/lib/entity/invoicing/invoice/invoiceState.d.ts +3 -3
  4. package/lib/entity/invoicing/invoicingCommonPayload.d.ts +2 -15
  5. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerPayload.d.ts +9 -2
  6. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerPayload.js +10 -2
  7. package/lib/entity/invoicing/invoicingCustomer/invoicingCustomerState.d.ts +0 -2
  8. package/lib/entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload.d.ts +8 -2
  9. package/lib/entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload.js +13 -2
  10. package/lib/entity/invoicing/invoicingSubscription/invoicingSubscriptionState.d.ts +1 -2
  11. package/lib/esm/entity/invoicing/invoice/invoicePayload.js +14 -2
  12. package/lib/esm/entity/invoicing/invoicingCustomer/invoicingCustomerPayload.js +8 -1
  13. package/lib/esm/entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload.js +11 -1
  14. package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +3 -0
  15. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +3 -0
  16. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +3 -4
  17. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +2 -2
  18. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +9 -4
  19. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +0 -26
  20. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +3 -0
  21. package/lib/esm/view/invoicing/invoiceAction/invoiceActionEpic.js +4 -0
  22. package/lib/esm/view/invoicing/invoiceDetail/fetchInvoiceDetailEpic.js +3 -0
  23. package/lib/esm/view/invoicing/invoiceDetail/invoiceDetailSelector.js +9 -1
  24. package/lib/esm/view/invoicing/invoiceList/fetchInvoiceListEpic.js +3 -0
  25. package/lib/esm/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailEpic.js +3 -0
  26. package/lib/esm/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +3 -0
  27. package/lib/esm/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewEpics.js +3 -0
  28. package/lib/esm/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +3 -0
  29. package/lib/esm/view/invoicing/settingsView/invoicingBrandingFormConfig.js +19 -29
  30. package/lib/esm/view/invoicing/settingsView/invoicingBrandingFormEpics.js +45 -22
  31. package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +6 -1
  32. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +2 -2
  33. package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +3 -0
  34. package/lib/index.d.ts +1 -1
  35. package/lib/view/invoicing/createInvoice/createInvoiceEpic.d.ts +2 -1
  36. package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +3 -0
  37. package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.d.ts +2 -1
  38. package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +3 -0
  39. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewPayload.js +2 -3
  40. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +2 -2
  41. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.d.ts +2 -1
  42. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +8 -3
  43. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.d.ts +0 -13
  44. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/invoicingSubscriptionFormConfig.js +1 -29
  45. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts +2 -1
  46. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +3 -0
  47. package/lib/view/invoicing/invoiceAction/invoiceActionEpic.d.ts +2 -1
  48. package/lib/view/invoicing/invoiceAction/invoiceActionEpic.js +4 -0
  49. package/lib/view/invoicing/invoiceDetail/fetchInvoiceDetailEpic.d.ts +2 -1
  50. package/lib/view/invoicing/invoiceDetail/fetchInvoiceDetailEpic.js +3 -0
  51. package/lib/view/invoicing/invoiceDetail/invoiceDetailSelector.d.ts +6 -1
  52. package/lib/view/invoicing/invoiceDetail/invoiceDetailSelector.js +9 -1
  53. package/lib/view/invoicing/invoiceList/fetchInvoiceListEpic.d.ts +2 -1
  54. package/lib/view/invoicing/invoiceList/fetchInvoiceListEpic.js +3 -0
  55. package/lib/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailEpic.d.ts +2 -1
  56. package/lib/view/invoicing/invoicingCustomerDetailView/fetchInvoicingCustomerDetailEpic.js +3 -0
  57. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.d.ts +2 -1
  58. package/lib/view/invoicing/invoicingCustomerListView/epics/fetchInvoicingCustomerListEpic.js +3 -0
  59. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewEpics.d.ts +2 -1
  60. package/lib/view/invoicing/invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewEpics.js +3 -0
  61. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.d.ts +2 -1
  62. package/lib/view/invoicing/invoicingSubscriptionListView/epics/fetchInvoicingSubscriptionListEpic.js +3 -0
  63. package/lib/view/invoicing/settingsView/invoicingBrandingFormConfig.d.ts +5 -9
  64. package/lib/view/invoicing/settingsView/invoicingBrandingFormConfig.js +21 -32
  65. package/lib/view/invoicing/settingsView/invoicingBrandingFormEpics.d.ts +13 -10
  66. package/lib/view/invoicing/settingsView/invoicingBrandingFormEpics.js +41 -18
  67. package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +2 -1
  68. package/lib/view/invoicing/settingsView/settingsViewEpics.js +6 -1
  69. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +1 -1
  70. package/lib/view/invoicing/settingsView/settingsViewSelector.js +2 -2
  71. package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.d.ts +2 -1
  72. package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +3 -0
  73. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
- import { InvoicingBillingAddressPayload, InvoicingPriceType } from '../invoicingCommonPayload';
1
+ import { AddressPayload } from '../../address/addressPayload';
2
+ import { InvoicingPriceType } from '../invoicingCommonPayload';
2
3
  import { InvoicingInvoice, InvoicingInvoiceKPIs } from './invoiceState';
3
4
  export type InvoicingInvoiceStatus = 'paid' | 'partially_paid' | 'posted' | 'payment_due' | 'not_paid' | 'voided' | 'pending' | 'draft';
4
5
  export interface InvoicingLineItemPayload {
@@ -55,7 +56,7 @@ export interface InvoicingInvoicePayload {
55
56
  amount_due?: number;
56
57
  amount_paid?: number;
57
58
  amount_to_collect?: number;
58
- billing_address?: InvoicingBillingAddressPayload;
59
+ billing_address?: AddressPayload | null;
59
60
  created_at?: string;
60
61
  credits_applied?: number;
61
62
  currency_code?: string;
@@ -82,7 +83,7 @@ export interface InvoicingInvoicePayload {
82
83
  price_type?: InvoicingPriceType;
83
84
  recurring?: boolean;
84
85
  round_off_amount?: number;
85
- shipping_address?: InvoicingBillingAddressPayload;
86
+ shipping_address?: AddressPayload | null;
86
87
  sub_total?: number;
87
88
  subscription_id?: string;
88
89
  subscription_name?: string;
@@ -96,5 +97,11 @@ export interface InvoicingInvoiceKPIsPayload {
96
97
  pending_total: number;
97
98
  total_invoiced: number;
98
99
  }
100
+ /**
101
+ * Collect the embedded billing + shipping addresses from invoice payloads so they
102
+ * can be pushed into the shared address store (`updateAddresses`), while the
103
+ * invoice entity keeps only the address ids — mirrors the vendor flow.
104
+ */
105
+ export declare const extractInvoicingInvoiceAddresses: (payloads: InvoicingInvoicePayload[]) => AddressPayload[];
99
106
  export declare const mapInvoicingInvoicePayloadToState: (payload: InvoicingInvoicePayload) => InvoicingInvoice;
100
107
  export declare const mapInvoicingInvoiceKPIsPayloadToState: (payload: InvoicingInvoiceKPIsPayload) => InvoicingInvoiceKPIs;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapInvoicingInvoiceKPIsPayloadToState = exports.mapInvoicingInvoicePayloadToState = void 0;
3
+ exports.mapInvoicingInvoiceKPIsPayloadToState = exports.mapInvoicingInvoicePayloadToState = exports.extractInvoicingInvoiceAddresses = void 0;
4
4
  const amount_1 = require("../../../commonStateTypes/amount");
5
5
  const zeniDayJS_1 = require("../../../zeniDayJS");
6
6
  // ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
@@ -57,6 +57,15 @@ const mapInvoiceNote = (payload) => ({
57
57
  entityID: payload.entity_id,
58
58
  entityType: payload.entity_type,
59
59
  });
60
+ /**
61
+ * Collect the embedded billing + shipping addresses from invoice payloads so they
62
+ * can be pushed into the shared address store (`updateAddresses`), while the
63
+ * invoice entity keeps only the address ids — mirrors the vendor flow.
64
+ */
65
+ const extractInvoicingInvoiceAddresses = (payloads) => payloads
66
+ .flatMap((payload) => [payload.billing_address, payload.shipping_address])
67
+ .filter((address) => address != null);
68
+ exports.extractInvoicingInvoiceAddresses = extractInvoicingInvoiceAddresses;
60
69
  const mapInvoicingInvoicePayloadToState = (payload) => {
61
70
  const currencyCode = payload.currency_code ?? DEFAULT_CURRENCY_CODE;
62
71
  const currencySymbol = DEFAULT_CURRENCY_SYMBOL;
@@ -76,7 +85,9 @@ const mapInvoicingInvoicePayloadToState = (payload) => {
76
85
  amountToCollect: payload.amount_to_collect != null
77
86
  ? toAmt(payload.amount_to_collect)
78
87
  : undefined,
79
- billingAddress: payload.billing_address,
88
+ billingAddressId: payload.billing_address != null
89
+ ? payload.billing_address.address_id
90
+ : undefined,
80
91
  createdAt: payload.created_at != null ? (0, zeniDayJS_1.date)(payload.created_at) : undefined,
81
92
  creditsApplied: payload.credits_applied != null
82
93
  ? toAmt(payload.credits_applied)
@@ -107,7 +118,9 @@ const mapInvoicingInvoicePayloadToState = (payload) => {
107
118
  roundOffAmount: payload.round_off_amount != null
108
119
  ? toAmt(payload.round_off_amount)
109
120
  : undefined,
110
- shippingAddress: payload.shipping_address,
121
+ shippingAddressId: payload.shipping_address != null
122
+ ? payload.shipping_address.address_id
123
+ : undefined,
111
124
  subscriptionID: payload.subscription_id,
112
125
  subscriptionName: payload.subscription_name,
113
126
  subTotal: payload.sub_total != null ? toAmt(payload.sub_total) : undefined,
@@ -1,7 +1,7 @@
1
1
  import { Amount } from '../../../commonStateTypes/amount';
2
2
  import { ID } from '../../../commonStateTypes/common';
3
3
  import { ZeniDate } from '../../../zeniDayJS';
4
- import { InvoicingBillingAddressPayload, InvoicingPriceType } from '../invoicingCommonPayload';
4
+ import { InvoicingPriceType } from '../invoicingCommonPayload';
5
5
  import { InvoicingInvoiceStatus } from './invoicePayload';
6
6
  export interface InvoicingLineItem {
7
7
  amount: Amount;
@@ -57,7 +57,7 @@ export interface InvoicingInvoice {
57
57
  amountDue?: Amount;
58
58
  amountPaid?: Amount;
59
59
  amountToCollect?: Amount;
60
- billingAddress?: InvoicingBillingAddressPayload;
60
+ billingAddressId?: ID;
61
61
  createdAt?: ZeniDate;
62
62
  creditsApplied?: Amount;
63
63
  currencyCode?: string;
@@ -84,7 +84,7 @@ export interface InvoicingInvoice {
84
84
  priceType?: InvoicingPriceType;
85
85
  recurring?: boolean;
86
86
  roundOffAmount?: Amount;
87
- shippingAddress?: InvoicingBillingAddressPayload;
87
+ shippingAddressId?: ID;
88
88
  subscriptionID?: ID;
89
89
  subscriptionName?: string;
90
90
  subTotal?: Amount;
@@ -1,17 +1,4 @@
1
- export interface InvoicingBillingAddressPayload {
2
- city?: string;
3
- company?: string;
4
- country?: string;
5
- email?: string;
6
- first_name?: string;
7
- last_name?: string;
8
- line1?: string;
9
- line2?: string;
10
- phone?: string;
11
- state_code?: string;
12
- validation_status?: 'not_validated' | 'valid' | 'partially_valid' | 'invalid';
13
- zip?: string;
14
- }
1
+ import { AddressPayload } from '../address/addressPayload';
15
2
  export type InvoicingPriceType = 'tax_exclusive' | 'tax_inclusive';
16
3
  /**
17
4
  * A single select-field option (label + typed value) owned by CES so the value
@@ -33,7 +20,7 @@ export interface InvoicingPaginatedList<T> {
33
20
  }
34
21
  export interface InvoicingSettingsPayload {
35
22
  accent_color?: string;
36
- address?: string;
23
+ address?: AddressPayload | null;
37
24
  address_enabled?: boolean;
38
25
  auto_collection?: 'on' | 'off';
39
26
  chargebee_connected?: boolean;
@@ -1,11 +1,12 @@
1
- import { InvoicingBillingAddressPayload, InvoicingListCounts } from '../invoicingCommonPayload';
1
+ import { AddressPayload } from '../../address/addressPayload';
2
+ import { InvoicingListCounts } from '../invoicingCommonPayload';
2
3
  import { InvoicingSubscriptionPayload } from '../invoicingSubscription/invoicingSubscriptionPayload';
3
4
  import { InvoicingCustomer } from './invoicingCustomerState';
4
5
  export interface InvoicingCustomerPayload {
5
6
  id: string;
6
7
  arr?: number;
7
8
  auto_collection?: 'on' | 'off';
8
- billing_address?: InvoicingBillingAddressPayload;
9
+ billing_address?: AddressPayload | null;
9
10
  billing_address_id?: string;
10
11
  card_status?: 'no_card' | 'valid' | 'expiring' | 'expired';
11
12
  company?: string;
@@ -52,4 +53,10 @@ export interface InvoicingCustomerCounts extends InvoicingListCounts {
52
53
  total: number;
53
54
  trial: number;
54
55
  }
56
+ /**
57
+ * Collect the embedded billing addresses from customer payloads so they can be
58
+ * pushed into the shared address store (`updateAddresses`), while the customer
59
+ * entity keeps only `billingAddressId` — mirrors the vendor flow.
60
+ */
61
+ export declare const extractInvoicingCustomerAddresses: (payloads: InvoicingCustomerPayload[]) => AddressPayload[];
55
62
  export declare const mapInvoicingCustomerPayloadToState: (payload: InvoicingCustomerPayload) => InvoicingCustomer;
@@ -1,11 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapInvoicingCustomerPayloadToState = void 0;
3
+ exports.mapInvoicingCustomerPayloadToState = exports.extractInvoicingCustomerAddresses = void 0;
4
4
  const amount_1 = require("../../../commonStateTypes/amount");
5
5
  const currencyHelper_1 = require("../../../commonStateTypes/currencyHelper");
6
6
  const zeniDayJS_1 = require("../../../zeniDayJS");
7
7
  const invoicingSubscriptionPayload_1 = require("../invoicingSubscription/invoicingSubscriptionPayload");
8
8
  // ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
9
+ /**
10
+ * Collect the embedded billing addresses from customer payloads so they can be
11
+ * pushed into the shared address store (`updateAddresses`), while the customer
12
+ * entity keeps only `billingAddressId` — mirrors the vendor flow.
13
+ */
14
+ const extractInvoicingCustomerAddresses = (payloads) => payloads
15
+ .map((payload) => payload.billing_address)
16
+ .filter((address) => address != null);
17
+ exports.extractInvoicingCustomerAddresses = extractInvoicingCustomerAddresses;
9
18
  const mapInvoicingCustomerPayloadToState = (payload) => {
10
19
  const currencyCode = payload.preferred_currency_code ?? currencyHelper_1.defaultCustomerCurrency.currencyCode;
11
20
  const currencySymbol = payload.preferred_currency_symbol ?? currencyHelper_1.defaultCustomerCurrency.currencySymbol;
@@ -15,7 +24,6 @@ const mapInvoicingCustomerPayloadToState = (payload) => {
15
24
  ? (0, amount_1.toAmount)(payload.arr, currencyCode, currencySymbol)
16
25
  : undefined,
17
26
  autoCollection: payload.auto_collection,
18
- billingAddress: payload.billing_address,
19
27
  billingAddressId: payload.billing_address_id,
20
28
  cardStatus: payload.card_status,
21
29
  company: payload.company,
@@ -1,13 +1,11 @@
1
1
  import { Amount } from '../../../commonStateTypes/amount';
2
2
  import { ID } from '../../../commonStateTypes/common';
3
3
  import { ZeniDate } from '../../../zeniDayJS';
4
- import { InvoicingBillingAddressPayload } from '../invoicingCommonPayload';
5
4
  import { InvoicingSubscription } from '../invoicingSubscription/invoicingSubscriptionState';
6
5
  export interface InvoicingCustomer {
7
6
  id: ID;
8
7
  arr?: Amount;
9
8
  autoCollection?: 'on' | 'off';
10
- billingAddress?: InvoicingBillingAddressPayload;
11
9
  billingAddressId?: ID;
12
10
  cardStatus?: 'no_card' | 'valid' | 'expiring' | 'expired';
13
11
  company?: string;
@@ -1,4 +1,4 @@
1
- import { InvoicingBillingAddressPayload } from '../invoicingCommonPayload';
1
+ import { AddressPayload } from '../../address/addressPayload';
2
2
  import { InvoicingContractTerm, InvoicingSubscription, InvoicingSubscriptionCoupon, InvoicingSubscriptionItem } from './invoicingSubscriptionState';
3
3
  export type InvoicingSubscriptionStatus = 'active' | 'in_trial' | 'future' | 'non_renewing' | 'paused' | 'cancelled';
4
4
  export type InvoicingBillingPeriodUnit = 'day' | 'week' | 'month' | 'year';
@@ -62,7 +62,7 @@ export interface InvoicingSubscriptionPayload {
62
62
  remaining_billing_cycles?: number;
63
63
  resume_date?: string;
64
64
  setup_fee?: number;
65
- shipping_address?: InvoicingBillingAddressPayload;
65
+ shipping_address?: AddressPayload | null;
66
66
  started_at?: string;
67
67
  subscription_items?: InvoicingSubscriptionItemPayload[];
68
68
  total_dues?: number;
@@ -73,4 +73,10 @@ export interface InvoicingSubscriptionPayload {
73
73
  export declare const mapInvoicingSubscriptionItemPayloadToState: (payload: InvoicingSubscriptionItemPayload, currencyCode: string, currencySymbol: string) => InvoicingSubscriptionItem;
74
74
  export declare const mapInvoicingSubscriptionCouponPayloadToState: (payload: InvoicingSubscriptionCouponPayload) => InvoicingSubscriptionCoupon;
75
75
  export declare const mapInvoicingContractTermPayloadToState: (payload: InvoicingContractTermPayload, currencyCode: string, currencySymbol: string) => InvoicingContractTerm;
76
+ /**
77
+ * Collect the embedded shipping addresses from subscription payloads so they can
78
+ * be pushed into the shared address store (via `updateAddresses`), while the
79
+ * subscription entity keeps only `shippingAddressId` — mirrors the vendor flow.
80
+ */
81
+ export declare const extractInvoicingSubscriptionAddresses: (payloads: InvoicingSubscriptionPayload[]) => AddressPayload[];
76
82
  export declare const mapInvoicingSubscriptionPayloadToState: (payload: InvoicingSubscriptionPayload) => InvoicingSubscription;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapInvoicingSubscriptionPayloadToState = exports.mapInvoicingContractTermPayloadToState = exports.mapInvoicingSubscriptionCouponPayloadToState = exports.mapInvoicingSubscriptionItemPayloadToState = void 0;
3
+ exports.mapInvoicingSubscriptionPayloadToState = exports.extractInvoicingSubscriptionAddresses = exports.mapInvoicingContractTermPayloadToState = exports.mapInvoicingSubscriptionCouponPayloadToState = exports.mapInvoicingSubscriptionItemPayloadToState = void 0;
4
4
  const amount_1 = require("../../../commonStateTypes/amount");
5
5
  const currencyHelper_1 = require("../../../commonStateTypes/currencyHelper");
6
6
  const zeniDayJS_1 = require("../../../zeniDayJS");
@@ -41,6 +41,15 @@ const mapInvoicingContractTermPayloadToState = (payload, currencyCode, currencyS
41
41
  : undefined,
42
42
  });
43
43
  exports.mapInvoicingContractTermPayloadToState = mapInvoicingContractTermPayloadToState;
44
+ /**
45
+ * Collect the embedded shipping addresses from subscription payloads so they can
46
+ * be pushed into the shared address store (via `updateAddresses`), while the
47
+ * subscription entity keeps only `shippingAddressId` — mirrors the vendor flow.
48
+ */
49
+ const extractInvoicingSubscriptionAddresses = (payloads) => payloads
50
+ .map((payload) => payload.shipping_address)
51
+ .filter((address) => address != null);
52
+ exports.extractInvoicingSubscriptionAddresses = extractInvoicingSubscriptionAddresses;
44
53
  const mapInvoicingSubscriptionPayloadToState = (payload) => {
45
54
  const currencyCode = payload.currency_code ?? currencyHelper_1.defaultCustomerCurrency.currencyCode;
46
55
  const currencySymbol = payload.currency_symbol ?? currencyHelper_1.defaultCustomerCurrency.currencySymbol;
@@ -90,7 +99,9 @@ const mapInvoicingSubscriptionPayloadToState = (payload) => {
90
99
  setupFee: payload.setup_fee != null
91
100
  ? (0, amount_1.toAmount)(payload.setup_fee, currencyCode, currencySymbol)
92
101
  : undefined,
93
- shippingAddress: payload.shipping_address,
102
+ shippingAddressId: payload.shipping_address != null
103
+ ? payload.shipping_address.address_id
104
+ : undefined,
94
105
  startedAt: payload.started_at != null ? (0, zeniDayJS_1.date)(payload.started_at) : undefined,
95
106
  subscriptionItems: payload.subscription_items?.map((item) => (0, exports.mapInvoicingSubscriptionItemPayloadToState)(item, currencyCode, currencySymbol)),
96
107
  totalDues: payload.total_dues != null
@@ -1,7 +1,6 @@
1
1
  import { Amount } from '../../../commonStateTypes/amount';
2
2
  import { ID } from '../../../commonStateTypes/common';
3
3
  import { ZeniDate } from '../../../zeniDayJS';
4
- import { InvoicingBillingAddressPayload } from '../invoicingCommonPayload';
5
4
  import { InvoicingBillingPeriodUnit, InvoicingSubscriptionStatus } from './invoicingSubscriptionPayload';
6
5
  export interface InvoicingSubscriptionItem {
7
6
  amount?: Amount;
@@ -62,7 +61,7 @@ export interface InvoicingSubscription {
62
61
  remainingBillingCycles?: number;
63
62
  resumeDate?: ZeniDate;
64
63
  setupFee?: Amount;
65
- shippingAddress?: InvoicingBillingAddressPayload;
64
+ shippingAddressId?: ID;
66
65
  startedAt?: ZeniDate;
67
66
  subscriptionItems?: InvoicingSubscriptionItem[];
68
67
  totalDues?: Amount;
@@ -54,6 +54,14 @@ const mapInvoiceNote = (payload) => ({
54
54
  entityID: payload.entity_id,
55
55
  entityType: payload.entity_type,
56
56
  });
57
+ /**
58
+ * Collect the embedded billing + shipping addresses from invoice payloads so they
59
+ * can be pushed into the shared address store (`updateAddresses`), while the
60
+ * invoice entity keeps only the address ids — mirrors the vendor flow.
61
+ */
62
+ export const extractInvoicingInvoiceAddresses = (payloads) => payloads
63
+ .flatMap((payload) => [payload.billing_address, payload.shipping_address])
64
+ .filter((address) => address != null);
57
65
  export const mapInvoicingInvoicePayloadToState = (payload) => {
58
66
  const currencyCode = payload.currency_code ?? DEFAULT_CURRENCY_CODE;
59
67
  const currencySymbol = DEFAULT_CURRENCY_SYMBOL;
@@ -73,7 +81,9 @@ export const mapInvoicingInvoicePayloadToState = (payload) => {
73
81
  amountToCollect: payload.amount_to_collect != null
74
82
  ? toAmt(payload.amount_to_collect)
75
83
  : undefined,
76
- billingAddress: payload.billing_address,
84
+ billingAddressId: payload.billing_address != null
85
+ ? payload.billing_address.address_id
86
+ : undefined,
77
87
  createdAt: payload.created_at != null ? date(payload.created_at) : undefined,
78
88
  creditsApplied: payload.credits_applied != null
79
89
  ? toAmt(payload.credits_applied)
@@ -104,7 +114,9 @@ export const mapInvoicingInvoicePayloadToState = (payload) => {
104
114
  roundOffAmount: payload.round_off_amount != null
105
115
  ? toAmt(payload.round_off_amount)
106
116
  : undefined,
107
- shippingAddress: payload.shipping_address,
117
+ shippingAddressId: payload.shipping_address != null
118
+ ? payload.shipping_address.address_id
119
+ : undefined,
108
120
  subscriptionID: payload.subscription_id,
109
121
  subscriptionName: payload.subscription_name,
110
122
  subTotal: payload.sub_total != null ? toAmt(payload.sub_total) : undefined,
@@ -3,6 +3,14 @@ import { defaultCustomerCurrency } from '../../../commonStateTypes/currencyHelpe
3
3
  import { date } from '../../../zeniDayJS';
4
4
  import { mapInvoicingSubscriptionPayloadToState, } from '../invoicingSubscription/invoicingSubscriptionPayload';
5
5
  // ── Payload → State mappers (snake_case wire shape → camelCase domain shape) ──
6
+ /**
7
+ * Collect the embedded billing addresses from customer payloads so they can be
8
+ * pushed into the shared address store (`updateAddresses`), while the customer
9
+ * entity keeps only `billingAddressId` — mirrors the vendor flow.
10
+ */
11
+ export const extractInvoicingCustomerAddresses = (payloads) => payloads
12
+ .map((payload) => payload.billing_address)
13
+ .filter((address) => address != null);
6
14
  export const mapInvoicingCustomerPayloadToState = (payload) => {
7
15
  const currencyCode = payload.preferred_currency_code ?? defaultCustomerCurrency.currencyCode;
8
16
  const currencySymbol = payload.preferred_currency_symbol ?? defaultCustomerCurrency.currencySymbol;
@@ -12,7 +20,6 @@ export const mapInvoicingCustomerPayloadToState = (payload) => {
12
20
  ? toAmount(payload.arr, currencyCode, currencySymbol)
13
21
  : undefined,
14
22
  autoCollection: payload.auto_collection,
15
- billingAddress: payload.billing_address,
16
23
  billingAddressId: payload.billing_address_id,
17
24
  cardStatus: payload.card_status,
18
25
  company: payload.company,
@@ -35,6 +35,14 @@ export const mapInvoicingContractTermPayloadToState = (payload, currencyCode, cu
35
35
  ? toAmount(payload.total_contract_value, currencyCode, currencySymbol)
36
36
  : undefined,
37
37
  });
38
+ /**
39
+ * Collect the embedded shipping addresses from subscription payloads so they can
40
+ * be pushed into the shared address store (via `updateAddresses`), while the
41
+ * subscription entity keeps only `shippingAddressId` — mirrors the vendor flow.
42
+ */
43
+ export const extractInvoicingSubscriptionAddresses = (payloads) => payloads
44
+ .map((payload) => payload.shipping_address)
45
+ .filter((address) => address != null);
38
46
  export const mapInvoicingSubscriptionPayloadToState = (payload) => {
39
47
  const currencyCode = payload.currency_code ?? defaultCustomerCurrency.currencyCode;
40
48
  const currencySymbol = payload.currency_symbol ?? defaultCustomerCurrency.currencySymbol;
@@ -84,7 +92,9 @@ export const mapInvoicingSubscriptionPayloadToState = (payload) => {
84
92
  setupFee: payload.setup_fee != null
85
93
  ? toAmount(payload.setup_fee, currencyCode, currencySymbol)
86
94
  : undefined,
87
- shippingAddress: payload.shipping_address,
95
+ shippingAddressId: payload.shipping_address != null
96
+ ? payload.shipping_address.address_id
97
+ : undefined,
88
98
  startedAt: payload.started_at != null ? date(payload.started_at) : undefined,
89
99
  subscriptionItems: payload.subscription_items?.map((item) => mapInvoicingSubscriptionItemPayloadToState(item, currencyCode, currencySymbol)),
90
100
  totalDues: payload.total_dues != null
@@ -1,5 +1,7 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { extractInvoicingInvoiceAddresses } from '../../../entity/invoicing/invoice/invoicePayload';
3
5
  import { updateInvoices } from '../../../entity/invoicing/invoice/invoiceReducer';
4
6
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
7
  import { createInvoice, createInvoiceFailure, createInvoiceSuccess, } from './createInvoiceReducer';
@@ -13,6 +15,7 @@ export const createInvoiceEpic = (actions$, _state$, zeniAPI) => actions$.pipe(f
13
15
  if (isSuccessResponse(response) && response.data != null) {
14
16
  return [
15
17
  updateInvoices([response.data], 'merge'),
18
+ updateAddresses(extractInvoicingInvoiceAddresses([response.data])),
16
19
  createInvoiceSuccess({ invoiceId: response.data.id }),
17
20
  ];
18
21
  }
@@ -1,5 +1,7 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { extractInvoicingCustomerAddresses } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerPayload';
3
5
  import { updateInvoicingCustomers } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerReducer';
4
6
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
7
  import { resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
@@ -25,6 +27,7 @@ export const saveInvoicingCustomerEpic = (actions$, state$, zeniAPI) => actions$
25
27
  if (isSuccessResponse(response) && response.data != null) {
26
28
  return [
27
29
  updateInvoicingCustomers([response.data], 'merge'),
30
+ updateAddresses(extractInvoicingCustomerAddresses([response.data])),
28
31
  submitInvoicingCustomerFormSuccess({
29
32
  customerId: response.data.id,
30
33
  }),
@@ -1,4 +1,5 @@
1
- import { addressUpdatableInfoToInvoicingShippingPayload, billingFrequencyToPeriod, } from './invoicingSubscriptionFormConfig';
1
+ import { toAddressUpdatableInfoPayload } from '../../addressView/addressViewPayload';
2
+ import { billingFrequencyToPeriod } from './invoicingSubscriptionFormConfig';
2
3
  /**
3
4
  * Build the create/update subscription request body from the form draft. The
4
5
  * shipping address is sent as an object (captured via the shared Address
@@ -38,9 +39,7 @@ export const localDataToSaveInvoicingSubscriptionPayload = (localData, shippingA
38
39
  ...(trialEnd !== '' ? { trial_end: trialEnd } : {}),
39
40
  ...(localData.couponId !== '' ? { coupon_ids: [localData.couponId] } : {}),
40
41
  ...(shippingAddress != null
41
- ? {
42
- shipping_address: addressUpdatableInfoToInvoicingShippingPayload(shippingAddress),
43
- }
42
+ ? { shipping_address: toAddressUpdatableInfoPayload(shippingAddress) }
44
43
  : {}),
45
44
  };
46
45
  };
@@ -27,8 +27,8 @@ export const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID)
27
27
  entityToInvoicingSubscriptionFormLocalData(subscription))
28
28
  : newSubscriptionDraft;
29
29
  // Shipping address is captured via the shared Address screen and seeded there
30
- // (from the subscription's inline shipping address) on detail load, so the
31
- // formatted label comes from that draft via the shared `getFormattedAddress`.
30
+ // (looked up in the shared address store by `shippingAddressId`) on detail
31
+ // load, so the formatted label comes from that draft via `getFormattedAddress`.
32
32
  const newAddress = state.addressViewState.newAddressState?.[INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE];
33
33
  const shippingAddressLabel = newAddress?.addressToCreate != null
34
34
  ? getFormattedAddress(newAddress.addressToCreate)
@@ -1,13 +1,15 @@
1
1
  import { EMPTY, of } from 'rxjs';
2
2
  import { filter, mergeMap } from 'rxjs/operators';
3
+ import { getAddressByAddressId } from '../../../entity/address/addressSelector';
3
4
  import { getInvoicingSubscriptionById } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector';
4
5
  import { newAddressInLocalStore } from '../../addressView/addressViewReducer';
5
6
  import { updateInvoicingSubscriptionDetail } from '../invoicingSubscriptionDetailView/invoicingSubscriptionDetailViewReducer';
6
7
  import { initializeInvoicingSubscriptionAddress } from './editInvoicingSubscriptionDetailViewReducer';
7
- import { INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE, invoicingShippingAddressToAddressUpdatableInfo, } from './invoicingSubscriptionFormConfig';
8
+ import { INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE } from './invoicingSubscriptionFormConfig';
8
9
  /**
9
10
  * Seed the shared Address screen with an existing subscription's saved shipping
10
- * address (carried inline on the subscription entity as `shippingAddress`).
11
+ * address (looked up in the shared address store by `shippingAddressId`, same as
12
+ * the customer billing-address flow).
11
13
  * Runs both when the subscription detail loads and on an explicit initialize
12
14
  * trigger. Skips when an in-progress draft already exists, so an address the
13
15
  * user just entered survives navigating between the form and the Address screen.
@@ -22,10 +24,13 @@ export const initializeInvoicingSubscriptionAddressEpic = (actions$, state$) =>
22
24
  return EMPTY;
23
25
  }
24
26
  const subscription = getInvoicingSubscriptionById(rootState.invoicingSubscriptionState, id);
25
- return subscription?.shippingAddress != null
27
+ const address = subscription?.shippingAddressId != null
28
+ ? getAddressByAddressId(rootState.addressState, subscription.shippingAddressId)
29
+ : undefined;
30
+ return address != null
26
31
  ? of(newAddressInLocalStore({
27
32
  addressType: INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE,
28
- addressToCreate: invoicingShippingAddressToAddressUpdatableInfo(subscription.shippingAddress),
33
+ addressToCreate: address,
29
34
  }))
30
35
  : EMPTY;
31
36
  }));
@@ -67,29 +67,3 @@ export const entityToInvoicingSubscriptionFormLocalData = (subscription) => {
67
67
  : '',
68
68
  };
69
69
  };
70
- const trimOrUndefined = (value) => value != null && value.trim() !== '' ? value.trim() : undefined;
71
- /**
72
- * Convert the shared Address screen's `AddressUpdatableInfo` into the invoicing
73
- * shipping-address payload shape the subscription API expects
74
- * (`line1`/`line2`/`city`/`state_code`/`zip`/`country`).
75
- */
76
- export const addressUpdatableInfoToInvoicingShippingPayload = (info) => ({
77
- city: trimOrUndefined(info.city),
78
- country: trimOrUndefined(info.country),
79
- line1: trimOrUndefined(info.street?.[0]),
80
- line2: trimOrUndefined(info.street?.[1]),
81
- state_code: trimOrUndefined(info.state),
82
- zip: trimOrUndefined(info.postalCode),
83
- });
84
- /**
85
- * Convert an existing subscription's shipping-address payload into the shared
86
- * Address screen's `AddressUpdatableInfo` (used to seed the screen on edit).
87
- */
88
- export const invoicingShippingAddressToAddressUpdatableInfo = (address) => ({
89
- city: address.city ?? '',
90
- country: address.country ?? '',
91
- postalCode: address.zip ?? '',
92
- state: address.state_code ?? '',
93
- street: [address.line1, address.line2].filter((part) => part != null && part !== ''),
94
- ...(address.country != null ? { countryCode: address.country } : {}),
95
- });
@@ -1,5 +1,7 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { extractInvoicingSubscriptionAddresses } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionPayload';
3
5
  import { updateInvoicingSubscriptions } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionReducer';
4
6
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
7
  import { resetNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
@@ -25,6 +27,7 @@ export const saveInvoicingSubscriptionEpic = (actions$, state$, zeniAPI) => acti
25
27
  if (isSuccessResponse(response) && response.data != null) {
26
28
  return [
27
29
  updateInvoicingSubscriptions([response.data], 'merge'),
30
+ updateAddresses(extractInvoicingSubscriptionAddresses([response.data])),
28
31
  submitInvoicingSubscriptionFormSuccess({
29
32
  subscriptionId: response.data.id,
30
33
  }),
@@ -1,5 +1,7 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { extractInvoicingInvoiceAddresses } from '../../../entity/invoicing/invoice/invoicePayload';
3
5
  import { updateInvoices } from '../../../entity/invoicing/invoice/invoiceReducer';
4
6
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
7
  import { runInvoicingInvoiceAction, runInvoicingInvoiceActionFailure, runInvoicingInvoiceActionSuccess, updateInvoicingInvoice, } from './invoiceActionReducer';
@@ -12,6 +14,7 @@ export const runInvoicingInvoiceActionEpic = (actions$, _state$, zeniAPI) => act
12
14
  if (isSuccessResponse(response) && response.data != null) {
13
15
  return [
14
16
  updateInvoices([response.data], 'merge'),
17
+ updateAddresses(extractInvoicingInvoiceAddresses([response.data])),
15
18
  runInvoicingInvoiceActionSuccess({ invoiceId }),
16
19
  ];
17
20
  }
@@ -34,6 +37,7 @@ export const updateInvoicingInvoiceEpic = (actions$, _state$, zeniAPI) => action
34
37
  if (isSuccessResponse(response) && response.data != null) {
35
38
  return [
36
39
  updateInvoices([response.data], 'merge'),
40
+ updateAddresses(extractInvoicingInvoiceAddresses([response.data])),
37
41
  runInvoicingInvoiceActionSuccess({ invoiceId }),
38
42
  ];
39
43
  }
@@ -1,5 +1,7 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, switchMap } from 'rxjs/operators';
3
+ import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { extractInvoicingInvoiceAddresses } from '../../../entity/invoicing/invoice/invoicePayload';
3
5
  import { updateInvoices } from '../../../entity/invoicing/invoice/invoiceReducer';
4
6
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
7
  import { fetchInvoiceDetail, updateInvoiceDetail, updateInvoiceDetailFailure, } from './invoiceDetailReducer';
@@ -9,6 +11,7 @@ export const fetchInvoiceDetailEpic = (actions$, _state$, zeniAPI) => actions$.p
9
11
  return zeniAPI.getJSON(apiUrl).pipe(switchMap((response) => {
10
12
  if (isSuccessResponse(response) && response.data != null) {
11
13
  return [
14
+ updateAddresses(extractInvoicingInvoiceAddresses([response.data])),
12
15
  updateInvoices([response.data], 'merge'),
13
16
  updateInvoiceDetail({ invoiceId: response.data.id }),
14
17
  ];
@@ -1,10 +1,18 @@
1
1
  import recordGet from 'lodash/get';
2
+ import { getAddressByAddressId } from '../../../entity/address/addressSelector';
2
3
  import { getInvoiceById } from '../../../entity/invoicing/invoice/invoiceSelector';
3
4
  import { getInvoicingInvoiceActionState } from '../invoiceAction/invoiceActionSelector';
4
5
  export const getInvoiceDetail = (state, invoiceId) => {
5
6
  const detail = recordGet(state.invoicingInvoiceDetailState.detailById, invoiceId, undefined);
7
+ const invoice = getInvoiceById(state, invoiceId);
6
8
  return {
7
- invoice: getInvoiceById(state, invoiceId),
9
+ invoice,
10
+ billingAddress: invoice?.billingAddressId != null
11
+ ? getAddressByAddressId(state.addressState, invoice.billingAddressId)
12
+ : undefined,
13
+ shippingAddress: invoice?.shippingAddressId != null
14
+ ? getAddressByAddressId(state.addressState, invoice.shippingAddressId)
15
+ : undefined,
8
16
  actionState: getInvoicingInvoiceActionState(invoiceId)(state),
9
17
  fetchState: detail?.fetchState ?? 'Not-Started',
10
18
  error: detail?.error,
@@ -1,5 +1,7 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, switchMap } from 'rxjs/operators';
3
+ import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { extractInvoicingInvoiceAddresses } from '../../../entity/invoicing/invoice/invoicePayload';
3
5
  import { updateInvoices } from '../../../entity/invoicing/invoice/invoiceReducer';
4
6
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
7
  import { INVOICING_LIST_PAGE_SIZE, applyListSortParams, withQuery, } from '../invoicingApiHelper';
@@ -39,6 +41,7 @@ export const fetchInvoiceListEpic = (actions$, _state$, zeniAPI) => actions$.pip
39
41
  const items = response.data?.items ?? [];
40
42
  const actions = [
41
43
  updateInvoices(items, 'merge'),
44
+ updateAddresses(extractInvoicingInvoiceAddresses(items)),
42
45
  updateInvoiceList({
43
46
  invoices: items,
44
47
  nextCursor: response.data?.next_cursor ?? null,
@@ -1,5 +1,7 @@
1
1
  import { of } from 'rxjs';
2
2
  import { catchError, filter, switchMap } from 'rxjs/operators';
3
+ import { updateAddresses } from '../../../entity/address/addressReducer';
4
+ import { extractInvoicingCustomerAddresses } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerPayload';
3
5
  import { updateInvoicingCustomers } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerReducer';
4
6
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
7
  import { fetchInvoicingCustomerDetail, updateInvoicingCustomerDetail, updateInvoicingCustomerDetailFailure, } from './invoicingCustomerDetailViewReducer';
@@ -9,6 +11,7 @@ export const fetchInvoicingCustomerDetailEpic = (actions$, _state$, zeniAPI) =>
9
11
  return zeniAPI.getJSON(apiUrl).pipe(switchMap((response) => {
10
12
  if (isSuccessResponse(response) && response.data != null) {
11
13
  return [
14
+ updateAddresses(extractInvoicingCustomerAddresses([response.data])),
12
15
  updateInvoicingCustomers([response.data], 'merge'),
13
16
  updateInvoicingCustomerDetail({ id: response.data.id }),
14
17
  ];