Пример #1
0
        public void AccountingPriceCalcByCurrentAccountingPrice_Initial_Parameters_Must_Be_Set()
        {
            var detRule = new AccountingPriceDeterminationRule(AccountingPriceDeterminationRuleType.ByAverageAccountingPrice, AccountingPriceListStorageTypeGroup.All, new List <Storage>());
            var apCalc  = new AccountingPriceCalcByCurrentAccountingPrice(detRule, 10);

            Assert.AreEqual(10, apCalc.MarkupPercentValue);
            Assert.AreEqual(detRule, apCalc.AccountingPriceDeterminationRule);
        }
Пример #2
0
        public void AccountingPriceCalcRule_When_Init_By_AccountingPriceCalcByCurrentAccountingPrice_Type_Must_Equal_ByCurrentAccountingPrice()
        {
            var apdRule = new AccountingPriceDeterminationRule(AccountingPriceDeterminationRuleType.ByAverageAccountingPrice, AccountingPriceListStorageTypeGroup.DistributionCenters, new List <Storage>());
            var apCalc  = new AccountingPriceCalcByCurrentAccountingPrice(apdRule, 18);
            var apRule  = new AccountingPriceCalcRule(apCalc);

            Assert.AreEqual(apCalc, apRule.CalcByCurrentAccountingPrice);
            Assert.IsNull(apRule.CalcByPurchaseCost);
            Assert.AreEqual(AccountingPriceCalcRuleType.ByCurrentAccountingPrice, apRule.Type);
        }
Пример #3
0
        public void AccountingPriceCalcByCurrentAccountingPrice_Create_With_Rule_Set_To_Null_Must_Throw_Exception()
        {
            var detRule = new AccountingPriceDeterminationRule(AccountingPriceDeterminationRuleType.ByAverageAccountingPrice, AccountingPriceListStorageTypeGroup.All, new List <Storage>());

            try
            {
                var apCalc = new AccountingPriceCalcByCurrentAccountingPrice(null, 10);
                Assert.Fail("Нельзя устанавливать правило в null.");
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Невозможно установить правило определения учетной цены в null.", ex.Message);
            }
        }
        public void GetTipsForArticle(AccountingPriceList accountingPriceList, Article article,
                                      out decimal?avgAccPrice, out decimal?minAccPrice, out decimal?maxAccPrice, out decimal?avgPurchaseCost, out decimal?minPurchaseCost,
                                      out decimal?maxPurchaseCost, out decimal?lastPurchaseCost, User user)
        {
            AccountingPriceCalcRule ruleForTips;

            var lastDigitRule = new LastDigitCalcRule(LastDigitCalcRuleType.LeaveAsIs);

            var byPurchaseCostRule    = new AccountingPriceCalcByPurchaseCost(PurchaseCostDeterminationRuleType.ByAveragePurchasePrice, new MarkupPercentDeterminationRule(0M));
            var byAccountingPriceRule = new AccountingPriceCalcByCurrentAccountingPrice(
                new AccountingPriceDeterminationRule(
                    AccountingPriceDeterminationRuleType.ByAverageAccountingPrice, AccountingPriceListStorageTypeGroup.All, storageService.GetList(user, Permission.Storage_List_Details)), 0);

            ruleForTips = accountingPriceCalcRuleService.GetReadyAccountingPriceCalcRule(new AccountingPriceCalcRule(byPurchaseCostRule), article.Id, user);

            avgPurchaseCost  = null;
            maxPurchaseCost  = null;
            minPurchaseCost  = null;
            lastPurchaseCost = null;

            Func <decimal?> calcPrice = () => { return(accountingPriceCalcService.CalculateAccountingPrice(ruleForTips, lastDigitRule, article)); };

            avgPurchaseCost = calcPrice();

            ruleForTips.CalcByPurchaseCost.PurchaseCostDeterminationRuleType = PurchaseCostDeterminationRuleType.ByMaximalPurchaseCost;
            maxPurchaseCost = calcPrice();

            ruleForTips.CalcByPurchaseCost.PurchaseCostDeterminationRuleType = PurchaseCostDeterminationRuleType.ByMinimalPurchaseCost;
            minPurchaseCost = calcPrice();

            ruleForTips = accountingPriceCalcRuleService.GetReadyAccountingPriceCalcRule(new AccountingPriceCalcRule(
                                                                                             new AccountingPriceCalcByPurchaseCost(PurchaseCostDeterminationRuleType.ByLastPurchaseCost, new MarkupPercentDeterminationRule(0M))),
                                                                                         article.Id, user);
            lastPurchaseCost = calcPrice();

            ruleForTips = accountingPriceCalcRuleService.GetReadyAccountingPriceCalcRule(new AccountingPriceCalcRule(byAccountingPriceRule), article.Id, user);

            avgAccPrice = null;
            maxAccPrice = null;
            minAccPrice = null;

            avgAccPrice = calcPrice();

            ruleForTips.CalcByCurrentAccountingPrice.AccountingPriceDeterminationRule.Type = AccountingPriceDeterminationRuleType.ByMaximalAccountingPrice;
            maxAccPrice = calcPrice();

            ruleForTips.CalcByCurrentAccountingPrice.AccountingPriceDeterminationRule.Type = AccountingPriceDeterminationRuleType.ByMinimalAccountingPrice;
            minAccPrice = calcPrice();
        }