public void AccountingPriceCalcByPurchaseCost_Initial_Parameters_Must_Be_Set() { var mpRule = new MarkupPercentDeterminationRule(MarkupPercentDeterminationRuleType.ByArticle); var apCalc = new AccountingPriceCalcByPurchaseCost(PurchaseCostDeterminationRuleType.ByAveragePurchasePrice, mpRule); Assert.AreEqual(PurchaseCostDeterminationRuleType.ByAveragePurchasePrice, apCalc.PurchaseCostDeterminationRuleType); Assert.AreEqual(mpRule, apCalc.MarkupPercentDeterminationRule); }
public void AccountingPriceCalcRule_When_Init_By_AccountingPriceCalcByPurchaseCost_Type_Must_Equal_ByPurchaseCost() { var mpdRule = new MarkupPercentDeterminationRule(28); var apCalc = new AccountingPriceCalcByPurchaseCost(PurchaseCostDeterminationRuleType.ByMaximalPurchaseCost, mpdRule); var apRule = new AccountingPriceCalcRule(apCalc); Assert.IsNull(apRule.CalcByCurrentAccountingPrice); Assert.AreEqual(apCalc, apRule.CalcByPurchaseCost); Assert.AreEqual(AccountingPriceCalcRuleType.ByPurchaseCost, apRule.Type); }
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(); }