-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Currency component and fix other issues in ToDo and tests
- Loading branch information
1 parent
2ef4ad7
commit c434dbc
Showing
10 changed files
with
1,107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line strict | ||
console.log('\x1b[33m%s\x1b[0m','Running in headless mode, use `npm run test:headed` for running in headed mode.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// eslint-disable-next-line strict | ||
const { devices } = require('@playwright/test'); | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
projects/angular-sdk-library/src/lib/_helpers/currency-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* eslint-disable import/no-named-default */ | ||
import { default as CurrencyAlias } from './formatters/currency'; | ||
import { default as CurrencyMapAlias } from './formatters/currency-map'; | ||
|
||
declare const PCore; | ||
|
||
export const getCurrencyOptions = (inISOCode: string) => { | ||
const operatorLocale = PCore.getEnvironmentInfo().getUseLocale() || 'en-US'; | ||
|
||
let currMapToUse = CurrencyMapAlias.US; | ||
let localeToUse = operatorLocale; | ||
|
||
// Determine CurrencyMap lookup based on ISO code (if specified). | ||
// If no ISO code, use locale | ||
// If no locale, default to US | ||
if (inISOCode) { | ||
if (inISOCode === 'EUR') { | ||
currMapToUse = CurrencyMapAlias.NL; | ||
localeToUse = 'nl-NL'; | ||
} else { | ||
// For all other ISO codes, use first 2 characters as the lookup from CurrencyMap | ||
const countryCode = inISOCode.substring(0, 2); | ||
currMapToUse = CurrencyMapAlias[countryCode]; | ||
} | ||
} else if (operatorLocale) { | ||
// No ISO Code so check for operator locale (and force upper case for lookup) | ||
const countryCode = operatorLocale.substring(3).toUpperCase(); | ||
currMapToUse = CurrencyMapAlias[countryCode]; | ||
} else { | ||
// no ISO code and no operator locale, default to US | ||
currMapToUse = CurrencyMapAlias.US; | ||
} | ||
|
||
// If no currMapToUse at this point, default to US as a failsafe | ||
if (!currMapToUse) { | ||
currMapToUse = CurrencyMapAlias['US']; | ||
} | ||
|
||
const theCode = currMapToUse.currencyCode.substring(0, 3); | ||
const currencyOptions = { locale: localeToUse, style: 'currency', currency: theCode }; | ||
|
||
return currencyOptions; | ||
}; | ||
|
||
export const getCurrencyCharacters = (inISOCode: string) => { | ||
const theCurrencyChars = { | ||
theCurrencySymbol: '$', | ||
theDecimalIndicator: '.', | ||
theDigitGroupSeparator: ',' | ||
}; | ||
|
||
const theCurrencyOptions = getCurrencyOptions(inISOCode); | ||
|
||
const testValue = 1234.56; | ||
const formattedString = CurrencyAlias.Currency(testValue, theCurrencyOptions); | ||
|
||
// console.log(`formattedString: ${formattedString}`); | ||
|
||
// Here, we have the formatted string (ex: $1,234.56) where: | ||
// Currency symbol = formattedString[0] | ||
// Separator = formattedString[2] | ||
// DecimalIndicator = formattedString[6]; | ||
|
||
theCurrencyChars.theCurrencySymbol = formattedString[0]; | ||
theCurrencyChars.theDigitGroupSeparator = formattedString[2]; | ||
theCurrencyChars.theDecimalIndicator = formattedString[6]; | ||
|
||
// console.log(`theCurrencyChars: symbol: ${theCurrencyChars.theCurrencySymbol} | theDigitGroupSeparator: ${theCurrencyChars.theDigitGroupSeparator} | theDecimalIndicator: ${theCurrencyChars.theDecimalIndicator}`); | ||
|
||
return theCurrencyChars; | ||
}; |
Oops, something went wrong.