Esempio n. 1
0
        public void New(int issuerEntityID, int receiverEntityID, decimal amount, int currencyID)
        {
            using (var ctx = new accountingEntities())
            using (var ts = new TransactionScope())
            {
                base.TRANSFER = new transfer()
                {
                    issuerEntityID = issuerEntityID,
                    receiverEntityID = receiverEntityID,
                    amount = amount,
                    currencyID = currencyID,
                    transferTypeID = (int)TRANSFERTYPE
                };
                ctx.transfers.AddObject(TRANSFER);

                EXTERNALTSFR = new externalTransfer { ID = TRANSFER.ID };
                ctx.externalTransfers.AddObject(EXTERNALTSFR);

                DBTSFR = new debitTransfer { ID = EXTERNALTSFR.ID };
                ctx.debitTransfers.AddObject(DBTSFR);

                ctx.SaveChanges();
                ts.Complete();
            }
        }
Esempio n. 2
0
        public void New(product p)
        {
            using (var ctx = new accountingEntities())
            {
                PRODUCT = p;

                ctx.products.AddObject(p);
                ctx.SaveChanges();
            }
        }
Esempio n. 3
0
        public void New(service s)
        {
            using (var ctx = new accountingEntities())
            {
                SERVICE = s;

                ctx.services.AddObject(s);
                ctx.SaveChanges();
            }
        }
Esempio n. 4
0
 public void addInvoiceOrderDetail(deliverable newItem)
 {
     using (var ctx = new accountingEntities())
     {
         var newOrderDetail = new orderDetail
         {
             deliverableID=newItem.ID
         };
         ctx.orderDetails.AddObject(newOrderDetail);
         ctx.SaveChanges();
     }
 }
Esempio n. 5
0
 public Transaction(decimal amount , account acc)
 {
     using (var ctx = new accountingEntities())
     {
         TXN = new transaction
         {
             accountID = acc.ID,
             amount = amount
         };
         ctx.transactions.AddObject(TXN);
         ctx.SaveChanges();
     }
 }
Esempio n. 6
0
 public void addCard(int cardID,int entityID)
 {
     using (var ctx = new accountingEntities())
     {
         var person = ctx.people.Where(x => x.ID.Equals(entityID)).SingleOrDefault();
         var newEntityCard = new entityCard()
         {
             entityID = entityID,
             cardID = cardID
         };
         ctx.entityCards.AddObject(newEntityCard);
         ctx.SaveChanges();
     }
 }
Esempio n. 7
0
        public void New(string firstName,string lastName)
        {
            using (var ctx = new accountingEntities())
            {
                var checkDuplication = ctx.people.Where(x => x.firstname == firstName && x.lastname == lastName).FirstOrDefault();
                if (checkDuplication != null)
                    throw new Exception("Person Duplicated");

                var newPerson = new person()
                {
                    firstname=firstName,
                    lastname=lastName,
                    ID = base.ENTITY.ID
                };
                ctx.people.AddObject(newPerson);
                ctx.SaveChanges();

                this.PERSON = newPerson;
            }
        }
Esempio n. 8
0
        public void New(string CurrencyName, int currencyTypeID)
        {
            using (var ctx = new accountingEntities())
            {
                var newCur = new currency
                {
                    currencyTypeID = currencyTypeID,
                    name = CurrencyName
                };
                var result = ctx.currencies.FirstOrDefault(x => x.name.Equals(CurrencyName) &&  x.currencyTypeID.Equals(currencyTypeID));
                if (result != null)
                    throw new Exception("Currency Duplicated");
                else
                {
                    ctx.currencies.AddObject(newCur);
                    ctx.SaveChanges();

                }
            }
        }
Esempio n. 9
0
        public account Create(int ownerEntityId,int currencyID,decimal balance=0)
        {
            using (var ctx = new accountingEntities())
            {
                var duplicate = ctx.accounts
                    .Where(x => x.ownerEntityID == ownerEntityId && x.currencyID == currencyID && x.catTypeID ==CATTYPE)
                    .SingleOrDefault();
                if (duplicate != null)
                    ctx.DeleteObject(duplicate);
                var newAccount = new account()
                {
                    catTypeID=CATTYPE,
                    ownerEntityID=ownerEntityId,
                    currencyID=currencyID,
                    balance=balance
                };
                ctx.accounts.AddObject(newAccount);
                ctx.SaveChanges();

                return newAccount;
            }
        }
Esempio n. 10
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();
                }
            }
        }
Esempio n. 11
0
        /*Payment for Invoice*/
        public void Transfer_Internal(decimal amount)
        {
            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
                InternalTransfer iPayment = new InternalTransfer();
                iPayment.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 = iPayment.TRANSFER.ID
                };
                ctx.invoiceTransfers.AddObject(NewInvTransfer);
                ctx.SaveChanges();

                //Record related transctions [for invoice payment]
                List<transaction> transactions = new List<transaction>();

                account acc_W = Account.getAccount((int)INV.order.issuerEntityID, (int)projectEnums.catType.W, (int)INV.currencyID);
                var t1 = new Transaction(-1 * (decimal)amount, acc_W);
                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_W2 = Account.getAccount((int)INV.order.receiverEntityID, (int)projectEnums.catType.W, (int)INV.currencyID);
                var t3 = new Transaction(+1 * (decimal)amount, acc_W2);
                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);

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

                /*Record Invoice Transaction*/
                this.RecordInvoiceTransaction(transactions, projectEnums.invoiceStatus.internalTransfer);

                ts.Complete();
            }
        }
Esempio n. 12
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();
            }
        }
Esempio n. 13
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();

            }
        }
Esempio n. 14
0
        public void New(invoice inv)
        {
            INV = inv;

            using (var ctx = new accountingEntities())
            using (var ts = new TransactionScope())
            {
                //Entity
                var e = new entity{entityTypeID = (int)projectEnums.entityType.invoice};
                ctx.entities.AddObject(e);

                //New Invoice
                var newInvoice = new invoice()
                {
                    currencyID = inv.currencyID,
                    ID=e.ID
                };

                //sys Action
                var sysaction = new sysAction{sysActionTypeID=(int)projectEnums.sysAction.invoice};
                ctx.sysActions.AddObject(sysaction);

                //sys Action Invoice
                var sysActionInvoice = new invoiceAction
                {
                    ID = sysaction.ID,
                    invoiceStatusID= (int)projectEnums.invoiceStatus.Generated,
                    name="Invoice Generated at "+DateTime.Now.ToLongTimeString()
                };
                ctx.invoiceActions.AddObject(sysActionInvoice);

                ctx.SaveChanges();
                ts.Complete();
            }
        }