@taxbit/react-sdk 1.0.0-beta.2 → 1.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Taxbit React SDK
2
2
 
3
- A React app, widget, and component for gathering Tax Documentation data for US and EU Tax forms.
3
+ A React component and hook for gathering Tax Documentation data for US and EU Tax forms.
4
+
5
+ ## Usage
6
+
7
+ The Taxbit React SDK provides a React component, hook, and Typescript types for gathering tax documentation data from users. The component can be used to collect data for the Taxbit DPS (Digital Platform Sales) or W-Form (W-9, W-8BEN, W-8BEN-E) tax documentation forms. A hook provides more tools to understand the user's tax documentation status and download any pdf versions of the files that are created if eligible.
8
+
9
+ DPS (Digital Platform Sales) is a data standard and UI flow used by Taxbit to gather the information needed to report income as directed by the DAC7 for the European Union, and equivalent reporting requirements in Canada, New Zealand, and the United Kingdom.
10
+
11
+ ## Beta Stage
12
+
13
+ During this stage, the Taxbit SDK is fully supported, and can be used in production environments. However, there may be breaking changes without a new major version release. If used in a production environment, Taxbit recommends setting a fixed version, updating regularly, and testing after each update.
4
14
 
5
15
  ## Installation
6
16
 
@@ -16,13 +26,13 @@ import { TaxbitQuestionnaire, ClientTaxDocumentation } from '@taxbit/react-sdk';
16
26
  ### Data
17
27
 
18
28
  ```typescript
19
- exampleData: ClientTaxDocumentation = {
29
+ const exampleData: ClientTaxDocumentation = {
20
30
  accountHolder: {
21
31
  name: 'John Smith',
22
32
  tin: '456456456',
23
33
  ftin: '667788991',
24
- usAccountType: 'individual',
25
- foreignAccountType: 'individual',
34
+ usAccountType: 'INDIVIDUAL',
35
+ foreignAccountType: 'INDIVIDUAL',
26
36
  address: {
27
37
  firstLine: '123 Main St',
28
38
  secondLine: 'Unit #2',
@@ -107,29 +117,69 @@ The WForm component language can be set to 'en', 'fr', or 'es'.
107
117
 
108
118
  See the `Locale` type below.
109
119
 
120
+ ## useTaxbit Hook
121
+
122
+ The `useTaxbit` hook can be used to get the data from the server or the account status.
123
+
124
+ ```typescript
125
+ const {
126
+ statusData,
127
+ serverData,
128
+ canGetDocumentUrl,
129
+ getNewDocumentUrl,
130
+ isGettingDocumentUrl,
131
+ documentUrl,
132
+ } = useTaxbit(bearerToken, questionnaire);
133
+ ```
134
+
135
+ It can also be used to get the document URL for the user's tax documentation. The `getNewDocumentUrl` function will trigger a temporary URL generation. The `documentUrl` will be the URL of the document if it is available. `isGettingDocumentUrl` will be true while the URL is being generated. `canGetDocumentUrl` will be true if the user has submitted the questionnaire and a PDF tax document is available to this user. Note, `DPS` data does not generate a PDF document.
136
+
137
+ ### Server Data
138
+
139
+ The serverData object contains the currently saved tax documentation data for the user. It is also a `ClientTaxDocumentation` object.
140
+
110
141
  ### Status
111
142
 
112
143
  The `useTaxbit` hook will return a `status` object that can be used to determine the status of the user's tax documentation. The `status` object will have the following shape:
113
144
 
114
145
  ```typescript
115
- {
116
- submissionStatus: 'SUBMITTED' | 'NOT_SUBMITTED';
117
- dpsQuestionnaire: {
146
+ type ClientTaxDocumentationStatus = {
147
+ dpsQuestionnaire?: {
118
148
  dataCollectionStatus: 'COMPLETE' | 'INCOMPLETE';
119
- expirationDate: 'PENDING' |
120
- 'VALID' |
121
- 'INVALID' |
122
- 'INSUFFICIENT_DATA' |
123
- 'NOT_REQUIRED';
124
- }
125
- }
149
+ vatStatus?:
150
+ | 'PENDING'
151
+ | 'VALID'
152
+ | 'INVALID'
153
+ | 'INSUFFICIENT_DATA'
154
+ | 'NOT_REQUIRED'
155
+ | 'NON_EU';
156
+ vatValidationDate?: string;
157
+ expirationDate?: string;
158
+ };
159
+ wFormQuestionnaire?: {
160
+ dataCollectionStatus: 'COMPLETE' | 'INCOMPLETE';
161
+ type: 'W-9' | 'W-8BEN' | 'W-8BEN-E';
162
+ expirationDate?: string;
163
+ tinStatus?:
164
+ | 'PENDING'
165
+ | 'FOREIGN'
166
+ | 'INVALID_DATA'
167
+ | 'VALID_SSN_MATCH'
168
+ | 'VALID_EIN_MATCH'
169
+ | 'VALID_SSN_EIN_MATCH'
170
+ | 'MISMATCH'
171
+ | 'TIN_NOT_ISSUED'
172
+ | 'ERROR';
173
+ tinValidationDate?: string;
174
+ needsResubmission: boolean;
175
+ };
176
+ };
126
177
  ```
127
178
 
128
179
  an example is below.
129
180
 
130
181
  ```json
131
182
  {
132
- "submissionStatus": "SUBMITTED",
133
183
  "dpsQuestionnaire": {
134
184
  "dataCollectionStatus": "COMPLETE",
135
185
  "expirationDate": "2026-11-20T00:00:00.000Z"
@@ -137,6 +187,19 @@ an example is below.
137
187
  }
138
188
  ```
139
189
 
190
+ or for W-Form status
191
+
192
+ ```json
193
+ {
194
+ "wFormQuestionnaire": {
195
+ "dataCollectionStatus": "COMPLETE",
196
+ "type": "W-9",
197
+ "tinValidationDate": "2027-11-01T17:09:05.962Z",
198
+ "needsResubmission": false
199
+ }
200
+ }
201
+ ```
202
+
140
203
  ### CSS and Style Customization
141
204
 
142
205
  The Taxbit React SDK renders a form for collecting user data. The form is structured with fairly semantic HTML and CSS classes and can be easily customized to closely match your client's style.
@@ -221,8 +284,25 @@ type Progress = {
221
284
  };
222
285
  ```
223
286
 
287
+ ```typescript
288
+ type QuestionnaireType = 'DPS' | 'W-FORM';
289
+ ```
290
+
224
291
  ## Changelog
225
292
 
293
+ ### Version 1.0.0-beta.4
294
+
295
+ 1. More explicit typing for TaxbitQuestionnaire component props
296
+
297
+ ### Version 1.0.0-beta.3
298
+
299
+ 1. Transforming deprecated tax documentation data types for import to SDK
300
+ 2. More Readme documentation around Status and Questionnaire types
301
+
302
+ ### Version 1.0.0-beta.2
303
+
304
+ 1. The ClientTaxDocumentation type is exposed in the `useTaxbit` hook.
305
+
226
306
  ### Version 1.0.0-beta.1
227
307
 
228
308
  1. Showing "\*" when required for Addresses on Summary
@@ -271,7 +351,7 @@ type Progress = {
271
351
 
272
352
  ### Version 0.4.1
273
353
 
274
- 1. Bug fix for onProgress callback not being triggered from the TaxbitDPSQuestionnaire component.
354
+ 1. Bug fix for onProgress callback not being triggered from the TaxBitDAC7Form component.
275
355
 
276
356
  ### Version 0.4.0
277
357
 
@@ -304,5 +384,5 @@ type Progress = {
304
384
  1. Fix in package.json to expose UMD module as main.
305
385
  2. Added specific CSS class names for each question and each screen of the form.
306
386
  3. Added the new status structure into the useTaxbit hook.
307
- 4. TaxbitDPSQuestionnaire component will now preload the form with previously submitted data.
387
+ 4. TaxBitDAC7Form component will now preload the form with previously submitted data.
308
388
  5. Validation update to enforce that primary address country and tax residence country are the same.
@@ -10,7 +10,7 @@ export type UseTaxDocumentationProps = {
10
10
  data?: ClientTaxDocumentation;
11
11
  language?: Locale;
12
12
  externalValidations?: ExternalValidations;
13
- onSubmit: (data: ClientTaxDocumentation) => void | Promise<void>;
13
+ onSubmit?: (data?: ClientTaxDocumentation) => void | Promise<void>;
14
14
  onProgress?: (progress: Progress) => void | Promise<void>;
15
15
  step?: InputStep;
16
16
  questionnaire: Questionnaire;
@@ -1,12 +1,26 @@
1
+ import { ClientTaxDocumentation } from '@taxbit/utilities';
1
2
  import React from 'react';
2
- import { TaxbitQuestionnairePersistProps } from 'widgets';
3
- import { TaxbitQuestionnaireUIProps } from 'wizard';
4
- import { Questionnaire } from '../../types';
3
+ import type { Locale, Questionnaire } from '../../types';
4
+ import { TaxbitQuestionnairePersistProps } from '../../widgets';
5
5
  export type TaxbitQuestionnaireProps = {
6
+ data?: ClientTaxDocumentation;
7
+ language?: Locale;
6
8
  questionnaire: Questionnaire;
7
- } & ((TaxbitQuestionnaireUIProps & {
9
+ onProgress?: TaxbitQuestionnairePersistProps['onProgress'];
10
+ onSubmit?: TaxbitQuestionnairePersistProps['onSubmit'];
11
+ } & ({
8
12
  demoMode: true;
9
- }) | (TaxbitQuestionnairePersistProps & {
13
+ bearerToken?: never;
14
+ onSuccess?: never;
15
+ onSettled?: never;
16
+ onError?: never;
17
+ staging?: never;
18
+ } | {
10
19
  demoMode?: false | undefined;
11
- }));
12
- export declare const TaxbitQuestionnaire: ({ ...props }: TaxbitQuestionnaireProps) => React.JSX.Element;
20
+ bearerToken: TaxbitQuestionnairePersistProps['bearerToken'];
21
+ onSuccess?: TaxbitQuestionnairePersistProps['onSuccess'];
22
+ onSettled?: TaxbitQuestionnairePersistProps['onSettled'];
23
+ onError?: TaxbitQuestionnairePersistProps['onError'];
24
+ staging?: TaxbitQuestionnairePersistProps['staging'];
25
+ });
26
+ export declare const TaxbitQuestionnaire: ({ questionnaire, data, onSubmit, onSuccess, onSettled, onError, language, onProgress, bearerToken, demoMode, staging, }: TaxbitQuestionnaireProps) => React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { SignedDatedComprehensiveTaxDocumentation } from '@taxbit/utilities';
2
+ export type Comprehensive = {
3
+ account_holder: SignedDatedComprehensiveTaxDocumentation['account_holder'];
4
+ regarded_owner?: SignedDatedComprehensiveTaxDocumentation['regarded_owner'];
5
+ document_type: 'COMPREHENSIVE';
6
+ };
@@ -0,0 +1,29 @@
1
+ import { Comprehensive } from './comprehensive';
2
+ import { W9 } from './w9';
3
+ export type W8 = {
4
+ name?: string;
5
+ country?: string;
6
+ tax_classification?: 'INDIVIDUAL' | 'CORPORATION' | 'PARTNERSHIP' | 'SIMPLE_TRUST' | 'COMPLEX_TRUST' | 'GRANTOR_TRUST' | 'ESTATE' | 'CENTRAL_BANK_OF_ISSUE' | 'FOREIGN_GOVERNMENT_CONTROLLED_ENTITY' | 'FOREIGN_GOVERNMENT_INTEGRAL_PART' | 'TAX_EXEMPT_ORGANIZATION' | 'PRIVATE_FOUNDATION' | 'INTERNATIONAL_ORGANIZATION';
7
+ permanent_address: {
8
+ first_line?: string;
9
+ city?: string;
10
+ state_or_province?: string;
11
+ postal_code?: string;
12
+ country?: string;
13
+ };
14
+ mailing_address?: {
15
+ first_line?: string;
16
+ city?: string;
17
+ state_or_province?: string;
18
+ postal_code?: string;
19
+ country?: string;
20
+ };
21
+ reference_numbers?: string;
22
+ tin?: string;
23
+ ftin?: string;
24
+ date_of_birth?: string;
25
+ ftin_not_legally_required?: true;
26
+ document_type: 'W-8BEN' | 'W-8BEN-E';
27
+ };
28
+ export declare const isW8TaxDocument: (taxDocument: Comprehensive | W9 | W8) => taxDocument is W8;
29
+ export declare const transformW8ToComprehensive: (taxDocument: W8) => Comprehensive;
@@ -0,0 +1,22 @@
1
+ import { Comprehensive } from './comprehensive';
2
+ import { W8 } from './w8';
3
+ export type W9 = {
4
+ name?: string;
5
+ tin?: string;
6
+ dba_name?: string;
7
+ tax_classification?: 'INDIVIDUAL' | 'LLC_S' | 'LLC_C' | 'LLC_P' | 'S_CORPORATION' | 'C_CORPORATION' | 'PARTNERSHIP' | 'TRUST_ESTATE' | 'OTHER';
8
+ address: {
9
+ first_line?: string;
10
+ second_line?: string;
11
+ city?: string;
12
+ state_or_province?: string;
13
+ postal_code?: string;
14
+ country?: string;
15
+ };
16
+ document_type: 'W-9';
17
+ other_tax_classification?: string;
18
+ exempt_payee_code?: string;
19
+ exempt_fatca_code?: string;
20
+ };
21
+ export declare const isW9TaxDocument: (taxDocument: Comprehensive | W9 | W8) => taxDocument is W9;
22
+ export declare const transformW9ToComprehensive: (taxDocument: W9) => Comprehensive;
@@ -1,7 +1,7 @@
1
1
  import type { SignedClientTaxDocumentation } from '@taxbit/utilities';
2
2
  import { Questionnaire } from 'types';
3
3
  export declare const useTaxbitConnect: (bearerToken: string, questionnaire: Questionnaire, staging?: boolean) => {
4
- doPostData: (data: SignedClientTaxDocumentation) => Promise<Response>;
4
+ doPostData: (data?: SignedClientTaxDocumentation) => Promise<Response>;
5
5
  formStatus: "COMPLETE" | "INCOMPLETE" | undefined;
6
6
  serverData: SignedClientTaxDocumentation | undefined;
7
7
  statusData: import("../../entry").ClientTaxDocumentationStatus | undefined;
@@ -1,6 +1,6 @@
1
1
  import type { SignedClientTaxDocumentation } from '@taxbit/utilities';
2
- import { Questionnaire } from 'types';
3
- import type { ClientTaxDocumentationStatus } from 'types/client';
2
+ import { Questionnaire } from '../../types';
3
+ import type { ClientTaxDocumentationStatus } from '../../types/client';
4
4
  export declare const useTaxbitStatus: (bearerToken: string, questionnaire: Questionnaire, staging?: boolean) => {
5
5
  formStatus: "COMPLETE" | "INCOMPLETE" | undefined;
6
6
  serverData: SignedClientTaxDocumentation | undefined;
@@ -1,9 +1,7 @@
1
1
  export type ClientTaxDocumentationStatus = {
2
- status: 'UNDOCUMENTED' | 'UNDETERMINED';
3
- submissionStatus: 'SUBMITTED' | 'NOT_SUBMITTED';
4
2
  dpsQuestionnaire?: {
5
3
  dataCollectionStatus: 'COMPLETE' | 'INCOMPLETE';
6
- vatStatus?: 'PENDING' | 'VALID' | 'INVALID' | 'INSUFFICIENT_DATA' | 'NOT_REQUIRED';
4
+ vatStatus?: 'PENDING' | 'VALID' | 'INVALID' | 'INSUFFICIENT_DATA' | 'NOT_REQUIRED' | 'NON_EU';
7
5
  vatValidationDate?: string;
8
6
  expirationDate?: string;
9
7
  };
@@ -11,7 +9,7 @@ export type ClientTaxDocumentationStatus = {
11
9
  dataCollectionStatus: 'COMPLETE' | 'INCOMPLETE';
12
10
  type: 'W-9' | 'W-8BEN' | 'W-8BEN-E';
13
11
  expirationDate?: string;
14
- tinStatus?: string;
12
+ tinStatus?: 'PENDING' | 'FOREIGN' | 'INVALID_DATA' | 'VALID_SSN_MATCH' | 'VALID_EIN_MATCH' | 'VALID_SSN_EIN_MATCH' | 'MISMATCH' | 'TIN_NOT_ISSUED' | 'ERROR';
15
13
  tinValidationDate?: string;
16
14
  needsResubmission: boolean;
17
15
  };
@@ -1,9 +1,7 @@
1
1
  export type TaxDocumentationStatus = {
2
- status: 'UNDOCUMENTED' | 'UNDETERMINED';
3
- submission_status: 'SUBMITTED' | 'NOT_SUBMITTED';
4
2
  dps_questionnaire?: {
5
3
  data_collection_status: 'COMPLETE' | 'INCOMPLETE';
6
- vat_status?: 'PENDING' | 'VALID' | 'INVALID' | 'INSUFFICIENT_DATA' | 'NOT_REQUIRED';
4
+ vat_status?: 'PENDING' | 'VALID' | 'INVALID' | 'INSUFFICIENT_DATA' | 'NOT_REQUIRED' | 'NON_EU';
7
5
  vat_validation_date?: string;
8
6
  expiration_date?: string;
9
7
  };
@@ -11,7 +9,7 @@ export type TaxDocumentationStatus = {
11
9
  data_collection_status: 'COMPLETE' | 'INCOMPLETE';
12
10
  type: 'W-9' | 'W-8BEN' | 'W-8BEN-E';
13
11
  expiration_date?: string;
14
- tin_status?: string;
12
+ tin_status?: 'PENDING' | 'FOREIGN' | 'INVALID_DATA' | 'VALID_SSN_MATCH' | 'VALID_EIN_MATCH' | 'VALID_SSN_EIN_MATCH' | 'MISMATCH' | 'TIN_NOT_ISSUED' | 'ERROR';
15
13
  tin_validation_date?: string;
16
14
  needs_resubmission: boolean;
17
15
  };
@@ -1,5 +1,5 @@
1
- import type { UseTaxDocumentationProps } from 'contexts';
2
1
  import React from 'react';
2
+ import type { UseTaxDocumentationProps } from '../../contexts';
3
3
  import { UseTaxbitPersistProps } from './useTaxbitPersist';
4
- export type TaxbitQuestionnairePersistProps = Omit<UseTaxDocumentationProps, 'onSubmit'> & UseTaxbitPersistProps;
4
+ export type TaxbitQuestionnairePersistProps = UseTaxDocumentationProps & UseTaxbitPersistProps;
5
5
  export declare const TaxbitQuestionnairePersist: ({ staging, data, bearerToken, language, questionnaire, onProgress, onSubmit, onSettled, onSuccess, onError, }: TaxbitQuestionnairePersistProps) => React.JSX.Element;
@@ -1,7 +1,7 @@
1
- import { ClientTaxDocumentation, SignedClientTaxDocumentation } from '@taxbit/utilities';
1
+ import { ClientTaxDocumentation } from '@taxbit/utilities';
2
2
  import { Questionnaire } from 'types';
3
3
  import { ExternalValidations } from 'types/client';
4
- type TaxbitResponseError = {
4
+ export type TaxbitResponseError = {
5
5
  message: string;
6
6
  response: Response;
7
7
  };
@@ -16,10 +16,9 @@ export type UseTaxbitPersistProps = {
16
16
  onSubmit?: (data?: ClientTaxDocumentation) => void | Promise<void>;
17
17
  };
18
18
  export declare const useTaxbitPersist: ({ bearerToken, data, onSubmit, onSuccess, onSettled, onError, staging, questionnaire, }: UseTaxbitPersistProps) => {
19
- handleOnSubmit: (data: SignedClientTaxDocumentation) => Promise<void>;
19
+ handleOnSubmit: (data?: ClientTaxDocumentation) => Promise<void>;
20
20
  externalValidations: ExternalValidations;
21
21
  formData: ClientTaxDocumentation;
22
22
  isComplete: boolean;
23
23
  isLoading: boolean;
24
24
  };
25
- export {};