예제 #1
0
 public Task closing_an_open_period(YearMonth openedOn, EquityAccount retainedEarnings,
                                    GeneralLedgerEntryIdentifier[] generalLedgerEntryIdentifiers,
                                    GeneralLedgerEntryIdentifier closingGeneralLedgerEntryIdentifier) =>
 new Scenario()
 .Given(ChartOfAccounts.Identifier, new AccountDefined {
     AccountNumber = retainedEarnings.AccountNumber.ToInt32(),
     AccountName   = retainedEarnings.AccountName.ToString()
 })
 .Given(GeneralLedger.Identifier, new GeneralLedgerOpened {
     OpenedOn = Time.Format.LocalDate(openedOn.OnDayOfMonth(1))
 })
 .When(new BeginClosingAccountingPeriod {
     GeneralLedgerEntryIds =
         ImmutableArray <Guid> .Empty.AddRange(Array.ConvertAll(generalLedgerEntryIdentifiers,
                                                                x => x.ToGuid())),
     ClosingOn = openedOn.OnDayOfMonth(2).AtMidnight().ToDateTimeUnspecified(),
     RetainedEarningsAccountNumber = retainedEarnings.AccountNumber.ToInt32(),
     ClosingGeneralLedgerEntryId   = closingGeneralLedgerEntryIdentifier.ToGuid()
 })
 .Then(GeneralLedger.Identifier, new AccountingPeriodClosing {
     Period = AccountingPeriod.Open(openedOn.OnDayOfMonth(1)).ToString(),
     GeneralLedgerEntryIds         = Array.ConvertAll(generalLedgerEntryIdentifiers, x => x.ToGuid()),
     ClosingOn                     = Time.Format.LocalDateTime(openedOn.OnDayOfMonth(2).AtMidnight()),
     RetainedEarningsAccountNumber = retainedEarnings.AccountNumber.ToInt32(),
     ClosingGeneralLedgerEntryId   = closingGeneralLedgerEntryIdentifier.ToGuid()
 })
 .Assert(_handler, _facts);
예제 #2
0
 protected override DateTime Wrap(YearMonth value)
 {
     if (_dayOfMonth > 28)
     {
         var lastDay = value.ToDateInterval().End.Day;
         if (lastDay < _dayOfMonth)
         {
             return(value.OnDayOfMonth(lastDay).ToDateTimeUnspecified());
         }
     }
     return(value.OnDayOfMonth(_dayOfMonth).ToDateTimeUnspecified());
 }
예제 #3
0
        public void OnDayOfMonth_Invalid(int calendarOrdinal, int year, int month, int day)
        {
            var calendar  = CalendarSystem.ForOrdinal((CalendarOrdinal)calendarOrdinal);
            var yearMonth = new YearMonth(year, month, calendar);

            Assert.Throws <ArgumentOutOfRangeException>(() => yearMonth.OnDayOfMonth(day));
        }
예제 #4
0
        public void OnDayOfMonth_Valid(int calendarOrdinal, int year, int month, int day)
        {
            var calendar     = CalendarSystem.ForOrdinal((CalendarOrdinal)calendarOrdinal);
            var yearMonth    = new YearMonth(year, month, calendar);
            var actualDate   = yearMonth.OnDayOfMonth(day);
            var expectedDate = new LocalDate(year, month, day, calendar);

            Assert.AreEqual(expectedDate, actualDate);
        }
예제 #5
0
 public Task closing_a_closed_period(YearMonth openedOn, EquityAccount retainedEarnings,
                                     GeneralLedgerEntryIdentifier closingGeneralLedgerEntryIdentifier) =>
 new Scenario()
 .Given(ChartOfAccounts.Identifier, new AccountDefined {
     AccountNumber = retainedEarnings.AccountNumber.ToInt32(),
     AccountName   = retainedEarnings.AccountName.ToString()
 })
 .Given(GeneralLedger.Identifier, new GeneralLedgerOpened {
     OpenedOn = Time.Format.LocalDate(openedOn.OnDayOfMonth(1))
 },
        new AccountingPeriodClosing {
     Period    = AccountingPeriod.Open(openedOn.OnDayOfMonth(1)).ToString(),
     ClosingOn = Time.Format.LocalDateTime(openedOn.OnDayOfMonth(2).AtMidnight()),
     RetainedEarningsAccountNumber = retainedEarnings.AccountNumber.ToInt32(),
     ClosingGeneralLedgerEntryId   = closingGeneralLedgerEntryIdentifier.ToGuid()
 })
 .When(new BeginClosingAccountingPeriod {
     ClosingOn = openedOn.OnDayOfMonth(2).AtMidnight().ToDateTimeUnspecified(),
     RetainedEarningsAccountNumber = retainedEarnings.AccountNumber.ToInt32(),
     ClosingGeneralLedgerEntryId   = closingGeneralLedgerEntryIdentifier.ToGuid()
 })
 .Throws(new PeriodClosingInProcessException(AccountingPeriod.Open(openedOn.OnDayOfMonth(1))))
 .Assert(_handler, _facts);