@cranberry-money/shared-utils 8.4.0 → 8.6.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 +4 -0
- package/dist/tax-residency.d.ts +67 -0
- package/dist/tax-residency.d.ts.map +1 -0
- package/dist/tax-residency.js +70 -0
- package/dist/withdrawal-status.d.ts +72 -0
- package/dist/withdrawal-status.d.ts.map +1 -0
- package/dist/withdrawal-status.js +127 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,4 +23,6 @@ export { validateAllocations } from './allocations';
|
|
|
23
23
|
export { calculatePortfolioValue, calculateHoldingAllocations, groupHoldingsByInstrument, filterHoldingsByMinQuantity, sortHoldings, } from './holdings';
|
|
24
24
|
export { processAllocationData, calculateTotals, formatPercentage, formatDashboardCurrency, type AllocationDisplayItem, } from './dashboard';
|
|
25
25
|
export { isValidTemplateSelection, validatePortfolioSelection, type PortfolioSelectionValidation, type PortfolioSelectionState, } from './portfolio-validation';
|
|
26
|
+
export { getStatusColor, getStatusLabel, getWithdrawalTypeLabel, getReasonLabel, getLiquidationStatusColor, getLiquidationStatusLabel, type WithdrawalStatus, type WithdrawalType, type WithdrawalReason, type LiquidationStatus, } from './withdrawal-status';
|
|
27
|
+
export { findPrimaryTaxResidency, filterTaxResidenciesByCountry, hasTaxResidencyInCountry, getNonExemptedTaxResidencies, type BaseTaxResidency, } from './tax-residency';
|
|
26
28
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MA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gBAAgB,EAChB,uBAAuB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,GAC7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,yBAAyB,EACzB,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -46,3 +46,7 @@ export { calculatePortfolioValue, calculateHoldingAllocations, groupHoldingsByIn
|
|
|
46
46
|
export { processAllocationData, calculateTotals, formatPercentage, formatDashboardCurrency, } from './dashboard';
|
|
47
47
|
// Portfolio validation utilities
|
|
48
48
|
export { isValidTemplateSelection, validatePortfolioSelection, } from './portfolio-validation';
|
|
49
|
+
// Withdrawal status utilities
|
|
50
|
+
export { getStatusColor, getStatusLabel, getWithdrawalTypeLabel, getReasonLabel, getLiquidationStatusColor, getLiquidationStatusLabel, } from './withdrawal-status';
|
|
51
|
+
// Tax residency utilities
|
|
52
|
+
export { findPrimaryTaxResidency, filterTaxResidenciesByCountry, hasTaxResidencyInCountry, getNonExemptedTaxResidencies, } from './tax-residency';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface BaseTaxResidency {
|
|
2
|
+
readonly country: string;
|
|
3
|
+
readonly isPrimary: boolean;
|
|
4
|
+
readonly isExempted: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Find the primary tax residency from a list
|
|
8
|
+
*
|
|
9
|
+
* @param taxResidencies - List of tax residencies
|
|
10
|
+
* @returns The primary tax residency if found, undefined otherwise
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const residencies = [
|
|
14
|
+
* { country: 'US', isPrimary: false, isExempted: false },
|
|
15
|
+
* { country: 'CA', isPrimary: true, isExempted: false }
|
|
16
|
+
* ];
|
|
17
|
+
* findPrimaryTaxResidency(residencies); // returns CA residency
|
|
18
|
+
*/
|
|
19
|
+
export declare const findPrimaryTaxResidency: <T extends BaseTaxResidency>(taxResidencies: readonly T[]) => T | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Filter tax residencies by country code
|
|
22
|
+
*
|
|
23
|
+
* @param taxResidencies - List of tax residencies
|
|
24
|
+
* @param countryCode - Country code to filter by
|
|
25
|
+
* @returns List of tax residencies for the specified country
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const residencies = [
|
|
29
|
+
* { country: 'US', isPrimary: true, isExempted: false },
|
|
30
|
+
* { country: 'US', isPrimary: false, isExempted: true },
|
|
31
|
+
* { country: 'CA', isPrimary: false, isExempted: false }
|
|
32
|
+
* ];
|
|
33
|
+
* filterTaxResidenciesByCountry(residencies, 'US'); // returns 2 US residencies
|
|
34
|
+
*/
|
|
35
|
+
export declare const filterTaxResidenciesByCountry: <T extends BaseTaxResidency>(taxResidencies: readonly T[], countryCode: string) => T[];
|
|
36
|
+
/**
|
|
37
|
+
* Check if user has tax residency in a specific country
|
|
38
|
+
*
|
|
39
|
+
* @param taxResidencies - List of tax residencies
|
|
40
|
+
* @param countryCode - Country code to check
|
|
41
|
+
* @returns True if user has residency in the country, false otherwise
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const residencies = [
|
|
45
|
+
* { country: 'US', isPrimary: true, isExempted: false },
|
|
46
|
+
* { country: 'CA', isPrimary: false, isExempted: false }
|
|
47
|
+
* ];
|
|
48
|
+
* hasTaxResidencyInCountry(residencies, 'US'); // returns true
|
|
49
|
+
* hasTaxResidencyInCountry(residencies, 'UK'); // returns false
|
|
50
|
+
*/
|
|
51
|
+
export declare const hasTaxResidencyInCountry: <T extends BaseTaxResidency>(taxResidencies: readonly T[], countryCode: string) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get all non-exempted tax residencies
|
|
54
|
+
*
|
|
55
|
+
* @param taxResidencies - List of tax residencies
|
|
56
|
+
* @returns List of non-exempted tax residencies
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* const residencies = [
|
|
60
|
+
* { country: 'US', isPrimary: true, isExempted: false },
|
|
61
|
+
* { country: 'CA', isPrimary: false, isExempted: true },
|
|
62
|
+
* { country: 'UK', isPrimary: false, isExempted: false }
|
|
63
|
+
* ];
|
|
64
|
+
* getNonExemptedTaxResidencies(residencies); // returns US and UK residencies
|
|
65
|
+
*/
|
|
66
|
+
export declare const getNonExemptedTaxResidencies: <T extends BaseTaxResidency>(taxResidencies: readonly T[]) => T[];
|
|
67
|
+
//# sourceMappingURL=tax-residency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tax-residency.d.ts","sourceRoot":"","sources":["../src/tax-residency.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,gBAAgB,EAChE,gBAAgB,SAAS,CAAC,EAAE,KAC3B,CAAC,GAAG,SAEN,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,6BAA6B,GAAI,CAAC,SAAS,gBAAgB,EACtE,gBAAgB,SAAS,CAAC,EAAE,EAC5B,aAAa,MAAM,KAClB,CAAC,EAEH,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,gBAAgB,EACjE,gBAAgB,SAAS,CAAC,EAAE,EAC5B,aAAa,MAAM,KAClB,OAEF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,4BAA4B,GAAI,CAAC,SAAS,gBAAgB,EACrE,gBAAgB,SAAS,CAAC,EAAE,KAC3B,CAAC,EAEH,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { findByField, hasItemWithFieldValue, filterByBooleanField } from './collections';
|
|
2
|
+
/**
|
|
3
|
+
* Find the primary tax residency from a list
|
|
4
|
+
*
|
|
5
|
+
* @param taxResidencies - List of tax residencies
|
|
6
|
+
* @returns The primary tax residency if found, undefined otherwise
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const residencies = [
|
|
10
|
+
* { country: 'US', isPrimary: false, isExempted: false },
|
|
11
|
+
* { country: 'CA', isPrimary: true, isExempted: false }
|
|
12
|
+
* ];
|
|
13
|
+
* findPrimaryTaxResidency(residencies); // returns CA residency
|
|
14
|
+
*/
|
|
15
|
+
export const findPrimaryTaxResidency = (taxResidencies) => {
|
|
16
|
+
return findByField([...taxResidencies], 'isPrimary', true);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Filter tax residencies by country code
|
|
20
|
+
*
|
|
21
|
+
* @param taxResidencies - List of tax residencies
|
|
22
|
+
* @param countryCode - Country code to filter by
|
|
23
|
+
* @returns List of tax residencies for the specified country
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const residencies = [
|
|
27
|
+
* { country: 'US', isPrimary: true, isExempted: false },
|
|
28
|
+
* { country: 'US', isPrimary: false, isExempted: true },
|
|
29
|
+
* { country: 'CA', isPrimary: false, isExempted: false }
|
|
30
|
+
* ];
|
|
31
|
+
* filterTaxResidenciesByCountry(residencies, 'US'); // returns 2 US residencies
|
|
32
|
+
*/
|
|
33
|
+
export const filterTaxResidenciesByCountry = (taxResidencies, countryCode) => {
|
|
34
|
+
return taxResidencies.filter((residency) => residency.country === countryCode);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Check if user has tax residency in a specific country
|
|
38
|
+
*
|
|
39
|
+
* @param taxResidencies - List of tax residencies
|
|
40
|
+
* @param countryCode - Country code to check
|
|
41
|
+
* @returns True if user has residency in the country, false otherwise
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const residencies = [
|
|
45
|
+
* { country: 'US', isPrimary: true, isExempted: false },
|
|
46
|
+
* { country: 'CA', isPrimary: false, isExempted: false }
|
|
47
|
+
* ];
|
|
48
|
+
* hasTaxResidencyInCountry(residencies, 'US'); // returns true
|
|
49
|
+
* hasTaxResidencyInCountry(residencies, 'UK'); // returns false
|
|
50
|
+
*/
|
|
51
|
+
export const hasTaxResidencyInCountry = (taxResidencies, countryCode) => {
|
|
52
|
+
return hasItemWithFieldValue([...taxResidencies], 'country', countryCode);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Get all non-exempted tax residencies
|
|
56
|
+
*
|
|
57
|
+
* @param taxResidencies - List of tax residencies
|
|
58
|
+
* @returns List of non-exempted tax residencies
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* const residencies = [
|
|
62
|
+
* { country: 'US', isPrimary: true, isExempted: false },
|
|
63
|
+
* { country: 'CA', isPrimary: false, isExempted: true },
|
|
64
|
+
* { country: 'UK', isPrimary: false, isExempted: false }
|
|
65
|
+
* ];
|
|
66
|
+
* getNonExemptedTaxResidencies(residencies); // returns US and UK residencies
|
|
67
|
+
*/
|
|
68
|
+
export const getNonExemptedTaxResidencies = (taxResidencies) => {
|
|
69
|
+
return filterByBooleanField([...taxResidencies], 'isExempted', false);
|
|
70
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { WITHDRAWAL_STATUS_PENDING_REVIEW, WITHDRAWAL_STATUS_APPROVED, WITHDRAWAL_STATUS_REJECTED, WITHDRAWAL_STATUS_PROCESSING, WITHDRAWAL_STATUS_AWAITING_LIQUIDATION, WITHDRAWAL_STATUS_LIQUIDATION_IN_PROGRESS, WITHDRAWAL_STATUS_COMPLETED, WITHDRAWAL_STATUS_CANCELLED, WITHDRAWAL_STATUS_FAILED, WITHDRAWAL_TYPE_FULL_CASH, WITHDRAWAL_TYPE_PARTIAL_CASH, WITHDRAWAL_REASON_INVESTMENT_STRATEGY, WITHDRAWAL_REASON_PERSONAL_EXPENSES, WITHDRAWAL_REASON_EMERGENCY, WITHDRAWAL_REASON_OTHER, LIQUIDATION_STATUS_PENDING, LIQUIDATION_STATUS_TRADES_CREATED, LIQUIDATION_STATUS_EXECUTED, LIQUIDATION_STATUS_SETTLED, LIQUIDATION_STATUS_FAILED } from '@cranberry-money/shared-constants';
|
|
2
|
+
export type WithdrawalStatus = typeof WITHDRAWAL_STATUS_PENDING_REVIEW | typeof WITHDRAWAL_STATUS_APPROVED | typeof WITHDRAWAL_STATUS_REJECTED | typeof WITHDRAWAL_STATUS_PROCESSING | typeof WITHDRAWAL_STATUS_AWAITING_LIQUIDATION | typeof WITHDRAWAL_STATUS_LIQUIDATION_IN_PROGRESS | typeof WITHDRAWAL_STATUS_COMPLETED | typeof WITHDRAWAL_STATUS_CANCELLED | typeof WITHDRAWAL_STATUS_FAILED;
|
|
3
|
+
export type WithdrawalType = typeof WITHDRAWAL_TYPE_FULL_CASH | typeof WITHDRAWAL_TYPE_PARTIAL_CASH;
|
|
4
|
+
export type WithdrawalReason = typeof WITHDRAWAL_REASON_INVESTMENT_STRATEGY | typeof WITHDRAWAL_REASON_PERSONAL_EXPENSES | typeof WITHDRAWAL_REASON_EMERGENCY | typeof WITHDRAWAL_REASON_OTHER;
|
|
5
|
+
export type LiquidationStatus = typeof LIQUIDATION_STATUS_PENDING | typeof LIQUIDATION_STATUS_TRADES_CREATED | typeof LIQUIDATION_STATUS_EXECUTED | typeof LIQUIDATION_STATUS_SETTLED | typeof LIQUIDATION_STATUS_FAILED;
|
|
6
|
+
/**
|
|
7
|
+
* Get the color class for a withdrawal status
|
|
8
|
+
*
|
|
9
|
+
* @param status - The withdrawal status
|
|
10
|
+
* @returns The corresponding color class string
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* getStatusColor('pending_review'); // returns 'text-warning-600'
|
|
14
|
+
* getStatusColor('completed'); // returns 'text-success-600'
|
|
15
|
+
*/
|
|
16
|
+
export declare const getStatusColor: (status: WithdrawalStatus) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Get the display label for a withdrawal status
|
|
19
|
+
*
|
|
20
|
+
* @param status - The withdrawal status
|
|
21
|
+
* @returns The human-readable label
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* getStatusLabel('pending_review'); // returns 'Pending Review'
|
|
25
|
+
* getStatusLabel('liquidation_in_progress'); // returns 'Liquidation in Progress'
|
|
26
|
+
*/
|
|
27
|
+
export declare const getStatusLabel: (status: WithdrawalStatus) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Get the display label for a withdrawal type
|
|
30
|
+
*
|
|
31
|
+
* @param type - The withdrawal type
|
|
32
|
+
* @returns The human-readable label
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* getWithdrawalTypeLabel('full_cash'); // returns 'Full Cash'
|
|
36
|
+
* getWithdrawalTypeLabel('partial_cash'); // returns 'Partial Cash'
|
|
37
|
+
*/
|
|
38
|
+
export declare const getWithdrawalTypeLabel: (type: WithdrawalType) => string;
|
|
39
|
+
/**
|
|
40
|
+
* Get the display label for a withdrawal reason
|
|
41
|
+
*
|
|
42
|
+
* @param reason - The withdrawal reason (optional)
|
|
43
|
+
* @returns The human-readable label
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* getReasonLabel('investment_strategy'); // returns 'Investment Strategy'
|
|
47
|
+
* getReasonLabel(null); // returns 'Not specified'
|
|
48
|
+
*/
|
|
49
|
+
export declare const getReasonLabel: (reason: WithdrawalReason | null | undefined) => string;
|
|
50
|
+
/**
|
|
51
|
+
* Get the color class for a liquidation status
|
|
52
|
+
*
|
|
53
|
+
* @param status - The liquidation status
|
|
54
|
+
* @returns The corresponding color class string
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* getLiquidationStatusColor('pending'); // returns 'text-warning-600'
|
|
58
|
+
* getLiquidationStatusColor('settled'); // returns 'text-success-600'
|
|
59
|
+
*/
|
|
60
|
+
export declare const getLiquidationStatusColor: (status: LiquidationStatus) => string;
|
|
61
|
+
/**
|
|
62
|
+
* Get the display label for a liquidation status
|
|
63
|
+
*
|
|
64
|
+
* @param status - The liquidation status
|
|
65
|
+
* @returns The human-readable label
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* getLiquidationStatusLabel('trades_created'); // returns 'Trades Created'
|
|
69
|
+
* getLiquidationStatusLabel('executed'); // returns 'Executed'
|
|
70
|
+
*/
|
|
71
|
+
export declare const getLiquidationStatusLabel: (status: LiquidationStatus) => string;
|
|
72
|
+
//# sourceMappingURL=withdrawal-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdrawal-status.d.ts","sourceRoot":"","sources":["../src/withdrawal-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,gCAAgC,EAChC,0BAA0B,EAC1B,0BAA0B,EAC1B,4BAA4B,EAC5B,sCAAsC,EACtC,yCAAyC,EACzC,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EAUxB,yBAAyB,EACzB,4BAA4B,EAG5B,qCAAqC,EACrC,mCAAmC,EACnC,2BAA2B,EAC3B,uBAAuB,EAKvB,0BAA0B,EAC1B,iCAAiC,EACjC,2BAA2B,EAC3B,0BAA0B,EAC1B,yBAAyB,EAM1B,MAAM,mCAAmC,CAAC;AAG3C,MAAM,MAAM,gBAAgB,GACxB,OAAO,gCAAgC,GACvC,OAAO,0BAA0B,GACjC,OAAO,0BAA0B,GACjC,OAAO,4BAA4B,GACnC,OAAO,sCAAsC,GAC7C,OAAO,yCAAyC,GAChD,OAAO,2BAA2B,GAClC,OAAO,2BAA2B,GAClC,OAAO,wBAAwB,CAAC;AAEpC,MAAM,MAAM,cAAc,GAAG,OAAO,yBAAyB,GAAG,OAAO,4BAA4B,CAAC;AAEpG,MAAM,MAAM,gBAAgB,GACxB,OAAO,qCAAqC,GAC5C,OAAO,mCAAmC,GAC1C,OAAO,2BAA2B,GAClC,OAAO,uBAAuB,CAAC;AAEnC,MAAM,MAAM,iBAAiB,GACzB,OAAO,0BAA0B,GACjC,OAAO,iCAAiC,GACxC,OAAO,2BAA2B,GAClC,OAAO,0BAA0B,GACjC,OAAO,yBAAyB,CAAC;AAErC;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,gBAAgB,KAAG,MAazD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,gBAAgB,KAAG,MAazD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,cAAc,KAAG,MAM7D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,gBAAgB,GAAG,IAAI,GAAG,SAAS,KAAG,MAU5E,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,iBAAiB,KAAG,MASrE,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,iBAAiB,KAAG,MASrE,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { STATUS_COLOR_PENDING, STATUS_COLOR_APPROVED, STATUS_COLOR_REJECTED, STATUS_COLOR_PROCESSING, STATUS_COLOR_AWAITING, STATUS_COLOR_IN_PROGRESS, STATUS_COLOR_COMPLETED, STATUS_COLOR_CANCELLED, STATUS_COLOR_FAILED, STATUS_COLOR_DEFAULT, WITHDRAWAL_STATUS_PENDING_REVIEW, WITHDRAWAL_STATUS_APPROVED, WITHDRAWAL_STATUS_REJECTED, WITHDRAWAL_STATUS_PROCESSING, WITHDRAWAL_STATUS_AWAITING_LIQUIDATION, WITHDRAWAL_STATUS_LIQUIDATION_IN_PROGRESS, WITHDRAWAL_STATUS_COMPLETED, WITHDRAWAL_STATUS_CANCELLED, WITHDRAWAL_STATUS_FAILED, WITHDRAWAL_STATUS_LABEL_PENDING_REVIEW, WITHDRAWAL_STATUS_LABEL_APPROVED, WITHDRAWAL_STATUS_LABEL_REJECTED, WITHDRAWAL_STATUS_LABEL_PROCESSING, WITHDRAWAL_STATUS_LABEL_AWAITING_LIQUIDATION, WITHDRAWAL_STATUS_LABEL_LIQUIDATION_IN_PROGRESS, WITHDRAWAL_STATUS_LABEL_COMPLETED, WITHDRAWAL_STATUS_LABEL_CANCELLED, WITHDRAWAL_STATUS_LABEL_FAILED, WITHDRAWAL_TYPE_FULL_CASH, WITHDRAWAL_TYPE_PARTIAL_CASH, WITHDRAWAL_TYPE_LABEL_FULL_CASH, WITHDRAWAL_TYPE_LABEL_PARTIAL_CASH, WITHDRAWAL_REASON_INVESTMENT_STRATEGY, WITHDRAWAL_REASON_PERSONAL_EXPENSES, WITHDRAWAL_REASON_EMERGENCY, WITHDRAWAL_REASON_OTHER, WITHDRAWAL_REASON_LABEL_INVESTMENT_STRATEGY, WITHDRAWAL_REASON_LABEL_PERSONAL_EXPENSES, WITHDRAWAL_REASON_LABEL_EMERGENCY, WITHDRAWAL_REASON_LABEL_OTHER, LIQUIDATION_STATUS_PENDING, LIQUIDATION_STATUS_TRADES_CREATED, LIQUIDATION_STATUS_EXECUTED, LIQUIDATION_STATUS_SETTLED, LIQUIDATION_STATUS_FAILED, LIQUIDATION_STATUS_LABEL_PENDING, LIQUIDATION_STATUS_LABEL_TRADES_CREATED, LIQUIDATION_STATUS_LABEL_EXECUTED, LIQUIDATION_STATUS_LABEL_SETTLED, LIQUIDATION_STATUS_LABEL_FAILED, } from '@cranberry-money/shared-constants';
|
|
2
|
+
/**
|
|
3
|
+
* Get the color class for a withdrawal status
|
|
4
|
+
*
|
|
5
|
+
* @param status - The withdrawal status
|
|
6
|
+
* @returns The corresponding color class string
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* getStatusColor('pending_review'); // returns 'text-warning-600'
|
|
10
|
+
* getStatusColor('completed'); // returns 'text-success-600'
|
|
11
|
+
*/
|
|
12
|
+
export const getStatusColor = (status) => {
|
|
13
|
+
const statusColors = {
|
|
14
|
+
[WITHDRAWAL_STATUS_PENDING_REVIEW]: STATUS_COLOR_PENDING,
|
|
15
|
+
[WITHDRAWAL_STATUS_APPROVED]: STATUS_COLOR_APPROVED,
|
|
16
|
+
[WITHDRAWAL_STATUS_REJECTED]: STATUS_COLOR_REJECTED,
|
|
17
|
+
[WITHDRAWAL_STATUS_PROCESSING]: STATUS_COLOR_PROCESSING,
|
|
18
|
+
[WITHDRAWAL_STATUS_AWAITING_LIQUIDATION]: STATUS_COLOR_AWAITING,
|
|
19
|
+
[WITHDRAWAL_STATUS_LIQUIDATION_IN_PROGRESS]: STATUS_COLOR_IN_PROGRESS,
|
|
20
|
+
[WITHDRAWAL_STATUS_COMPLETED]: STATUS_COLOR_COMPLETED,
|
|
21
|
+
[WITHDRAWAL_STATUS_CANCELLED]: STATUS_COLOR_CANCELLED,
|
|
22
|
+
[WITHDRAWAL_STATUS_FAILED]: STATUS_COLOR_FAILED,
|
|
23
|
+
};
|
|
24
|
+
return statusColors[status] || STATUS_COLOR_DEFAULT;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Get the display label for a withdrawal status
|
|
28
|
+
*
|
|
29
|
+
* @param status - The withdrawal status
|
|
30
|
+
* @returns The human-readable label
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* getStatusLabel('pending_review'); // returns 'Pending Review'
|
|
34
|
+
* getStatusLabel('liquidation_in_progress'); // returns 'Liquidation in Progress'
|
|
35
|
+
*/
|
|
36
|
+
export const getStatusLabel = (status) => {
|
|
37
|
+
const statusLabels = {
|
|
38
|
+
[WITHDRAWAL_STATUS_PENDING_REVIEW]: WITHDRAWAL_STATUS_LABEL_PENDING_REVIEW,
|
|
39
|
+
[WITHDRAWAL_STATUS_APPROVED]: WITHDRAWAL_STATUS_LABEL_APPROVED,
|
|
40
|
+
[WITHDRAWAL_STATUS_REJECTED]: WITHDRAWAL_STATUS_LABEL_REJECTED,
|
|
41
|
+
[WITHDRAWAL_STATUS_PROCESSING]: WITHDRAWAL_STATUS_LABEL_PROCESSING,
|
|
42
|
+
[WITHDRAWAL_STATUS_AWAITING_LIQUIDATION]: WITHDRAWAL_STATUS_LABEL_AWAITING_LIQUIDATION,
|
|
43
|
+
[WITHDRAWAL_STATUS_LIQUIDATION_IN_PROGRESS]: WITHDRAWAL_STATUS_LABEL_LIQUIDATION_IN_PROGRESS,
|
|
44
|
+
[WITHDRAWAL_STATUS_COMPLETED]: WITHDRAWAL_STATUS_LABEL_COMPLETED,
|
|
45
|
+
[WITHDRAWAL_STATUS_CANCELLED]: WITHDRAWAL_STATUS_LABEL_CANCELLED,
|
|
46
|
+
[WITHDRAWAL_STATUS_FAILED]: WITHDRAWAL_STATUS_LABEL_FAILED,
|
|
47
|
+
};
|
|
48
|
+
return statusLabels[status] || status;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Get the display label for a withdrawal type
|
|
52
|
+
*
|
|
53
|
+
* @param type - The withdrawal type
|
|
54
|
+
* @returns The human-readable label
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* getWithdrawalTypeLabel('full_cash'); // returns 'Full Cash'
|
|
58
|
+
* getWithdrawalTypeLabel('partial_cash'); // returns 'Partial Cash'
|
|
59
|
+
*/
|
|
60
|
+
export const getWithdrawalTypeLabel = (type) => {
|
|
61
|
+
const typeLabels = {
|
|
62
|
+
[WITHDRAWAL_TYPE_FULL_CASH]: WITHDRAWAL_TYPE_LABEL_FULL_CASH,
|
|
63
|
+
[WITHDRAWAL_TYPE_PARTIAL_CASH]: WITHDRAWAL_TYPE_LABEL_PARTIAL_CASH,
|
|
64
|
+
};
|
|
65
|
+
return typeLabels[type] || type;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Get the display label for a withdrawal reason
|
|
69
|
+
*
|
|
70
|
+
* @param reason - The withdrawal reason (optional)
|
|
71
|
+
* @returns The human-readable label
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* getReasonLabel('investment_strategy'); // returns 'Investment Strategy'
|
|
75
|
+
* getReasonLabel(null); // returns 'Not specified'
|
|
76
|
+
*/
|
|
77
|
+
export const getReasonLabel = (reason) => {
|
|
78
|
+
if (!reason)
|
|
79
|
+
return 'Not specified';
|
|
80
|
+
const reasonLabels = {
|
|
81
|
+
[WITHDRAWAL_REASON_INVESTMENT_STRATEGY]: WITHDRAWAL_REASON_LABEL_INVESTMENT_STRATEGY,
|
|
82
|
+
[WITHDRAWAL_REASON_PERSONAL_EXPENSES]: WITHDRAWAL_REASON_LABEL_PERSONAL_EXPENSES,
|
|
83
|
+
[WITHDRAWAL_REASON_EMERGENCY]: WITHDRAWAL_REASON_LABEL_EMERGENCY,
|
|
84
|
+
[WITHDRAWAL_REASON_OTHER]: WITHDRAWAL_REASON_LABEL_OTHER,
|
|
85
|
+
};
|
|
86
|
+
return reasonLabels[reason] || reason;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Get the color class for a liquidation status
|
|
90
|
+
*
|
|
91
|
+
* @param status - The liquidation status
|
|
92
|
+
* @returns The corresponding color class string
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* getLiquidationStatusColor('pending'); // returns 'text-warning-600'
|
|
96
|
+
* getLiquidationStatusColor('settled'); // returns 'text-success-600'
|
|
97
|
+
*/
|
|
98
|
+
export const getLiquidationStatusColor = (status) => {
|
|
99
|
+
const statusColors = {
|
|
100
|
+
[LIQUIDATION_STATUS_PENDING]: 'text-warning-600',
|
|
101
|
+
[LIQUIDATION_STATUS_TRADES_CREATED]: 'text-primary-600',
|
|
102
|
+
[LIQUIDATION_STATUS_EXECUTED]: 'text-accent-secondary',
|
|
103
|
+
[LIQUIDATION_STATUS_SETTLED]: 'text-success-600',
|
|
104
|
+
[LIQUIDATION_STATUS_FAILED]: 'text-error-600',
|
|
105
|
+
};
|
|
106
|
+
return statusColors[status] || 'text-content-muted';
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Get the display label for a liquidation status
|
|
110
|
+
*
|
|
111
|
+
* @param status - The liquidation status
|
|
112
|
+
* @returns The human-readable label
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* getLiquidationStatusLabel('trades_created'); // returns 'Trades Created'
|
|
116
|
+
* getLiquidationStatusLabel('executed'); // returns 'Executed'
|
|
117
|
+
*/
|
|
118
|
+
export const getLiquidationStatusLabel = (status) => {
|
|
119
|
+
const statusLabels = {
|
|
120
|
+
[LIQUIDATION_STATUS_PENDING]: LIQUIDATION_STATUS_LABEL_PENDING,
|
|
121
|
+
[LIQUIDATION_STATUS_TRADES_CREATED]: LIQUIDATION_STATUS_LABEL_TRADES_CREATED,
|
|
122
|
+
[LIQUIDATION_STATUS_EXECUTED]: LIQUIDATION_STATUS_LABEL_EXECUTED,
|
|
123
|
+
[LIQUIDATION_STATUS_SETTLED]: LIQUIDATION_STATUS_LABEL_SETTLED,
|
|
124
|
+
[LIQUIDATION_STATUS_FAILED]: LIQUIDATION_STATUS_LABEL_FAILED,
|
|
125
|
+
};
|
|
126
|
+
return statusLabels[status] || status;
|
|
127
|
+
};
|