protected override void SaveRelative(WarehouseTransfer warehouseTransfer, SaveRelativeOption saveRelativeOption)
        {
            base.SaveRelative(warehouseTransfer, saveRelativeOption);

            if (warehouseTransfer.OneStep)
            {
                GRHelperService grHelperService = new GRHelperService(this.GetGROption(warehouseTransfer.NMVNTaskID), this.GenericWithDetailRepository.TotalSmartPortalEntities, this.UserID);

                IGoodsReceiptAPIRepository goodsReceiptAPIRepository = new GoodsReceiptAPIRepository(this.GenericWithDetailRepository.TotalSmartPortalEntities);
                if (saveRelativeOption == SaveRelativeOption.Update)
                {
                    IGoodsReceiptDTO goodsReceiptDTO = grHelperService.NewGoodsReceiptDTO();

                    goodsReceiptDTO.EntryDate = warehouseTransfer.EntryDate;

                    goodsReceiptDTO.GoodsReceiptTypeID  = (int)GlobalEnums.GoodsReceiptTypeID.WarehouseTransfer;
                    goodsReceiptDTO.WarehouseTransferID = warehouseTransfer.WarehouseTransferID;

                    goodsReceiptDTO.ShiftID = warehouseTransfer.ShiftID;
                    goodsReceiptDTO.OneStep = warehouseTransfer.OneStep;

                    goodsReceiptDTO.Warehouse = new TotalDTO.Commons.WarehouseBaseDTO()
                    {
                        WarehouseID = warehouseTransfer.WarehouseReceiptID
                    };
                    goodsReceiptDTO.WarehouseIssue = new TotalDTO.Commons.WarehouseBaseDTO()
                    {
                        WarehouseID = warehouseTransfer.WarehouseID
                    };

                    goodsReceiptDTO.StorekeeperID    = warehouseTransfer.StorekeeperID;
                    goodsReceiptDTO.PreparedPersonID = warehouseTransfer.PreparedPersonID;
                    goodsReceiptDTO.ApproverID       = warehouseTransfer.PreparedPersonID;

                    goodsReceiptDTO.Purposes    = warehouseTransfer.Caption;
                    goodsReceiptDTO.Description = warehouseTransfer.Description;
                    goodsReceiptDTO.Remarks     = warehouseTransfer.Remarks;

                    goodsReceiptDTO.Approved     = warehouseTransfer.Approved;
                    goodsReceiptDTO.ApprovedDate = warehouseTransfer.ApprovedDate;

                    List <GoodsReceiptPendingWarehouseTransferDetail> pendingWarehouseTransferDetails = goodsReceiptAPIRepository.GetPendingWarehouseTransferDetails((int)goodsReceiptDTO.NMVNTaskID, null, goodsReceiptDTO.WarehouseTransferID, goodsReceiptDTO.WarehouseID, goodsReceiptDTO.WarehouseIssueID, null, goodsReceiptDTO.OneStep);
                    foreach (GoodsReceiptPendingWarehouseTransferDetail pendingWarehouseTransferDetail in pendingWarehouseTransferDetails)
                    {
                        GoodsReceiptDetailDTO goodsReceiptDetailDTO = new GoodsReceiptDetailDTO()
                        {
                            GoodsReceiptID = goodsReceiptDTO.GoodsReceiptID,

                            WarehouseTransferID        = pendingWarehouseTransferDetail.WarehouseTransferID,
                            WarehouseTransferDetailID  = pendingWarehouseTransferDetail.WarehouseTransferDetailID,
                            WarehouseTransferReference = pendingWarehouseTransferDetail.WarehouseTransferReference,
                            WarehouseTransferEntryDate = pendingWarehouseTransferDetail.WarehouseTransferEntryDate,
                            GoodsReceiptReference      = pendingWarehouseTransferDetail.GoodsReceiptReference,
                            GoodsReceiptEntryDate      = pendingWarehouseTransferDetail.GoodsReceiptEntryDate,

                            BatchID        = pendingWarehouseTransferDetail.BatchID,
                            BatchEntryDate = pendingWarehouseTransferDetail.BatchEntryDate,


                            CommodityID     = pendingWarehouseTransferDetail.CommodityID,
                            CommodityCode   = pendingWarehouseTransferDetail.CommodityCode,
                            CommodityName   = pendingWarehouseTransferDetail.CommodityName,
                            CommodityTypeID = pendingWarehouseTransferDetail.CommodityTypeID,

                            LabID = pendingWarehouseTransferDetail.LabID,

                            Barcode   = pendingWarehouseTransferDetail.Barcode,
                            BatchCode = pendingWarehouseTransferDetail.BatchCode,
                            SealCode  = pendingWarehouseTransferDetail.SealCode,
                            LabCode   = pendingWarehouseTransferDetail.LabCode,

                            ProductionDate = pendingWarehouseTransferDetail.ProductionDate,
                            ExpiryDate     = pendingWarehouseTransferDetail.ExpiryDate,

                            BinLocationID   = pendingWarehouseTransferDetail.BinLocationID,
                            BinLocationCode = pendingWarehouseTransferDetail.BinLocationCode,

                            UnitWeight = pendingWarehouseTransferDetail.UnitWeight,
                            TareWeight = pendingWarehouseTransferDetail.TareWeight,

                            QuantityRemains = (decimal)pendingWarehouseTransferDetail.QuantityRemains,
                            Quantity        = (decimal)pendingWarehouseTransferDetail.QuantityRemains,
                        };
                        goodsReceiptDTO.ViewDetails.Add(goodsReceiptDetailDTO);
                    }

                    goodsReceiptDTO.TotalQuantity = goodsReceiptDTO.GetTotalQuantity();

                    grHelperService.Save(goodsReceiptDTO);
                }

                if (saveRelativeOption == SaveRelativeOption.Undo)
                {//NOTES: THIS UNDO REQUIRE: JUST SAVE ONLY ONE GoodsReceipt FOR AN WarehouseTransfer
                    int?goodsReceiptID = goodsReceiptAPIRepository.GetGoodsReceiptID(null, null, warehouseTransfer.WarehouseTransferID, null);
                    grHelperService.Delete(goodsReceiptID);
                }
            }
        }
        protected override void SaveRelative(WarehouseAdjustment warehouseAdjustment, SaveRelativeOption saveRelativeOption)
        {
            base.SaveRelative(warehouseAdjustment, saveRelativeOption);

            if (warehouseAdjustment.HasPositiveLine)
            {
                GRHelperService grHelperService = new GRHelperService(this.GetGROption(warehouseAdjustment.NMVNTaskID), this.GenericWithDetailRepository.TotalSmartPortalEntities, this.UserID);

                IGoodsReceiptAPIRepository goodsReceiptAPIRepository = new GoodsReceiptAPIRepository(this.GenericWithDetailRepository.TotalSmartPortalEntities);
                if (saveRelativeOption == SaveRelativeOption.Update)
                {
                    IGoodsReceiptDTO goodsReceiptDTO = grHelperService.NewGoodsReceiptDTO();

                    goodsReceiptDTO.EntryDate = warehouseAdjustment.EntryDate;
                    goodsReceiptDTO.ShiftID   = 1; // warehouseAdjustment.ShiftID;

                    goodsReceiptDTO.GoodsReceiptTypeID    = (int)GlobalEnums.GoodsReceiptTypeID.WarehouseAdjustments;
                    goodsReceiptDTO.WarehouseAdjustmentID = warehouseAdjustment.WarehouseAdjustmentID;

                    goodsReceiptDTO.Warehouse = new TotalDTO.Commons.WarehouseBaseDTO()
                    {
                        WarehouseID = warehouseAdjustment.WarehouseReceiptID
                    };
                    goodsReceiptDTO.Customer = new TotalDTO.Commons.CustomerBaseDTO()
                    {
                        CustomerID = warehouseAdjustment.CustomerID
                    };

                    goodsReceiptDTO.StorekeeperID    = warehouseAdjustment.StorekeeperID;
                    goodsReceiptDTO.PreparedPersonID = warehouseAdjustment.PreparedPersonID;
                    goodsReceiptDTO.ApproverID       = warehouseAdjustment.PreparedPersonID;

                    goodsReceiptDTO.Purposes    = warehouseAdjustment.AdjustmentJobs;
                    goodsReceiptDTO.Description = warehouseAdjustment.Description;
                    goodsReceiptDTO.Remarks     = warehouseAdjustment.Remarks;

                    goodsReceiptDTO.Approved     = warehouseAdjustment.Approved;
                    goodsReceiptDTO.ApprovedDate = warehouseAdjustment.ApprovedDate;

                    List <PendingWarehouseAdjustmentDetail> pendingWarehouseAdjustmentDetails = goodsReceiptAPIRepository.GetPendingWarehouseAdjustmentDetails(warehouseAdjustment.LocationID, null, goodsReceiptDTO.WarehouseAdjustmentID, goodsReceiptDTO.WarehouseID, null, false);
                    foreach (PendingWarehouseAdjustmentDetail pendingWarehouseAdjustmentDetail in pendingWarehouseAdjustmentDetails)
                    {
                        GoodsReceiptDetailDTO goodsReceiptDetailDTO = new GoodsReceiptDetailDTO()
                        {
                            GoodsReceiptID = goodsReceiptDTO.GoodsReceiptID,

                            WarehouseAdjustmentID        = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentID,
                            WarehouseAdjustmentDetailID  = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentDetailID,
                            WarehouseAdjustmentReference = pendingWarehouseAdjustmentDetail.PrimaryReference,
                            WarehouseAdjustmentEntryDate = pendingWarehouseAdjustmentDetail.PrimaryEntryDate,

                            WarehouseAdjustmentTypeID = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentTypeID,

                            BatchID        = pendingWarehouseAdjustmentDetail.BatchID,
                            BatchCode      = pendingWarehouseAdjustmentDetail.BatchCode,
                            BatchEntryDate = pendingWarehouseAdjustmentDetail.BatchEntryDate,

                            CommodityID   = pendingWarehouseAdjustmentDetail.CommodityID,
                            CommodityCode = pendingWarehouseAdjustmentDetail.CommodityCode,
                            CommodityName = pendingWarehouseAdjustmentDetail.CommodityName,

                            LabID = -1,

                            QuantityRemains = (decimal)pendingWarehouseAdjustmentDetail.QuantityRemains,
                            Quantity        = (decimal)pendingWarehouseAdjustmentDetail.QuantityRemains,
                        };
                        goodsReceiptDTO.ViewDetails.Add(goodsReceiptDetailDTO);
                    }

                    goodsReceiptDTO.TotalQuantity = goodsReceiptDTO.GetTotalQuantity();

                    grHelperService.Save(goodsReceiptDTO);
                }

                if (saveRelativeOption == SaveRelativeOption.Undo)
                {//NOTES: THIS UNDO REQUIRE: JUST SAVE ONLY ONE GoodsReceipt FOR AN WarehouseAdjustment
                    int?goodsReceiptID = goodsReceiptAPIRepository.GetGoodsReceiptID(null, null, null, warehouseAdjustment.WarehouseAdjustmentID);
                    grHelperService.Delete(goodsReceiptID);
                }
            }
        }