Skip to content

Commit

Permalink
Corrected issue with unintentionally overriding of sender information
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasEnioKohler committed Apr 3, 2023
1 parent 36a52c7 commit b4aa21a
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 41 deletions.
134 changes: 109 additions & 25 deletions iso20022-generator/generator-test/GeneratorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void InitGenerator()
{
UniqueDocumentId = Guid.NewGuid().ToString().Substring(0, 34), // Must be unique for the bank within 90 days
ContactDetailsName = "enio AG",
ContactDetailsOther = "3.0.0",
ContactDetailsOther = "3.0.1",
AutoCalculateControlSum = true
// SenderBic = "ZKBKCHZZ80A" //ZKB
},
Expand All @@ -29,14 +29,14 @@ public void InitGenerator()
var p1 = generator.AddPaymentInfo(DateTime.Now.AddDays(10), "TRA");

generator.AddTransaction(p1, new Receiver
{
Name = "Max Kälin",
StreetName = "Dorfstrasse",
StreetNumber = "9b",
Zip = "8808",
City = "Pfäffikon",
CountryCode = "CH"
},
{
Name = "Max Kälin",
StreetName = "Dorfstrasse",
StreetNumber = "9b",
Zip = "8808",
City = "Pfäffikon",
CountryCode = "CH"
},
new TransactionIBANandQRR
{
CurrencyCode = "CHF",
Expand All @@ -49,14 +49,14 @@ public void InitGenerator()
});

generator.AddTransaction(p1, new Receiver
{
Name = "Alpkorporation Kohlschlag",
StreetName = "Kohlschlagerstrasse",
StreetNumber = "2",
Zip = "8887",
City = "Mels",
CountryCode = "CH",
},
{
Name = "Alpkorporation Kohlschlag",
StreetName = "Kohlschlagerstrasse",
StreetNumber = "2",
Zip = "8887",
City = "Mels",
CountryCode = "CH",
},
new TransactionIBANandQRR
{
CurrencyCode = "CHF",
Expand All @@ -65,7 +65,7 @@ public void InitGenerator()
ReferenceIdentification = "QRR Test",
QRReferenceNumber = "36 63580 00000 00000 30060 03574",
InstructionForDebtorAgent = "Instruction",
AdditionalRemittanceInformation = new string[] {"Auftrag vom 25.10.2022"}
AdditionalRemittanceInformation = new string[] { "Auftrag vom 25.10.2022" }
});

var p2 = generator.AddPaymentInfo(DateTime.Now.AddDays(5), "TRF");
Expand Down Expand Up @@ -93,7 +93,7 @@ public void InitGenerator()
{
UniqueDocumentId = Guid.NewGuid().ToString().Substring(0, 34), // Must be unique for the bank within 90 days
ContactDetailsName = "enio AG",
ContactDetailsOther = "3.0.0",
ContactDetailsOther = "3.0.1",
AutoCalculateControlSum = true
// SenderBic = "ZKBKCHZZ80A" //ZKB
},
Expand All @@ -107,8 +107,47 @@ public void InitGenerator()
var p3 = generator2.AddPaymentInfo(DateTime.Now.AddDays(10), "TRA");

generator2.AddTransaction(p3, new Receiver
{
Name = "Test Name",
StreetName = "",
StreetNumber = "",
Zip = "70372",
City = "Stuttgart",
CountryCode = "DE"
},
new TransactionIBANandQRR
{
Name = "Test Name",
CurrencyCode = "JPY",
Amount = 1117,
ReceiverIban = "CH23 0024 5245 1002 3901 K",
ReferenceIdentification = "69-10",
QRReferenceNumber = "36 63580 00000 00000 30060 03574",
InstructionForDebtorAgent = null
});

string ret2 = generator2.GetPain001String();


var generatorph = new Pain001Generator(new Initialization()
{
UniqueDocumentId = Guid.NewGuid().ToString().Substring(0, 34), // Must be unique for the bank within 90 days
ContactDetailsName = "enio AG",
ContactDetailsOther = "3.0.1",
AutoCalculateControlSum = true
},
new Sender()
{
SenderPartyName = "Muster AG",
SenderIban = "InitialWertInitialWert",
SenderBic = "HHHHCH22", //HBL
});

generatorph.Sender.SenderIban = "CH5656565656565656565";
var ph = generatorph.AddPaymentInfo(DateTime.Now.AddDays(10), "TRA");

generatorph.AddTransaction(ph, new Receiver
{
Name = "Hypo AG",
StreetName = "",
StreetNumber = "",
Zip = "70372",
Expand All @@ -117,15 +156,60 @@ public void InitGenerator()
},
new TransactionIBANandQRR
{
CurrencyCode = "JPY",
Amount = 1117,
ReceiverIban = "CH23 0024 5245 1002 3901 K",
CurrencyCode = "CHF",
Amount = 100,
ReceiverIban = "CH0200202020202020202",
ReferenceIdentification = "69-10",
QRReferenceNumber = "36 63580 00000 00000 30060 03574",
InstructionForDebtorAgent = null
InstructionForDebtorAgent = "/Cost center/1/VAT/1/Project number/1/"
});

string ret2 = generator2.GetPain001String();
generatorph.Sender.SenderIban = "CH2929292929292929292";
var ph2 = generatorph.AddPaymentInfo(DateTime.Now.AddDays(10), "TRA");

generatorph.AddTransaction(ph2, new Receiver
{
Name = "Hypo AG",
StreetName = "",
StreetNumber = "",
Zip = "70372",
City = "Stuttgart",
CountryCode = "DE"
},
new TransactionIBANandQRR
{
CurrencyCode = "CHF",
Amount = 100,
ReceiverIban = "CH0200202020202020202",
ReferenceIdentification = "69-10",
QRReferenceNumber = "36 63580 00000 00000 30060 03574",
InstructionForDebtorAgent = "/Cost center/1/VAT/1/Project number/1/"
});

generatorph.Sender.SenderIban = "CH0200202020202020202";
var ph3 = generatorph.AddPaymentInfo(DateTime.Now.AddDays(10), "TRA");

generatorph.AddTransaction(ph3, new Receiver
{
Name = "Hypo AG",
StreetName = "",
StreetNumber = "",
Zip = "70372",
City = "Stuttgart",
CountryCode = "DE"
},
new TransactionIBANandQRR
{
CurrencyCode = "CHF",
Amount = 200,
ReceiverIban = "CH7777777777777777777",
ReferenceIdentification = "69-10",
QRReferenceNumber = "36 63580 00000 00000 30060 03574",
InstructionForDebtorAgent = ""
});

string retph = generatorph.GetPain001String();


Assert.True(true);
}
Expand Down
23 changes: 12 additions & 11 deletions iso20022-generator/iso20022-generator/Pain001Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,9 @@ namespace iso20022_generator
public class Pain001Generator
{
private Document doc = new Document();
private GroupHeader32CH grpHdr = new GroupHeader32CH(); // Index 1.0
private PartyIdentification32CH_NameAndId initPty = new PartyIdentification32CH_NameAndId(); // Index 1.8
private ContactDetails2CH ctctDtls = new ContactDetails2CH(); // Index 1.8
private PartyIdentification32CH dbtr = new PartyIdentification32CH(); // Index 2.19
private CashAccount16CH_IdTpCcy dbtrAcct = new CashAccount16CH_IdTpCcy(); // Index 2.20
private AccountIdentification4ChoiceCH dbtrAcctId = new AccountIdentification4ChoiceCH(); // Index 2.20 / Id
private BranchAndFinancialInstitutionIdentification4CH_BicOrClrId dbtrAgt = new BranchAndFinancialInstitutionIdentification4CH_BicOrClrId(); // Index 2.21
private FinancialInstitutionIdentification7CH_BicOrClrId finInstnIdDbtr = new FinancialInstitutionIdentification7CH_BicOrClrId(); // Index 2.21 / Financial Institution Identification

private List<PaymentInstructionInformation3CH> pmtInfList = new List<PaymentInstructionInformation3CH>(); // Index 2.0

private CustomerCreditTransferInitiationV03CH cstmrCdtTrfInitn = new CustomerCreditTransferInitiationV03CH();
private GroupHeader32CH grpHdr = new GroupHeader32CH(); // Index 1.0
private Initialization initialization;
public Sender Sender { get; set; }

Expand All @@ -35,6 +26,7 @@ public class Pain001Generator
public Pain001Generator(Initialization init, Sender sender)
{
initialization = init;

doc.CstmrCdtTrfInitn = cstmrCdtTrfInitn;

// Level A
Expand All @@ -48,9 +40,11 @@ public Pain001Generator(Initialization init, Sender sender)
grpHdr.CtrlSumSpecified = true;
}

PartyIdentification32CH_NameAndId initPty = new PartyIdentification32CH_NameAndId(); // Index 1.8
grpHdr.InitgPty = initPty; // Index 1.8

initPty.Nm = sender.SenderPartyName; // Index 1.8 - Name
ContactDetails2CH ctctDtls = new ContactDetails2CH(); // Index 1.8
initPty.CtctDtls = ctctDtls; // Index 1.8 - Contact Details
ctctDtls.Nm = init.ContactDetailsName; // Index 1.8 - Contact Details.Name
ctctDtls.Othr = init.ContactDetailsOther; // Index 1.8 - Contact Details.Other
Expand All @@ -77,19 +71,26 @@ public PaymentInstructionInformation3CH AddPaymentInfo(DateTime requiredExecutio
pmtInf.BtchBookg = true; // Index 2.3

pmtInf.ReqdExctnDt = requiredExecutionDate; // Index 2.17
PartyIdentification32CH dbtr = new PartyIdentification32CH(); // Index 2.19
pmtInf.Dbtr = dbtr;

dbtr.Nm = Sender.SenderPartyName;

CashAccount16CH_IdTpCcy dbtrAcct = new CashAccount16CH_IdTpCcy(); // Index 2.20
pmtInf.DbtrAcct = dbtrAcct;
AccountIdentification4ChoiceCH dbtrAcctId = new AccountIdentification4ChoiceCH(); // Index 2.20 / Id
dbtrAcct.Id = dbtrAcctId;
dbtrAcctId.Item = Sender.SenderIban; // Index 2.20 / Id / IBAN Bezugs-Konto

BranchAndFinancialInstitutionIdentification4CH_BicOrClrId dbtrAgt = new BranchAndFinancialInstitutionIdentification4CH_BicOrClrId(); // Index 2.21
pmtInf.DbtrAgt = dbtrAgt;

// Add BIC only if is set to guarantee the compatibility to the old version
FinancialInstitutionIdentification7CH_BicOrClrId finInstnIdDbtr = new FinancialInstitutionIdentification7CH_BicOrClrId(); // Index 2.21 / Financial Institution Identification
if (!string.IsNullOrEmpty(Sender.SenderBic)) // Index 2.21
{
finInstnIdDbtr.BIC = Sender.SenderBic;
}

dbtrAgt.FinInstnId = finInstnIdDbtr;

Expand Down Expand Up @@ -313,7 +314,7 @@ public string GetPain001String()

/// <summary>
/// Allows direct access to the generated document object. This method is not thought to
/// be used under normal conditions however your financial institude maybe requires
/// be used under normal conditions however your financial institute maybe requires
/// setting some addittional properties.
/// </summary>
/// <returns>Document object which will be serialized to xml</returns>
Expand Down
5 changes: 4 additions & 1 deletion iso20022-generator/iso20022-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ https://www.six-group.com/dam/download/banking-services/interbank-clearing/de/st


# Version Information
## 3.0.1 (2023-04-03)
- Corrected issue with unintentionally overriding of sender information

## 3.0.0 (2023-03-30) - Breaking Changes
- Separeted Sender information from Initialzation
- Separated Sender information from Initialzation
- Changed Sender information to public property
- Added README.md for nuget package and moved help documentation to this file

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Initialization

private decimal _controlSum;
private string _contactDetailsName = "iso20022-Generator / enio AG";
private string _contactDetailsOther = "3.0.0";
private string _contactDetailsOther = "3.0.1";

public decimal ControlSum
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<PackageLicenseUrl></PackageLicenseUrl>
<PackageId>iso20022Generator</PackageId>
<Product>iso20022Generator</Product>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<Copyright>enio AG</Copyright>
<Description>This generator library helps you building iso 20022 artifacts with the minimum amount of information you need to set up valid documents. Currently pain.001 files are only supported.</Description>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
<AssemblyVersion>3.0.1.0</AssemblyVersion>
<FileVersion>3.0.1.0</FileVersion>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down

0 comments on commit b4aa21a

Please sign in to comment.