public void DealPaymentDocumentDistributionService_PayDealPaymentDocument_Must_Pay_From_DealPaymentFromClient_To_DealPaymentToClient()
        {
            // Создаем оплату от клиента
            var currentDate           = DateTime.Now;
            var dealPaymentFromClient = new DealPaymentFromClient(team, user.Object, "001", new DateTime(2012, 2, 18), 600M, DealPaymentForm.Cash, currentDate);

            // Создаем возврат оплаты клиенту
            var dealPaymentToClient = new DealPaymentToClient(team, user.Object, "0003", new DateTime(2012, 2, 16), 510M, DealPaymentForm.Cashless, currentDate);

            Assert.AreEqual(0M, dealPaymentFromClient.DistributedSum);
            Assert.AreEqual(0M, dealPaymentToClient.DistributedSum);
            Assert.AreEqual(600M, dealPaymentFromClient.UndistributedSum);
            Assert.AreEqual(510M, dealPaymentToClient.UndistributedSum);
            Assert.IsFalse(dealPaymentFromClient.IsFullyDistributed);
            Assert.IsFalse(dealPaymentToClient.IsFullyDistributed);

            // Act
            dealPaymentDocumentDistributionService.PayDealPaymentDocument(new List <DealPaymentUndistributedPartInfo>()
            {
                new DealPaymentUndistributedPartInfo(dealPaymentFromClient, dealPaymentFromClient.Date, 510M)
            },
                                                                          dealPaymentToClient, 510M, currentDate);

            Assert.AreEqual(510M, dealPaymentFromClient.DistributedSum);
            Assert.AreEqual(510M, dealPaymentToClient.DistributedSum);
            Assert.AreEqual(90M, dealPaymentFromClient.UndistributedSum);
            Assert.AreEqual(0M, dealPaymentToClient.UndistributedSum);
            Assert.AreEqual(new DateTime(2012, 2, 18), dealPaymentToClient.Distributions.First().DistributionDate);
            Assert.IsFalse(dealPaymentFromClient.IsFullyDistributed);
            Assert.IsTrue(dealPaymentToClient.IsFullyDistributed);
        }
        public void DealPaymentDocumentDistributionTest_DealPaymentDocumentDistributionToSaleWaybill_InitialParameters_Must_Be_Set()
        {
            // Создаем оплату от клиента
            var currentDate           = DateTime.Now;
            var distributionDate      = DateTime.Now.AddDays(1);
            var dealPaymentFromClient = new DealPaymentFromClient(team.Object, user, "001", new DateTime(2012, 2, 18), 500M, DealPaymentForm.Cash, currentDate);

            var dealPaymentDocumentDistributionToSaleWaybill = new DealPaymentDocumentDistributionToSaleWaybill(dealPaymentFromClient, expenditureWaybill, 500M, distributionDate, currentDate);

            Assert.AreEqual(distributionDate, dealPaymentDocumentDistributionToSaleWaybill.DistributionDate);
            Assert.AreEqual(currentDate, dealPaymentDocumentDistributionToSaleWaybill.CreationDate);
            Assert.AreEqual(dealPaymentFromClient, dealPaymentDocumentDistributionToSaleWaybill.SourceDealPaymentDocument);
            Assert.AreEqual(expenditureWaybill, dealPaymentDocumentDistributionToSaleWaybill.SaleWaybill);
            Assert.AreEqual(500M, dealPaymentDocumentDistributionToSaleWaybill.Sum);
        }
        public void DealPaymentDocumentDistributionTest_AddDealPaymentDocumentDistribution_Must_Set_IsFullyDistributed_Flag_If_Fully_Distributed()
        {
            // Создаем оплату от клиента
            var currentDate           = DateTime.Now;
            var distributionDate      = DateTime.Now.AddDays(1);
            var dealPaymentFromClient = new DealPaymentFromClient(team.Object, user, "001", new DateTime(2012, 2, 18), 500M, DealPaymentForm.Cash, currentDate);

            // Создаем разнесение
            var dealPaymentDocumentDistributionToSaleWaybill = new DealPaymentDocumentDistributionToSaleWaybill(dealPaymentFromClient, expenditureWaybill, 500M, distributionDate, currentDate);

            Assert.IsFalse(dealPaymentFromClient.IsFullyDistributed);

            // Act
            dealPaymentFromClient.AddDealPaymentDocumentDistribution(dealPaymentDocumentDistributionToSaleWaybill);

            Assert.IsTrue(dealPaymentFromClient.IsFullyDistributed);
        }
Exemplo n.º 4
0
        public void DealPaymentDocumentTest_DealPaymentFromClient_InitialParameters_Must_Be_Set()
        {
            // Act (создаем оплату от клиента)
            var currentDate           = DateTime.Now;
            var dealPaymentFromClient = new DealPaymentFromClient(team.Object, user.Object, "001", new DateTime(2012, 2, 18), 500M, DealPaymentForm.Cash, currentDate);

            Assert.AreEqual("001", dealPaymentFromClient.PaymentDocumentNumber);
            Assert.AreEqual(currentDate, dealPaymentFromClient.CreationDate);
            Assert.AreEqual(new DateTime(2012, 2, 18), dealPaymentFromClient.Date);
            Assert.IsNull(dealPaymentFromClient.Deal);
            Assert.IsNull(dealPaymentFromClient.DeletionDate);
            Assert.IsNotNull(dealPaymentFromClient.Distributions);
            Assert.AreEqual(0, dealPaymentFromClient.Distributions.Count());
            Assert.AreEqual(DealPaymentForm.Cash, dealPaymentFromClient.DealPaymentForm);
            Assert.AreEqual(500M, dealPaymentFromClient.Sum);
            Assert.AreEqual(user.Object, dealPaymentFromClient.User);
            Assert.AreEqual(team.Object, dealPaymentFromClient.Team);
        }
Exemplo n.º 5
0
        public void DealPaymentDocumentTest_Adding_DealPaymentFromClient_With_Cashless_To_Deal_Must_Set_DealPaymentSum_UndistributedDealPaymentFromClientSum_Not_CashDealPaymentSum()
        {
            // Создаем оплату от клиента
            var currentDate           = DateTime.Now;
            var dealPaymentFromClient = new DealPaymentFromClient(team.Object, user.Object, "004", new DateTime(2012, 2, 19), 600M, DealPaymentForm.Cashless, currentDate);

            Assert.IsNull(dealPaymentFromClient.Deal);
            Assert.AreEqual(0M, deal.DealPaymentSum);
            Assert.AreEqual(0M, deal.CashDealPaymentSum);
            Assert.AreEqual(0M, deal.UndistributedDealPaymentFromClientSum);

            // Act
            deal.AddDealPaymentDocument(dealPaymentFromClient);

            Assert.AreEqual(deal, dealPaymentFromClient.Deal);
            Assert.AreEqual(600M, deal.DealPaymentSum);
            Assert.AreEqual(0M, deal.CashDealPaymentSum);
            Assert.AreEqual(600M, deal.UndistributedDealPaymentFromClientSum);
        }
Exemplo n.º 6
0
 public void Delete(DealPaymentFromClient value)
 {
     CurrentSession.SaveOrUpdate(value);
 }
Exemplo n.º 7
0
 public void Save(DealPaymentFromClient value)
 {
     CurrentSession.SaveOrUpdate(value);
     CurrentSession.Flush();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Разнесение оплаты от клиента на список других сущностей. Создает разнесения платежного документа.
 /// Может остаться неразнесенный остаток.
 /// Если неразнесенной суммы оплаты от клиента недостаточно для разнесения, выбрасывается исключение.
 /// </summary>
 /// <param name="dealPaymentFromClient">Оплата от клиента для разнесения</param>
 /// <param name="dealPaymentDocumentDistributionInfoList">Список сущностей и сумм для разнесения</param>
 /// <param name="currentDate">Дата операции</param>
 public void DistributeDealPaymentFromClient(DealPaymentFromClient dealPaymentFromClient,
                                             IEnumerable <DealPaymentDocumentDistributionInfo> dealPaymentDocumentDistributionInfoList, DateTime currentDate)
 {
     DistributeDealPaymentDocument <DealPaymentFromClient>(dealPaymentFromClient, dealPaymentDocumentDistributionInfoList, currentDate);
 }