Skip to content

Commit

Permalink
fix(registry): patch Finland bank code to 6 digits (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
skwasjer authored Dec 21, 2024
1 parent da9e946 commit 4f8d918
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
21 changes: 21 additions & 0 deletions src/IbanNet.CodeGen/Swift/Patches/9_FinlandBankCodePatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace IbanNet.CodeGen.Swift.Patches;

internal sealed class _9_FinlandBankCodePatch : RecordPatcher
{
protected override SwiftCsvRecord Apply(SwiftCsvRecord record)
{
switch (record)
{
case { CountryCode: "FI" }:
record.Bban.Pattern = "6!n8!n";
record.Bban.Example = "12345600000785";
record.Bank.Pattern = "6!n";
record.Bank.Example = "123456";

return record;

default:
return record;
}
}
}
1 change: 1 addition & 0 deletions src/IbanNet.CodeGen/Swift/Patches/RecordPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ private static IEnumerable<RecordPatcher> GetPatches()
.Where(t => !t.IsAbstract && typeof(RecordPatcher).IsAssignableFrom(t))
.Select(Activator.CreateInstance)
.Cast<RecordPatcher>()
.OrderBy(rp => rp.GetType().Name)
.ToList();
}
}
8 changes: 4 additions & 4 deletions src/IbanNet/Registry/Swift/SwiftRegistryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -692,13 +692,13 @@ private static IEnumerable<IbanCountry> Load()
Example = "FI2112345600000785",
EffectiveDate = new DateTimeOffset(2011, 12, 1, 0, 0, 0, TimeSpan.Zero)
},
Bban = new BbanStructure(new SwiftPattern("3!n11!n"), 4)
Bban = new BbanStructure(new SwiftPattern("6!n8!n"), 4)
{
Example = ""
Example = "12345600000785"
},
Bank = new BankStructure(new SwiftPattern("3!n"), 4)
Bank = new BankStructure(new SwiftPattern("6!n"), 4)
{
Example = "123"
Example = "123456"
},
Sepa = new SepaInfo
{
Expand Down
21 changes: 21 additions & 0 deletions test/IbanNet.Tests/Issues/224_FinlandBankCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using IbanNet.Registry;

namespace IbanNet.Issues;

public sealed class _224_FinlandBankCode
{
[Theory]
[InlineData("FI4017453000182859", "174530")]
[InlineData("FI2840554920113105", "405549")]
public void When_extracting_bank_code_it_should_return_expected(string ibanStr, string expectedBankCode)
{
var ibanParser = new IbanParser(IbanRegistry.Default);

// Act
bool isValid = ibanParser.TryParse(ibanStr, out Iban? iban);

// Assert
isValid.Should().BeTrue();
iban!.BankIdentifier.Should().Be(expectedBankCode);
}
}

0 comments on commit 4f8d918

Please sign in to comment.