Ejemplo n.º 1
0
        public List<transaction> cancelTransfer(projectEnums.transferAction tsfrAction)
        {
            if (TRANSFER.Equals(null))
                throw new Exception("Transfer has not been loaded");

            List<transaction> reveresedTransactions=new List<transaction>();

            //get Related transacions and input reveres ones
            using (var ctx = new accountingEntities())
            {
                //Transfer Transactions
                var Transactions = ctx.transferActions
                    .Join(ctx.sysActionTransactions, ta => ta.ID, sat => sat.sysActionID, (ta, sat) => new { ta,sat})
                    .Where(x => x.ta.transferID.Equals(TRANSFER.ID))
                    .Where(x => x.ta.transferActionTypeID.Equals(tsfrAction))
                    .Join(ctx.transactions, J => J.sat.transactionID, tr => tr.ID, (J, tr) =>  tr)
                    .ToList();

                //enter and save revered Transactions
                foreach (var txn in Transactions)
                {
                    account acc = Account.getAccount((int)txn.accountID);
                    var tx = new Transaction(-1 * (decimal)txn.amount, acc);
                    reveresedTransactions.Add(tx.TXN);
                }

                //IF PAYMENT ACTION IS REFUND, NEW FEE HANDLING TRANSACTIONS WOULD BE NEEDED

            }
            return reveresedTransactions;
        }
Ejemplo n.º 2
0
 protected void payInvoiceByCC(Invoice inv, decimal amount, int cardID, projectEnums.ccCardType cardType)
 {
     inv.Transfer_Ext_Credit(amount, cardID, cardType);
 }
Ejemplo n.º 3
0
        public void Transfer_Ext_Credit(decimal amount, int cardID, projectEnums.ccCardType ccCardType)
        {
            if (INV.Equals(null))
                throw new Exception("No invocie set.pleae laod or create new Invoice");

            using (var ctx = new accountingEntities())
            using (var ts = new TransactionScope())
            {
                //create new Internal Payment
                CreditTransfer ccPayment = new CreditTransfer();
                ccPayment.New((int)INV.order.receiverEntityID, (int)INV.order.issuerEntityID, amount, (int)INV.currencyID);

                /*Record New Invoice Payment*/
                var NewInvTransfer = new invoiceTransfer()
                {
                    invoiceID = INV.ID,
                    transferID = ccPayment.TRANSFER.ID
                };
                ctx.invoiceTransfers.AddObject(NewInvTransfer);
                ctx.SaveChanges();

                //Record related transctions [for invoice Transfer]
                var FEE = 1;
                List<transaction> transactions = new List<transaction>();

                account acc_CCCASH = Account.getAccount((int)INV.order.receiverEntityID, (int)projectEnums.catType.CCCASH, (int)INV.currencyID);
                var t1 = new Transaction(-1 * (decimal)amount, acc_CCCASH);
                transactions.Add(t1.TXN);

                account acc_AP = Account.getAccount((int)INV.order.receiverEntityID, (int)projectEnums.catType.AP, (int)INV.currencyID);
                var t2 = new Transaction(+1 * (decimal)amount, acc_AP);
                transactions.Add(t2.TXN);

                account acc_W = Account.getAccount((int)INV.order.issuerEntityID, (int)projectEnums.catType.W, (int)INV.currencyID);
                var t3 = new Transaction(+1 * (decimal)amount  -  FEE, acc_W);
                transactions.Add(t3.TXN);

                account acc_AR = Account.getAccount((int)INV.order.issuerEntityID, (int)projectEnums.catType.AR, (int)INV.currencyID);
                var t4 = new Transaction(-1 * (decimal)amount, acc_AR);
                transactions.Add(t4.TXN);

                account acc_EXP = Account.getAccount((int)INV.order.issuerEntityID, (int)projectEnums.catType.AR, (int)INV.currencyID);
                var t5 = new Transaction(FEE, acc_EXP);
                transactions.Add(t5.TXN);

                /*Record Invoice Payment transactions*/
                this.RecordInvoiceTransferTransactions(transactions, ccPayment.TRANSFER.ID, projectEnums.transferStatus.PaidApproved);

                /*Record Invoice Transaction*/
                projectEnums.invoiceStatus? invoicestat = null;
                switch (ccCardType)
                {
                    case projectEnums.ccCardType.MASTERCARD:
                        invoicestat = projectEnums.invoiceStatus.masterCardTransfer;
                        break;
                    case projectEnums.ccCardType.VISACARD:
                        invoicestat = projectEnums.invoiceStatus.visaCardTransfer;
                        break;
                }

                this.RecordInvoiceTransaction(transactions, (projectEnums.invoiceStatus)invoicestat);

                ts.Complete();
            }
        }
Ejemplo n.º 4
0
        private void RecordInvoiceTransferTransactions(List<transaction> txns, int transferID, projectEnums.transferStatus transferStat)
        {
            using (var ctx = new accountingEntities())
            {
                //Create Payment Action
                var transferAction = new transferAction()
                {
                    transferID = transferID,
                    transferStatusID = (int)transferStat
                };
                ctx.transferActions.AddObject(transferAction);
                ctx.SaveChanges();

                //Record Pyament Action TXNS
                foreach (var txn in txns)
                {
                    var NewsysActionTxn = new sysActionTransaction()
                    {
                        sysActionID = -1,
                        transactionID = txn.ID
                    };
                    ctx.sysActionTransactions.AddObject(NewsysActionTxn);
                    ctx.SaveChanges();
                }
            }
        }
Ejemplo n.º 5
0
        public void RecordInvoiceTransaction(List<transaction> transactions, projectEnums.invoiceStatus invoiceStat)
        {
            if (INV.Equals(null))
                throw new Exception("Invoice does not exists");

            using (var ctx = new accountingEntities())
            using (var ts = new TransactionScope())
            {
                //create invoice Action
                var invAction = new invoiceAction()
                {
                    invoiceID = INV.ID,
                    invoiceStatusID = (int)invoiceStat
                };
                ctx.invoiceActions.AddObject(invAction);
                ctx.SaveChanges();

                //create invoice Transactions and invoice action Transactions
                foreach (var item in transactions)
                {
                    var invActionTrans = new sysActionTransaction()
                    {
                        sysActionID = invAction.ID,
                        transactionID = item.ID
                    };
                    ctx.sysActionTransactions.AddObject(invActionTrans);

                    ctx.SaveChanges();
                }

                ts.Complete();

            }
        }