public void New(int issuerEntityID, int receiverEntityID, int currencyID) { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { var newInvoice = new AccountingLib.Models.invoice() { issuerEntityID = issuerEntityID, receiverEntityID = receiverEntityID, currencyID = currencyID }; ctx.invoice.AddObject(newInvoice); ctx.SaveChanges(); //create invoice Action var invAction = new AccountingLib.Models.invoiceAction() { invoiceID = newInvoice.ID, invoiceStatID = (int)enums.invoiceStat.Generated }; ctx.invoiceAction.AddObject(invAction); ctx.SaveChanges(); this.loadInvoiceByInvoiceID(newInvoice.ID); ts.Complete(); } }
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(); } }
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(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; } }
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 void doCCExtPayment(decimal amount, int cardID, enums.ccCardType ccCardType) { //var ccFeeFor using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { classes.ccPayment creditCardPayment = new ccPayment(); creditCardPayment.createNew(this.receiverEntityID, this.issuerEntityID, amount, this.currencyID, cardID); /*Record New Invoice Payment*/ var NewInvoicePayment = new AccountingLib.Models.invoicePayment() { invoiceID = invoiceID, paymentID = creditCardPayment.paymentID }; ctx.invoicePayment.AddObject(NewInvoicePayment); ctx.SaveChanges(); //get Fee bank cardType var card = new classes.card.CreditCard(); card.loadByCardID(cardID); ccFee ccfee = new ccFee(); ccfee.loadccFeeByBankCardTypeID((int)ccCardType, (card as Entity).getBankByCard(card.cardID).bankID); //Record related transctions [for invoice payment] List <int> transactions = new List <int>(); transactions.Add(Transaction.createNew(receiverEntityID, (int)AssetCategories.CCCASH, -1 * amount, this.currencyID)); transactions.Add(Transaction.createNew(receiverEntityID, (int)LibCategories.AP, +1 * amount, this.currencyID)); transactions.Add(Transaction.createNew(issuerEntityID, (int)AssetCategories.W, +1 * amount - (decimal)ccfee.amount, this.currencyID)); transactions.Add(Transaction.createNew(issuerEntityID, (int)AssetCategories.AR, -1 * amount, this.currencyID)); transactions.Add(Transaction.createNew(issuerEntityID, (int)OECategories.EXP, (decimal)ccfee.amount, this.currencyID)); /*Record Invoice Payment transactions*/ this.RecordInvoicePaymentTransactions(transactions, creditCardPayment.paymentID, enums.paymentStat.PaidApproved); /*Record Invoice Transaction*/ enums.invoiceStat?invoicestat = null; switch (ccCardType) { case enums.ccCardType.MASTERCARD: invoicestat = enums.invoiceStat.masterCardPaymant; break; case enums.ccCardType.VISACARD: invoicestat = enums.invoiceStat.visaCardPaymant; break; } this.RecordInvoiceTransaction(transactions, (enums.invoiceStat)invoicestat); ts.Complete(); } }
protected void New(int entityTypeID) { using (var ctx = new AccContexts()) { var newEntity = new AccountingLib.Models.entity() { entityTypeID = entityTypeID }; ctx.entity.AddObject(newEntity); ctx.SaveChanges(); /*reload entity*/ this.ENTITYID = newEntity.ID; } }
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 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 doINTERACPayment(decimal amount, int cardID) { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { classes.dbPayment debitCardPayment = new dbPayment(); debitCardPayment.createNew(this.receiverEntityID, this.issuerEntityID, amount, this.currencyID, cardID); /*Record New Invoice Payment*/ var NewInvoicePayment = new AccountingLib.Models.invoicePayment() { invoiceID = this.invoiceID, paymentID = debitCardPayment.paymentID }; ctx.invoicePayment.AddObject(NewInvoicePayment); ctx.SaveChanges(); //get Fee bank cardType var card = new classes.card.DebitCard(); card.loadByCardID(cardID); Fee fee = new Fee(); fee.loadFeeByBankCardTypeID(card.cardTypeID, ((Entity)card).getBankByCard(cardID).bankID); //Record related transctions [for invoice payment] List <int> transactions = new List <int>(); transactions.Add(Transaction.createNew(receiverEntityID, (int)AssetCategories.DBCASH, -1 * amount, this.currencyID)); transactions.Add(Transaction.createNew(receiverEntityID, (int)LibCategories.AP, +1 * amount, this.currencyID)); transactions.Add(Transaction.createNew(issuerEntityID, (int)AssetCategories.W, +1 * amount - (decimal)fee.amount, this.currencyID)); transactions.Add(Transaction.createNew(issuerEntityID, (int)AssetCategories.AR, -1 * amount, this.currencyID)); transactions.Add(Transaction.createNew(issuerEntityID, (int)OECategories.EXP, (decimal)fee.amount, this.currencyID)); /*Record Invoice Payment transactions*/ this.RecordInvoicePaymentTransactions(transactions, debitCardPayment.paymentID, enums.paymentStat.PaidApproved); /*Record Invoice Transaction*/ this.RecordInvoiceTransaction(transactions, enums.invoiceStat.interacPaymant); 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); } }
public void createNew(int payerEntityID, int payeeEntityID, decimal amount, int currencyID) { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { base.createNew(payerEntityID, payeeEntityID, amount, currencyID, (int)enums.paymentType.Internal); var _internalPayment = new AccountingLib.Models.internalPayment() { paymentID = base.paymentID }; ctx.internalPayment.AddObject(_internalPayment); ctx.SaveChanges(); this.loadByPaymentID((int)_internalPayment.paymentID); ts.Complete(); } }
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() { base.createNew((int)enums.ccCardType.VISACARD); using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { var newvisaCard = new visaCard() { ccCardID = base.ccCardID }; ctx.visaCard.AddObject(newvisaCard); ctx.SaveChanges(); /*Reload object Props*/ this.visaCardID = newvisaCard.ID; ts.Complete(); } }
/// <summary> /// this function records INVOICEACTION and INVOICEACTIONTRANSACTIONS /// </summary> /// <param name="invoiceID"></param> /// <param name="transactions"></param> /*Payment for Invoice*/ public void doINTERNALTransfer(decimal amount) { try { using (var ctx = new AccContexts()) using (var ts = new TransactionScope()) { classes.internalPayment internalPayment = new classes.internalPayment(); internalPayment.createNew(this.receiverEntityID, this.issuerEntityID, amount, this.currencyID); /*Record New Invoice Payment*/ var NewInvoicePayment = new AccountingLib.Models.invoicePayment() { invoiceID = this.invoiceID, paymentID = internalPayment.paymentID }; ctx.invoicePayment.AddObject(NewInvoicePayment); ctx.SaveChanges(); //Record related transctions [for invoice payment] List <int> transactions = new List <int>(); transactions.Add(Transaction.createNew(issuerEntityID, (int)AssetCategories.W, -1 * amount, this.currencyID)); transactions.Add(Transaction.createNew(receiverEntityID, (int)LibCategories.AP, +1 * amount, this.currencyID)); transactions.Add(Transaction.createNew(receiverEntityID, (int)AssetCategories.W, +1 * amount, this.currencyID)); transactions.Add(Transaction.createNew(issuerEntityID, (int)AssetCategories.AR, -1 * amount, this.currencyID)); /*Record Invoice Payment transactions*/ this.RecordInvoicePaymentTransactions(transactions, internalPayment.paymentID, enums.paymentStat.PaidApproved); /*Record Invoice Transaction*/ this.RecordInvoiceTransaction(transactions, enums.invoiceStat.internalPaymant); ts.Complete(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
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(); } }
/// <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 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()) { 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); } }