예제 #1
0
        public override void UpdateDebit(Movement newMovement)
        {
            if (newMovement.SourceAccountId.HasValue)
            {
                var account = BankAccountRepository.GetById(newMovement.SourceAccountId.Value);
                if (CurrentMovement.PaymentMethod != newMovement.PaymentMethod)
                {
                    Credit(account, CurrentMovement);

                    var strategy = ContextMovementStrategy.GetMovementStrategy(newMovement, BankAccountRepository,
                                                                               HistoricMovementRepository, IncomeRepository, AtmWithdrawRepository);

                    strategy.Debit();
                }
                else if (CurrentMovement.Amount != newMovement.Amount)
                {
                    Credit(account, CurrentMovement);
                    Debit(account, newMovement);
                }
            }
            else
            {
                throw new ArgumentException("Current Source account can't be null.");
            }
        }
        public void TestRaiffeisenGetById()
        {
            TestRaiffeisenInsert();
            var acc = BankAccountRepository.GetById(BankAccountEntity.Id);

            IsNotNull(acc);
            AreEqual(acc.Transactions.Count, 1);
        }
예제 #3
0
        public void TestDkbInitialImport()
        {
            var creditCard = CreditCardAccountRepository.InsertOrGetWithEquality(new CreditCardEntity
            {
                AccountNumber    = TestConfiguration.DownloadHandler.Dkb.CreditAccountNumber,
                CreditCardNumber = null,
                BankName         = Constants.DownloadHandler.BankNameDkb,
                AccountName      = Constants.DownloadHandler.AccountNameVisa
            });

            DownloadHandler.ProcessFiles(new[]
            {
                new FileParserInput
                {
                    OwningEntity         = creditCard,
                    FileParser           = Container.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserDkbCredit),
                    FilePath             = TestConfiguration.Parser.DkbCreditPath,
                    TargetEntity         = typeof(DkbCreditTransactionEntity),
                    UniqueIdGroupingFunc = entity => ((DkbCreditTransactionEntity)entity).AvailabilityDate.Date,
                    OrderingFuncs        = new List <Func <object, object> > {
                        o => ((DkbCreditTransactionEntity)o).AvailabilityDate.Date, o => ((DkbCreditTransactionEntity)o).Text, o => ((DkbCreditTransactionEntity)o).Amount
                    },
                    Balance             = TestConfiguration.DownloadHandler.Dkb.CreditBalance,
                    BalanceSelectorFunc =
                        () =>
                        CreditCardAccountRepository.GetById(creditCard.Id).Transactions.Sum(entity => entity.Amount)
                }
            });
            Assert.AreEqual(TestConfiguration.DownloadHandler.Dkb.CreditCount, CreditTransactionRepository.GetAll().Count());

            var bankAccount = BankAccountRepository.InsertOrGetWithEquality(new BankAccountEntity
            {
                Iban        = TestConfiguration.DownloadHandler.Dkb.GiroIban,
                BankName    = Constants.DownloadHandler.BankNameDkb,
                AccountName = Constants.DownloadHandler.AccountNameGiro
            });

            DownloadHandler.ProcessFiles(new[]
            {
                new FileParserInput
                {
                    OwningEntity         = bankAccount,
                    FileParser           = Container.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserDkbGiro),
                    FilePath             = TestConfiguration.Parser.DkbGiroPath,
                    TargetEntity         = typeof(DkbTransactionEntity),
                    UniqueIdGroupingFunc = entity => ((DkbTransactionEntity)entity).AvailabilityDate.Date,
                    OrderingFuncs        = new List <Func <object, object> > {
                        o => ((DkbTransactionEntity)o).AvailabilityDate.Date, o => ((DkbTransactionEntity)o).Text, o => ((DkbTransactionEntity)o).Amount
                    },
                    Balance             = TestConfiguration.DownloadHandler.Dkb.GiroBalance,
                    BalanceSelectorFunc =
                        () =>
                        BankAccountRepository.GetById(bankAccount.Id).Transactions.Sum(entity => entity.Amount)
                }
            });
            Assert.AreEqual(TestConfiguration.DownloadHandler.Dkb.GiroCount, TransactionRepository.GetAll().Count());
        }
예제 #4
0
 public override void Credit()
 {
     if (CurrentMovement?.SourceAccountId != null)
     {
         var account = BankAccountRepository.GetById(CurrentMovement.SourceAccountId.Value);
         Credit(account, CurrentMovement);
     }
     else
     {
         throw new ArgumentException("Current movement / Source account can't be null.");
     }
 }
 public override void Debit()
 {
     if (CurrentMovement?.SourceAccountId != null && CurrentMovement.TargetAccountId.HasValue)
     {
         var account         = BankAccountRepository.GetById(CurrentMovement.SourceAccountId.Value);
         var internalAccount = BankAccountRepository.GetById(CurrentMovement.TargetAccountId.Value);
         Debit(account, internalAccount, CurrentMovement);
     }
     else
     {
         throw new ArgumentException("Current movement / Source account / Target Account can't be null.");
     }
 }
예제 #6
0
        public BankAccountModel CreateEditBankAccount(BankAccountModel model)
        {
            BankAccountEntity entity;

            //is update
            if (model.Id != default(long))
            {
                entity = BankAccountRepository.GetById(model.Id);
                entity = Mapper.Map(model, entity);
            }
            else
            {
                entity = Mapper.Map <BankAccountEntity>(model);
                entity = BankAccountRepository.Insert(entity);
            }
            BankAccountRepository.Save();
            return(Mapper.Map <BankAccountModel>(entity));
        }
예제 #7
0
 public BankAccountModel BankAccount(long id)
 {
     return(Mapper.Map <BankAccountModel>(BankAccountRepository.GetById(id)));
 }
 public BankAccount GetById(int id)
 {
     return(_bankAccountRepository.GetById(id));
 }