Skip to content

Commit

Permalink
feat: updates SwiftRegistryProvider to r98 (July '24), which adds Oma…
Browse files Browse the repository at this point in the history
…n (OM) and Yemen (YE) and updates branch for Portugal (PT). We also have to patch Pakistan (PK) back in, because it seems to have been removed from TXT even though it is still documented in PDF.
  • Loading branch information
skwasjer committed Oct 5, 2024
1 parent 20c6bd4 commit 3516111
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 94 deletions.
4 changes: 3 additions & 1 deletion SupportedCountries.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ See the [SWIFT website](https://www.swift.com/standards/data-standards/iban-inte
| NI | Nicaragua | 28 | `NI45 BAPR 0000 0013 0000 0355 8124` | No | ![Supported][supported] | - |
| NL | Netherlands (The) | 18 | `NL91 ABNA 0417 1643 00` | Yes | ![Supported][supported] | - |
| NO | Norway | 15 | `NO93 8601 1117 947` | Yes | ![Supported][supported] | - |
| OM | Oman | 23 | `OM81 0180 0000 0129 9123 456` | No | ![Supported][supported] | - |
| PK | Pakistan | 24 | `PK36 SCBL 0000 0011 2345 6702` | No | ![Supported][supported] | - |
| PL | Poland | 28 | `PL61 1090 1014 0000 0712 1981 2874` | Yes | - | ![Supported][supported] |
| PS | Palestine, State of | 29 | `PS92 PALS 0000 0000 0400 1234 5670 2` | No | ![Supported][supported] | - |
| PT | Portugal | 25 | `PT50 0002 0123 1234 5678 9015 4` | Yes | ![Supported][supported] | - |
| PT | Portugal | 25 | `PT50 0002 0123 1234 5678 9015 4` | Yes | ![Supported][supported] | ![Supported][supported] |
| QA | Qatar | 29 | `QA58 DOHB 0000 1234 5678 90AB CDEF G` | No | ![Supported][supported] | - |
| RO | Romania | 24 | `RO49 AAAA 1B31 0075 9384 0000` | Yes | ![Supported][supported] | - |
| RS | Serbia | 22 | `RS35 2600 0560 1001 6113 79` | No | ![Supported][supported] | - |
Expand All @@ -95,6 +96,7 @@ See the [SWIFT website](https://www.swift.com/standards/data-standards/iban-inte
| VA | Vatican City State | 22 | `VA59 0011 2300 0012 3456 78` | Yes | ![Supported][supported] | - |
| VG | Virgin Islands | 24 | `VG96 VPVG 0000 0123 4567 8901` | No | ![Supported][supported] | - |
| XK | Kosovo | 20 | `XK05 1212 0123 4567 8906` | No | ![Supported][supported] | ![Supported][supported] |
| YE | Yemen | 30 | `YE15 CBYE 0001 0188 6123 4567 8912 34` | No | ![Supported][supported] | ![Supported][supported] |

### Finland includes:

Expand Down
38 changes: 38 additions & 0 deletions src/IbanNet.CodeGen/Swift/Patches/_8_PakistanDisappearedPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace IbanNet.CodeGen.Swift.Patches;

/// <summary>
/// Somewhere between r95 and r98, Pakistan disappeared from the txt while it is still is documented in the PDF.
/// I am starting to hate the interns at SWIFT. This patches it back in.
/// </summary>
internal sealed record _8_PakistanDisappearedPatch : SwiftCsvRecord
{
public _8_PakistanDisappearedPatch()
{
CountryCode = "PK";
EnglishName = "Pakistan";
Iban = new IbanCsvData
{
Pattern = "2!c2!n4!a16!c",
Length = 24,
ElectronicFormatExample = "PK36SCBL0000001123456702"
};
EffectiveDate = new DateTimeOffset(2012, 12, 1, 0, 0, 0, TimeSpan.Zero);
Bban = new BbanCsvData
{
Pattern = "4!a16!c",
Length = 20,
Example = "SCBL0000001123456702"
};
Bank = new BankCsvData
{
Pattern = "4!a",
Position = new Position { StartPos = 1, EndPos = 4 },
Example = "SCBL"
};
Branch = new BranchCsvData();
Sepa = new SepaCsvData { IsMember = false, OtherTerritories = [] };
OtherTerritories = [];
DomesticExample = "00260101036360";
LastUpdatedDate = new DateTimeOffset(2012, 12, 1, 0, 0, 0, TimeSpan.Zero);
}
}
14 changes: 14 additions & 0 deletions src/IbanNet.CodeGen/Swift/SwiftCsvReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,18 @@ public SwiftCsvReader(TextReader reader)
Parser.Context.TypeConverterCache.AddConverter<Position>(new PositionConverter());
typeConverterOptions.AddOptions<Position?>(new TypeConverterOptions { NullValues = { "", "N/A" } });
}

public override IEnumerable<T> GetRecords<T>()
{
IEnumerable<T> insertRecords = [];
if (typeof(T) == typeof(SwiftCsvRecord))
{
insertRecords = typeof(SwiftCsvRecord).Assembly.GetTypes()
.Where(t => t != typeof(SwiftCsvRecord) && typeof(SwiftCsvRecord).IsAssignableFrom(t))
.Select(Activator.CreateInstance)
.Cast<T>();
}

return base.GetRecords<T>().Concat(insertRecords);
}
}
2 changes: 1 addition & 1 deletion src/IbanNet.CodeGen/Swift/SwiftCsvRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace IbanNet.CodeGen.Swift;

public sealed record SwiftCsvRecord
public record SwiftCsvRecord
{
private string _countryCode = default!;

Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit 3516111

Please sign in to comment.