main
 1using System.Collections.Generic;
 2using System.Linq;
 3using gorilla.commons.utility;
 4using Gorilla.Commons.Utility;
 5
 6namespace presentation.windows.server.domain.payroll
 7{
 8    public class Compensation : Visitable<Grant>
 9    {
10        IList<Grant> grants = new List<Grant>();
11
12        public void issue_grant(Money grant_value, UnitPrice price, Fraction portion_to_issue_at_each_vest, Frequency frequency)
13        {
14            grants.Add(Grant.New(grant_value, price, portion_to_issue_at_each_vest, frequency));
15        }
16
17        public Grant grant_for(Date date)
18        {
19            return grants.Single(x => x.was_issued_on(date));
20        }
21
22        public Money unvested_balance(Date on_date)
23        {
24            var total = Money.Zero;
25            accept(new AnonymousVisitor<Grant>(grant => total = total.plus(grant.balance(on_date))));
26            return total;
27        }
28
29        public void accept(Visitor<Grant> visitor)
30        {
31            grants.each(x => visitor.visit(x));
32        }
33    }
34}