@zeniai/client-epic-state 5.2.76 → 5.2.77

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.
@@ -41,6 +41,16 @@ export const createInvoiceFormLocalDataToRequest = (localData) => {
41
41
  quantity: toQuantity(line.quantity),
42
42
  tax_amount: line.taxAmount.amount,
43
43
  unit_amount: line.unitAmount.amount,
44
+ ...(line.catalogLine != null
45
+ ? {
46
+ entity_id: line.catalogLine.entityId,
47
+ entity_type: line.catalogLine.entityType,
48
+ is_taxed: line.catalogLine.isTaxed,
49
+ ...(line.catalogLine.isTaxed
50
+ ? {}
51
+ : { tax_exempt_reason: 'not_taxable' }),
52
+ }
53
+ : {}),
44
54
  }));
45
55
  const invoiceDate = localData.invoiceDate != null && localData.invoiceDate !== ''
46
56
  ? localData.invoiceDate
@@ -73,6 +73,12 @@ export const getCreateInvoiceFormView = (state) => {
73
73
  planNames: catalogListView.plans.flatMap((plan) => (plan.subFamilies ?? [])
74
74
  .filter((subFamily) => (subFamily.name ?? '') !== '')
75
75
  .map((subFamily) => ({
76
+ // A price point with no flag is taxable, as subscription billing reads it.
77
+ catalogLine: {
78
+ entityId: subFamily.id,
79
+ entityType: plan.itemType ?? 'plan',
80
+ isTaxed: subFamily.isTaxable ?? true,
81
+ },
76
82
  planName: plan.name ?? '',
77
83
  price: planNamePrefillPrice(subFamily),
78
84
  subFamilyName: subFamily.name ?? '',
package/lib/index.d.ts CHANGED
@@ -1088,7 +1088,7 @@ export { getInvoiceDetail } from './view/invoicing/invoiceDetail/invoiceDetailSe
1088
1088
  export type { InvoiceDetailView } from './view/invoicing/invoiceDetail/invoiceDetailSelector';
1089
1089
  export { createInvoice, fetchCreateInvoiceFormPage, resetCreateInvoice, updateInvoicingCreateInvoiceFormDraft, } from './view/invoicing/createInvoice/createInvoiceReducer';
1090
1090
  export type { CreateInvoiceLineItemRequest, CreateInvoiceRequest, } from './view/invoicing/createInvoice/createInvoicePayload';
1091
- export type { InvoicingCreateInvoiceFormLineItem, InvoicingCreateInvoiceFormLocalData, } from './view/invoicing/createInvoice/createInvoiceState';
1091
+ export type { InvoicingCreateInvoiceCatalogLine, InvoicingCreateInvoiceFormLineItem, InvoicingCreateInvoiceFormLocalData, } from './view/invoicing/createInvoice/createInvoiceState';
1092
1092
  export { blankInvoicingCreateInvoiceLineItem, createInvoiceFormLocalDataToRequest, initialInvoicingCreateInvoiceFormLocalData, } from './view/invoicing/createInvoice/createInvoiceFormConfig';
1093
1093
  export { resetRecordPayment, initializeRecordPaymentDraft, submitRecordPayment, updateRecordPaymentFormDraft, } from './view/invoicing/recordPayment/recordPaymentReducer';
1094
1094
  export { initializeIssueCreditNoteDraft, issueCreditNoteFailure, issueCreditNoteSuccess, resetIssueCreditNote, submitIssueCreditNote, updateIssueCreditNoteFormDraft, } from './view/invoicing/issueCreditNote/issueCreditNoteReducer';
@@ -45,6 +45,16 @@ const createInvoiceFormLocalDataToRequest = (localData) => {
45
45
  quantity: toQuantity(line.quantity),
46
46
  tax_amount: line.taxAmount.amount,
47
47
  unit_amount: line.unitAmount.amount,
48
+ ...(line.catalogLine != null
49
+ ? {
50
+ entity_id: line.catalogLine.entityId,
51
+ entity_type: line.catalogLine.entityType,
52
+ is_taxed: line.catalogLine.isTaxed,
53
+ ...(line.catalogLine.isTaxed
54
+ ? {}
55
+ : { tax_exempt_reason: 'not_taxable' }),
56
+ }
57
+ : {}),
48
58
  }));
49
59
  const invoiceDate = localData.invoiceDate != null && localData.invoiceDate !== ''
50
60
  ? localData.invoiceDate
@@ -5,7 +5,11 @@ export interface CreateInvoiceLineItemRequest {
5
5
  description: string;
6
6
  quantity: number;
7
7
  unit_amount: number;
8
+ entity_id?: string;
9
+ entity_type?: string;
10
+ is_taxed?: boolean;
8
11
  tax_amount?: number;
12
+ tax_exempt_reason?: string;
9
13
  }
10
14
  /** Request body for creating an invoice; mirrors the Invoicing backend. */
11
15
  export interface CreateInvoiceRequest {
@@ -4,7 +4,7 @@ import { Address } from '../../../entity/address/addressState';
4
4
  import { InvoicingCatalogPricePoint } from '../../../entity/invoicing/invoicingCatalog/invoicingCatalogState';
5
5
  import { InvoicingFieldHelpByCode, InvoicingSettingsPayload } from '../../../entity/invoicing/invoicingCommonPayload';
6
6
  import { RootState } from '../../../rootStateTypes';
7
- import { InvoicingCreateInvoiceFormLocalData } from './createInvoiceState';
7
+ import { InvoicingCreateInvoiceCatalogLine, InvoicingCreateInvoiceFormLocalData } from './createInvoiceState';
8
8
  /**
9
9
  * One catalog plan price, split into its two naming parts so consumers can
10
10
  * compose the label themselves (the plan family name and the price point/price
@@ -18,6 +18,7 @@ import { InvoicingCreateInvoiceFormLocalData } from './createInvoiceState';
18
18
  * produce a plausible-looking wrong total. Those lines start unpriced.
19
19
  */
20
20
  export interface InvoicingPlanNameOption {
21
+ catalogLine: InvoicingCreateInvoiceCatalogLine;
21
22
  planName: string;
22
23
  subFamilyName: string;
23
24
  price?: number;
@@ -76,6 +76,12 @@ const getCreateInvoiceFormView = (state) => {
76
76
  planNames: catalogListView.plans.flatMap((plan) => (plan.subFamilies ?? [])
77
77
  .filter((subFamily) => (subFamily.name ?? '') !== '')
78
78
  .map((subFamily) => ({
79
+ // A price point with no flag is taxable, as subscription billing reads it.
80
+ catalogLine: {
81
+ entityId: subFamily.id,
82
+ entityType: plan.itemType ?? 'plan',
83
+ isTaxed: subFamily.isTaxable ?? true,
84
+ },
79
85
  planName: plan.name ?? '',
80
86
  price: planNamePrefillPrice(subFamily),
81
87
  subFamilyName: subFamily.name ?? '',
@@ -1,6 +1,15 @@
1
1
  import { Amount } from '../../../commonStateTypes/amount';
2
2
  import { FetchedState, ID } from '../../../commonStateTypes/common';
3
3
  import { CreateInvoiceRequest } from './createInvoicePayload';
4
+ /**
5
+ * The catalog price point a line was picked from, so the invoice line links to
6
+ * it and takes its taxability, the way subscription billing builds its lines.
7
+ */
8
+ export interface InvoicingCreateInvoiceCatalogLine {
9
+ entityId: ID;
10
+ entityType: string;
11
+ isTaxed: boolean;
12
+ }
4
13
  /**
5
14
  * A single line item in the create-invoice form draft. Amounts are USD values
6
15
  * (whole units, e.g. dollars) held via the `Amount` interface — never minor
@@ -11,6 +20,8 @@ export interface InvoicingCreateInvoiceFormLineItem {
11
20
  quantity: string;
12
21
  taxAmount: Amount;
13
22
  unitAmount: Amount;
23
+ /** Unset for a typed description, which the backend taxes by default. */
24
+ catalogLine?: InvoicingCreateInvoiceCatalogLine;
14
25
  }
15
26
  /**
16
27
  * Draft form state for the create-invoice form. Held in CES so the form flows
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.76",
3
+ "version": "5.2.77",
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",