private void AddPaymentRecord(MassPaymentOrder order, long AccountNumber, int Amount, long PayeeAccNum,
                                      string payeeName)
        {
            var record = new BETFOR22();

            record.EnterpriseNum = EnterpriseNumber;

            record.Header = CreateDefaultHeader();

            record.AccountNumber = AccountNumber;
            record.Amount        = Amount;
            record.PayeeAccNum   = PayeeAccNum;
            record.PayeeName     = payeeName;

            order.AddRecord(record);
        }
        private void AddTransferRecord(MassPaymentOrder order, long AccountNumber, DateTime PaymentDate, string OwnRef,
                                       TextCode textCode, TransferCode transferCode)
        {
            var transferRecord = new BETFOR21();

            transferRecord.Header = CreateDefaultHeader();

            transferRecord.EnterpriseNum = EnterpriseNumber;


            transferRecord.AccountNumber = AccountNumber;
            transferRecord.PaymentDate   = PaymentDate.ToString("yyMMdd");
            transferRecord.OwnRefOrder   = OwnRef;
            transferRecord.TextCode      = textCode;
            transferRecord.TransferCode  = transferCode;

            order.TransferRecord = transferRecord;
        }
        public void AddPayment(long AccountNumber, DateTime PaymentDate, string OwnRef, TextCode textCode,
                               TransferCode transferCode, int Amount, long PayeeAccNum, string PayeeName)
        {
            MassPaymentOrder order =
                PaymentOrders.Where(o => ((BETFOR21)o.TransferRecord).AccountNumber == AccountNumber)
                .Select(o => (MassPaymentOrder)o)
                .FirstOrDefault();

            if (order == null)
            {
                order = new MassPaymentOrder();
                PaymentOrders.Add(order);
            }

            if (order.TransferRecord == null || ((BETFOR21)order.TransferRecord).AccountNumber != null)
            {
                AddTransferRecord(order, AccountNumber, PaymentDate, OwnRef, textCode, transferCode);
            }

            AddPaymentRecord(order, AccountNumber, Amount, PayeeAccNum, PayeeName);
        }
Beispiel #4
0
        public static void SetValue(string data, PropertyInfo prop, TelepayFieldAttribute attr, object obj)
        {
            object value = null;

            switch (attr.Type)
            {
            case FieldType.Object:
            {
                var t = prop.PropertyType;
                if ((typeof(List <PaymentOrder>).IsAssignableFrom(t)))
                {
                    var orders = new List <PaymentOrder>();
                    // PaymentOrder val = new PaymentOrder();

                    PaymentOrder order = null;

                    for (int i = 0; i < data.Length; i = i + BatchBase.RecordLength)
                    {
                        BetforBase rec = new BetforBase();
                        ParseObject(data.Substring(i, BatchBase.RecordLength), rec);

                        switch (rec.TransactionCode)
                        {
                        case RecordType.BETFOR21:
                            var trRec = new BETFOR21();
                            order         = new PaymentOrder();
                            order.Records = new List <BetforBase>();
                            ParseObject(data.Substring(i, BatchBase.RecordLength), trRec);
                            order.TransferRecord = trRec;
                            break;

                        case RecordType.BETFOR01:
                            var trRecInt = new BETFOR01();
                            var ordTmp   = new InternationalPaymentOrder();
                            ordTmp.Invoice     = new BETFOR04();
                            ordTmp.BankDetails = new BETFOR02();
                            ordTmp.Payee       = new BETFOR03();
                            order = ordTmp;
                            ParseObject(data.Substring(i, BatchBase.RecordLength), trRecInt);
                            order.TransferRecord = trRecInt;
                            orders.Add(order);
                            break;

                        case RecordType.BETFOR02:
                            if (order != null)
                            {
                                var payment = new BETFOR02();
                                ParseObject(data.Substring(i, BatchBase.RecordLength), payment);
                                ((InternationalPaymentOrder)order).BankDetails = payment;
                            }
                            break;

                        case RecordType.BETFOR03:
                            if (order != null)
                            {
                                var payment = new BETFOR03();
                                ParseObject(data.Substring(i, BatchBase.RecordLength), payment);
                                ((InternationalPaymentOrder)order).Payee = payment;
                            }
                            break;

                        case RecordType.BETFOR04:
                            if (order != null)
                            {
                                var payment = new BETFOR04();
                                ParseObject(data.Substring(i, BatchBase.RecordLength), payment);
                                ((InternationalPaymentOrder)order).Invoice = payment;
                            }
                            break;

                        case RecordType.BETFOR22:
                            if (order != null)
                            {
                                if (!(typeof(MassPaymentOrder).Equals(order.GetType())))
                                {
                                    var ord = new MassPaymentOrder();
                                    ord.TransferRecord = order.TransferRecord ?? null;
                                    order         = ord;
                                    order.Records = new List <BETFOR22>();
                                    orders.Add(order);
                                }
                                var payment = new BETFOR22();
                                ParseObject(data.Substring(i, BatchBase.RecordLength), payment);
                                order.AddRecord(payment);
                            }
                            break;

                        case RecordType.BETFOR23:
                            if (order != null)
                            {
                                if (!(typeof(InvoicesPaymentOrder).Equals(order.GetType())))
                                {
                                    var ord = new InvoicesPaymentOrder();
                                    ord.TransferRecord = order.TransferRecord ?? null;
                                    order         = ord;
                                    order.Records = new List <BETFOR21>();
                                    orders.Add(order);
                                }
                                var payment = new BETFOR21();
                                ParseObject(data.Substring(i, BatchBase.RecordLength), payment);
                                order.AddRecord(payment);
                            }
                            break;
                        }
                    }
                    value = orders;
                }
                else if ((typeof(IEnumerable <BetforBase>)).IsAssignableFrom(prop.PropertyType))
                {
                    var records = new List <BetforBase>();
                    var record  = new BetforBase();
                    ParseObject(data, record);
                    switch (record.TransactionCode)
                    {
                    case RecordType.BETFOR21:
                        record = new BETFOR21();
                        break;

                    case RecordType.BETFOR22:
                        record = new BETFOR22();
                        break;
                    }
                    ParseObject(data, record);
                    records.Add(record);
                    value = records;
                }
                else if ((typeof(TelepayObject).IsAssignableFrom(prop.PropertyType)))
                {
                    value = Activator.CreateInstance(prop.PropertyType);
                    ParseObject(data, value);
                }
            }
            break;

            default:
                value = ParseData(data, attr);
                break;
            }

            if (prop.PropertyType.IsEnum)
            {
                value = Enum.Parse(prop.PropertyType, value.ToString());
            }

            prop.SetValue(obj, value, null);
        }