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); }
/// <summary> /// Автоматическое разнесение подходящих платежных документов на создаваемый возврат оплаты клиенту /// </summary> /// <param name="dealPaymentToClient">Возврат оплаты клиенту для разнесения на него</param> /// <param name="currentDate">Дата операции</param> public void DistributeDealPaymentToClient(DealPaymentToClient dealPaymentToClient, DateTime currentDate) { // получение информации о всех неразнесенных частях оплат по сделке и команде var dealPaymentUndistributedPartsInfo = GetTotalDealPaymentUndistributedPartsInfo(dealPaymentToClient.Deal, dealPaymentToClient.Team); // неразнесенные части оплат на дату текущего платежого документа и их сумма var dealPaymentUndistributedPartsInfoOnDealPaymentDocumentDate = dealPaymentUndistributedPartsInfo.Where(x => x.AppearenceDate <= dealPaymentToClient.Date).ToList(); var dealPaymentUndistributedPartsInfoOnDealPaymentDocumentDateSum = dealPaymentUndistributedPartsInfoOnDealPaymentDocumentDate.Sum(x => x.Sum); // сумма неразнесенных частей на дату должна быть не меньше неразнесенного остатка по текущему платежному документу ValidationUtils.Assert(dealPaymentUndistributedPartsInfoOnDealPaymentDocumentDateSum >= dealPaymentToClient.UndistributedSum, String.Format("Недостаточно средств на {0} для возврата оплаты клиенту. Доступно к возврату всего {1} руб.", dealPaymentToClient.Date.ToFullDateTimeString(), dealPaymentUndistributedPartsInfoOnDealPaymentDocumentDateSum.ForDisplay(ValueDisplayType.Money))); // дата документа возврата оплаты и дебетовой корректировки должна быть больше даты освобождения денег на него. PayDealPaymentDocument(dealPaymentUndistributedPartsInfoOnDealPaymentDocumentDate, dealPaymentToClient, dealPaymentToClient.UndistributedSum, currentDate); }
public void DealPaymentDocumentTest_DealPaymentToClient_InitialParameters_Must_Be_Set() { // Act (создаем возврат оплаты клиенту) var currentDate = DateTime.Now; var dealPaymentToClient = new DealPaymentToClient(team.Object, user.Object, "0003", new DateTime(2012, 2, 16), 510M, DealPaymentForm.Cashless, currentDate); Assert.AreEqual("0003", dealPaymentToClient.PaymentDocumentNumber); Assert.AreEqual(currentDate, dealPaymentToClient.CreationDate); Assert.AreEqual(new DateTime(2012, 2, 16), dealPaymentToClient.Date); Assert.IsNull(dealPaymentToClient.Deal); Assert.IsNull(dealPaymentToClient.DeletionDate); Assert.IsNotNull(dealPaymentToClient.Distributions); Assert.AreEqual(0, dealPaymentToClient.Distributions.Count()); Assert.AreEqual(DealPaymentForm.Cashless, dealPaymentToClient.DealPaymentForm); Assert.AreEqual(510M, dealPaymentToClient.Sum); Assert.AreEqual(user.Object, dealPaymentToClient.User); Assert.AreEqual(team.Object, dealPaymentToClient.Team); }
public void Delete(DealPaymentToClient value) { CurrentSession.SaveOrUpdate(value); }
public void Save(DealPaymentToClient value) { CurrentSession.SaveOrUpdate(value); CurrentSession.Flush(); }