Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/migrate tools #76

Merged
merged 137 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
e4e3805
add print info tool
dgg Mar 18, 2024
3bd2a05
move tools to polyglot books
dgg Jun 5, 2024
57f86d2
Merge branch 'master' into feature/migrate-tools
dgg Jun 19, 2024
b7ca1f9
changes after comparing with latest ISO list
dgg Jun 19, 2024
e3777d5
add explanations
dgg Jun 19, 2024
1cd4a70
make UYU canonical for es-UY, align ISO information for UYI and UYW
dgg Jun 21, 2024
25fe1fa
remove weird canonical culture from XDR and amend ALL with canonical
dgg Jun 25, 2024
4f2bd14
amend DZD according to canonical
dgg Jun 25, 2024
23de9a5
amend ARS as per canonical
dgg Jun 25, 2024
5598bd3
amend BHD accoring to canonical
dgg Jun 25, 2024
e816d74
amend BDT accoring to canonical
dgg Jun 25, 2024
2747dac
amend AMD
dgg Jun 25, 2024
9a794ff
amend BBD
dgg Jun 25, 2024
5bd59e2
amend BOB
dgg Jun 25, 2024
43364ef
amend BWP
dgg Jun 25, 2024
28ffb3e
amend BWP
dgg Jun 25, 2024
849687b
tacking changes to BOB
dgg Jun 25, 2024
7ffc80c
amend BZD
dgg Jun 26, 2024
e7ae1ee
amend MMK
dgg Jun 26, 2024
82d3ec2
amend KHR and BIF
dgg Jun 26, 2024
8180643
amend CNY
dgg Jun 26, 2024
905b354
amend COP
dgg Jun 26, 2024
1ab0834
amend KMF
dgg Jun 26, 2024
67f00f5
amend CRC
dgg Jun 26, 2024
ee3d4e5
check amendments to AMD, CRC, KMF and LKR
dgg Jun 26, 2024
22f3f98
amend CUB
dgg Jun 28, 2024
07af772
amend DKK
dgg Jun 28, 2024
e24121e
amend DOP
dgg Jun 28, 2024
c524777
amend (deprecate) SVC
dgg Jun 28, 2024
e664d7c
amend FJD
dgg Jun 28, 2024
7f45603
amend DJF
dgg Jun 28, 2024
c79f554
amend GMD
dgg Jun 28, 2024
cc15909
amend GTQ
dgg Jun 28, 2024
9372b5a
amedn GNF
dgg Jun 28, 2024
e160e8f
amend GYD
dgg Jun 28, 2024
9cda183
amend HTG
dgg Jun 28, 2024
b107858
amend HNL
dgg Jun 28, 2024
42b0821
amend HKD
dgg Jun 28, 2024
95e7669
amend ISK
dgg Jun 28, 2024
10d80c5
amend INR
dgg Jun 28, 2024
ccaa352
amend IDR
dgg Jun 28, 2024
92174e7
amend IQD
dgg Jun 28, 2024
6b2263d
checking overwritten rules
dgg Jun 28, 2024
f5f2f19
better control on Overwritten property, amend: GYD, ILS, JOD, JPY, KE…
dgg Jul 1, 2024
94a342b
close remarks comment
dgg Jul 1, 2024
ae1531b
overwrite LSL and LVL
dgg Jul 1, 2024
07800d0
amend LYD
dgg Jul 1, 2024
3d208d9
overwrite deprecated LTL
dgg Jul 1, 2024
b4facf2
fix MOP
dgg Jul 1, 2024
6866430
fix MWK
dgg Jul 1, 2024
be2ddf0
fix and overwrite MVR
dgg Jul 1, 2024
bace7cc
overwrite and fix MRO and MRU
dgg Jul 1, 2024
cfe8436
fix MUR
dgg Jul 1, 2024
f88a3da
overwrite MXN
dgg Jul 1, 2024
b4d0d7d
fix MNT
dgg Jul 1, 2024
5396bf1
fix MAD
dgg Jul 1, 2024
70b6838
fix OMR
dgg Jul 1, 2024
bcb7cd2
fix NAD
dgg Jul 1, 2024
64e4b39
fix and overwrite NPR
dgg Jul 1, 2024
876186f
overwrite ANG
dgg Jul 1, 2024
b7cbec6
fix and overwrite AWG
dgg Jul 1, 2024
fd2c2fc
fix VUV
dgg Jul 1, 2024
cfeaea8
fix NIO
dgg Jul 1, 2024
5171d84
fix NGN
dgg Jul 1, 2024
70dcada
fix PKR
dgg Jul 1, 2024
d44d519
fix PAB
dgg Jul 1, 2024
ea82a4a
fix PGK
dgg Jul 1, 2024
a4be39e
fix and overwrite PYG
dgg Jul 1, 2024
90c4d4d
fix PEN
dgg Jul 1, 2024
aa7409a
fix QAR
dgg Jul 1, 2024
c825960
fix RUB
dgg Jul 1, 2024
a14ee1b
fix and overwrite RWF
dgg Jul 1, 2024
89e9741
fix and overwrite SHP
dgg Jul 1, 2024
79af74f
fix STD
dgg Jul 1, 2024
eae0910
fix SAR
dgg Jul 1, 2024
e1239a6
overwrite IRR
dgg Jul 1, 2024
02ade22
fix SCR
dgg Jul 1, 2024
0e862ef
overwrite SLL and SLE
dgg Jul 1, 2024
3bc3a1a
fix SGD
dgg Jul 1, 2024
fbbe7b6
fix VND
dgg Jul 1, 2024
108ff9c
fix SOS
dgg Jul 1, 2024
efebec6
fix ZAR
dgg Jul 1, 2024
d5b25a2
overwrite SZL
dgg Jul 1, 2024
db7e5b9
fix SEK
dgg Jul 1, 2024
3bc2022
fix and overwrite CHF
dgg Jul 1, 2024
821c1bc
fix and overwrite SYP
dgg Jul 1, 2024
327a338
fix and overwrite TOP
dgg Jul 1, 2024
7ffd334
overwrite TTD
dgg Jul 1, 2024
d2c2f96
fix AED
dgg Jul 1, 2024
fdf724e
fix TND
dgg Jul 1, 2024
7cfed1c
fix UGX
dgg Jul 1, 2024
55838b6
fix and overwrite MKD
dgg Jul 1, 2024
9e060bc
fix EGP
dgg Jul 1, 2024
9025a87
overwrite GBP
dgg Jul 1, 2024
63068ab
fix TZS
dgg Jul 1, 2024
c1aba55
fix USD, USN and USS
dgg Jul 1, 2024
87f95be
fix and overwrite UYU
dgg Jul 1, 2024
5c4bf5c
fix UZS
dgg Jul 1, 2024
9f4bc4f
fix ZMK and ZMW
dgg Jul 1, 2024
4ddfe3b
fix and overwrite VEF, VES and VED
dgg Jul 1, 2024
b451459
overwrite and fix CUC
dgg Jul 1, 2024
14a602d
fix and overwrite ZWL
dgg Jul 1, 2024
7638bd8
fix TMT
dgg Jul 1, 2024
1544898
fix GHS
dgg Jul 1, 2024
844e4a8
fix RSD and SDG
dgg Jul 1, 2024
db474d3
fix MZN
dgg Jul 1, 2024
d4db3f8
fix AZN
dgg Jul 1, 2024
aabd9f6
overwrite RON
dgg Jul 1, 2024
a94d680
fix and overwrite CHE
dgg Jul 1, 2024
9b11eae
fix and overwrite CHW
dgg Jul 1, 2024
a32da72
fix TRY
dgg Jul 1, 2024
14d7058
fix XAF and XOF
dgg Jul 1, 2024
3a0c9b7
fix and overwrite XPF
dgg Jul 1, 2024
c6d26b9
overwrite and fix COU
dgg Jul 1, 2024
e2b9866
overwrite and fix AFN
dgg Jul 1, 2024
3e9b833
fix and overwrite TJS
dgg Jul 1, 2024
cad013c
fix AOA
dgg Jul 1, 2024
1f0e98a
overwrite deprecated BYR
dgg Jul 1, 2024
ae918f5
fix BGN
dgg Jul 1, 2024
7636368
fix CDF
dgg Jul 1, 2024
f356d45
overwrite BAM
dgg Jul 1, 2024
ec3302b
fix and overwrite MXV
dgg Jul 1, 2024
14e427c
fix UAH
dgg Jul 1, 2024
6af507f
fix GEL
dgg Jul 1, 2024
61c201b
fix and overwrite BOV
dgg Jul 1, 2024
17023b0
fix PLN
dgg Jul 1, 2024
3c0624d
fix BRL
dgg Jul 1, 2024
49ee4ef
fix and overwrite CLF
dgg Jul 1, 2024
85d161a
overwrite USN and USS
dgg Jul 1, 2024
c5e13d0
fix MZN
dgg Jul 1, 2024
928aa98
update tool
dgg Jul 1, 2024
c98e72f
ignore unparseable currency
dgg Jul 1, 2024
b973c62
fix tests
dgg Jul 1, 2024
8f5646b
amendment 177: ZWL -> ZWG
dgg Jul 3, 2024
d3d4915
fixes #74: add int extensions methods
dgg Jul 3, 2024
60906d5
add ability to overwrite a currency with a combination of CultureInfo…
dgg Jul 3, 2024
be14b72
explicitly add token in secrets
dgg Jul 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: ./release/TestResults/coverage.cobertura.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

- name: Upload Coveralls coverage
Expand Down
12 changes: 12 additions & 0 deletions src/NMoneys/Currency.Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reflection;
using NMoneys.Support;

namespace NMoneys;
Expand Down Expand Up @@ -39,4 +40,15 @@ public static void Configure(ValueTuple<CurrencyIsoCode, CurrencyConfiguration>[
Configure(tuple.Item1, tuple.Item2);
}
}

/// <summary>
/// Returns the corresponding canonical culture assigned to the currency.
/// </summary>
/// <remarks>For internal verification purposes.</remarks>
/// <returns>The canonical culture or <c>null</c> is not decorated.</returns>
public CanonicalCultureAttribute? GetCanonicalCulture()
{
CanonicalCultureAttribute? attribute = IsoCode.FieldOf().GetCustomAttribute<CanonicalCultureAttribute>();
return attribute;
}
}
39 changes: 39 additions & 0 deletions src/NMoneys/CurrencyConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Globalization;

namespace NMoneys;

/// <summary>
Expand Down Expand Up @@ -52,4 +54,41 @@ public record CurrencyConfiguration()
/// Override <see cref="Currency.Entity"/>.
/// </summary>
public ValueTuple<ushort?, string?> Reference { get; init; } = (null, null);

/// <summary>
/// Creates a <see cref="Currency"/> configuration override with the data of the provided <paramref name="culture"/>
/// and its corresponding <see cref="RegionInfo"/>.
/// </summary>
/// <param name="culture">Instance with the overriding information (<see cref="CultureInfo.NumberFormat"/> "currency" properties).</param>
/// <param name="isObsolete">Whether the corresponding override is considered obsolete (<c>false</c> by default).</param>
/// <returns>An instance with the overriding data.</returns>
public static CurrencyConfiguration From(CultureInfo culture, bool isObsolete = false) =>
From(culture, new RegionInfo(culture.Name), isObsolete);

/// <summary>
/// Creates a <see cref="Currency"/> configuration override with the data of the provided <paramref name="culture"/>
/// and <paramref name="region"/>.
/// </summary>
/// <param name="culture">Instance with the overriding information (<see cref="CultureInfo.NumberFormat"/> "currency" properties).</param>
/// <param name="region">Instance with the overriding information (currency English and native names).</param>
/// <param name="isObsolete">Whether the corresponding override is considered obsolete (<c>false</c> by default).</param>
/// <returns>An instance with the overriding data.</returns>
public static CurrencyConfiguration From(CultureInfo culture, RegionInfo region, bool isObsolete = false)
{
NumberFormatInfo nf = culture.NumberFormat;
CurrencyConfiguration configuration = new()
{
NativeName = region.CurrencyNativeName,
EnglishName = region.CurrencyEnglishName,
Symbol = nf.CurrencySymbol,
SignificantDecimalDigits = (byte)nf.CurrencyDecimalDigits,
DecimalSeparator = nf.CurrencyDecimalSeparator,
GroupSeparator = nf.CurrencyGroupSeparator,
GroupSizes = nf.CurrencyGroupSizes.Select(s => (byte)s).ToArray(),
PositivePattern = (byte)nf.CurrencyPositivePattern,
NegativePattern = (byte)nf.CurrencyNegativePattern,
IsObsolete = isObsolete
};
return configuration;
}
}
Loading
Loading