public void UnPostLedger(CapitalActivity capitalInvestment) { Console.WriteLine("> Un Posting " + capitalInvestment.No); organization.LedgersDal.RemoveTransaction(capitalInvestment.Id); capitalInvestment.PostStatus = LedgerPostStatus.ReadyToPost; erpNodeDBContext.SaveChanges(); }
public CapitalActivity CreateNew(Guid investorProfileId) { var newInvestment = new CapitalActivity() { Id = Guid.NewGuid(), InvestorId = investorProfileId, TransactionDate = DateTime.Today }; erpNodeDBContext.CapitalActivities.Add(newInvestment); erpNodeDBContext.SaveChanges(); return(newInvestment); }
public CapitalActivity Save(CapitalActivity capitalInvestment) { var existCapitalActivity = erpNodeDBContext.CapitalActivities.Find(capitalInvestment.Id); if (existCapitalActivity == null) { existCapitalActivity = capitalInvestment; existCapitalActivity.FiscalYear = organization.FiscalYears.Find(existCapitalActivity.TransactionDate); existCapitalActivity.Id = Guid.NewGuid(); existCapitalActivity.No = this.NextNumber; existCapitalActivity.AssetAccountGuid = existCapitalActivity.AssetAccountGuid ?? organization.SystemAccounts.Cash.Id; existCapitalActivity.EquityAccountGuid = existCapitalActivity.EquityAccountGuid ?? organization.SystemAccounts.EquityStock.Id; existCapitalActivity.CaluculateTotal(); erpNodeDBContext.CapitalActivities.Add(existCapitalActivity); } else { if (existCapitalActivity.PostStatus != LedgerPostStatus.Posted) { existCapitalActivity.FiscalYear = organization.FiscalYears.Find(existCapitalActivity.TransactionDate); existCapitalActivity.TransactionDate = capitalInvestment.TransactionDate; existCapitalActivity.Type = capitalInvestment.Type; existCapitalActivity.AssetAccountGuid = capitalInvestment.AssetAccountGuid ?? organization.SystemAccounts.Cash.Id; existCapitalActivity.EquityAccountGuid = capitalInvestment.EquityAccountGuid ?? organization.SystemAccounts.EquityStock.Id; existCapitalActivity.StockAmount = capitalInvestment.StockAmount; existCapitalActivity.EachStockParValue = capitalInvestment.EachStockParValue; existCapitalActivity.InvestorId = capitalInvestment.InvestorId; existCapitalActivity.CaluculateTotal(); } } erpNodeDBContext.SaveChanges(); return(existCapitalActivity); }
public void PostLedger(CapitalActivity tr, bool SaveImmediately = true) { if (tr.PostStatus == LedgerPostStatus.Posted) { return; } var trLedger = new Models.Accounting.LedgerGroup() { Id = tr.Id, TransactionDate = tr.TransactionDate, TransactionName = tr.Name, TransactionNo = tr.No ?? 0, TransactionType = transactionType }; erpNodeDBContext.LedgerGroups.Add(trLedger); if (tr.Type == Models.Equity.Enums.CapitalActivityType.Invest) { trLedger.AddDebit(tr.AssetAccount, tr.TotalStockParValue); trLedger.AddCredit(tr.EquityAccount, tr.TotalStockParValue); } else { trLedger.AddCredit(tr.AssetAccount, Math.Abs(tr.TotalStockParValue)); trLedger.AddDebit(tr.EquityAccount, Math.Abs(tr.TotalStockParValue)); } tr.PostStatus = LedgerPostStatus.Posted; if (SaveImmediately) { erpNodeDBContext.SaveChanges(); } }