@cranberry-money/shared-utils 8.17.35 → 8.17.37
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/document.d.ts.map +1 -1
- package/dist/document.js +3 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/instruments.d.ts +1 -49
- package/dist/instruments.d.ts.map +1 -1
- package/dist/instruments.js +1 -100
- package/dist/portfolio-template.d.ts.map +1 -1
- package/dist/portfolio-template.js +3 -2
- package/dist/withdrawal.d.ts +1 -39
- package/dist/withdrawal.d.ts.map +1 -1
- package/dist/withdrawal.js +1 -58
- package/package.json +1 -1
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAAI,cAAc,MAAM,EAAE,cAAc,MAAM,KAAG,MAErF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,GAAI,cAAc,MAAM,KAAG,MAgBzD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,KAAG,MAGrD,CAAC"}
|
package/dist/document.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { generateTimestampedFilename } from './downloads';
|
|
2
|
-
import { formatStatus } from './formatting';
|
|
3
2
|
import { DOCUMENT_TYPE_MDA, DOCUMENT_TYPE_SOA, DOCUMENT_TYPE_AGREEMENT, DOCUMENT_TYPE_LABELS, } from '@cranberry-money/shared-constants';
|
|
4
3
|
/**
|
|
5
4
|
* Generate filename for document downloads
|
|
@@ -52,5 +51,7 @@ export const formatDocumentType = (documentType) => {
|
|
|
52
51
|
* formatDocumentStatus('archived'); // returns 'Archived'
|
|
53
52
|
*/
|
|
54
53
|
export const formatDocumentStatus = (status) => {
|
|
55
|
-
|
|
54
|
+
if (!status)
|
|
55
|
+
return status;
|
|
56
|
+
return status.charAt(0).toUpperCase() + status.slice(1).toLowerCase();
|
|
56
57
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -10,14 +10,13 @@ export { NUMBER_FORMAT_OPTIONS_CURRENCY, NUMBER_FORMAT_OPTIONS_CURRENCY_SIGNED,
|
|
|
10
10
|
export { createBadge, BADGE_VARIANTS, BADGE_SIZES } from './badge';
|
|
11
11
|
export { getTradeStatusBadge, getWithdrawalStatusBadge, getLiquidationStatusBadge, getTargetTradeStatusBadge, } from './badge-status';
|
|
12
12
|
export { formatPortfolioValue, calculateTotalValue, getMarketAllocation, getCashAllocation } from './portfolio';
|
|
13
|
-
export {
|
|
13
|
+
export { calculateLiquidationProgress, getTotalEstimatedValue, } from './withdrawal';
|
|
14
14
|
export { isNumericOnly, validatePassword, isValidTokenFormat, formatVerificationToken, validateEmailConfirmation, isValidEmail, hasUppercase, hasLowercase, hasSpecialCharacter, hasDigit, validatePasswordExtended, isValidPhoneNumber, isValidPhoneFormat, isValidUrl, isValidDate, isEmptyOrWhitespace, meetsMinLength, meetsMaxLength, isInRange, isPositiveNumber, isNonNegativeNumber, isValidFullName, isValidDateOfBirth, formatPhoneNumber, isValidInvestmentAmount, isValidSourceOfFunds, hasMinimumSelection, isSelected, validatePercentageSum, validateAllocationSum, isInNumberRange, isValidPercentage, } from './validation';
|
|
15
15
|
export { hasActiveFilters, countActiveFilters, clearAllFilters, updateFilters, isFilterEmpty, removeEmptyFilters, mergeFilters, areFiltersEqual, createFilterPredicate, hasActiveInstrumentFilters, countActiveInstrumentFilters, hasActiveTradeFilters, countActiveTradeFilters, hasActiveTransactionFilters, countActiveTransactionFilters, hasActiveTargetTradeFilters, countActiveTargetTradeFilters, } from './filters';
|
|
16
16
|
export { isTokenExpired, isTokenExpiringSoon, getTimeUntilExpiry, formatTimeUntilExpiry, parseDeviceInfo, isRefreshSuccess, getRefreshErrorMessage, createAutoRefreshHandler, } from './auth';
|
|
17
|
-
export { formatInstrumentPrice, getCurrencySymbol,
|
|
17
|
+
export { formatInstrumentPrice, getCurrencySymbol, } from './instruments';
|
|
18
18
|
export { sortByStringField, filterByTextSearch, filterByBooleanField, findByField, findByStringField, extractAndSortField, groupByFirstLetter, groupByField, hasItemWithFieldValue, countByFieldValue, } from './collections';
|
|
19
19
|
export { downloadBlob, downloadTextFile, downloadJsonFile, generateTimestampedFilename, downloadDataUrl, downloadCsvFile, } from './downloads';
|
|
20
|
-
export { capitalizeFirstLetter, formatStatus, formatRiskLevel, capitalizeFirst, formatLabel, camelToTitle, } from './formatting';
|
|
21
20
|
export { formatQuantityWithSuffix, formatLargeNumber, formatAsPercentage, formatWithSeparators, roundToDecimals, clampNumber, } from './numbers';
|
|
22
21
|
export { validateAllocations } from './allocations';
|
|
23
22
|
export { calculatePortfolioValue, calculateHoldingAllocations, groupHoldingsByInstrument, filterHoldingsByMinQuantity, sortHoldings, } from './holdings';
|
|
@@ -33,3 +32,4 @@ export { sortCountriesByName, filterCountriesByName, filterAvailableCountries, f
|
|
|
33
32
|
export { calculateTotalAllocation, validateAllocationPercentages, formatRiskLevelDisplay, type BaseAllocation, } from './portfolio-template';
|
|
34
33
|
export { validateInvestmentAmount, formatInvestmentAmount } from './investment-preference';
|
|
35
34
|
export { formatBalance, formatTransactionAmount, getTransactionTypeLabel, type BaseTransactionType, } from './cash-account';
|
|
35
|
+
//# 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,U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B,EAC7B,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,4BAA4B,EAC5B,yBAAyB,EACzB,kBAAkB,EAClB,KAAK,WAAW,IAAI,eAAe,GACpC,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAG3F,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,uBAAuB,EACvB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export { getTradeStatusBadge, getWithdrawalStatusBadge, getLiquidationStatusBadg
|
|
|
17
17
|
// Portfolio utilities
|
|
18
18
|
export { formatPortfolioValue, calculateTotalValue, getMarketAllocation, getCashAllocation } from './portfolio';
|
|
19
19
|
// Withdrawal utilities
|
|
20
|
-
export {
|
|
20
|
+
export { calculateLiquidationProgress, getTotalEstimatedValue, } from './withdrawal';
|
|
21
21
|
// Validation utilities
|
|
22
22
|
export { isNumericOnly, validatePassword, isValidTokenFormat, formatVerificationToken, validateEmailConfirmation, isValidEmail, hasUppercase, hasLowercase, hasSpecialCharacter, hasDigit, validatePasswordExtended, isValidPhoneNumber, isValidPhoneFormat, isValidUrl, isValidDate, isEmptyOrWhitespace, meetsMinLength, meetsMaxLength, isInRange, isPositiveNumber, isNonNegativeNumber, isValidFullName, isValidDateOfBirth, formatPhoneNumber, isValidInvestmentAmount, isValidSourceOfFunds, hasMinimumSelection, isSelected,
|
|
23
23
|
// Enhanced validation utilities (Phase 14)
|
|
@@ -29,13 +29,11 @@ hasActiveInstrumentFilters, countActiveInstrumentFilters, hasActiveTradeFilters,
|
|
|
29
29
|
// Authentication utilities
|
|
30
30
|
export { isTokenExpired, isTokenExpiringSoon, getTimeUntilExpiry, formatTimeUntilExpiry, parseDeviceInfo, isRefreshSuccess, getRefreshErrorMessage, createAutoRefreshHandler, } from './auth';
|
|
31
31
|
// Instrument utilities
|
|
32
|
-
export { formatInstrumentPrice, getCurrencySymbol,
|
|
32
|
+
export { formatInstrumentPrice, getCurrencySymbol, } from './instruments';
|
|
33
33
|
// Collection utilities
|
|
34
34
|
export { sortByStringField, filterByTextSearch, filterByBooleanField, findByField, findByStringField, extractAndSortField, groupByFirstLetter, groupByField, hasItemWithFieldValue, countByFieldValue, } from './collections';
|
|
35
35
|
// Download utilities
|
|
36
36
|
export { downloadBlob, downloadTextFile, downloadJsonFile, generateTimestampedFilename, downloadDataUrl, downloadCsvFile, } from './downloads';
|
|
37
|
-
// String formatting utilities
|
|
38
|
-
export { capitalizeFirstLetter, formatStatus, formatRiskLevel, capitalizeFirst, formatLabel, camelToTitle, } from './formatting';
|
|
39
37
|
// Number formatting utilities
|
|
40
38
|
export { formatQuantityWithSuffix, formatLargeNumber, formatAsPercentage, formatWithSeparators, roundToDecimals, clampNumber, } from './numbers';
|
|
41
39
|
// Allocation utilities
|
package/dist/instruments.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instrument and market data formatting utilities
|
|
3
3
|
*/
|
|
4
|
-
import type { InstrumentTypeInfo, InstrumentBasicInfo, PriceChangeResult, PriceSnapshot, FormattedPriceChange, TradeableInstrument, MarketDataInfo } from '@cranberry-money/shared-types';
|
|
5
4
|
/**
|
|
6
5
|
* Format instrument price with currency symbol
|
|
7
6
|
* @param price - The price as string
|
|
@@ -15,51 +14,4 @@ export declare function formatInstrumentPrice(price: string, currency?: string |
|
|
|
15
14
|
* @returns Currency symbol
|
|
16
15
|
*/
|
|
17
16
|
export declare function getCurrencySymbol(currency?: string | null): string;
|
|
18
|
-
|
|
19
|
-
* Determine instrument type based on flags
|
|
20
|
-
* @param instrument - The instrument with type flags
|
|
21
|
-
* @returns Instrument type string
|
|
22
|
-
*/
|
|
23
|
-
export declare function getInstrumentType(instrument: InstrumentTypeInfo): string;
|
|
24
|
-
/**
|
|
25
|
-
* Format instrument display name with symbol
|
|
26
|
-
* @param instrument - The instrument with symbol and name
|
|
27
|
-
* @returns Formatted display name
|
|
28
|
-
*/
|
|
29
|
-
export declare function formatInstrumentName(instrument: InstrumentBasicInfo): string;
|
|
30
|
-
/**
|
|
31
|
-
* Calculate price change from snapshot
|
|
32
|
-
* @param snapshot - The price snapshot
|
|
33
|
-
* @returns Price change calculation result
|
|
34
|
-
*/
|
|
35
|
-
export declare function calculatePriceChange(snapshot: PriceSnapshot): PriceChangeResult;
|
|
36
|
-
/**
|
|
37
|
-
* Format price change with appropriate color class
|
|
38
|
-
* @param snapshot - The price snapshot
|
|
39
|
-
* @returns Formatted price change with color class
|
|
40
|
-
*/
|
|
41
|
-
export declare function formatPriceChange(snapshot: PriceSnapshot): FormattedPriceChange;
|
|
42
|
-
/**
|
|
43
|
-
* Check if instrument is actively tradeable
|
|
44
|
-
* @param instrument - The instrument with trading flags
|
|
45
|
-
* @returns true if tradeable, false otherwise
|
|
46
|
-
*/
|
|
47
|
-
export declare function isInstrumentTradeable(instrument: TradeableInstrument): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Format market cap value
|
|
50
|
-
* @param marketCap - The market cap value as string or null
|
|
51
|
-
* @returns Formatted market cap string
|
|
52
|
-
*/
|
|
53
|
-
export declare function formatMarketCap(marketCap: string | null | undefined): string;
|
|
54
|
-
/**
|
|
55
|
-
* Format trading volume
|
|
56
|
-
* @param volume - The volume number
|
|
57
|
-
* @returns Formatted volume string
|
|
58
|
-
*/
|
|
59
|
-
export declare function formatVolume(volume: number): string;
|
|
60
|
-
/**
|
|
61
|
-
* Check if market data is available
|
|
62
|
-
* @param marketData - The market data to check
|
|
63
|
-
* @returns true if market data is available, false otherwise
|
|
64
|
-
*/
|
|
65
|
-
export declare function hasMarketData(marketData: MarketDataInfo): boolean;
|
|
17
|
+
//# sourceMappingURL=instruments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruments.d.ts","sourceRoot":"","sources":["../src/instruments.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"instruments.d.ts","sourceRoot":"","sources":["../src/instruments.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAMrF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAalE"}
|
package/dist/instruments.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Instrument and market data formatting utilities
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { CURRENCY_USD, CURRENCY_AUD, } from '@cranberry-money/shared-constants';
|
|
5
5
|
/**
|
|
6
6
|
* Format instrument price with currency symbol
|
|
7
7
|
* @param price - The price as string
|
|
@@ -34,102 +34,3 @@ export function getCurrencySymbol(currency) {
|
|
|
34
34
|
return '$'; // Default to USD symbol
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Determine instrument type based on flags
|
|
39
|
-
* @param instrument - The instrument with type flags
|
|
40
|
-
* @returns Instrument type string
|
|
41
|
-
*/
|
|
42
|
-
export function getInstrumentType(instrument) {
|
|
43
|
-
if (instrument.isEtf)
|
|
44
|
-
return INSTRUMENT_TYPE_ETF;
|
|
45
|
-
if (instrument.isFund)
|
|
46
|
-
return INSTRUMENT_TYPE_FUND;
|
|
47
|
-
return INSTRUMENT_TYPE_STOCK;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Format instrument display name with symbol
|
|
51
|
-
* @param instrument - The instrument with symbol and name
|
|
52
|
-
* @returns Formatted display name
|
|
53
|
-
*/
|
|
54
|
-
export function formatInstrumentName(instrument) {
|
|
55
|
-
return `${instrument.symbol} - ${instrument.name}`;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Calculate price change from snapshot
|
|
59
|
-
* @param snapshot - The price snapshot
|
|
60
|
-
* @returns Price change calculation result
|
|
61
|
-
*/
|
|
62
|
-
export function calculatePriceChange(snapshot) {
|
|
63
|
-
const change = parseFloat(snapshot.change);
|
|
64
|
-
const changePercent = parseFloat(snapshot.changePercent);
|
|
65
|
-
return {
|
|
66
|
-
change,
|
|
67
|
-
changePercent,
|
|
68
|
-
isPositive: change >= 0,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Format price change with appropriate color class
|
|
73
|
-
* @param snapshot - The price snapshot
|
|
74
|
-
* @returns Formatted price change with color class
|
|
75
|
-
*/
|
|
76
|
-
export function formatPriceChange(snapshot) {
|
|
77
|
-
const { change, changePercent, isPositive } = calculatePriceChange(snapshot);
|
|
78
|
-
const changeText = `${isPositive ? '+' : ''}${change.toFixed(2)}`;
|
|
79
|
-
const changePercentText = `${isPositive ? '+' : ''}${changePercent.toFixed(2)}%`;
|
|
80
|
-
const colorClass = isPositive ? 'text-positive' : 'text-negative';
|
|
81
|
-
return {
|
|
82
|
-
changeText,
|
|
83
|
-
changePercentText,
|
|
84
|
-
colorClass,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Check if instrument is actively tradeable
|
|
89
|
-
* @param instrument - The instrument with trading flags
|
|
90
|
-
* @returns true if tradeable, false otherwise
|
|
91
|
-
*/
|
|
92
|
-
export function isInstrumentTradeable(instrument) {
|
|
93
|
-
return instrument.isActive && instrument.isActivelyTrading;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Format market cap value
|
|
97
|
-
* @param marketCap - The market cap value as string or null
|
|
98
|
-
* @returns Formatted market cap string
|
|
99
|
-
*/
|
|
100
|
-
export function formatMarketCap(marketCap) {
|
|
101
|
-
if (!marketCap)
|
|
102
|
-
return 'N/A';
|
|
103
|
-
const marketCapValue = parseFloat(marketCap);
|
|
104
|
-
if (isNaN(marketCapValue))
|
|
105
|
-
return 'N/A';
|
|
106
|
-
if (marketCapValue >= 1e12)
|
|
107
|
-
return `$${(marketCapValue / 1e12).toFixed(1)}T`;
|
|
108
|
-
if (marketCapValue >= 1e9)
|
|
109
|
-
return `$${(marketCapValue / 1e9).toFixed(1)}B`;
|
|
110
|
-
if (marketCapValue >= 1e6)
|
|
111
|
-
return `$${(marketCapValue / 1e6).toFixed(1)}M`;
|
|
112
|
-
return `$${marketCapValue.toFixed(0)}`;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Format trading volume
|
|
116
|
-
* @param volume - The volume number
|
|
117
|
-
* @returns Formatted volume string
|
|
118
|
-
*/
|
|
119
|
-
export function formatVolume(volume) {
|
|
120
|
-
if (volume >= 1e9)
|
|
121
|
-
return `${(volume / 1e9).toFixed(1)}B`;
|
|
122
|
-
if (volume >= 1e6)
|
|
123
|
-
return `${(volume / 1e6).toFixed(1)}M`;
|
|
124
|
-
if (volume >= 1e3)
|
|
125
|
-
return `${(volume / 1e3).toFixed(1)}K`;
|
|
126
|
-
return volume.toString();
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Check if market data is available
|
|
130
|
-
* @param marketData - The market data to check
|
|
131
|
-
* @returns true if market data is available, false otherwise
|
|
132
|
-
*/
|
|
133
|
-
export function hasMarketData(marketData) {
|
|
134
|
-
return Boolean(marketData.openPrice || marketData.dayHigh || marketData.dayLow || marketData.volume);
|
|
135
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio-template.d.ts","sourceRoot":"","sources":["../src/portfolio-template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"portfolio-template.d.ts","sourceRoot":"","sources":["../src/portfolio-template.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,cAAc,EAAE,aAAa,SAAS,CAAC,EAAE,KAAG,MAI9F,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,6BAA6B,GAAI,CAAC,SAAS,cAAc,EACpE,aAAa,SAAS,CAAC,EAAE,EACzB,YAAW,MAAa,KACvB,OAGF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GAAI,WAAW,MAAM,KAAG,MAG1D,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { formatRiskLevel } from './formatting';
|
|
2
1
|
/**
|
|
3
2
|
* Calculate total allocation from an array of allocations
|
|
4
3
|
*
|
|
@@ -56,5 +55,7 @@ export const validateAllocationPercentages = (allocations, tolerance = 0.01) =>
|
|
|
56
55
|
* formatRiskLevelDisplay('moderate'); // returns 'Moderate'
|
|
57
56
|
*/
|
|
58
57
|
export const formatRiskLevelDisplay = (riskLevel) => {
|
|
59
|
-
|
|
58
|
+
if (!riskLevel)
|
|
59
|
+
return riskLevel;
|
|
60
|
+
return riskLevel.charAt(0).toUpperCase() + riskLevel.slice(1).toLowerCase();
|
|
60
61
|
};
|
package/dist/withdrawal.d.ts
CHANGED
|
@@ -6,45 +6,6 @@
|
|
|
6
6
|
* Functions are designed to work with generic types to maintain flexibility.
|
|
7
7
|
*/
|
|
8
8
|
import type { LiquidationProgress } from '@cranberry-money/shared-types';
|
|
9
|
-
/**
|
|
10
|
-
* Formats a withdrawal amount as currency
|
|
11
|
-
*
|
|
12
|
-
* @param amount - Withdrawal amount as string or number
|
|
13
|
-
* @returns Formatted currency string with AUD symbol
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* formatWithdrawalAmount(5000) // 'A$5,000.00'
|
|
18
|
-
* formatWithdrawalAmount('5000.50') // 'A$5,000.50'
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function formatWithdrawalAmount(amount: string | number): string;
|
|
22
|
-
/**
|
|
23
|
-
* Formats a liquidation value as currency
|
|
24
|
-
*
|
|
25
|
-
* @param value - Liquidation value as string or number
|
|
26
|
-
* @returns Formatted currency string with AUD symbol
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* formatLiquidationValue(10000) // 'A$10,000.00'
|
|
31
|
-
* formatLiquidationValue('10000.50') // 'A$10,000.50'
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export declare function formatLiquidationValue(value: string | number): string;
|
|
35
|
-
/**
|
|
36
|
-
* Formats share quantity without decimal places
|
|
37
|
-
*
|
|
38
|
-
* @param shares - Number of shares
|
|
39
|
-
* @returns Formatted number string with thousands separators
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* formatSharesQuantity(1234) // '1,234'
|
|
44
|
-
* formatSharesQuantity(1234567) // '1,234,567'
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare function formatSharesQuantity(shares: number): string;
|
|
48
9
|
/**
|
|
49
10
|
* Calculates liquidation progress statistics
|
|
50
11
|
*
|
|
@@ -84,3 +45,4 @@ export declare function calculateLiquidationProgress<T extends {
|
|
|
84
45
|
export declare function getTotalEstimatedValue<T extends {
|
|
85
46
|
estimatedValue?: string | null;
|
|
86
47
|
}>(liquidations: T[]): number;
|
|
48
|
+
//# sourceMappingURL=withdrawal.d.ts.map
|
package/dist/withdrawal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../src/withdrawal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"withdrawal.d.ts","sourceRoot":"","sources":["../src/withdrawal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAWzE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS;IAAE,iBAAiB,EAAE,MAAM,CAAA;CAAE,EAClF,YAAY,EAAE,CAAC,EAAE,GAChB,mBAAmB,CAkBrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS;IAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,MAAM,CAI9G"}
|
package/dist/withdrawal.js
CHANGED
|
@@ -5,64 +5,7 @@
|
|
|
5
5
|
* calculating liquidation progress, and other withdrawal-related operations.
|
|
6
6
|
* Functions are designed to work with generic types to maintain flexibility.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import { NUMBER_FORMAT_OPTIONS_CURRENCY } from './currency';
|
|
10
|
-
/**
|
|
11
|
-
* Formats a withdrawal amount as currency
|
|
12
|
-
*
|
|
13
|
-
* @param amount - Withdrawal amount as string or number
|
|
14
|
-
* @returns Formatted currency string with AUD symbol
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* formatWithdrawalAmount(5000) // 'A$5,000.00'
|
|
19
|
-
* formatWithdrawalAmount('5000.50') // 'A$5,000.50'
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export function formatWithdrawalAmount(amount) {
|
|
23
|
-
const numValue = typeof amount === 'string' ? parseFloat(amount) : amount;
|
|
24
|
-
return new Intl.NumberFormat(LOCALE_AUSTRALIA, {
|
|
25
|
-
...NUMBER_FORMAT_OPTIONS_CURRENCY,
|
|
26
|
-
currency: CURRENCY_AUD,
|
|
27
|
-
}).format(numValue);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Formats a liquidation value as currency
|
|
31
|
-
*
|
|
32
|
-
* @param value - Liquidation value as string or number
|
|
33
|
-
* @returns Formatted currency string with AUD symbol
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* formatLiquidationValue(10000) // 'A$10,000.00'
|
|
38
|
-
* formatLiquidationValue('10000.50') // 'A$10,000.50'
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export function formatLiquidationValue(value) {
|
|
42
|
-
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
43
|
-
return new Intl.NumberFormat(LOCALE_AUSTRALIA, {
|
|
44
|
-
...NUMBER_FORMAT_OPTIONS_CURRENCY,
|
|
45
|
-
currency: CURRENCY_AUD,
|
|
46
|
-
}).format(numValue);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Formats share quantity without decimal places
|
|
50
|
-
*
|
|
51
|
-
* @param shares - Number of shares
|
|
52
|
-
* @returns Formatted number string with thousands separators
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* formatSharesQuantity(1234) // '1,234'
|
|
57
|
-
* formatSharesQuantity(1234567) // '1,234,567'
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export function formatSharesQuantity(shares) {
|
|
61
|
-
return new Intl.NumberFormat(LOCALE_AUSTRALIA, {
|
|
62
|
-
minimumFractionDigits: 0,
|
|
63
|
-
maximumFractionDigits: 0,
|
|
64
|
-
}).format(shares);
|
|
65
|
-
}
|
|
8
|
+
import { LIQUIDATION_STATUS_PENDING, LIQUIDATION_STATUS_TRADES_CREATED, LIQUIDATION_STATUS_EXECUTED, LIQUIDATION_STATUS_SETTLED, LIQUIDATION_STATUS_FAILED, } from '@cranberry-money/shared-constants';
|
|
66
9
|
/**
|
|
67
10
|
* Calculates liquidation progress statistics
|
|
68
11
|
*
|