Esempio n. 1
0
 public Debit(Guid accountId, PositiveAmount amount)
 {
     Id              = Guid.NewGuid();
     AccountId       = accountId;
     Amount          = amount;
     TransactionDate = DateTime.UtcNow;
 }
        public ICredit Deposit(PositiveAmount amount)
        {
            var credit = new Credit(Id, amount);

            _credits.Add(credit);
            return(credit);
        }
        public ICredit Deposit(IEntityFactory entityFactory, PositiveAmount amountToDeposit)
        {
            var credit = entityFactory.NewCredit(this, amountToDeposit);

            Credits.Add(credit);
            return(credit);
        }
 public Input(SSN ssn, Name name, Password password, PositiveAmount initialAmount)
 {
     SSN           = ssn;
     Name          = name;
     InitialAmount = initialAmount;
     Password      = password;
 }
 }                                 //add
 public Input(SSN ssn, Name name, Email email, Mobile mobile, Password password, PositiveAmount initialAmount)
 {
     SSN           = ssn;
     Name          = name;
     Email         = email;
     Mobile        = mobile;
     InitialAmount = initialAmount;
     Password      = password;
 }
        public PositiveAmount GetTotal()
        {
            PositiveAmount total = new PositiveAmount(0);

            foreach (ICredit credit in _credits)
            {
                total = credit.Sum(total);
            }

            return(total);
        }
        public PositiveAmount GetTotal()
        {
            PositiveAmount total = new PositiveAmount(0);

            foreach (IDebit debit in _debits)
            {
                total = debit.Sum(total);
            }

            return(total);
        }
        public IDebit Withdraw(PositiveAmount amount)
        {
            if (GetCurrentBalance().LessThan(amount))
            {
                return(null);
            }

            var debit = new Debit(Id, amount);

            _debits.Add(debit);
            return(debit);
        }
        public IDebit Withdraw(IEntityFactory entityFactory, PositiveAmount amountToWithdraw)
        {
            if (GetCurrentBalance().LessThan(amountToWithdraw))
            {
                return(null);
            }

            var debit = entityFactory.NewDebit(this, amountToWithdraw);

            Debits.Add(debit);
            return(debit);
        }
        public WithdrawInput(Guid accountId, PositiveAmount amount)
        {
            if (accountId == Guid.Empty)
            {
                throw new InputValidationException($"{nameof(accountId)} cannot be empty.");
            }

            if (amount == null)
            {
                throw new InputValidationException($"{nameof(amount)} cannot be null.");
            }

            AccountId = accountId;
            Amount    = amount;
        }
Esempio n. 11
0
        public void New_Account_Should_Have_100_Credit_After_Deposit()
        {
            //
            // Arrange
            Guid           customerId = Guid.NewGuid();
            PositiveAmount amount     = new PositiveAmount(100.0);
            Account        sut        = new Account(customerId);

            //
            // Act
            Credit actual = (Credit)sut.Deposit(amount);

            //
            // Assert
            Assert.Equal(100, actual.Amount.ToAmount().ToDouble());
            Assert.Equal("Credit", actual.Description);
            Assert.True(actual.AccountId != Guid.Empty);
        }
Esempio n. 12
0
        public TransferInput(Guid originAccountId, Guid destinationAccountId, PositiveAmount amount)
        {
            if (originAccountId == Guid.Empty)
            {
                throw new InputValidationException($"{nameof(originAccountId)} cannot be empty.");
            }

            if (destinationAccountId == Guid.Empty)
            {
                throw new InputValidationException($"{nameof(destinationAccountId)} cannot be empty.");
            }

            if (amount == null)
            {
                throw new InputValidationException($"{nameof(amount)} cannot be null.");
            }

            OriginAccountId      = originAccountId;
            DestinationAccountId = destinationAccountId;
            Amount = amount;
        }
        public RegisterInput(SSN ssn, Name name, PositiveAmount initialAmount)
        {
            if (ssn == null)
            {
                throw new InputValidationException($"{nameof(ssn)} cannot be null.");
            }

            if (name == null)
            {
                throw new InputValidationException($"{nameof(name)} cannot be null.");
            }

            if (initialAmount == null)
            {
                throw new InputValidationException($"{nameof(initialAmount)} cannot be null.");
            }

            SSN           = ssn;
            Name          = name;
            InitialAmount = initialAmount;
        }
        public void New_Account_Should_Have_100_Credit_After_Deposit()
        {
            var entityFactory = new Manga.Infrastructure.InMemoryDataAccess.EntityFactory();
            //
            // Arrange
            PositiveAmount amount   = new PositiveAmount(100.0);
            ICustomer      customer = entityFactory.NewCustomer(
                new SSN("198608179922"),
                new Name("Ivan Paulovich")
                );

            IAccount sut = entityFactory.NewAccount(customer);

            //
            // Act
            Credit actual = (Credit)sut.Deposit(entityFactory, amount);

            //
            // Assert
            Assert.Equal(100, actual.Amount.ToAmount().ToDouble());
            Assert.Equal("Credit", actual.Description);
        }
Esempio n. 15
0
 public CityTax(CityTaxType type, PositiveAmount amount)
 {
     Type   = type;
     Amount = amount ?? throw new ArgumentNullException(nameof(amount));
 }
Esempio n. 16
0
 public Input(Guid accountId, PositiveAmount amount)
 {
     this.AccountId = accountId;
     this.Amount    = amount;
 }
Esempio n. 17
0
 public Debit(IAccount account, PositiveAmount amountToWithdraw)
 {
     this.AccountId = account.Id;
     this.Amount    = amountToWithdraw;
 }
Esempio n. 18
0
 public Credit(IAccount account, PositiveAmount amountToDeposit)
 {
     this.AccountId = account.Id;
     this.Amount    = amountToDeposit;
 }
 public Input(string accountId, PositiveAmount amount)
 {
     AccountId = accountId;
     Amount    = amount;
 }
Esempio n. 20
0
 public Input(Guid originAccountId, Guid destinationAccountId, PositiveAmount amount)
 {
     OriginAccountId      = originAccountId;
     DestinationAccountId = destinationAccountId;
     Amount = amount;
 }
 public Input(Guid accountId, PositiveAmount amount)
 {
     AccountId = accountId;
     Amount    = amount;
 }
Esempio n. 22
0
 public PositivePayment(PositiveAmount amount, PaymentType paymentType)
     : base(amount, paymentType)
 {
 }
 public Input(SSN ssn, Name name, PositiveAmount initialAmount)
 {
     SSN           = ssn;
     Name          = name;
     InitialAmount = initialAmount;
 }
Esempio n. 24
0
 public Input(string ssn, string name, PositiveAmount initialAmount)
 {
     SSN           = ssn;
     Name          = name;
     InitialAmount = initialAmount;
 }
        public ICredit NewCredit(IAccount account, PositiveAmount amountToDeposit)
        {
            var credit = new Credit(account, amountToDeposit);

            return(credit);
        }
 public Input(string accountId, PositiveAmount amount)
 {
     this.AccountId = accountId;
     this.Amount    = amount;
 }
Esempio n. 27
0
 public PositiveAmount Sum(PositiveAmount amount)
 {
     return(Amount.Add(amount));
 }
 public PositiveRevenue(PositiveAmount netValue, TaxType taxType, PositiveAmount vatValue, IEnumerable <ItemIncomeClassification> incomeClassifications, PositiveInt lineNumber = null, VatExemptionType?vatExemption = null, CityTax cityTax = null)
     : base(netValue, taxType, vatValue, incomeClassifications, lineNumber, vatExemption, cityTax)
 {
 }
        public IDebit NewDebit(IAccount account, PositiveAmount amountToWithdraw)
        {
            var debit = new Debit(account, amountToWithdraw);

            return(debit);
        }
 public PositiveRevenue(PositiveAmount netValue, TaxType taxType, PositiveAmount vatValue, ClassificationType classificationType, ClassificationCategory classificationCategory, PositiveInt lineNumber = null, VatExemptionType?vatExemption = null, CityTax cityTax = null)
     : base(netValue, taxType, vatValue, new[] { new ItemIncomeClassification(classificationType, classificationCategory, netValue) }, lineNumber, vatExemption, cityTax)
 {
 }