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);
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()); }
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)); }
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); }
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);