Ejemplo n.º 1
0
        public static SnbDepositPayment Parse(IposDepositPayment[] lines)
        {
            var credit = lines.Single(x => x.PostingKey == "50");
            var debit  = lines.Single(x => x.PostingKey == "40");
            var p      = new SnbDepositPayment
            {
                Sequence     = credit.SequenceNumber,
                DocumentDate = credit.DocumentDate,
                PostingDate  = credit.PostingDate,
                CostCenter   = credit.CostCenter
            };

            if (debit.AccountNo == "272120")
            {
                p.PaymentMethod = "Cheque";
                p.CheckNo       = debit.Text;
            }

            if (debit.AccountNo == "272110")
            {
                p.PaymentMethod = "Cash";
            }
            p.Amount      = credit.Amount;
            p.ReferenceNo = credit.Text;
            p.ReceiptNo   = debit.ReferenceKey;
            return(p);
        }
Ejemplo n.º 2
0
        public IEnumerable <SnbDepositPayment> Process(IEnumerable <string> lines)
        {
            var fields = new Dictionary <string, int> {
                { "DocumentDate", 8 },
                { "PostingDate", 8 },
                { "DocumentType", 2 },
                { "Currency", 5 },
                { "ExchangeRate", 9 },
                { "Reference", 16 },
                { "DocumentHeaderText", 25 },
                { "PostingKey", 2 },
                { "AccountNo", 10 },
                { "Amount", 15 },
                { "CostCenter", 10 },
                { "Quantity", 13 },
                { "Assignment", 2 },
                { "Text", 18 },
                { "ReferenceKey", 50 },
                { "SequenceNumber", 5 }
            };

            var positions    = fields.Values.ToArray();
            var names        = fields.Keys.ToArray();
            var sequence     = 0;
            var engine       = new FileHelperEngine <IposDepositPayment>();
            var transactions = new List <IposDepositPayment>();

            var payments = new List <SnbDepositPayment>();

            foreach (var line in lines)
            {
                if (line.StartsWith("EOF"))
                {
                    continue;
                }
                /**/
                for (int i = 0; i < positions.Length; i++)
                {
                    var value = line.Substring(positions.Take(i).Sum(x => x), positions[i]);
                    Debug.Write($"{names[i]} = {value}, ");
                }
                Debug.WriteLine("");
                Debug.WriteLine("--------------------");
                var record = engine.ReadString(line)[0];
                if (record.SequenceNumber == sequence)
                {
                    transactions.Add(record);
                    continue;
                }
                sequence = record.SequenceNumber;
                if (transactions.Count > 0)
                {
                    var snb = SnbDepositPayment.Parse(transactions.ToArray());
                    payments.Add(snb);
                }
                transactions = new List <IposDepositPayment> {
                    record
                };
            }
            var snb2 = SnbDepositPayment.Parse(transactions.ToArray());

            payments.Add(snb2);


            return(payments);
        }