public PurchaseReceivalDetail ConfirmObject(PurchaseReceivalDetail purchaseReceivalDetail, DateTime ConfirmationDate, IPurchaseReceivalService _purchaseReceivalService, IPurchaseOrderDetailService _purchaseOrderDetailService, IStockMutationService _stockMutationService, IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService) { purchaseReceivalDetail.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(purchaseReceivalDetail, this, _purchaseOrderDetailService)) { purchaseReceivalDetail = _repository.ConfirmObject(purchaseReceivalDetail); PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseReceivalDetail.PurchaseReceivalId); WarehouseItem warehouseItem = _warehouseItemService.FindOrCreateObject(purchaseReceival.WarehouseId, purchaseReceivalDetail.ItemId); Item item = _itemService.GetObjectById(purchaseReceivalDetail.ItemId); IList <StockMutation> stockMutations = _stockMutationService.CreateStockMutationForPurchaseReceival(purchaseReceivalDetail, warehouseItem); foreach (var stockMutation in stockMutations) { // decimal itemPrice = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId).Price; // item.AvgCost = _itemService.CalculateAvgCost(item, purchaseReceivalDetail.Quantity, itemPrice); //item.PendingReceival -= purchaseReceivalDetail.Quantity; //item.Quantity += purchaseReceivalDetail.Quantity; _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService); } PurchaseOrderDetail purchaseOrderDetail = _purchaseOrderDetailService.GetObjectById(purchaseReceivalDetail.PurchaseOrderDetailId); _purchaseOrderDetailService.SetReceivalComplete(purchaseOrderDetail, purchaseReceivalDetail.Quantity); } return(purchaseReceivalDetail); }