Example #1
0
        public async ValueTask Handle(BeginClosingAccountingPeriod command,
                                      CancellationToken cancellationToken = default)
        {
            var generalLedger = await _generalLedger.Get(cancellationToken);

            var retainedEarningsAccountNumber = new AccountNumber(command.RetainedEarningsAccountNumber);

            AccountType.OfAccountNumber(retainedEarningsAccountNumber).MustBe(AccountType.Equity);

            generalLedger.BeginClosingPeriod(retainedEarningsAccountNumber,
                                             new GeneralLedgerEntryIdentifier(command.ClosingGeneralLedgerEntryId),
                                             Array.ConvertAll(command.GeneralLedgerEntryIds, id => new GeneralLedgerEntryIdentifier(id)),
                                             command.ClosingOn);
        }
Example #2
0
        public async ValueTask Handle(AccountingPeriodClosing @event, CancellationToken cancellationToken)
        {
            var retainedEarningsAccountNumber = new AccountNumber(@event.RetainedEarningsAccountNumber);

            AccountType.OfAccountNumber(retainedEarningsAccountNumber).MustBe(AccountType.Equity);
            var generalLedger = await _generalLedger.Get(cancellationToken);

            foreach (var id in @event.GeneralLedgerEntryIds)
            {
                var generalLedgerEntry =
                    await _generalLedgerEntries.Get(new GeneralLedgerEntryIdentifier(id), cancellationToken);

                generalLedger.TransferEntry(generalLedgerEntry);
            }

            var chartOfAccounts = await _chartOfAccounts.Get(cancellationToken);

            generalLedger.CompleteClosingPeriod(chartOfAccounts, retainedEarningsAccountNumber);
        }