@cranberry-money/shared-services 1.8.0 → 1.10.0
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/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/services/portfolio_templates/constants.d.ts +8 -0
- package/dist/services/portfolio_templates/constants.d.ts.map +1 -0
- package/dist/services/portfolio_templates/constants.js +8 -0
- package/dist/services/portfolio_templates/index.d.ts +5 -0
- package/dist/services/portfolio_templates/index.d.ts.map +1 -0
- package/dist/services/portfolio_templates/index.js +5 -0
- package/dist/services/portfolio_templates/service.d.ts +6 -0
- package/dist/services/portfolio_templates/service.d.ts.map +1 -0
- package/dist/services/portfolio_templates/service.js +14 -0
- package/dist/services/portfolio_templates/types.d.ts +49 -0
- package/dist/services/portfolio_templates/types.d.ts.map +1 -0
- package/dist/services/portfolio_templates/types.js +1 -0
- package/dist/services/portfolio_templates/utils.d.ts +8 -0
- package/dist/services/portfolio_templates/utils.d.ts.map +1 -0
- package/dist/services/portfolio_templates/utils.js +13 -0
- package/dist/services/tax_residencies/constants.d.ts +7 -0
- package/dist/services/tax_residencies/constants.d.ts.map +1 -0
- package/dist/services/tax_residencies/constants.js +7 -0
- package/dist/services/tax_residencies/index.d.ts +10 -0
- package/dist/services/tax_residencies/index.d.ts.map +1 -0
- package/dist/services/tax_residencies/index.js +11 -0
- package/dist/services/tax_residencies/service.d.ts +6 -0
- package/dist/services/tax_residencies/service.d.ts.map +1 -0
- package/dist/services/tax_residencies/service.js +20 -0
- package/dist/services/tax_residencies/types.d.ts +26 -0
- package/dist/services/tax_residencies/types.d.ts.map +1 -0
- package/dist/services/tax_residencies/types.js +4 -0
- package/dist/services/tax_residencies/utils.d.ts +9 -0
- package/dist/services/tax_residencies/utils.d.ts.map +1 -0
- package/dist/services/tax_residencies/utils.js +19 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export * as AuthService from './services/auth';
|
|
|
17
17
|
export * as CashAccountsService from './services/cash_accounts';
|
|
18
18
|
export * as InstrumentsService from './services/instruments';
|
|
19
19
|
export * as PortfoliosService from './services/portfolios';
|
|
20
|
+
export * as PortfolioTemplatesService from './services/portfolio_templates';
|
|
21
|
+
export * as TaxResidenciesService from './services/tax_residencies';
|
|
20
22
|
export * as UsersService from './services/users';
|
|
21
23
|
export * as TradesService from './services/trades';
|
|
22
24
|
export * as WithdrawalsService from './services/withdrawals';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAG3C,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAGrB,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAG5C,OAAO,KAAK,eAAe,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,kBAAkB,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,kBAAkB,MAAM,wBAAwB,CAAC;AAG7D,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAG3C,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAGrB,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAG5C,OAAO,KAAK,eAAe,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,kBAAkB,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,iBAAiB,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,yBAAyB,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,kBAAkB,MAAM,wBAAwB,CAAC;AAG7D,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,8 @@ export * as AuthService from './services/auth';
|
|
|
21
21
|
export * as CashAccountsService from './services/cash_accounts';
|
|
22
22
|
export * as InstrumentsService from './services/instruments';
|
|
23
23
|
export * as PortfoliosService from './services/portfolios';
|
|
24
|
+
export * as PortfolioTemplatesService from './services/portfolio_templates';
|
|
25
|
+
export * as TaxResidenciesService from './services/tax_residencies';
|
|
24
26
|
export * as UsersService from './services/users';
|
|
25
27
|
export * as TradesService from './services/trades';
|
|
26
28
|
export * as WithdrawalsService from './services/withdrawals';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portfolio templates API constants
|
|
3
|
+
*/
|
|
4
|
+
export declare const API_ENDPOINTS: {
|
|
5
|
+
readonly PORTFOLIO_TEMPLATES: "/api/portfolio-templates/";
|
|
6
|
+
readonly PORTFOLIO_TEMPLATES_RECOMMENDED: "/api/portfolio-templates/recommended/";
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/services/portfolio_templates/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,aAAa;;;CAGhB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/portfolio_templates/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PortfolioTemplate, TargetAssetAllocation, ApplyTemplateResponse, PaginatedPortfolioTemplates } from './types';
|
|
2
|
+
export declare const getPortfolioTemplates: () => Promise<import("axios").AxiosResponse<PaginatedPortfolioTemplates, any>>;
|
|
3
|
+
export declare const getRecommendedPortfolioTemplate: () => Promise<import("axios").AxiosResponse<PortfolioTemplate, any>>;
|
|
4
|
+
export declare const getPortfolioTemplateAllocations: (templateUuid: string) => Promise<import("axios").AxiosResponse<TargetAssetAllocation[], any>>;
|
|
5
|
+
export declare const applyPortfolioTemplate: (templateUuid: string) => Promise<import("axios").AxiosResponse<ApplyTemplateResponse, any>>;
|
|
6
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/services/portfolio_templates/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,qBAAqB,gFAEjC,CAAC;AAEF,eAAO,MAAM,+BAA+B,sEAE3C,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,cAAc,MAAM,yEAEnE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,cAAc,MAAM,uEAE1D,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { webApiClient } from '../../api/apiClient';
|
|
2
|
+
import { API_ENDPOINTS } from './constants';
|
|
3
|
+
export const getPortfolioTemplates = () => {
|
|
4
|
+
return webApiClient.get(API_ENDPOINTS.PORTFOLIO_TEMPLATES);
|
|
5
|
+
};
|
|
6
|
+
export const getRecommendedPortfolioTemplate = () => {
|
|
7
|
+
return webApiClient.get(API_ENDPOINTS.PORTFOLIO_TEMPLATES_RECOMMENDED);
|
|
8
|
+
};
|
|
9
|
+
export const getPortfolioTemplateAllocations = (templateUuid) => {
|
|
10
|
+
return webApiClient.get(`${API_ENDPOINTS.PORTFOLIO_TEMPLATES}${templateUuid}/allocations/`);
|
|
11
|
+
};
|
|
12
|
+
export const applyPortfolioTemplate = (templateUuid) => {
|
|
13
|
+
return webApiClient.post(`${API_ENDPOINTS.PORTFOLIO_TEMPLATES}${templateUuid}/apply/`, {});
|
|
14
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PaginatedResponse } from '../../api/types';
|
|
2
|
+
export interface Instrument {
|
|
3
|
+
uuid: string;
|
|
4
|
+
symbol: string;
|
|
5
|
+
name: string;
|
|
6
|
+
instrumentType: string;
|
|
7
|
+
sector?: string;
|
|
8
|
+
stockExchange?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Portfolio {
|
|
11
|
+
uuid: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
isActive: boolean;
|
|
15
|
+
createdAt?: string;
|
|
16
|
+
updatedAt?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface PortfolioTemplate {
|
|
19
|
+
uuid: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
isActive: boolean;
|
|
23
|
+
riskLevel: string;
|
|
24
|
+
createdAt?: string;
|
|
25
|
+
updatedAt?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TargetAssetAllocation {
|
|
28
|
+
uuid: string;
|
|
29
|
+
instrument: Instrument;
|
|
30
|
+
percentage: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AssetAllocation {
|
|
33
|
+
instrument: {
|
|
34
|
+
symbol: string;
|
|
35
|
+
name: string;
|
|
36
|
+
};
|
|
37
|
+
percentage: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Response when applying a portfolio template
|
|
41
|
+
*/
|
|
42
|
+
export interface ApplyTemplateResponse {
|
|
43
|
+
success: boolean;
|
|
44
|
+
message: string;
|
|
45
|
+
portfolio: Portfolio;
|
|
46
|
+
allocations: AssetAllocation[];
|
|
47
|
+
}
|
|
48
|
+
export type PaginatedPortfolioTemplates = PaginatedResponse<PortfolioTemplate>;
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/portfolio_templates/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC;AAGD,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const calculateTotalAllocation: (allocations: {
|
|
2
|
+
percentage: string;
|
|
3
|
+
}[]) => number;
|
|
4
|
+
export declare const validateAllocationPercentages: (allocations: {
|
|
5
|
+
percentage: string;
|
|
6
|
+
}[]) => boolean;
|
|
7
|
+
export declare const formatRiskLevel: (riskLevel: string) => string;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/services/portfolio_templates/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,GAAI,aAAa;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,KAAG,MAIhF,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,aAAa;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,KAAG,OAGrF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,KAAG,MAEnD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Portfolio template utilities and helper functions
|
|
2
|
+
export const calculateTotalAllocation = (allocations) => {
|
|
3
|
+
return allocations.reduce((total, allocation) => {
|
|
4
|
+
return total + parseFloat(allocation.percentage || '0');
|
|
5
|
+
}, 0);
|
|
6
|
+
};
|
|
7
|
+
export const validateAllocationPercentages = (allocations) => {
|
|
8
|
+
const total = calculateTotalAllocation(allocations);
|
|
9
|
+
return Math.abs(total - 100) < 0.01; // Allow for small floating point differences
|
|
10
|
+
};
|
|
11
|
+
export const formatRiskLevel = (riskLevel) => {
|
|
12
|
+
return riskLevel.charAt(0).toUpperCase() + riskLevel.slice(1).toLowerCase();
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,aAAa;;CAEhB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tax Residencies domain exports
|
|
3
|
+
*
|
|
4
|
+
* Centralizes all tax residencies-related exports for easy importing
|
|
5
|
+
*/
|
|
6
|
+
export type { TaxResidency, TaxResidencyPayload, PaginatedTaxResidencies } from './types';
|
|
7
|
+
export { createTaxResidency, updateTaxResidency, deleteTaxResidency, getTaxResidencies } from './service';
|
|
8
|
+
export { findPrimaryTaxResidency, filterTaxResidenciesByCountry, hasTaxResidencyInCountry, getNonExemptedTaxResidencies, } from './utils';
|
|
9
|
+
export { API_ENDPOINTS } from './constants';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAG1F,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG1G,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tax Residencies domain exports
|
|
3
|
+
*
|
|
4
|
+
* Centralizes all tax residencies-related exports for easy importing
|
|
5
|
+
*/
|
|
6
|
+
// Service functions
|
|
7
|
+
export { createTaxResidency, updateTaxResidency, deleteTaxResidency, getTaxResidencies } from './service';
|
|
8
|
+
// Utility functions
|
|
9
|
+
export { findPrimaryTaxResidency, filterTaxResidenciesByCountry, hasTaxResidencyInCountry, getNonExemptedTaxResidencies, } from './utils';
|
|
10
|
+
// Constants
|
|
11
|
+
export { API_ENDPOINTS } from './constants';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TaxResidency, TaxResidencyPayload, PaginatedTaxResidencies } from './types';
|
|
2
|
+
export declare const createTaxResidency: (data: TaxResidencyPayload) => Promise<import("axios").AxiosResponse<TaxResidency, any>>;
|
|
3
|
+
export declare const updateTaxResidency: (uuid: string, data: TaxResidencyPayload) => Promise<import("axios").AxiosResponse<TaxResidency, any>>;
|
|
4
|
+
export declare const deleteTaxResidency: (uuid: string) => Promise<import("axios").AxiosResponse<void, any>>;
|
|
5
|
+
export declare const getTaxResidencies: () => Promise<import("axios").AxiosResponse<PaginatedTaxResidencies, any>>;
|
|
6
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAE1F,eAAO,MAAM,kBAAkB,GAAI,MAAM,mBAAmB,8DAE3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,MAAM,mBAAmB,8DAEzE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,sDAE9C,CAAC;AAIF,eAAO,MAAM,iBAAiB,4EAM7B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { webApiClient } from '../../api/apiClient';
|
|
2
|
+
import { API_ENDPOINTS } from './constants';
|
|
3
|
+
export const createTaxResidency = (data) => {
|
|
4
|
+
return webApiClient.post(API_ENDPOINTS.TAX_RESIDENCIES, data);
|
|
5
|
+
};
|
|
6
|
+
export const updateTaxResidency = (uuid, data) => {
|
|
7
|
+
return webApiClient.patch(`${API_ENDPOINTS.TAX_RESIDENCIES}${uuid}/`, data);
|
|
8
|
+
};
|
|
9
|
+
export const deleteTaxResidency = (uuid) => {
|
|
10
|
+
return webApiClient.delete(`${API_ENDPOINTS.TAX_RESIDENCIES}${uuid}/`);
|
|
11
|
+
};
|
|
12
|
+
// Fetch list of tax residencies with optional filtering
|
|
13
|
+
// Orders by is_primary descending (primary first), then by country name
|
|
14
|
+
export const getTaxResidencies = () => {
|
|
15
|
+
return webApiClient.get(API_ENDPOINTS.TAX_RESIDENCIES, {
|
|
16
|
+
params: {
|
|
17
|
+
order_by: '-is_primary,country',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tax Residency types and interfaces
|
|
3
|
+
*/
|
|
4
|
+
export interface TaxResidency {
|
|
5
|
+
uuid: string;
|
|
6
|
+
userProfile: string;
|
|
7
|
+
country: string;
|
|
8
|
+
isPrimary: boolean;
|
|
9
|
+
taxNumber: string;
|
|
10
|
+
isExempted: boolean;
|
|
11
|
+
exemptionReason: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface TaxResidencyPayload {
|
|
14
|
+
country: string;
|
|
15
|
+
isPrimary: boolean;
|
|
16
|
+
taxNumber: string;
|
|
17
|
+
isExempted: boolean;
|
|
18
|
+
exemptionReason: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface PaginatedTaxResidencies {
|
|
21
|
+
count: number;
|
|
22
|
+
next: string | null;
|
|
23
|
+
previous: string | null;
|
|
24
|
+
results: TaxResidency[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tax Residency utility functions
|
|
3
|
+
*/
|
|
4
|
+
import type { TaxResidency } from './types';
|
|
5
|
+
export declare const findPrimaryTaxResidency: (taxResidencies: TaxResidency[]) => TaxResidency | undefined;
|
|
6
|
+
export declare const filterTaxResidenciesByCountry: (taxResidencies: TaxResidency[], countryCode: string) => TaxResidency[];
|
|
7
|
+
export declare const hasTaxResidencyInCountry: (taxResidencies: TaxResidency[], countryCode: string) => boolean;
|
|
8
|
+
export declare const getNonExemptedTaxResidencies: (taxResidencies: TaxResidency[]) => TaxResidency[];
|
|
9
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/services/tax_residencies/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,eAAO,MAAM,uBAAuB,GAAI,gBAAgB,YAAY,EAAE,KAAG,YAAY,GAAG,SAEvF,CAAC;AAGF,eAAO,MAAM,6BAA6B,GAAI,gBAAgB,YAAY,EAAE,EAAE,aAAa,MAAM,KAAG,YAAY,EAE/G,CAAC;AAGF,eAAO,MAAM,wBAAwB,GAAI,gBAAgB,YAAY,EAAE,EAAE,aAAa,MAAM,KAAG,OAE9F,CAAC;AAGF,eAAO,MAAM,4BAA4B,GAAI,gBAAgB,YAAY,EAAE,KAAG,YAAY,EAEzF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tax Residency utility functions
|
|
3
|
+
*/
|
|
4
|
+
// Find primary tax residency
|
|
5
|
+
export const findPrimaryTaxResidency = (taxResidencies) => {
|
|
6
|
+
return taxResidencies.find((residency) => residency.isPrimary);
|
|
7
|
+
};
|
|
8
|
+
// Filter tax residencies by country
|
|
9
|
+
export const filterTaxResidenciesByCountry = (taxResidencies, countryCode) => {
|
|
10
|
+
return taxResidencies.filter((residency) => residency.country === countryCode);
|
|
11
|
+
};
|
|
12
|
+
// Check if user has tax residency in specific country
|
|
13
|
+
export const hasTaxResidencyInCountry = (taxResidencies, countryCode) => {
|
|
14
|
+
return taxResidencies.some((residency) => residency.country === countryCode);
|
|
15
|
+
};
|
|
16
|
+
// Get non-exempted tax residencies
|
|
17
|
+
export const getNonExemptedTaxResidencies = (taxResidencies) => {
|
|
18
|
+
return taxResidencies.filter((residency) => !residency.isExempted);
|
|
19
|
+
};
|