Exemple #1
0
        public void UpdateCategory(Category category)
        {
            if(category.Property != Property)
                throw new DomainException("Propriedade da categoria é inválida");

            Category = category;
        }
Exemple #2
0
 public CategoryDto(Category category)
 {
     Id = category.Id;
     Name = category.Name;
     TransactionType = category.TransactionType;
     TransactionTypeDescription = category.TransactionType.DescriptionAttr();
 }
        private void AddCategoryToReport(Category category)
        {
            var categoryData = CreateTransactionPerCategoryData(category);

            if (category.TransactionType == TransactionType.Credit)
                _report.AddCredit(categoryData);
            else
                _report.AddDebit(categoryData);
        }
Exemple #4
0
        public void Save(int propertyId, CategoryDto categoryToSave)
        {
            var property = _propertyRepository.Get(propertyId);

            var category = new Category(categoryToSave.Name, property, categoryToSave.TransactionType);

            if (categoryToSave.Id != 0)
                _categoryRepository.Update(category, categoryToSave.Id);
            else
                _categoryRepository.Add(category);
        }
Exemple #5
0
        public void UpdateValues(decimal value, DateTime date, Category category, string description, Account account, Property property)
        {
            Validate(value, date, category, description, account, property);

            Value = value;
            Date = date;
            TransactionType = category.TransactionType;
            Category = category;
            Description = description;
            Account = account;
            Property = property;
        }
        private TransactionPerCategoryItemData CreateTransactionPerCategoryData(Category category)
        {
            var categoryData = new TransactionPerCategoryItemData(category.Name, category.Id);

            for (var date = _report.InitialDate; date <= _report.FinalDate; date = date.AddMonths(1))
            {
                var sumOfTheMonth = SumTransactionsForCategoryAndDate(category.Name, date);
                categoryData.AddValue(sumOfTheMonth);
                AddToSumOfTheMonth(sumOfTheMonth.Copy(), category.TransactionType == TransactionType.Credit);
            }
            return categoryData;
        }
        public void Setup()
        {
            _property = PropertyBuilder.AProperty().WithId(3).Build();
            _category = CategoryBuilder.ACategory().WithProperty(_property).WithId(3).Build();
            _account = AccountBuilder.AnAccount().WithProperty(_property).Build();

            _categoryRepository.Setup(x => x.Get(_category.Id)).Returns(_category);
            _accountRepository.Setup(x => x.Get(_account.Id)).Returns(_account);
            _propertyRepository.Setup(x => x.Get(_property.Id)).Returns((_property));

            _categoryChangerApp = new CategoryChangerApp(_transactionRepository.Object, _categoryRepository.Object);
        }
        public Transaction Build()
        {
            if (_value == 0)
                _value = 10m;

            if (_property == null)
                _property = PropertyBuilder.AProperty().Build();

            if (_category == null)
                _category = CategoryBuilder.ACategory().WithTransactiontype(_type).WithProperty(_property).Build();

            if (_account == null)
                _account = AccountBuilder.AnAccount().WithProperty(_property).Build();

            if (string.IsNullOrEmpty(_description))
                _description = "test";

            var transaction = new Transaction(_value, _date, _category, _description, _account, _property) {Id = _id};

            return transaction;
        }
Exemple #9
0
        public static void FillSampleData(IRepositoryFactory repositoryFactory)
        {
            var propertyRepository = repositoryFactory.GetPropertyRepository();
            var userRepository = repositoryFactory.GetUserRepository();
            var accountRepository = repositoryFactory.GetAccountRepository();
            var categoryRepository = repositoryFactory.GetCategoryRepository();
            var transactionRepository = repositoryFactory.GetTransactionRepository();

            var property = new Property("property");
            var user = new User("name", "username", "40bd001563085fc35165329ea1ff5c5ecbdbbeef", property);
            user.AddProperty(property);
            var account = new Account("account", property);
            var creditCategory = new Category("credit", property, TransactionType.Credit);
            var creditTransferCategory = new Category("credit transfer", property, TransactionType.CreditTransfer);
            var debitCategory = new Category("debit", property, TransactionType.Debit);
            var debitTransferCategory = new Category("debit transfer", property, TransactionType.DebitTransfer);
            var creditTransaction = new Transaction(40.3m, DateTime.Today, creditCategory, " crédito ", account, property);
            var debitTransaction = new Transaction(10.89m, DateTime.Today, debitCategory, "débito ", account, property);
            var creditTransferTransaction = new Transaction(10.32m, DateTime.Today, creditTransferCategory, "transaferencia de credito ", account, property);
            var debitTransferTransaction = new Transaction(10.32m, DateTime.Today, debitTransferCategory, "transaferencia de débito ", account, property);

            if (propertyRepository.GetAll().Count != 0)
                return;

            propertyRepository.Add(property);
            userRepository.Add(user);
            accountRepository.Add(account);
            categoryRepository.Add(creditCategory);
            categoryRepository.Add(creditTransferCategory);
            categoryRepository.Add(debitCategory);
            categoryRepository.Add(debitTransferCategory);
            transactionRepository.Add(creditTransaction);
            transactionRepository.Add(debitTransaction);
            transactionRepository.Add(debitTransferTransaction);
            transactionRepository.Add(creditTransferTransaction);
        }
Exemple #10
0
        private static void Validate(decimal value, DateTime date, Category category, string description, Account account, Property property)
        {
            if (value <= 0)
                throw new DomainException("Valor deve ser maior que zero");

            if (category == null)
                throw new DomainException("Categoria é obrigatória");

            if (account == null)
                throw new DomainException("Conta é obrigatória");

            if (property == null)
                throw new DomainException("Propriedade é obrigatória");

            if (property != category.Property)
                throw new DomainException("Propriedade da categoria é inválida");

            if (property != account.Property)
                throw new DomainException("Propriedade da conta é inválida");
        }
 public TransactionBuilder WithCategory(Category category)
 {
     _category = category;
     return this;
 }
Exemple #12
0
 public void SetUp()
 {
     _property = PropertyBuilder.AProperty().Build();
     _account = AccountBuilder.AnAccount().WithProperty(_property).Build();
     _category = new Category("test", _property, TransactionType.Debit);
 }