Exemple #1
0
        protected override void OnDispose()
        {
            lock (SyncRoot)
            {
                EventPublisher.RemoveSubscriber(this);
            }

            AccountingModelHandler.Dispose();
            PostingLineModelHandler?.Dispose();
        }
Exemple #2
0
        protected override async Task OnUpdateAsync(TAccount account, TAccountModel accountModel)
        {
            NullGuard.NotNull(account, nameof(account))
            .NotNull(accountModel, nameof(accountModel));

            accountModel.AccountingIdentifier = account.Accounting.Number;
            accountModel.Accounting           = await AccountingModelHandler.ForAsync(account.Accounting.Number);

            accountModel.AccountNumber            = account.AccountNumber;
            accountModel.BasicAccount.AccountName = account.AccountName;
            accountModel.BasicAccount.Description = account.Description;
            accountModel.BasicAccount.Note        = account.Note;
        }
Exemple #3
0
        protected override async Task PrepareReadAsync(AccountingIdentificationState accountingIdentificationState)
        {
            NullGuard.NotNull(accountingIdentificationState, nameof(accountingIdentificationState));

            _accountingModel ??= await AccountingModelHandler.ForAsync(accountingIdentificationState.AccountingIdentifier);

            if (_includePostingLines == false || PostingLineModelHandler == null)
            {
                return;
            }

            _postingLineModelCollection ??= await PostingLineModelHandler.ForAsync(accountingIdentificationState.AccountingIdentifier);
        }
Exemple #4
0
        protected override async Task <TAccountModel> OnCreateAsync(TAccount account, TAccountModel accountModel)
        {
            NullGuard.NotNull(account, nameof(account))
            .NotNull(accountModel, nameof(accountModel));

            EntityEntry <BasicAccountModel> basicAccountEntityEntry = await DbContext.BasicAccounts.AddAsync(accountModel.BasicAccount);

            accountModel.Accounting = await AccountingModelHandler.ForAsync(account.Accounting.Number);

            accountModel.BasicAccount = basicAccountEntityEntry.Entity;

            return(accountModel);
        }
Exemple #5
0
        protected AccountModelHandlerBase(RepositoryContext dbContext, IConverter modelConverter, IEventPublisher eventPublisher, DateTime statusDate, bool includePostingLines, PostingLineModelHandler postingLineModelHandler, bool fromPostingLineModelHandler)
            : base(dbContext, modelConverter)
        {
            NullGuard.NotNull(eventPublisher, nameof(eventPublisher));

            _includePostingLines = includePostingLines;

            EventPublisher              = eventPublisher;
            StatusDate                  = statusDate.Date;
            AccountingModelHandler      = new AccountingModelHandler(dbContext, modelConverter, EventPublisher, StatusDate, false, false);
            PostingLineModelHandler     = postingLineModelHandler;
            FromPostingLineModelHandler = fromPostingLineModelHandler;
            SyncRoot = new object();

            EventPublisher.AddSubscriber(this);
        }
        public PostingLineModelHandler(RepositoryContext dbContext, IConverter modelConverter, IEventPublisher eventPublisher, DateTime fromDate, DateTime toDate, bool includeCreditInformation, bool includeBudgetInformation, int?numberOfPostingLines = null, bool applyingPostingLines = false)
            : base(dbContext, modelConverter)
        {
            NullGuard.NotNull(eventPublisher, nameof(eventPublisher));

            _eventPublisher             = eventPublisher;
            _fromDate                   = fromDate.Date;
            _toDate                     = toDate.Date;
            _includeCreditInformation   = includeCreditInformation;
            _includeBudgetInformation   = includeBudgetInformation;
            _numberOfPostingLines       = numberOfPostingLines;
            _applyingPostingLines       = applyingPostingLines;
            _accountingModelHandler     = new AccountingModelHandler(dbContext, ModelConverter, _eventPublisher, _toDate, false, false);
            _accountModelHandler        = new AccountModelHandler(dbContext, modelConverter, _eventPublisher, _toDate, _includeCreditInformation, false, true);
            _budgetAccountModelHandler  = new BudgetAccountModelHandler(dbContext, modelConverter, _eventPublisher, _toDate, _includeBudgetInformation, false, true);
            _contactAccountModelHandler = new ContactAccountModelHandler(dbContext, modelConverter, _eventPublisher, _toDate, false, true);

            _eventPublisher.AddSubscriber(this);
        }