コード例 #1
0
        public RecoveryOrderDetail RejectObject(RecoveryOrderDetail recoveryOrderDetail, DateTime RejectedDate, ICoreIdentificationService _coreIdentificationService, ICoreIdentificationDetailService _coreIdentificationDetailService,
                                                IRecoveryOrderService _recoveryOrderService, IRecoveryAccessoryDetailService _recoveryAccessoryDetailService, ICoreBuilderService _coreBuilderService, IRollerBuilderService _rollerBuilderService,
                                                IItemService _itemService, IWarehouseItemService _warehouseItemService, IBarringService _barringService, IStockMutationService _stockMutationService)
        {
            recoveryOrderDetail.RejectedDate = RejectedDate;
            if (_validator.ValidRejectObject(recoveryOrderDetail, _recoveryOrderService))
            {
                _repository.RejectObject(recoveryOrderDetail);

                // add recovery order quantity reject
                // if valid, complete recovery order = true
                RecoveryOrder recoveryOrder = _recoveryOrderService.GetObjectById(recoveryOrderDetail.RecoveryOrderId);
                recoveryOrder.QuantityRejected += 1;
                _recoveryOrderService.AdjustQuantity(recoveryOrder);
                if (_recoveryOrderService.GetValidator().ValidCompleteObject(recoveryOrder, this, _recoveryAccessoryDetailService))
                {
                    _recoveryOrderService.CompleteObject(recoveryOrder, _coreIdentificationDetailService, this, _recoveryAccessoryDetailService);
                }

                bool CaseAddition = false;

                // deduce compound
                RollerBuilder rollerBuilder         = _rollerBuilderService.GetObjectById(recoveryOrderDetail.RollerBuilderId);
                Item          compound              = _itemService.GetObjectById(rollerBuilder.CompoundId);
                WarehouseItem warehouseCompound     = _warehouseItemService.FindOrCreateObject(recoveryOrder.WarehouseId, compound.Id);
                StockMutation stockMutationCompound = _stockMutationService.CreateStockMutationForRecoveryOrderCompound(recoveryOrderDetail, warehouseCompound, CaseAddition);
                _stockMutationService.StockMutateObject(stockMutationCompound, _itemService, _barringService, _warehouseItemService);

                // deduce core
                CoreIdentificationDetail coreIdentificationDetail = _coreIdentificationDetailService.GetObjectById(recoveryOrderDetail.CoreIdentificationDetailId);
                _coreIdentificationDetailService.UnsetJobScheduled(coreIdentificationDetail, _recoveryOrderService, this);

                CoreBuilder coreBuilder = _coreBuilderService.GetObjectById(coreIdentificationDetail.CoreBuilderId);
                Item        core        = (coreIdentificationDetail.MaterialCase == Core.Constants.Constant.MaterialCase.New) ?
                                          _coreBuilderService.GetNewCore(coreBuilder.Id) : _coreBuilderService.GetUsedCore(coreBuilder.Id);
                WarehouseItem warehouseCore     = _warehouseItemService.FindOrCreateObject(recoveryOrder.WarehouseId, core.Id);
                StockMutation stockMutationCore = _stockMutationService.CreateStockMutationForRecoveryOrder(recoveryOrderDetail, warehouseCore, CaseAddition);
                _stockMutationService.StockMutateObject(stockMutationCore, _itemService, _barringService, _warehouseItemService);


                // accesories uncounted
            }
            return(recoveryOrderDetail);
        }
コード例 #2
0
        public RecoveryOrderDetail FinishObject(RecoveryOrderDetail recoveryOrderDetail, DateTime FinishedDate, ICoreIdentificationService _coreIdentificationService, ICoreIdentificationDetailService _coreIdentificationDetailService,
                                                IRecoveryOrderService _recoveryOrderService, IRecoveryAccessoryDetailService _recoveryAccessoryDetailService, ICoreBuilderService _coreBuilderService, IRollerBuilderService _rollerBuilderService,
                                                IItemService _itemService, IWarehouseItemService _warehouseItemService, IBarringService _barringService, IStockMutationService _stockMutationService)
        {
            recoveryOrderDetail.FinishedDate = FinishedDate;
            if (_validator.ValidFinishObject(recoveryOrderDetail, _recoveryOrderService, _recoveryAccessoryDetailService))
            {
                // set object to finish
                _repository.FinishObject(recoveryOrderDetail);

                // add recovery order quantity final
                // if valid, complete recovery order = true
                RecoveryOrder recoveryOrder = _recoveryOrderService.GetObjectById(recoveryOrderDetail.RecoveryOrderId);
                recoveryOrder.QuantityFinal += 1;
                _recoveryOrderService.AdjustQuantity(recoveryOrder);
                if (_recoveryOrderService.GetValidator().ValidCompleteObject(recoveryOrder, this, _recoveryAccessoryDetailService))
                {
                    _recoveryOrderService.CompleteObject(recoveryOrder, _coreIdentificationDetailService, this, _recoveryAccessoryDetailService);
                }

                bool CaseAdditionCompound = false;
                bool CaseAdditionCore     = false;
                bool CaseAdditionRoller   = true;

                // deduce compound
                RollerBuilder rollerBuilder         = _rollerBuilderService.GetObjectById(recoveryOrderDetail.RollerBuilderId);
                Item          compound              = _itemService.GetObjectById(rollerBuilder.CompoundId);
                WarehouseItem warehouseCompound     = _warehouseItemService.FindOrCreateObject(recoveryOrder.WarehouseId, compound.Id);
                StockMutation stockMutationCompound = _stockMutationService.CreateStockMutationForRecoveryOrderCompound(recoveryOrderDetail, warehouseCompound, CaseAdditionCompound);
                _stockMutationService.StockMutateObject(stockMutationCompound, _itemService, _barringService, _warehouseItemService);

                CoreIdentificationDetail coreIdentificationDetail = _coreIdentificationDetailService.GetObjectById(recoveryOrderDetail.CoreIdentificationDetailId);
                _coreIdentificationDetailService.UnsetJobScheduled(coreIdentificationDetail, _recoveryOrderService, this);
                _coreIdentificationDetailService.BuildRoller(coreIdentificationDetail);

                // deduce core
                CoreBuilder coreBuilder = _coreBuilderService.GetObjectById(coreIdentificationDetail.CoreBuilderId);
                Item        core        = (coreIdentificationDetail.MaterialCase == Core.Constants.Constant.MaterialCase.New) ?
                                          _coreBuilderService.GetNewCore(coreBuilder.Id) : _coreBuilderService.GetUsedCore(coreBuilder.Id);
                WarehouseItem warehouseCore     = _warehouseItemService.FindOrCreateObject(recoveryOrder.WarehouseId, core.Id);
                StockMutation stockMutationCore = _stockMutationService.CreateStockMutationForRecoveryOrder(recoveryOrderDetail, warehouseCore, CaseAdditionCore);
                _stockMutationService.StockMutateObject(stockMutationCore, _itemService, _barringService, _warehouseItemService);

                // add roller
                Item roller = (coreIdentificationDetail.MaterialCase == Core.Constants.Constant.MaterialCase.New) ?
                              _rollerBuilderService.GetRollerNewCore(rollerBuilder.Id) : _rollerBuilderService.GetRollerUsedCore(rollerBuilder.Id);
                WarehouseItem warehouseRoller     = _warehouseItemService.FindOrCreateObject(recoveryOrder.WarehouseId, roller.Id);
                StockMutation stockMutationRoller = _stockMutationService.CreateStockMutationForRecoveryOrder(recoveryOrderDetail, warehouseRoller, CaseAdditionRoller);
                _stockMutationService.StockMutateObject(stockMutationRoller, _itemService, _barringService, _warehouseItemService);

                // deduce accessories
                IList <RecoveryAccessoryDetail> recoveryAccessoryDetails = _recoveryAccessoryDetailService.GetObjectsByRecoveryOrderDetailId(recoveryOrderDetail.Id);
                if (recoveryAccessoryDetails.Any())
                {
                    foreach (var recoveryAccessoryDetail in recoveryAccessoryDetails)
                    {
                        Item          accessory              = _itemService.GetObjectById(recoveryAccessoryDetail.ItemId);
                        WarehouseItem warehouseAccessory     = _warehouseItemService.FindOrCreateObject(recoveryOrder.WarehouseId, accessory.Id);
                        StockMutation stockMutationAccessory = _stockMutationService.CreateStockMutationForRecoveryAccessory(recoveryAccessoryDetail, warehouseAccessory);
                        _stockMutationService.StockMutateObject(stockMutationAccessory, _itemService, _barringService, _warehouseItemService);
                    }
                }
            }
            return(recoveryOrderDetail);
        }