Exemplo n.º 1
0
        public static BudgetDistributionViewModel Create(Ledger managerBudget, User employee, Ledger employeePoints)
        {
            var last = managerBudget.Debits
                .Where(x => x.Credit == employeePoints.Account.Document.Id)
                .OrderBy(x => x.Date)
                .Select(x => (DateTime?)x.Date)
                .LastOrDefault();

            return new BudgetDistributionViewModel
            {
                Id = employee.Document.Id,
                DisplayName = employee.DisplayName,
                Balance = employeePoints.Balance,
                LastBudgetDistribution = last,
                LastBudgetDistributionText = last.HasValue ? last.Value.ToShortDateString() : "Never",
                Wishlist = employee.Wishlist,
            };
        }
Exemplo n.º 2
0
 public void AddBudgets(User u, IAccountingService accounting)
 {
     PointsLedger = accounting.GetPointsLedger(u);
     BudgetLedger = accounting.GetBudgetLedger(u);
 }
        public Ledger GetLedger(Account account)
        {
            if (null == account) return null; 
            
            var key = "ledger-" + account.Document.Id;
            if (Cache.ContainsKey(key))
            {
                return Cache.Get<Ledger>(key);
            }

            var l = new Ledger
            {
                Account = account,
                Transactions = TransactionRepository.GetTransactionsForAccount(account.Document.Id),
            };

            // cache user account for 30 minutes, cache the general control and
            // expense accounts for longer
            var ts = (account.Type == AccountType.Control)
                         ? TimeSpan.FromHours(12)
                         : TimeSpan.FromMinutes(30);

            Cache.Put(key, l, ts);
            return l;
        }
 public ProgramLiabilityLedger(
     Ledger control,
     Ledger expense)
 {
     _control = control;
     _expense = expense;
 }