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