コード例 #1
0
        /// <summary>
        /// Расчет основных показателей накладной
        /// </summary>
        public decimal CalculateAccountingPriceSum(ReturnFromClientWaybill waybill)
        {
            decimal?accountingPriceSum = 0M;

            if (waybill.IsAccepted)
            {
                accountingPriceSum = waybill.RecipientAccountingPriceSum;
            }
            else
            {
                var articleSubQuery = returnFromClientWaybillRepository.GetArticlesSubquery(waybill.Id);

                var accountingPrices = articlePriceService.GetAccountingPrice(waybill.RecipientStorage.Id, articleSubQuery);

                foreach (var row in waybill.Rows)
                {
                    accountingPriceSum += (accountingPrices[row.Article.Id] ?? 0) * row.ReturnCount;
                }
            }

            return(Math.Round(accountingPriceSum.HasValue ? accountingPriceSum.Value : 0M, 2));
        }
コード例 #2
0
        /// <summary>
        /// Проводка накладной
        /// </summary>
        /// <param name="waybill">Накладная</param>
        public void Accept(ReturnFromClientWaybill waybill, User user, DateTime currentDateTime)
        {
            // регулярная проверка - появились ли РЦ для переоценки
            articleRevaluationService.CheckAccountingPriceListWithoutCalculatedRevaluation(currentDateTime);

            CheckPossibilityToAccept(waybill, user);

            // получаем учетные цены для товаров в накладной
            var senderPriceLists = articlePriceService.GetArticleAccountingPrices(waybill.RecipientStorage.Id,
                                                                                  returnFromClientWaybillRepository.GetArticlesSubquery(waybill.Id), currentDateTime);

            // проводим накладную
            waybill.Accept(senderPriceLists, UseReadyToAcceptState, user, currentDateTime);

            returnFromClientWaybillRepository.Save(waybill);

            // Пересчет показателей входящего проведенного наличия
            articleAvailabilityService.ReturnFromClientWaybillAccepted(waybill);

            // резервирование товара для возвратов и пересчет показателей возвратов
            returnFromClientService.ReturnFromClientWaybillAccepted(waybill);
        }