protected virtual CodaTransaction ParseTransaction(IEnumerable <ICodaTransactionComponentLine> lines) { CodaTransactionPart1Line transactionPart1Line = lines.OfType <CodaTransactionPart1Line>().Single(); CodaTransactionPart2Line transactionPart2Line = lines.OfType <CodaTransactionPart2Line>().FirstOrDefault(); CodaTransactionPart3Line transactionPart3Line = lines.OfType <CodaTransactionPart3Line>().FirstOrDefault(); CodaInformationPart1Line informationPart1Line = lines.OfType <CodaInformationPart1Line>().FirstOrDefault(); BankAccount counterPartyAccount = null; if (transactionPart3Line != null) { counterPartyAccount = BankAccount.CreateFrom(transactionPart3Line.CounterPartyAccount, null, null, transactionPart2Line.CounterPartyBic); } CodaCommunication communication = null; if (transactionPart1Line?.Communication == null) { communication = transactionPart1Line.Communication; } else if (informationPart1Line?.Communication == null) { communication = informationPart1Line?.Communication; } string message = Regex.Replace(this.ParseTransactionMessage(lines).Trim(), " {2,}", " "); return(new CodaTransaction(transactionPart1Line.Type, transactionPart1Line.Family, transactionPart1Line.Operation, transactionPart1Line.Category, transactionPart1Line.StatementSequenceNumber, transactionPart1Line.SequenceNumber, transactionPart1Line.Reference, transactionPart1Line.EntryDate, transactionPart1Line.EffectiveDate, transactionPart1Line.Amount, counterPartyAccount, transactionPart1Line.Communication, message, transactionPart1Line.GlobalizationCode)); }
protected virtual CodaLine ParseTransactionPart1(string line) { int sequenceNumber = int.Parse(line.Substring(2, 4).Trim()); int detailNumber = int.Parse(line.Substring(6, 4).Trim()); string reference = line.Substring(10, 21).Trim(); CodaTransactionType type = (CodaTransactionType)int.Parse(line[31].ToString()); decimal amount = decimal.Parse(line.Substring(32, 15).Trim()) / 1000; if (type == CodaTransactionType.Debit) { amount *= -1; } string codaDate = line.Substring(47, 6).Trim(); DateTime?effectiveDate = null; if (codaDate != "000000") { effectiveDate = CodaDate.Parse(codaDate); } string code = line.Substring(53, 8).Trim(); string family = code.Substring(1, 2).Trim(); string operation = code.Substring(3, 2).Trim(); string category = code.Substring(5, 3).Trim(); CodaCommunication communication = CodaCommunication.Parse(line.Substring(61, 54).Trim(), family == "05"); DateTime entryDate = CodaDate.Parse(line.Substring(115, 6).Trim()); int statementSequenceNumber = int.Parse(line.Substring(121, 3).Trim()); int globalizationCode = int.Parse(line.Substring(124, 1).Trim()); return(new CodaTransactionPart1Line(sequenceNumber, statementSequenceNumber, detailNumber, reference, effectiveDate, entryDate, type, code, family, operation, category, communication, amount, globalizationCode)); }
protected virtual CodaLine ParseInformationPart1(string line) { int sequenceNumber = int.Parse(line.Substring(2, 4).Trim()); int detailNumber = int.Parse(line.Substring(6, 4).Trim()); string reference = line.Substring(10, 31).Trim(); string transactionCode = line.Substring(31, 8).Trim(); CodaCommunication communication = CodaCommunication.Parse(line.Substring(39, 74).Trim(), false); return(new CodaInformationPart1Line(sequenceNumber, detailNumber, reference, transactionCode, communication)); }
public CodaTransactionPart1Line(int sequenceNumber, int statementSequenceNumber, int detailNumber, string reference, DateTime?effectiveDate, DateTime entryDate, CodaTransactionType type, string code, string family, string operation, string category, CodaCommunication communication, decimal amount, int globalizationCode) : base(CodaLineType.TransactionPart1) { this.SequenceNumber = sequenceNumber; this.StatementSequenceNumber = statementSequenceNumber; this.DetailNumber = detailNumber; this.Reference = reference; this.EffectiveDate = effectiveDate; this.EntryDate = entryDate; this.Type = type; this.Code = code; this.Family = family; this.Operation = operation; this.Category = category; this.Communication = communication; this.Amount = amount; this.GlobalizationCode = globalizationCode; }
public CodaTransaction(CodaTransactionType type, string family, string operation, string category, int statementSequenceNumber, int sequenceNumber, string reference, DateTime entryDate, DateTime?effectiveDate, decimal amount, BankAccount counterPartyAccount, CodaCommunication communication, string message, int globalizationCode) { this.Type = type; this.Family = family; this.Operation = operation; this.Category = category; this.StatementSequenceNumber = statementSequenceNumber; this.SequenceNumber = sequenceNumber; this.Reference = reference; this.EntryDate = entryDate; this.EffectiveDate = effectiveDate; this.Amount = amount; this.CounterPartyAccount = counterPartyAccount; this.Communication = communication; this.Message = message; this.GlobalizationCode = globalizationCode; }