public List <SelectListItem> GetAccountTypes(bool includeAll = false, int?selected = null) { var accountTypes = AccountTypeRepository.GetAccountTypes().OrderBy(o => o.Description); List <SelectListItem> lookup = accountTypes.Select(l => new SelectListItem() { Value = l.Id.ToString(), Text = l.Description }).ToList(); if (includeAll) { lookup.Add(new SelectListItem() { Value = All.ToString(), Text = "ALL" }); } if (selected.HasValue) { var selectedItem = lookup.Where(l => l.Value == selected.Value.ToString()).FirstOrDefault(); if (selectedItem != null) { selectedItem.Selected = true; } } return(lookup); }
public InvoiceModel CreateInvoice(NewInvoiceModel invoice, int locationId) { Data.Graph.Invoice inv = new Data.Graph.Invoice(); var account = AccountRepository.GetAccount(invoice.AccountId); if (account == null) { account = new Data.Graph.Account(); account.Name = invoice.AccountName; account.AccountType = AccountTypeRepository.GetAccountType(invoice.AccountTypeId); AccountRepository.SaveAccount(account); } inv.Account = account; inv.Color = invoice.Color; inv.Location = new Data.Graph.Location(locationId); inv.Make = invoice.Make; inv.Model = invoice.Model; inv.ReceiveDate = DateTime.Now; inv.StockNumber = invoice.StockNumber; inv.Year = invoice.Year; inv.TaxRate = (decimal)account.AccountType.TaxRate; InvoiceRepository.SaveInvoice(inv); Logger.InfoFormat("Created new invoice {0} for {1} at location id {2}", inv.Id, inv.Account.Name, locationId); return(Mapper.Map <Data.Graph.Invoice, InvoiceModel>(inv)); }
public void AddServiceToAccountType(int accountTypeId, int serviceTypeId) { var accountType = AccountTypeRepository.GetAccountType(accountTypeId); if (accountType == null) { throw new ArgumentException("accountTypeId"); } var serviceType = AccountTypeRepository.GetServiceType(serviceTypeId); if (serviceType == null) { throw new ArgumentException("serviceTypeId"); } var newService = new Data.Graph.AccountTypeService(); newService.ServiceType = serviceType; newService.DefaultEstimatedTime = 0; newService.DefaultRate = 0; newService.IsActive = true; accountType.AddService(newService); AccountTypeRepository.SaveAccountType(accountType); }
public UnitOfWork(bool test = false) { if (!test && !Test) { AccountTypes = new AccountTypeRepository(new AccountTypeOracleContext()); Employees = new EmployeeRepository(new EmployeeOracleContext()); AttachedTracks = new AttachedTrackRepository(new AttachedTrackOracleContext()); Routes = new RouteRepository(new RouteOracleContext()); Sectors = new SectorRepository(new SectorOracleContext()); Statuses = new StatusRepository(new StatusOracleContext()); Tracks = new TrackRepository(new TrackOracleContext()); //TrackRoutes = new TrackRouteRepository(new TrackRouteOracleContext()); Trams = new TramRepository(new TramOracleContext()); TramRoutes = new TramRouteRepository(new TramRouteOracleContext()); Tasks = new TaskRepository(new TaskOracleContext()); } else { AccountTypes = new AccountTypeRepository(new AccountTypeTestContext()); Employees = new EmployeeRepository(new EmployeeTestContext()); Tracks = new TrackRepository(new TrackTestContext()); Sectors = new SectorRepository(new SectorTestContext()); Trams = new TramRepository(new TramTestContext()); Routes = new RouteRepository(new RouteTestContext()); AttachedTracks = new AttachedTrackRepository(new AttachedTrackTestContext()); TramRoutes = new TramRouteRepository(new TramRouteTestContext()); TrackRoutes = new TrackRouteRepository(new TrackRouteTestContext()); TramStatuses = new TramStatusRepository(new TramStatusTestContext()); } }
public void AddLaborToAccountType(int accountTypeId, int accountTypeServiceId, int laborTypeId) { var accountType = AccountTypeRepository.GetAccountType(accountTypeId); if (accountType == null) { throw new ArgumentException("accountTypeId"); } var service = accountType.ServiceTypeList.Where(s => s.Id == accountTypeServiceId).FirstOrDefault(); if (service == null) { throw new ArgumentException("accountTypeServiceId"); } var laborType = AccountTypeRepository.GetLaborType(laborTypeId); if (laborType == null) { throw new ArgumentException("laborTypeId"); } var newLabor = new AccountTypeLabor(); newLabor.DefaultRate = 0; newLabor.DefaultRateType = "F"; newLabor.LaborType = laborType; service.AddLabor(newLabor); AccountTypeRepository.SaveAccountType(accountType); }
public void RemoveLaborFromAccountType(int accountTypeId, int accountTypeServiceId, int accountTypeLaborId) { var accountType = AccountTypeRepository.GetAccountType(accountTypeId); if (accountType == null) { throw new ArgumentException("accountTypeId"); } var service = accountType.ServiceTypeList.Where(s => s.Id == accountTypeServiceId).FirstOrDefault(); if (service == null) { throw new ArgumentException("accountTypeServiceId"); } var labor = service.LaborTypeList.Where(l => l.Id == accountTypeLaborId).FirstOrDefault(); if (labor == null) { throw new ArgumentException("accountTypeLaborId"); } service.LaborTypeList.Remove(labor); AccountTypeRepository.SaveAccountType(accountType); }
public AccountService(AccountRepository repository, AccountGroupRepository accountGroupRepository, AccountTypeRepository accountTypeRepository, OrganizationService organizationService, ILogger <AccountService> logger) { this.repository = repository; this.accountGroupRepository = accountGroupRepository; this.accountTypeRepository = accountTypeRepository; this.organizationService = organizationService; this.logger = logger; }
// // GET: /AccountType/ public ActionResult Index() { var accountTypeRepository = new AccountTypeRepository() { UnitOfWork = SessionState.Current.UnitOfWork }; return(View(accountTypeRepository.Items())); }
public void UpdateLaborType(int id, string description) { var existing = AccountTypeRepository.GetLaborType(id); if (null == existing) { throw new ArgumentException(string.Format("{0} is not a valid labor type id", id)); } //TODO: validate description existing.Description = description; AccountTypeRepository.SaveLaborType(existing); }
public void AddLaborType(string description) { var existing = AccountTypeRepository.GetLaborTypes(); if (null != existing.Where(e => e.Description == description).FirstOrDefault()) { throw new InvalidOperationException(string.Format("{0} already exists as a labor type", description)); } AccountTypeRepository.SaveLaborType(new LaborType() { Description = description }); }
public void TestCreateAccountTypes() { var accountType = Utility.CreateLoanGivenAccountType(); var repository = new AccountTypeRepository { UnitOfWork = new UnitOfWork() }; repository.Create(accountType); accountType = Utility.CreateSavingsAccountType(); repository.Create(accountType); }
public UnitOfWork(DataContext context) { _context = context; Account = new AccountRepository(_context); AccountHistory = new AccountHistoryRepository(_context); AccountType = new AccountTypeRepository(_context); Business = new BusinessRepository(_context); Client = new ClientRepository(_context); Group = new GroupRepository(_context); Relationship = new RelationshipRepository(_context); Role = new RoleRepository(_context); Transaction = new TransactionRepository(_context); TransactionType = new TransactionTypeRepository(_context); User = new UserRepository(_context); UserHistory = new UserHistoryRepository(_context); }
public AccountModel CreateAccount(AccountModel account) { var graph = new Data.Graph.Account(); graph.AccountType = AccountTypeRepository.GetAccountType(account.AccountTypeId); graph.AddressLine1 = account.AddressLine1; graph.AddressLine2 = account.AddressLine2; graph.City = account.City; graph.Name = account.Name; graph.Notes = account.Notes; graph.PostalCode = account.PostalCode; graph.StateCode = account.StateCode; AccountRepository.SaveAccount(graph); return(Mapper.Map <Data.Graph.Account, AccountModel>(graph)); }
public UnitOfWork(INavyAccountDbContext context) { this.context = context; Users = new UserRepository(context); Menus = new MenuRepository(context); RoleMenus = new RoleMenuRepository(context); MenuGroups = new MenuGroupRepository(context); UserRoles = new UserRoleRepository(context); FundType = new FundTypeRepo(context); actType = new AccountTypeRepository(context); balSheet = new BalanceSheetRepository(context); mainAccount = new MainAccountRepository(context); accountChart = new ChartRepository(context); subtype = new SubTypeRepository(context); fundTypeCode = new FundTypeRepository(context); loanType = new LoanTypeRepo(context); rank = new RankRepo(context); person = new PersonRepo(context); beneficiary = new BeneficiaryRepo(context); bank = new BankRepository(context); pfundrate = new PfFundRateRepository(context); contribution = new NPFContributionRepository(context); loanRegisterRepository = new LoanRegisterRepository(context); register = new InvestmentRegisterRepository(context); loanStatus = new LoanStatusRepository(context); schedule = new LoanScheduleRepository(context); balance = new TrialBalanceRepository(context); accountHistory = new AccountHistoryRepository(context); npf_Ledgers = new LedgerRepositoy(context); report = new TrialBalanceReportRepository(context); history = new TrialBalanceHistoryRepository(context); pf_loandisc = new LoandiscRepo(context); loanPerRank = new LoanPerRankRepository(context); claimregister = new ClaimRepository(context); npfHistories = new FinancialDocRepo(context); trail = new AuditRailRepository(context); npf_contrdisc = new ContrRepo(context); surplus = new SurplusRepository(context); cam = new ClaimTypeRepository(context); navip = new NavipRepository(context); loantypereview = new LoanTypeReviewRepo(context); }
public UnitOfWork(DataContext context) { _context = context; Account = new AccountRepository(_context); AccountHistory = new AccountHistoryRepository(_context); AccountType = new AccountTypeRepository(_context); Business = new BusinessRepository(_context); Client = new ClientRepository(_context); Group = new GroupRepository(_context); Relationship = new RelationshipRepository(_context); Role = new RoleRepository(_context); Transaction = new TransactionRepository(_context); TransactionCode = new TransactionCodeRepository(_context); TransactionType = new TransactionTypeRepository(_context); TransactionTypeDetail = new TransactionTypeDetailRepository(_context); User = new UserRepository(_context); UserHistory = new UserHistoryRepository(_context); UserActivity = new UserActivityRepository(_context); Menu = new MenuRepository(_context); Control = new ControlRepository(_context); Image = new ImageRepository(_context); }
static void Main(string[] args) { var factory = new BankingSystemContextFactory(); var cityService = new Repository <City>(factory); var disabilityService = new Repository <Disability>(factory); var genderService = new Repository <Gender>(factory); var maritalStatusService = new Repository <MaritalStatus>(factory); var nationalityService = new Repository <Nationality>(factory); var passportService = new Repository <Passport>(factory); var userService = new Repository <User>(factory); var accountService = new AccountRepository(factory); var accountTypeService = new AccountTypeRepository(factory); var programService = new ProgramRepository(factory); var programTypeService = new ProgramTypeRepository(factory); var currencyService = new CurrencyRepository(factory); //var x = accountService.GetAllAsync().Result; var currency = currencyService.GetAsync(1).Result; var program = new Domain.Entities.Program() { Currency = currency, DateStart = DateTime.Now, DateEnd = DateTime.Now, Name = "lol", Percent = 13, ProgramTypeId = 1, TermMonthCount = 12 }; var x = programService.CreateAsync(program).Result; Console.WriteLine(x.Id); //foreach (var entity in x) //{ // Console.WriteLine(entity.Name); // //foreach (var entityContract in entity.Programs) // //{ // // Console.WriteLine(entityContract.Name); // //} //} }
public List <AccountTypeModel> GetServicesAndLabor() { var accountTypes = AccountTypeRepository.GetAccountTypes().OrderBy(o => o.Description); List <AccountTypeModel> tree = new List <AccountTypeModel>(); foreach (var accountType in accountTypes) { AccountTypeModel anode = new AccountTypeModel(); anode.Id = accountType.Id; anode.Description = accountType.Description; anode.TaxRate = (decimal)accountType.TaxRate; foreach (var service in accountType.ServiceTypeList.OrderBy(o => o.ServiceType.Description)) { AccountTypeServiceModel snode = new AccountTypeServiceModel(); snode.Parent = anode; snode.Id = service.Id; snode.ServiceTypeId = service.ServiceType.Id; snode.ServiceTypeDescription = service.ServiceType.Description; anode.Services.Add(snode); foreach (var labor in service.LaborTypeList.OrderBy(o => o.LaborType.Description)) { AccountTypeLaborModel lnode = new AccountTypeLaborModel(); lnode.Parent = snode; lnode.Id = labor.Id; lnode.LaborTypeId = labor.LaborType.Id; lnode.LaborTypeDescription = labor.LaborType.Description; snode.Labor.Add(lnode); } } tree.Add(anode); } return(tree); }
public AccountTypeLogic() { repository = new AccountTypeRepository(); }
public AccountTypeService() { _repository = new AccountTypeRepository(); }
public SelectList GetLaborTypes() { var laborTypes = AccountTypeRepository.GetLaborTypes().OrderBy(o => o.Description); return(new SelectList(laborTypes, "Id", "Description")); }
public SelectList GetServiceTypes() { var serviceTypes = AccountTypeRepository.GetServiceTypes().OrderBy(o => o.Description); return(new SelectList(serviceTypes, "Id", "Description")); }
public AllAccountsOverview GetAllAccountsOverview(Guid ownerId, int year, int month) { var accountsResponse = new AllAccountsOverview { RelevantMonth = month, RelevantYear = year }; // Get last day of month previous to passed month. var lastDayOfLastMonth = DateTimeExtensions.EndOfPreviousMonth(month, year); // Get last day of this month. var lastDayOfThisMonth = DateTimeExtensions.EndOfMonth(month, year); accountsResponse.StartOfMonth = lastDayOfLastMonth.ToBalanceInfo(); accountsResponse.EndOfMonth = lastDayOfThisMonth.ToBalanceInfo(); var accountTypesCollection = AccountTypeRepository.GetAllAccountTypes(); var accountsCollection = AccountRepo.FindAllByOwnerAndMonth(ownerId, year, month); var accountCategoryValuesLastMonth = AccountBalanceRepo.GetAllAccountBalances(ownerId, lastDayOfLastMonth); var accountCategoryValuesEndOfMonth = AccountBalanceRepo.GetAllAccountBalances(ownerId, lastDayOfThisMonth); var allAccountsFromAllTypes = new List <AccountsOfTypeOverview>(); foreach (var accountType in accountTypesCollection.OrderBy(m => m.Id)) { var relevantAccountEntities = accountsCollection.Where(m => m.AccountTypeId == accountType.Id); if (relevantAccountEntities.Count() > 0) { var allAccountsFromType = new List <AccountOverview>(); var accountTypeInfo = new AccountsOfTypeOverview() { Info = accountType, AreAccountsOpen = false, StartOfMonth = lastDayOfLastMonth.ToBalanceInfo(), EndOfMonth = lastDayOfThisMonth.ToBalanceInfo() }; allAccountsFromAllTypes.Add(accountTypeInfo); foreach (var accountEntity in relevantAccountEntities.OrderBy(m => m.DisplayIndex)) { allAccountsFromType.Add(accountEntity); foreach (var accountCategory in accountEntity.AccountCategories) { var lastMonthBalance = accountCategoryValuesLastMonth.FirstOrDefault(m => m.Id.CompareTo(accountCategory.Id) == 0); if (lastMonthBalance != null) { accountCategory.StartingBalance = lastMonthBalance.CurrentBalance; accountEntity.StartingBalance += lastMonthBalance.CurrentBalance; accountTypeInfo.StartOfMonth.Balance += lastMonthBalance.CurrentBalance; accountsResponse.StartOfMonth.Balance += lastMonthBalance.CurrentBalance; } var endOfMonthBalance = accountCategoryValuesEndOfMonth.FirstOrDefault(m => m.Id.CompareTo(accountCategory.Id) == 0); if (endOfMonthBalance != null) { accountCategory.EndingBalance = endOfMonthBalance.CurrentBalance; accountEntity.EndingBalance += endOfMonthBalance.CurrentBalance; accountTypeInfo.EndOfMonth.Balance += endOfMonthBalance.CurrentBalance; accountsResponse.EndOfMonth.Balance += endOfMonthBalance.CurrentBalance; } accountCategory.Delta = accountCategory.EndingBalance - accountCategory.StartingBalance; } accountEntity.Delta = accountEntity.EndingBalance - accountEntity.StartingBalance; } accountTypeInfo.Delta = accountTypeInfo.EndOfMonth.Balance - accountTypeInfo.StartOfMonth.Balance; accountTypeInfo.Accounts = allAccountsFromType.ToArray(); } } accountsResponse.Delta = accountsResponse.EndOfMonth.Balance - accountsResponse.StartOfMonth.Balance; accountsResponse.AccountTypes = allAccountsFromAllTypes.ToArray(); return(accountsResponse); }