public static bool ComposeBarCode(string accountNum, string rfNum, double sum, string dueDate, out List <int> barCode)
        {
            string res = string.Empty;

            if (IBAN.IsValidFinnishIBAN(accountNum) && (RF.IsValidFinnishRFnumber(rfNum) || RF.IsValidInternationalRFnumber(rfNum)))
            {
                res += rfNum.StartsWith("RF") ? "5" : "4";
                res += FormatAccountNumber(accountNum);
                if (sum >= 0)
                {
                    res += sum > 999999.99 ? "00000000" : int.Parse(Math.Round(sum * 100).ToString()).ToString("D8");
                }
                res += FormatRFnumber(rfNum);
                res += IsProperDate(dueDate) ? dueDate : "000000";
            }
            barCode = new List <int>();
            if (res.Length == 54)
            {
                barCode.Add(105);
                int i = 0;
                while (i < res.Length - 1)
                {
                    barCode.Add(int.Parse(res.Substring(i, 2)));
                    i += 2;
                }
                barCode.Add(CalculateCheckNumber(barCode));
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 private static bool IsValidAccountNumber(string input, out string accountNum)
 {
     input      = CommonUtilities.SanitizeAlphaNumeric(input.ToUpper());
     accountNum = input;
     if (IBAN.IsValidFinnishIBAN(input))
     {
         return(true);
     }
     if (BBAN.IsValid(input))
     {
         if (BBAN.ToIBAN(input, out accountNum))
         {
             return(true);
         }
     }
     Console.WriteLine("Syötetty tilinumero ei ollut kelvollinen.");
     return(false);
 }