Example #1
0
        private void ReadEntryDate(ref StatementLine statementLine)
        {
            var value = _reader.ReadWhile(c => char.IsNumber(c), 4);

            if (value.Length > 0)
            {
                if (value.Length < 4)
                {
                    throw new InvalidDataException("The statement line data ended unexpectedly. Detected field \"Entry Date\", however the field does not have the expected four characters.");
                }

                var valueDateYear = statementLine.ValueDate.Value.ToString("yy");
                value = $"{valueDateYear}{value}";

                var date = DateParser.Parse(value);

                if (date > statementLine.ValueDate)
                {
                    date = date.AddYears(-1);  // Correct entry date if new year has happened between entry and value date.
                }

                statementLine.EntryDate = date;
            }

            ReadDebitCreditMark(ref statementLine);
        }
Example #2
0
        private void ReadStatementDate(ref Balance balance)
        {
            var value = _reader.ReadWhile(char.IsDigit, 6);

            if (value.Length < 6)
            {
                throw new InvalidDataException("The balance data ended unexpectedly. Expected value Date with a length of six characters.");
            }

            balance.Date = DateParser.Parse(value);

            ReadCurrency(ref balance);
        }
Example #3
0
        private void ReadValueDate(ref StatementLine statementLine)
        {
            var value = _reader.Read(6);

            if (value.Length < 6)
            {
                throw new InvalidDataException("The statement line data ended unexpectedly. Expected \"Value Date\" with a length of six characters.");
            }

            statementLine.ValueDate = DateParser.Parse(value);

            ReadEntryDate(ref statementLine);
        }
Example #4
0
        private void DetectFieldCode(ref Information information)
        {
            var value = _reader.Read(2);

            if (value.Length < 2)
            {
                throw new InvalidDataException("Unexpected end of statement. Expected \"Field Code\"");
            }
            if (!char.IsDigit(value[0]))
            {
                value += _reader.ReadWhile(c => c != ':').Trim();
                value += _reader.Read(1);
                value  = value.Trim();
            }

            switch (value)
            {
            case "00":
                information.PostingText = ReadValue();
                break;

            case "10":
                information.JournalNumber = ReadValue();
                break;

            case "20":
                information.OperationDescription = ReadValue();
                break;

            case "21":
            case "22":
            case "23":
            case "24":
            case "25":
            case "TYT.:":
                information.OperationDescription += ReadValue();
                break;

            case "26":
                information.UploadDate = DateParser.Parse(ReadValue());
                break;

            case "27":
            case "28":
                information.ContragentName += ReadValue();
                break;

            case "29":
            case "60":
                information.ContragentAddress += ReadValue();
                break;

            case "30":
                information.BankCodeOfPayer = ReadValue();
                break;

            case "31":
                information.AccountIDOfPayer = ReadValue();
                break;

            case "32":
            case "DLA:":
                ReadNameOfPayer(ref information);
                break;

            case "33":
                information.AddressOfPayer = ReadValue();
                break;

            case "34":
                ReadTextKeyAddition(ref information);
                break;

            case "38":
                information.AccountNumberOfPayer = ReadValue();
                break;

            case "61":
            case "62":
            case "63":
            case "REF. KLIENTA:":
                ReadRemittanceInformation(ref information);
                break;

            default:
                information.UnstructuredRemittanceInformation += ReadValue();
                break;
            }

            ReadSeparator(ref information);
        }