private void RecordInvoicePaymentTransactions(List <int> txns, int paymentID, enums.paymentStat payStat) { using (var ctx = new AccountingLib.Models.AccContexts()) { //Create Payment Action var payAction = new AccountingLib.Models.paymentAction() { paymentID = paymentID, paymentStatID = (int)payStat }; ctx.paymentAction.AddObject(payAction); ctx.SaveChanges(); //Record Pyament Action TXNS foreach (var txn in txns) { var newPayActionTxn = new paymentActionTransaction() { paymentActionID = payAction.ID, transactionID = txn }; ctx.paymentActionTransaction.AddObject(newPayActionTxn); ctx.SaveChanges(); } } }
public void createNew(int bankID, decimal amount, string description, int ccCardTypeID) { using (var ctx = new AccountingLib.Models.AccContexts()) { var existingFee = ctx.ccFee .Where(x => x.ccCardTypeID == ccCardTypeID && x.bankID == bankID).SingleOrDefault(); if (existingFee != null) { ctx.ccFee.DeleteObject(existingFee); ctx.SaveChanges(); } var _ccFee = new AccountingLib.Models.ccFee() { bankID = (int)bankID, ccCardTypeID = (int)ccCardTypeID, amount = (decimal)amount, description = description }; ctx.ccFee.AddObject(_ccFee); ctx.SaveChanges(); /*Reload Object*/ this.loadFeeByID(_ccFee.ID); } }
public void createNew(int cardTypeID) { if (this.cardNumber == null) throw new Exception("No Card Number Entered"); if (this.expiryDate == null) throw new Exception("No Expiy Date Entered"); using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { var newCard = new AccountingLib.Models.card() { cardTypeID = cardTypeID, cardNumber = this.cardNumber, expiryDate = this.expiryDate }; ctx.card.AddObject(newCard); ctx.SaveChanges(); /*Reload object Props*/ this.loadByCardID(newCard.ID); ts.Complete(); } }
public static AccountingLib.Models.account getAccount(int entityID, int catTypeID, int currencyID) { using (var ctx = new AccContexts()) { var account = ctx.account.Where(x => x.catTypeID == catTypeID && x.ownerEntityID == entityID && x.currencyID == currencyID).SingleOrDefault(); return account; } }
public void loadccFeeByBankCardTypeID(int ccCardTypeID, int bankID) { using (var ctx = new AccContexts()) { var ccfee = ctx.ccFee.Where(x => (int)x.ccCardTypeID == ccCardTypeID && x.bankID == bankID) .SingleOrDefault(); if (ccfee == null) throw new Exception("CC fee does not Exists [loadccFeeByBankCardTypeID]"); this.loadFeeByID(ccfee.ID); } }
public List<AccountingLib.Models.card> fetchCards() { using (var ctx = new AccContexts()) { var cardsList = ctx.entityCard .Where(x => x.entityID == this.ENTITYID) .Select(x => x.card).ToList(); this.cards = cardsList; return cardsList; } }
public void loadBankByEntityID(int entityID) { using (var ctx = new AccContexts()) { var _bank = ctx.bank .Where(x => x.entityID == entityID).SingleOrDefault(); if (_bank == null) throw new Exception("bank has not found"); this.bankID = _bank.ID; this.bankName = _bank.name; base.ENTITYID = (int)_bank.entityID; } }
public Bank getBankByCard(int cardID) { using (var ctx = new AccountingLib.Models.AccContexts()) { var theBank = ctx.entityCard .Where(x => x.CardID == cardID) .Where(x => x.entity.entityTypeID == (int)enums.entityType.bank) .SingleOrDefault(); Bank b = new Bank(); b.loadBankByEntityID((int)theBank.entityID); return(b); } }
public new void loadByPaymentID(int paymentID) { using (var ctx = new AccContexts()) { base.loadByPaymentID(paymentID); var internalPaymentRecord = ctx.internalPayment .Where(x => x.paymentID == paymentID) .SingleOrDefault(); if (internalPaymentRecord == null) throw new Exception("no such a EXT Payment Exists"); this.internalPaymentID = internalPaymentRecord.ID; this.internalPaymentDescription = internalPaymentRecord.description; } }
public invoiceService addService(int serviceID,decimal amount) { using (var ctx = new AccContexts()) { var newInvoiceService= new AccountingLib.Models.invoiceService() { invoiceID=this.invoiceID, serviceID=serviceID, currencyID=this.currencyID, amount=amount }; ctx.invoiceService.AddObject(newInvoiceService); ctx.SaveChanges(); return newInvoiceService; } }
public void addCard(int cardID) { int entityID = (int)this.ENTITYID; using (var ctx = new AccContexts()) { var person = ctx.person.Where(x => x.entityID == entityID).SingleOrDefault(); var newEntityCard = new AccountingLib.Models.entityCard() { entityID = this.ENTITYID, CardID = cardID }; ctx.entityCard.AddObject(newEntityCard); ctx.SaveChanges(); } }
public void loadFeeByID(int ccfeeID) { using (var ctx = new AccContexts()) { var _fee = ctx.ccFee .Where(x => x.ID == ccfeeID) .SingleOrDefault(); if (_fee == null) throw new Exception("no such a CCFee Exists"); this.ccfeeID = _fee.ID; this.bankID = (int)_fee.bankID; this.ccCardTypeID = (int)_fee.ccCardTypeID; this.amount = (decimal)_fee.amount; this.deacription = _fee.description; } }
public List<int> cancelPayment(enums.paymentAction _paymentAction) { //First check this payment is able to be cancelled ************ //get Related transacions and input reveres ones using (var ctx = new AccContexts()) { //get Payment details var payment = ctx.payment .Where(x => x.ID == paymentID).SingleOrDefault(); if (payment == null) throw new Exception("Payment Could not be found"); this.paymentID=(int)payment.ID; this.payerEntityID=(int)payment.payerEntityID; this.payeeEntityID=(int)payment.payeeEntityID; this.amount=(decimal)payment.amount; this.currencyID=(int)payment.currencyID; //get payment Transactions var paymentTransactions = ctx.paymentAction .Where(x => x.paymentID == this.paymentID) .Single() .paymentActionTransaction .Select(x => new { ownerEntityID=x.transaction.account.ownerEntityID, catTypeID = x.transaction.account.catTypeID, amount = x.transaction.amount, currencyID = x.transaction.account.currencyID }) .ToList(); //enter and save revered Transactions List<int> reveresedTransactions = new List<int>(); foreach (var txn in paymentTransactions) reveresedTransactions.Add(Transaction.createNew((int)txn.ownerEntityID, (int)txn.catTypeID, -1 * (decimal)txn.amount, (int)txn.currencyID)); //IF PAYMENT ACTION IS REFUND, NEW FEE HANDLING TRANSACTIONS WOULD BE NEEDED return reveresedTransactions; } }
public new void createNew(int payerEntityID, int payeeEntityID, decimal amount, int currencyID, int cardID) { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { base.createNew(payerEntityID, payeeEntityID, amount, currencyID, cardID, (int)enums.extPaymentType.CreditPayment); var _ccPayment = new AccountingLib.Models.ccPayment() { extPaymentID=base.extPaymentID }; ctx.ccPayment.AddObject(_ccPayment); ctx.SaveChanges(); this.loadByPaymentID((int)_ccPayment.externalPayment.paymentID); ts.Complete(); } }
public new void loadByPaymentID(int paymentID) { using (var ctx = new AccContexts()) { base.loadByPaymentID(paymentID); var extPaymentRecord = ctx.externalPayment .Where(x => x.paymentID == paymentID) .Select(x => x) .SingleOrDefault(); if (extPaymentRecord == null) throw new Exception("no such a EXT Payment Exists"); this.extPaymentID = extPaymentRecord.ID; this.extPaymentDescription = extPaymentRecord.description; this.cardID = (int)extPaymentRecord.cardID; this.extPaymentTypeID = (int)extPaymentRecord.extPaymentTypeID; } }
public void create(string CurrencyName, int currencyTypeID) { using (var ctx = new AccContexts()) { var newCur = new AccountingLib.Models.currency { currencyTypeID = currencyTypeID, name = CurrencyName }; var result = ctx.currency.FirstOrDefault(x => x.name == CurrencyName && x.currencyType.ID == currencyTypeID); if (result != null) throw new Exception("Currency Duplicated"); else { ctx.currency.AddObject(newCur); ctx.SaveChanges(); this.currencyID = newCur.ID; } } }
public void New() { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { base.createNew((int)enums.cardType.DebitCard); var newDBCard = new AccountingLib.Models.dbCard() { cardID = base.cardID, cardTypeID = this.CARDTYPEID }; ctx.dbCard.AddObject(newDBCard); ctx.SaveChanges(); /*reload object props*/ this.dbCardID = newDBCard.ID; ts.Complete(); } }
public void New() { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { base.createNew((int)enums.ccCardType.MASTERCARD); var newmcCard = new mcCard() { ccCardID = base.ccCardID }; ctx.mcCard.AddObject(newmcCard); ctx.SaveChanges(); /*Reload object Props*/ this.mcCardID = newmcCard.ID; this.ccCardID = (int)newmcCard.ccCardID; ts.Complete(); } }
public new void createNew(int ccCardTypeID) { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { base.createNew((int)enums.cardType.CreditCard); var newCCCard = new AccountingLib.Models.ccCard() { cardID = base.cardID, ccCardTypeID = ccCardTypeID }; ctx.ccCard.AddObject(newCCCard); ctx.SaveChanges(); /*Reload the object props*/ this.cardID = (int)newCCCard.cardID; this.ccCardID = newCCCard.ID; ts.Complete(); } }
public AccountingLib.Models.account Create(int ownerEntityId,int currencyID,decimal balance=0) { using (var ctx = new AccContexts()) { var duplicate = ctx.account .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.account.AddObject(newAccount); ctx.SaveChanges(); return newAccount; } }
public void New() { using (var ctx = new AccContexts()) { var giverPerson = ctx.person.Where(x => x.entityID == issuerEntityID).FirstOrDefault(); var receiverPerson = ctx.person.Where(x => x.entityID == receiverEntityID).FirstOrDefault(); if (receiverPerson == null || giverPerson == null) throw new Exception("No entities defined"); var newService = new AccountingLib.Models.service() { issuerEntityID=issuerEntityID, receiverEntityID=receiverEntityID, name=serviceName }; ctx.service.AddObject(newService); ctx.SaveChanges(); mapData(newService); } }
public new void loadByPaymentID(int paymentID) { using (var ctx = new AccContexts()) { var ccPaymentrecord = ctx.ccPayment .Where(x => x.externalPayment.paymentID == paymentID) .SingleOrDefault(); if (ccPaymentrecord == null) throw new Exception("no such a cc Payment Exists"); this.ccPaymentID = ccPaymentrecord.ID; this.extPaymentID = (int)ccPaymentrecord.extPaymentID; this.ccPaymentDescription = ccPaymentrecord.description; /*base.paymentID = (int)ccPaymentrecord.externalPayment.paymentID; base. = (int)ccPaymentrecord.externalPayment; base. = (int)ccPaymentrecord.externalPayment; */ } }
/*cancel invoice all payments*/ public void cancelInvoice() { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { /*get all invoice payments*/ List<AccountingLib.Models.payment> payments = this.getAllPayments(); /*cancel payments one by one*/ foreach (var item in payments) { if(item.paymentTypeID==(int)enums.paymentType.Internal) cancelInvoicePaymentINTERNAL(item.ID); if(item.paymentTypeID==(int)enums.paymentType.External) cancelInvoicePaymentEXT(item.ID); } /*Cancel invoice*/ this.loadInvoiceByInvoiceID(invoiceID); //Get Sum of Invoice Services added decimal invoiceServicesAmt = this.getInvoiceServicesSumAmt(); //Record related transctions List<int> transactions = new List<int>(); var trans1 = Transaction.createNew((int)this.receiverEntityID, (int)LibCategories.AP, +1 * (decimal)invoiceServicesAmt, (int)this.currencyID); transactions.Add(trans1); var trans2 = Transaction.createNew((int)this.issuerEntityID, (int)AssetCategories.AR, -1 * (decimal)invoiceServicesAmt, (int)this.currencyID); transactions.Add(trans2); /*Record Invoice Transaction*/ this.RecordInvoiceTransaction(transactions, enums.invoiceStat.Cancelled); ts.Complete(); } }
protected void addWalletMoney(decimal amount, string title, int currencyID) { using (var ts = new TransactionScope()) using (var ctx = new AccountingLib.Models.AccContexts()) { //Record related transctions List <int> transactions = new List <int>(); var trans1 = Transaction.createNew(this.ENTITYID, (int)AssetCategories.W, +1 * (decimal)amount, currencyID); transactions.Add(trans1); var trans2 = Transaction.createNew(this.ENTITYID, (int)AssetCategories.CCCASH, -1 * (decimal)amount, currencyID); transactions.Add(trans2); //Record Wallet entity and walletEntityTransaction var entityWallet = new AccountingLib.Models.entityWallet() { entityID = this.ENTITYID, amount = amount, title = title, currencyID = currencyID }; ctx.entityWallet.AddObject(entityWallet); ctx.SaveChanges(); foreach (var txn in transactions) { var entityWalletTxn = new AccountingLib.Models.entityWalletTransaction() { entityWalletID = entityWallet.ID, transactionID = txn }; ctx.entityWalletTransaction.AddObject(entityWalletTxn); ctx.SaveChanges(); } ts.Complete(); } }
public void New(string firstName,string lastName) { using (var ctx = new AccContexts()) { base.New((int)enums.entityType.Person); var checkDuplication = ctx.person.Where(x => x.firstName == firstName && x.lastName == lastName).FirstOrDefault(); if (checkDuplication != null) throw new Exception("Person Duplicated"); var newPerson = new AccountingLib.Models.person() { firstName=firstName, lastName=lastName, entityID = base.ENTITYID }; ctx.person.AddObject(newPerson); ctx.SaveChanges(); this.id = newPerson.ID; this.firstname = newPerson.firstName; this.lastname = newPerson.lastName; } }
/// <summary> /// create new bank w/ optioanl addressing /// </summary> /// <param name="name"></param> /// <param name="address"></param> public void New(string name,Address address=null) { using (var ctx = new AccContexts()) { base.New((int)enums.entityType.bank); var _newBank = new AccountingLib.Models.bank() { name=name, entityID=base.ENTITYID }; ctx.bank.AddObject(_newBank); ctx.SaveChanges(); if (address != null) { } /*Update Class props*/ this.bankID = _newBank.ID; this.bankName = _newBank.name; } }
public void loadByCardID(int cardID) { using (var ctx = new AccContexts()) { var paymentRecord = ctx.card .Where(x => x.ID == cardID) .Select(x => new { cardID = x.ID, cardNumber = x.cardNumber, cardTypeID = x.cardTypeID, expiryDate= (DateTime)x.expiryDate, }) .SingleOrDefault(); if (paymentRecord == null) throw new Exception("no such a Card Exists"); this.cardID = paymentRecord.cardID; this.cardTypeID = (int)paymentRecord.cardTypeID; this.cardNumber = paymentRecord.cardNumber; this.expiryDate = (DateTime)paymentRecord.expiryDate; } }
protected void loadByPaymentID(int paymentID) { using (var ctx = new AccContexts()) { var paymentRecord = ctx.payment .Where(x => x.ID == paymentID) .Select(x => new { paymentID = x.ID, payerEntityID = (int)x.payerEntityID, payeeEntityID = (int)x.payeeEntityID, amount = (decimal)x.amount, paymentTypeID = (int)x.paymentTypeID, currencyID = (int)x.currencyID }) .SingleOrDefault(); if (paymentRecord == null) throw new Exception("no such a Payment Exists"); this.paymentID = paymentRecord.paymentID; this.paymentTypeID = (int)paymentRecord.paymentTypeID; this.payerEntityID = (int)paymentRecord.payerEntityID; this.payeeEntityID = (int)paymentRecord.payeeEntityID; this.amount = (decimal)paymentRecord.amount; this.currencyID = (int)paymentRecord.currencyID; } }
private void loadInvoiceByInvoiceID(int invoiceID) { using (var ctx = new AccContexts()) { var inv = ctx.invoice .Where(x => x.ID == invoiceID).SingleOrDefault(); if (inv == null) throw new Exception("Invoice does not exists"); this.invoiceID = inv.ID; this.issuerEntityID = (int)inv.issuerEntityID; this.receiverEntityID = (int)inv.receiverEntityID; this.currencyID = (int)inv.currencyID; } }
private void RecordInvoicePaymentTransactions(List<int> txns, int paymentID , enums.paymentStat payStat) { using (var ctx = new AccountingLib.Models.AccContexts()) { //Create Payment Action var payAction = new AccountingLib.Models.paymentAction() { paymentID = paymentID, paymentStatID = (int)payStat }; ctx.paymentAction.AddObject(payAction); ctx.SaveChanges(); //Record Pyament Action TXNS foreach (var txn in txns) { var newPayActionTxn = new paymentActionTransaction() { paymentActionID = payAction.ID, transactionID = txn }; ctx.paymentActionTransaction.AddObject(newPayActionTxn); ctx.SaveChanges(); } } }
private void RecordInvoiceTransaction(List<int> transactions, enums.invoiceStat invoiceStat) { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { //create invoice Action var invAction = new AccountingLib.Models.invoiceAction() { invoiceID = this.invoiceID, invoiceStatID = (int)invoiceStat }; ctx.invoiceAction.AddObject(invAction); ctx.SaveChanges(); //create invoice Transactions and invoice action Transactions foreach (var item in transactions) { var invActionTrans = new AccountingLib.Models.invoiceActionTransaction() { invoiceActionID = invAction.ID, transactionID = item }; ctx.invoiceActionTransaction.AddObject(invActionTrans); ctx.SaveChanges(); } ts.Complete(); } }
protected void createNew(int payerEntityID,int payeeEntityID,decimal amount,int currencyID,int paymentTypeID) { using (var ctx = new AccContexts()) { var _payment = new AccountingLib.Models.payment() { payerEntityID=payerEntityID, payeeEntityID=payeeEntityID, amount=amount, currencyID=currencyID, paymentTypeID=paymentTypeID }; ctx.payment.AddObject(_payment); ctx.SaveChanges(); loadByPaymentID(_payment.ID); } }
private void loadPerson(int personEntityId) { using (var ctx = new AccContexts()) { var person = ctx.person .Where(x => x.entityID == personEntityId) .SingleOrDefault(); if (person == null) throw new Exception("no such a Person Exists"); this.id = person.ID; this.firstname = person.firstName; this.lastname = person.lastName; base.ENTITYID = (int)person.entityID; } }