Exemplo n.º 1
0
        private static ParseResult ParseNumberFFBBBUUUUP([NotNull] string number, [NotNull] string originalNumber, Province province)
        {
            if (number.Length != 10)
            {
                return(ParseResult.AsError(originalNumber, province, TaxNumberStatus.InvalidLength));
            }

            string prefix;

            switch (province)
            {
            case Elster.Province.Berlin:
                prefix = "11";
                break;

            case Elster.Province.Hamburg:
                prefix = "22";
                break;

            case Elster.Province.RheinlandPfalz:
                prefix = "27";
                break;

            case Elster.Province.BadenWuerttemberg:
                prefix = "28";
                break;

            case Elster.Province.Bremen:
                prefix = "24";
                break;

            case Elster.Province.Niedersachsen:
                prefix = "23";
                break;

            case Elster.Province.SchleswigHolstein:
                prefix = "21";
                break;

            default:
                throw new NotSupportedException($"Kein Präfix für das Bundesland {province} hinterlegt");
            }

            var result = string.Format(
                "{4}{0}0{1}{2}{3}",
                number.Substring(0, 2),
                number.Substring(2, 3),
                number.Substring(5, 4),
                number.Substring(9, 1),
                prefix);

            return(ParseResult.AsSuccess(result, province));
        }
Exemplo n.º 2
0
        private static ParseResult ParseNumberFFFBBBBUUUP([NotNull] string number, [NotNull] string originalNumber, Province province)
        {
            if (number.Length != 11)
            {
                return(ParseResult.AsError(originalNumber, province, TaxNumberStatus.InvalidLength));
            }
            const string prefix = "5";
            var          result = string.Format(
                "{4}{0}0{1}{2}{3}",
                number.Substring(0, 3),
                number.Substring(3, 3),
                number.Substring(6, 4),
                number.Substring(10, 1),
                prefix);

            return(ParseResult.AsSuccess(result, province));
        }
Exemplo n.º 3
0
        private ParseResult <Foo> ParseFoo(string rawValue)
        {
            // Convert raw input to concrete type

            var values = rawValue.Split(':');

            if (values.Length == 2)
            {
                var value = new Foo
                {
                    Key   = values[0],
                    Value = values[1],
                };

                return(ParseResult.AsSuccess(value));
            }
            return(ParseResult.AsError <Foo>("Invalid value. Must be in `<key>:<value>` format"));
        }
Exemplo n.º 4
0
        private static ParseResult ParseNumber0FFBBBUUUUP([NotNull] string number, [NotNull] string originalNumber, Province province)
        {
            if (number.Length != 10 && (number.Length != 11 || number[0] != '0'))
            {
                return(ParseResult.AsError(originalNumber, province, TaxNumberStatus.InvalidLength));
            }
            const string prefix      = "26";
            var          startOffset = (number.Length == 10) ? 0 : 1;
            var          result      = string.Format(
                "{4}{0}0{1}{2}{3}",
                number.Substring(startOffset, 2),
                number.Substring(startOffset + 2, 3),
                number.Substring(startOffset + 5, 4),
                number.Substring(startOffset + 9, 1),
                prefix);

            return(ParseResult.AsSuccess(result, province));
        }
Exemplo n.º 5
0
        private static ParseResult ParseNumberFFFBBBUUUUP([NotNull] string number, [NotNull] string originalNumber, Province province)
        {
            if (number.Length != 11)
            {
                return(ParseResult.AsError(originalNumber, province, TaxNumberStatus.InvalidLength));
            }

            string prefix;

            switch (province)
            {
            case Elster.Province.Bayern:
                prefix = "9";
                break;

            case Elster.Province.Brandenburg:
            case Elster.Province.Sachsen:
            case Elster.Province.SachsenAnhalt:
                prefix = "3";
                break;

            case Elster.Province.MecklenburgVorpommern:
            case Elster.Province.Thueringen:
                prefix = "4";
                break;

            case Elster.Province.Saarland:
                prefix = "1";
                break;

            default:
                throw new NotSupportedException($"Kein Präfix für das Bundesland {province} hinterlegt");
            }

            var result = string.Format(
                "{4}{0}0{1}{2}{3}",
                number.Substring(0, 3),
                number.Substring(3, 3),
                number.Substring(6, 4),
                number.Substring(10, 1),
                prefix);

            return(ParseResult.AsSuccess(result, province));
        }