main
 1using Gorilla.Commons.Utility;
 2
 3namespace presentation.windows.server.domain.accounting
 4{
 5    public class Entry
 6    {
 7        static public Entry New<Transaction>(double amount, UnitOfMeasure units) where Transaction : TransactionType, new()
 8        {
 9            return New<Transaction>(new Quantity(amount, units));
10        }
11
12        static public Entry New<Transaction>(Quantity amount) where Transaction : TransactionType, new()
13        {
14            return new Entry
15                   {
16                       when_booked = Calendar.now(),
17                       transaction_type = new Transaction(),
18                       amount = amount,
19                   };
20        }
21
22        public virtual Quantity adjust(Quantity balance)
23        {
24            return transaction_type.adjust(balance, amount);
25        }
26
27        public virtual bool booked_in(Range<Date> period)
28        {
29            return period.includes(when_booked);
30        }
31
32        Date when_booked;
33        TransactionType transaction_type;
34        Quantity amount;
35    }
36}