/// <summary>
 /// Ensures the deposit source has been set.
 /// </summary>
 /// <param name="merchantDepositSource">The merchant deposit source.</param>
 /// <exception cref="InvalidOperationException">Merchant deposit source must be set</exception>
 private void EnsureDepositSourceHasBeenSet(MerchantDepositSource merchantDepositSource)
 {
     if (merchantDepositSource == MerchantDepositSource.NotSet)
     {
         throw new InvalidOperationException("Merchant deposit source must be set");
     }
 }
        /// <summary>
        /// Makes the deposit.
        /// </summary>
        /// <param name="depositId">The deposit identifier.</param>
        /// <param name="source">The source.</param>
        /// <param name="reference">The reference.</param>
        /// <param name="depositDateTime">The deposit date time.</param>
        /// <param name="amount">The amount.</param>
        public void MakeDeposit(MerchantDepositSource source,
                                String reference,
                                DateTime depositDateTime,
                                Decimal amount)
        {
            String depositData = $"{depositDateTime.ToString("yyyyMMdd hh:mm:ss.fff")}-{reference}-{amount:N2}-{source}";
            Guid   depositId   = this.GenerateGuidFromString(depositData);

            this.EnsureMerchantHasBeenCreated();
            this.EnsureNotDuplicateDeposit(depositId);
            // TODO: Change amount to a value object (PositiveAmount VO)
            this.EnsureDepositSourceHasBeenSet(source);

            if (source == MerchantDepositSource.Manual)
            {
                ManualDepositMadeEvent manualDepositMadeEvent =
                    new ManualDepositMadeEvent(this.AggregateId, this.EstateId, depositId, reference, depositDateTime, amount);
                this.ApplyAndAppend(manualDepositMadeEvent);
            }
            else if (source == MerchantDepositSource.Automatic)
            {
                // TODO:
                throw new NotSupportedException("Automatic deposits are not yet supported");
            }
        }
Exemple #3
0
 /// <summary>
 /// Creates the specified deposit identifier.
 /// </summary>
 /// <param name="depositId">The deposit identifier.</param>
 /// <param name="source">The source.</param>
 /// <param name="reference">The reference.</param>
 /// <param name="depositDateTime">The deposit date time.</param>
 /// <param name="amount">The amount.</param>
 /// <returns></returns>
 internal static Deposit Create(Guid depositId,
                                MerchantDepositSource source,
                                String reference,
                                DateTime depositDateTime,
                                Decimal amount)
 {
     return(new Deposit(depositId, source, reference, depositDateTime, amount));
 }
 /// <summary>
 /// Creates the specified estate identifier.
 /// </summary>
 /// <param name="estateId">The estate identifier.</param>
 /// <param name="merchantId">The merchant identifier.</param>
 /// <param name="source">The source.</param>
 /// <param name="reference">The reference.</param>
 /// <param name="depositDateTime">The deposit date time.</param>
 /// <param name="amount">The amount.</param>
 /// <returns></returns>
 public static MakeMerchantDepositRequest Create(Guid estateId,
                                                 Guid merchantId,
                                                 MerchantDepositSource source,
                                                 String reference,
                                                 DateTime depositDateTime,
                                                 Decimal amount)
 {
     return(new MakeMerchantDepositRequest(estateId, merchantId, source, reference, depositDateTime, amount));
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Deposit" /> class.
 /// </summary>
 /// <param name="depositId">The deposit identifier.</param>
 /// <param name="source">The source.</param>
 /// <param name="reference">The reference.</param>
 /// <param name="depositDateTime">The deposit date time.</param>
 /// <param name="amount">The amount.</param>
 private Deposit(Guid depositId,
                 MerchantDepositSource source,
                 String reference,
                 DateTime depositDateTime,
                 Decimal amount)
 {
     this.DepositId       = depositId;
     this.Source          = source;
     this.Reference       = reference;
     this.DepositDateTime = depositDateTime;
     this.Amount          = amount;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MakeMerchantDepositRequest"/> class.
 /// </summary>
 /// <param name="estateId">The estate identifier.</param>
 /// <param name="merchantId">The merchant identifier.</param>
 /// <param name="source">The source.</param>
 /// <param name="reference">The reference.</param>
 /// <param name="depositDateTime">The deposit date time.</param>
 /// <param name="amount">The amount.</param>
 public MakeMerchantDepositRequest(Guid estateId,
                                   Guid merchantId,
                                   MerchantDepositSource source,
                                   String reference,
                                   DateTime depositDateTime,
                                   Decimal amount)
 {
     this.EstateId        = estateId;
     this.MerchantId      = merchantId;
     this.Source          = source;
     this.Reference       = reference;
     this.DepositDateTime = depositDateTime;
     this.Amount          = amount;
 }
Exemple #7
0
        public void MakeMerchantDepositRequest_CanBeCreated_IsCreated(MerchantDepositSource merchantDepositSource)
        {
            MakeMerchantDepositRequest makeMerchantDepositRequest = MakeMerchantDepositRequest.Create(TestData.EstateId,
                                                                                                      TestData.MerchantId,
                                                                                                      merchantDepositSource,
                                                                                                      TestData.DepositReference,
                                                                                                      TestData.DepositDateTime,
                                                                                                      TestData.DepositAmount);

            makeMerchantDepositRequest.ShouldNotBeNull();
            makeMerchantDepositRequest.EstateId.ShouldBe(TestData.EstateId);
            makeMerchantDepositRequest.MerchantId.ShouldBe(TestData.MerchantId);
            makeMerchantDepositRequest.Source.ShouldBe(merchantDepositSource);
            makeMerchantDepositRequest.Amount.ShouldBe(TestData.DepositAmount);
            makeMerchantDepositRequest.DepositDateTime.ShouldBe(TestData.DepositDateTime);
            makeMerchantDepositRequest.Reference.ShouldBe(TestData.DepositReference);
        }