public static BankReference GetReference(BankReference reference) { try { return(InternationalReference.CreateReference(reference)); } catch (Exception e) { throw e; } }
public static BankReference CreateReference(BankReference reference) { //There is currently no format check and error handling, //currently always created from other reference that is assumed to be valid! string referenceIdentifier = "RF"; string alphanumericSequence = reference.Reference + referenceIdentifier + "00"; string digitSequence = String.Empty; CharacterConverter.Convert(alphanumericSequence, out digitSequence); string checkDigits = Modulus97.GetCheckDigits(digitSequence); string referenceSequence = referenceIdentifier + checkDigits + reference.Reference; return(new InternationalReference(referenceSequence)); }
public BankBarcode(IBAN iban, BankReference reference, Decimal sum, DateTime date) { if (reference is NationalReference) { //Barcode symbol version 4 with IBAN and national reference _barcode = buildBarcode4(iban, reference, sum, date); } else if (reference is InternationalReference) { //Barcode symbol version 5 with IBAN and international reference _barcode = buildBarcode5(iban, reference, sum, date); } else { throw new ArgumentException("Bank barcode creation failed:\nUnsupported reference type!"); } }
public static IList <BankReference> GetReferenceList(string basepart, int count) { //Create list of sequential national references //Could be extended with parameter indicating reference type to enable //getting also international references try { IList <BankReference> referenceList = new List <BankReference>(); for (int i = 0; i < count; i++) { string sequentialReferenceBody = basepart + referenceIncrement.ToString(); BankReference reference = NationalReference.CreateReference(sequentialReferenceBody); referenceList.Add(reference); referenceIncrement++; } return(referenceList); } catch (Exception e) { throw e; } }
private static string buildBarcode5(IBAN iban, BankReference reference, Decimal sum, DateTime date) { decimal maxSum = (decimal)999999.99; string barcode = String.Empty; barcode += "5"; //Version 5 barcode += iban.Iban.Substring(2); if (sum >= 0) { //Current implementation sets sum to 0 if the sum exceeds the supported range [0-999999.99] barcode += sum > maxSum ? "00000000" : sum.ToString("000000.00").Replace(",", String.Empty); } else { //Sum cannot be negative throw new ArgumentException(String.Format("Bank barcode creation failed:\nInvalid sum: {0}", sum)); } barcode += "000"; //Reserved barcode += reference.Reference.Substring(2, 2) + reference.Reference.Substring(4).PadLeft(21, '0'); barcode += date.ToString("yyMMdd"); return(barcode); }