Exemplo n.º 1
0
        public GetAccountingQueryHandler(IValidator validator, IAccountingRepository accountingRepository, IAccountingHelper accountingHelper)
            : base(validator, accountingRepository)
        {
            NullGuard.NotNull(accountingHelper, nameof(accountingHelper));

            _accountingHelper = accountingHelper;
        }
Exemplo n.º 2
0
        public async Task CreateBudgetAccountAsync_WhenCalled_CreatesBudgetAccount()
        {
            IAccountingRepository sut = CreateSut();

            DateTime today = DateTime.Today;

            IAccounting accounting = await sut.GetAccountingAsync(WithExistingAccountingNumber(), today);

            IBudgetAccountGroup[] budgetAccountGroupCollection = (await sut.GetBudgetAccountGroupsAsync()).ToArray();

            IBudgetAccount budgetAccount = new BudgetAccount(accounting, WithExistingAccountNumberForBudgetAccount(), _fixture.Create <string>(), budgetAccountGroupCollection[_random.Next(0, budgetAccountGroupCollection.Length - 1)])
            {
                Description = _fixture.Create <string>()
            };

            decimal income   = _random.Next(50, 70) * 1000;
            decimal expenses = _random.Next(25, 35) * 1000;

            budgetAccount.BudgetInfoCollection.Add(CreateBudgetInfo(budgetAccount, today.AddMonths(-3), income, expenses));
            budgetAccount.BudgetInfoCollection.Add(CreateBudgetInfo(budgetAccount, today.AddMonths(-2), income, expenses));
            budgetAccount.BudgetInfoCollection.Add(CreateBudgetInfo(budgetAccount, today.AddMonths(-1), income, expenses));

            income   += _random.Next(5, 10) * 1000;
            expenses += _random.Next(5, 10) * 1000;

            budgetAccount.BudgetInfoCollection.Add(CreateBudgetInfo(budgetAccount, today, income, expenses));
            budgetAccount.BudgetInfoCollection.Add(CreateBudgetInfo(budgetAccount, today.AddMonths(1), income, expenses));
            budgetAccount.BudgetInfoCollection.Add(CreateBudgetInfo(budgetAccount, today.AddMonths(2), income, expenses));

            budgetAccount.BudgetInfoCollection.Add(CreateBudgetInfo(budgetAccount, today.AddMonths(3), 0M, 0M));

            IBudgetAccount result = await sut.CreateBudgetAccountAsync(budgetAccount);

            Assert.That(result, Is.Not.Null);
        }
Exemplo n.º 3
0
 public AccountingService(
     IUnitOfWork unitOfWork,
     IAccountingRepository customRepository)
 {
     _unitOfWork = unitOfWork;
        _customRepository = customRepository;
 }
        public virtual IValidator Validate(IValidator validator, IAccountingRepository accountingRepository)
        {
            NullGuard.NotNull(validator, nameof(validator))
            .NotNull(accountingRepository, nameof(accountingRepository));

            return(validator.ValidatePaymentTermIdentifier(Number, GetType(), nameof(Number)));
        }
        public IValidator Validate(IValidator validator, IAccountingRepository accountingRepository)
        {
            NullGuard.NotNull(validator, nameof(validator))
            .NotNull(accountingRepository, nameof(accountingRepository));

            return(validator.ValidateAccountGroupIdentifier(Number, GetType(), nameof(Number)));
        }
 public AccountingService(
     IUnitOfWork unitOfWork,
     IAccountingRepository customRepository)
 {
     _unitOfWork       = unitOfWork;
     _customRepository = customRepository;
 }
 public SPOPaymentRepository(IDataRepository <IcrDetail> icrDetailContext, IDataRepository <SupplierPurchaseOrder> supplierPurchaseOrderContext,
                             IAccountingRepository iAccountingRepository, IDataRepository <POBillPayment> poBillPaymentContext, IDataRepository <ParamType> paramTypeContext,
                             IDataRepository <PurchaseOrderItem> purchaseOrderItemContext,
                             ISupplierPOWorkListRepository supplierPOWorkListRepository, IDataRepository <CreditNoteDetail> creditNoteDetailContext,
                             IDataRepository <CreditNotePayment> creditNotePaymentContext, IICRRepository iICRRepository, IDataRepository <PaymentType> paymentTypeContext,
                             IDataRepository <PurchaseOrderBranch> purchaseOrderBranchContext, IWorkFlowDetailsRepository iWorkFlowDetailsRepository,
                             IDataRepository <SupplierReturnCreditNote> supplierReturnCreditNoteContext, IDataRepository <POSupplierBill> poSupplierBillContext,
                             IDataRepository <PaymentTypeCreditNote> paymentTypeCreditNoteContext, IDataRepository <SupplierPaymentDetail> supplierPaymentDetailContext,
                             IDataRepository <WorkFlowDetail> workFlowContext, IDataRepository <ParentRecord> parentRecordContext, IErrorLog errorLog,
                             IDataRepository <SupplierDaysLimit> supplierDaysLimit)
 {
     _supplierPaymentDetailContext    = supplierPaymentDetailContext;
     _supplierPurchaseOrderContext    = supplierPurchaseOrderContext;
     _icrDetailContext                = icrDetailContext;
     _supplierPOWorkListRepository    = supplierPOWorkListRepository;
     _paymentTypeContext              = paymentTypeContext;
     _supplierReturnCreditNoteContext = supplierReturnCreditNoteContext;
     _paymentTypeCreditNoteContext    = paymentTypeCreditNoteContext;
     _poBillPaymentContext            = poBillPaymentContext;
     _poSupplierBillContext           = poSupplierBillContext;
     _paramTypeContext                = paramTypeContext;
     _creditNotePaymentContext        = creditNotePaymentContext;
     _creditNoteDetailContext         = creditNoteDetailContext;
     _workFlowContext            = workFlowContext;
     _purchaseOrderBranchContext = purchaseOrderBranchContext;
     _iAccountingRepository      = iAccountingRepository;
     _iWorkFlowDetailsRepository = iWorkFlowDetailsRepository;
     _purchaseOrderItemContext   = purchaseOrderItemContext;
     _iICRRepository             = iICRRepository;
     _supplierDaysLimit          = supplierDaysLimit;
     _errorLog = errorLog;
 }
        public override IValidator Validate(IValidator validator, IAccountingRepository accountingRepository, ICommonRepository commonRepository)
        {
            NullGuard.NotNull(validator, nameof(validator))
            .NotNull(accountingRepository, nameof(accountingRepository))
            .NotNull(commonRepository, nameof(commonRepository));

            IValidator result = base.Validate(validator, accountingRepository, commonRepository)
                                .Object.ShouldBeKnownValue(AccountingNumber, accountingNumber => AccountingExistsAsync(accountingRepository), GetType(), nameof(AccountingNumber))
                                .Object.ShouldNotBeNull(PostingLineCollection, GetType(), nameof(PostingLineCollection))
                                .Enumerable.ShouldContainItems(PostingLineCollection, GetType(), nameof(PostingLineCollection));

            IAccounting accounting = GetAccountingAsync(accountingRepository).GetAwaiter().GetResult();

            if (accounting == null)
            {
                return(result);
            }

            foreach (IApplyPostingLineCommand applyPostingLineCommand in PostingLineCollection)
            {
                result = applyPostingLineCommand.Validate(result, accounting);
            }

            return(result);
        }
Exemplo n.º 9
0
 public CreditNoteController(IErrorLog errorLog, IMerchantDataRepository merchantDataRepository, ICreditNoteRepository iCreditNoteRepository, IAccountingRepository iAccountingRepository)
     : base(errorLog, merchantDataRepository)
 {
     _errorLog = errorLog;
     _iAccountingRepository = iAccountingRepository;
     _iCreditNoteRepository = iCreditNoteRepository;
 }
Exemplo n.º 10
0
 public SupReturnWorkListRepository(IDataRepository <ParamType> paramTypeContext, IDataRepository <WorkFlowLog> workFlowLogContext,
                                    IAccountingRepository iAccountingRepository, IItemRepository iItemRepository, IDataRepository <UserDetail> userDetailContext,
                                    IDataRepository <ItemQuantity> itemQuantityContext, IDataRepository <ItemProfile> itemProfileContext, IErrorLog errorLog,
                                    IWorkFlowDetailsRepository IWorkFlowDetailsRepository, IDataRepository <CreditNoteItem> creditNoteItemContext,
                                    IDataRepository <CreditNoteDetail> creditNoteDetailContext, IDataRepository <SupplierReturnCreditNote> supplierReturnCreditNoteContext,
                                    IDataRepository <WorkFlowDetail> workFlowDetailContext, IDataRepository <SupplierReturnDetail> supplierReturnDetailContext,
                                    IDataRepository <SupplierReturnItem> supplierReturnItemContext, IItemRepository itemRepository)
 {
     _supplierReturnDetailContext     = supplierReturnDetailContext;
     _userDetailContext               = userDetailContext;
     _supplierReturnItemContext       = supplierReturnItemContext;
     _supplierReturnCreditNoteContext = supplierReturnCreditNoteContext;
     _creditNoteDetailContext         = creditNoteDetailContext;
     _creditNoteItemContext           = creditNoteItemContext;
     _itemProfileContext              = itemProfileContext;
     _iItemRepository            = iItemRepository;
     _workFlowDetailContext      = workFlowDetailContext;
     _itemQuantityContext        = itemQuantityContext;
     _iAccountingRepository      = iAccountingRepository;
     _IWorkFlowDetailsRepository = IWorkFlowDetailsRepository;
     _workFlowLogContext         = workFlowLogContext;
     _paramTypeContext           = paramTypeContext;
     _errorLog       = errorLog;
     _itemRepository = itemRepository;
 }
Exemplo n.º 11
0
        public async Task CreateAccountAsync_WhenCalled_CreatesAccount()
        {
            IAccountingRepository sut = CreateSut();

            DateTime today = DateTime.Today;

            IAccounting accounting = await sut.GetAccountingAsync(WithExistingAccountingNumber(), today);

            IAccountGroup[] accountGroupCollection = (await sut.GetAccountGroupsAsync()).ToArray();

            IAccount account = new Account(accounting, WithExistingAccountNumberForAccount(), _fixture.Create <string>(), accountGroupCollection[_random.Next(0, accountGroupCollection.Length - 1)])
            {
                Description = _fixture.Create <string>()
            };

            decimal credit = _random.Next(50, 70) * 1000;

            account.CreditInfoCollection.Add(CreateCreditInfo(account, today.AddMonths(-3), credit));
            account.CreditInfoCollection.Add(CreateCreditInfo(account, today.AddMonths(-2), credit));
            account.CreditInfoCollection.Add(CreateCreditInfo(account, today.AddMonths(-1), credit));

            credit += _random.Next(5, 10) * 1000;

            account.CreditInfoCollection.Add(CreateCreditInfo(account, today, credit));
            account.CreditInfoCollection.Add(CreateCreditInfo(account, today.AddMonths(1), credit));
            account.CreditInfoCollection.Add(CreateCreditInfo(account, today.AddMonths(2), credit));

            account.CreditInfoCollection.Add(CreateCreditInfo(account, today.AddMonths(3), 0M));

            IAccount result = await sut.CreateAccountAsync(account);

            Assert.That(result, Is.Not.Null);
        }
        public async Task GetAccountingAsync_WhenAccountingNumberExists_ReturnsAccounting()
        {
            IAccountingRepository sut = CreateSut();

            IAccounting result = await sut.GetAccountingAsync(WithExistingAccountingNumber(), DateTime.Today);

            Assert.That(result, Is.Not.Null);
        }
Exemplo n.º 13
0
        public GetAccountingCollectionQueryHandler(IAccountingRepository accountingRepository, IAccountingHelper accountingHelper)
        {
            NullGuard.NotNull(accountingRepository, nameof(accountingRepository))
            .NotNull(accountingHelper, nameof(accountingHelper));

            _accountingRepository = accountingRepository;
            _accountingHelper     = accountingHelper;
        }
Exemplo n.º 14
0
        public async Task BudgetAccountExistsAsync_WhenAccountingNumberDoesNotExist_ReturnsFalse()
        {
            IAccountingRepository sut = CreateSut();

            bool result = await sut.BudgetAccountExistsAsync(WithNonExistingAccountingNumber(), WithExistingAccountNumberForBudgetAccount());

            Assert.That(result, Is.False);
        }
        protected PaymentTermIdentificationCommandHandlerBase(IValidator validator, IAccountingRepository accountingRepository)
        {
            NullGuard.NotNull(validator, nameof(validator))
            .NotNull(accountingRepository, nameof(accountingRepository));

            Validator            = validator;
            AccountingRepository = accountingRepository;
        }
        public async Task GetContactAccountAsync_WhenAccountNumberExistsWithinAccounting_ReturnsContactAccount()
        {
            IAccountingRepository sut = CreateSut();

            IContactAccount result = await sut.GetContactAccountAsync(WithExistingAccountingNumber(), WithExistingAccountNumberForContactAccount(), DateTime.Today);

            Assert.That(result, Is.Not.Null);
        }
        public override IValidator Validate(IValidator validator, IAccountingRepository accountingRepository)
        {
            NullGuard.NotNull(validator, nameof(validator))
            .NotNull(accountingRepository, nameof(accountingRepository));

            return(base.Validate(validator, accountingRepository)
                   .Integer.ShouldBeBetween(NumberOfPostingLines, 1, 512, GetType(), nameof(NumberOfPostingLines)));
        }
        public GetAccountGroupQueryHandler(IValidator validator, IAccountingRepository accountingRepository)
        {
            NullGuard.NotNull(validator, nameof(validator))
            .NotNull(accountingRepository, nameof(accountingRepository));

            _validator            = validator;
            _accountingRepository = accountingRepository;
        }
Exemplo n.º 19
0
        protected AccountingIdentificationQueryHandlerBase(IValidator validator, IAccountingRepository accountingRepository)
        {
            NullGuard.NotNull(validator, nameof(validator))
            .NotNull(accountingRepository, nameof(accountingRepository));

            Validator            = validator;
            AccountingRepository = accountingRepository;
        }
        public async Task GetAccountGroupAsync_WhenCalled_ReturnsAccountGroup()
        {
            IAccountingRepository sut = CreateSut();

            IAccountGroup result = await sut.GetAccountGroupAsync(1);

            Assert.That(result, Is.Not.Null);
        }
Exemplo n.º 21
0
        public async Task BudgetAccountExistsAsync_WhenAccountNumberExistsWithinAccounting_ReturnsTrue()
        {
            IAccountingRepository sut = CreateSut();

            bool result = await sut.BudgetAccountExistsAsync(WithExistingAccountingNumber(), WithExistingAccountNumberForBudgetAccount());

            Assert.That(result, Is.True);
        }
Exemplo n.º 22
0
        public async Task BudgetAccountExistsAsync_WhenAccountingNumberDoesNotExist_ReturnsNull()
        {
            IAccountingRepository sut = CreateSut();

            IBudgetAccount result = await sut.GetBudgetAccountAsync(WithNonExistingAccountingNumber(), WithExistingAccountNumberForBudgetAccount(), DateTime.Today);

            Assert.That(result, Is.Null);
        }
        public override IValidator Validate(IValidator validator, IAccountingRepository accountingRepository)
        {
            NullGuard.NotNull(validator, nameof(validator))
            .NotNull(accountingRepository, nameof(accountingRepository));

            return(base.Validate(validator, accountingRepository)
                   .Object.ShouldBeKnownValue(Number, number => Task.Run(async() => await GetPaymentTermAsync(accountingRepository) != null), GetType(), nameof(Number)));
        }
        public void UpdateBudgetAccountGroupAsync_WhenBudgetAccountGroupIsNull_ThrowsArgumentException()
        {
            IAccountingRepository sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.UpdateBudgetAccountGroupAsync(null));

            Assert.That(result.ParamName, Is.EqualTo("budgetAccountGroup"));
        }
Exemplo n.º 25
0
        public void GetBudgetAccountAsync_WhenAccountNumberIsWhiteSpace_ThrowsArgumentNullException()
        {
            IAccountingRepository sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.GetBudgetAccountAsync(WithExistingAccountingNumber(), " ", DateTime.Today));

            Assert.That(result.ParamName, Is.EqualTo("accountNumber"));
        }
        public void CreateContactAccountAsync_WhenContactAccountIsNull_ThrowsArgumentNullException()
        {
            IAccountingRepository sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.CreateContactAccountAsync(null));

            Assert.That(result.ParamName, Is.EqualTo("contactAccount"));
        }
Exemplo n.º 27
0
        public override IValidator Validate(IValidator validator, IAccountingRepository accountingRepository)
        {
            NullGuard.NotNull(validator, nameof(validator))
            .NotNull(accountingRepository, nameof(accountingRepository));

            return(base.Validate(validator, accountingRepository)
                   .Object.ShouldBeKnownValue(AccountingNumber, accountingRepository.AccountingExistsAsync, GetType(), nameof(AccountingNumber)));
        }
        public async Task GetAccountGroupsAsync_WhenCalled_ReturnsAccountGroups()
        {
            IAccountingRepository sut = CreateSut();

            IList <IAccountGroup> result = (await sut.GetAccountGroupsAsync()).ToList();

            Assert.That(result.Count, Is.GreaterThan(0));
        }
Exemplo n.º 29
0
        public async Task GetBudgetAccountsAsync_WhenAccountingNumberDoesNotExist_ReturnsEmptyBudgetAccountCollection()
        {
            IAccountingRepository sut = CreateSut();

            IBudgetAccountCollection result = await sut.GetBudgetAccountsAsync(WithNonExistingAccountingNumber(), DateTime.Today);

            Assert.That(result.Count(), Is.EqualTo(0));
        }
Exemplo n.º 30
0
        public async Task DeleteAccountAsync_WhenCalled_DeletesAccount()
        {
            IAccountingRepository sut = CreateSut();

            IAccount result = await sut.DeleteAccountAsync(WithExistingAccountingNumber(), WithExistingAccountNumberForAccount());

            Assert.That(result, Is.Null);
        }
Exemplo n.º 31
0
        public void DeleteAccountAsync_WhenAccountNumberIsEmpty_ThrowsArgumentNullException()
        {
            IAccountingRepository sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.DeleteAccountAsync(WithExistingAccountingNumber(), string.Empty));

            Assert.That(result.ParamName, Is.EqualTo("accountNumber"));
        }
Exemplo n.º 32
0
 public AccountingManager(IAccountingRepository accountingRepository)
 {
     AccountingRepository = accountingRepository;
 }