public void Accept(AccountingPriceList accountingPriceList, DateTime currentDateTime, User user) { CheckPossibilityToAccept(accountingPriceList, user); // регулярная проверка - не появились ли РЦ для переоценки articleRevaluationService.CheckAccountingPriceListWithoutCalculatedRevaluation(currentDateTime); accountingPriceList.Accept(currentDateTime); accountingPriceListRepository.Save(accountingPriceList); // добавление показателей учетных цен var articleAccountingPriceIndicators = new List <ArticleAccountingPriceIndicator>(); foreach (var storage in accountingPriceList.Storages) { foreach (var row in accountingPriceList.ArticlePrices) { articleAccountingPriceIndicatorService.Add(accountingPriceList.StartDate, accountingPriceList.EndDate, storage.Id, row.Article.Id, accountingPriceList.Id, row.Id, row.AccountingPrice); } } // пересчет показателей переоценки articleRevaluationService.AccountingPriceListAccepted(accountingPriceList, currentDateTime); }
public void AccountingPriceList_CantAcceptWithZeroArticles() { try { var accountingPriceList = new AccountingPriceList("234", DateTime.Today.AddYears(1), DateTime.Today.AddYears(2), new List <Storage>() { storage1 }, user); accountingPriceList.Accept(DateTime.Now); Assert.Fail("Исключения не было."); } catch (Exception ex) { Assert.AreEqual("Невозможно провести реестр цен без товаров.", ex.Message); } }
public void AccountingPriceList_AcceptAndCancellationMustWork() { var accountingPriceList = new AccountingPriceList("234", DateTime.Today.AddYears(1), DateTime.Today.AddYears(2), storage1, articleAccountingPriceCorrectList1, user); var dateBeforeAccept = DateTime.Now; accountingPriceList.Accept(DateTime.Now); var dateAfterAccept = DateTime.Now; Assert.AreEqual(AccountingPriceListState.Accepted, accountingPriceList.State); Assert.IsNotNull(accountingPriceList.AcceptanceDate); Assert.IsTrue(dateBeforeAccept <= accountingPriceList.AcceptanceDate && accountingPriceList.AcceptanceDate <= dateAfterAccept); accountingPriceList.CancelAcceptance(); Assert.AreEqual(AccountingPriceListState.New, accountingPriceList.State); Assert.IsNull(accountingPriceList.AcceptanceDate); }