Example #1
0
        /// <summary>
        /// Расчет процента отгрузки по накладной
        /// </summary>
        /// <param name="waybill"></param>
        /// <returns></returns>
        public decimal CalculateShippingPercent(MovementWaybill waybill)
        {
            var     accountingPrices = articlePriceService.GetAccountingPrice(waybill.RecipientStorage.Id, movementWaybillRepository.GetArticlesSubquery(waybill.Id));
            decimal totalIn = 0, totalOut = 0;

            decimal?price = 0M;

            foreach (var item in waybill.Rows)
            {
                price = accountingPrices[item.Article.Id];

                if (price == null || price == 0)
                {
                    price = 0.0000000001M;
                }

                totalIn  += item.MovingCount * price.Value;
                totalOut += item.TotallyReservedCount * price.Value;
            }

            return(totalIn != 0 ? (totalOut / totalIn) * 100 : 0);
        }
Example #2
0
        public void Accept(MovementWaybill waybill, User user, DateTime currentDateTime)
        {
            // регулярная проверка - появились ли РЦ для переоценки
            articleRevaluationService.CheckAccountingPriceListWithoutCalculatedRevaluation(currentDateTime);

            CheckPossibilityToAccept(waybill, user);

            // получение текущих позиций реестров цен
            var recipientArticleAccountingPrices = articlePriceService.GetArticleAccountingPrices(waybill.RecipientStorage.Id,
                                                                                                  movementWaybillRepository.GetArticlesSubquery(waybill.Id), currentDateTime);
            var senderArticleAccountingPrices = articlePriceService.GetArticleAccountingPrices(waybill.SenderStorage.Id,
                                                                                               movementWaybillRepository.GetArticlesSubquery(waybill.Id), currentDateTime);

            // проводка накладной
            waybill.Accept(senderArticleAccountingPrices, recipientArticleAccountingPrices, UseReadyToAcceptState, user, currentDateTime);

            // резервирование товаров при проводке
            var reservationInfoList = articleMovementService.AcceptArticles(waybill);

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