/// <summary>
        /// This method is used to review Item Change Request. - JJ
        /// </summary>
        /// <param name="itemChangedDetail">object of ItemChangedDetailsAC</param>
        /// <param name="user">object of UserDetail</param>
        /// <param name="company">object of CompanyDetail</param>
        /// <param name="Comment"></param>
        /// <param name="RecordId"></param>
        /// <returns>status</returns>
        public string ReviewICR(ItemChangedDetailsAC itemChangedDetail, UserDetail user, CompanyDetail company, int RecordId, string Comment)
        {
            var currentUser  = _userDetailContext.First(x => x.UserName == user.UserName && x.IsDelete == false);
            var log          = _workFlowLogContext.Fetch(x => x.RecordId == RecordId).ToList().Last();
            var prevActivity = log.WorkFlowDetail.NextActivity.AcceptPermission;
            var profitMargin = _itemProfileContext.Fetch(x => x.Id == itemChangedDetail.ItemId).FirstOrDefault().ProfitMargin;
            var total        = (itemChangedDetail.ModifyingCostPrice * (100 + profitMargin)) / 100;

            itemChangedDetail.CalculatedCostPrice = total;
            if (log.WorkFlowDetail.AssignedId == currentUser.RoleId)
            {
                Comment = (Comment == ".") ? null : Comment;

                if (log.WorkFlowDetail.IsReview || log.WorkFlowDetail.IsCondition)
                {
                    var loger = _iWorkFlowDetailsRepository.GetReviewActionWorkFlow(RecordId, itemChangedDetail, itemChangedDetail, StringConstants.ReviewAction, Comment, user);
                    if (loger != null)
                    {
                        return(CheckApproved(RecordId, true, prevActivity, company, user));
                    }
                    else
                    {
                        return(StringConstants.WorkFlowNotCreated);
                    }
                }
                else
                {
                    return(StringConstants.WorkFlowNotCreated);
                }
            }
            else
            {
                return(StringConstants.WorkFlowNotCreated);
            }
        }
 /// <summary>
 /// this method is used for fetching Item Change Request list.
 /// </summary>
 /// <param name="branchId">current user's branch id</param>
 /// <returns>list of object of ItemChangedDetailsAC</returns>
 public List <ItemChangedDetailsAC> GetICRWorkListForParticularBranch(int?branchId)
 {
     try
     {
         var itemcrList = new List <ItemChangedDetailsAC>();
         var icrList    = _icrDetailContext.Fetch(x => !x.IsDeleted).OrderByDescending(x => x.CreatedDateTime).ToList();
         foreach (var icr in icrList)
         {
             ItemChangedDetailsAC icrAC = new ItemChangedDetailsAC
             {
                 ItemName             = icr.ItemProfile.ItemNameEn,
                 RequestedDate        = icr.CreatedDateTime,
                 Barcode              = icr.ItemProfile.Barcode,
                 BranchId             = branchId,
                 Id                   = icr.Id,
                 IsPriceChangeRequest = icr.IsPriceChangeRequest,
                 IsRejected           = icr.IsRejected,
                 Action               = GetActionName(icr.RecordId)
             };
             itemcrList.Add(icrAC);
         }
         return(itemcrList);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Exemple #3
0
 public IHttpActionResult SaveICR(ItemChangedDetailsAC itemChangedDetail)
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             if (MerchantContext.Permission.IsAllowedToInitiateICR || MerchantContext.Permission.IsAllowedToInitiateICRForOtherBranches)
             {
                 var status = _icrContext.SaveICR(itemChangedDetail, MerchantContext.UserDetails, MerchantContext.CompanyDetails, null);
                 return(Ok(new { status = status }));
             }
             else
             {
                 var status = StringConstants.PermissionDenied;
                 return(Ok(new { status = status }));
             }
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Exemple #4
0
 /// <summary>
 /// this method is used for adding ICR.- JJ
 /// </summary>
 /// <param name="itemChangedDetail">object of ItemChangedDetailsAC</param>
 /// <param name="user">object of UserDetail</param>
 /// <param name="company"></param>
 /// <param name="WorkFlowId"></param>
 /// <returns>status</returns>
 public string SaveICR(ItemChangedDetailsAC itemChangedDetail, UserDetail user, CompanyDetail company, int?WorkFlowId)
 {
     try
     {
         var ParentRecordId = 0;
         if (itemChangedDetail.IsInDirect)
         {
             ParentRecordId = (int)itemChangedDetail.ParentRecordId;
             itemChangedDetail.IsPOItemIcr = true;
         }
         else
         {
             var workFlowLog = _IWorkFlowDetailsRepository.GetInitiationActionWorkFlow(StringConstants.ItemChangeRequest, StringConstants.InitiateICR, user, company, itemChangedDetail, itemChangedDetail.Comment, itemChangedDetail);
             if (workFlowLog != null)
             {
                 WorkFlowLog log = (WorkFlowLog)workFlowLog.Item1;
                 ParentRecordId = log.RecordId;
                 WorkFlowDetail WorkFlow = (WorkFlowDetail)workFlowLog.Item2;
                 WorkFlowId = WorkFlow.Id;
             }
             else
             {
                 return(StringConstants.WorkFlowNotCreated);
             }
         }
         return(AddICR(itemChangedDetail, ParentRecordId, WorkFlowId, company, user));
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Exemple #5
0
 public IHttpActionResult UpdateICR(ItemChangedDetailsAC itemChangedDetail)
 {
     try
     {
         if (HttpContext.Current.User.Identity.IsAuthenticated)
         {
             if (MerchantContext.Permission.IsAllowedToEditICR)
             {
                 var status = _icrContext.UpdateICR(itemChangedDetail, MerchantContext.UserDetails, MerchantContext.CompanyDetails, itemChangedDetail.ParentRecordId);
                 return(Ok(new { status = status }));
             }
             else
             {
                 var status = StringConstants.PermissionDenied;
                 return(Ok(new { status = status }));
             }
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Exemple #6
0
        public IHttpActionResult ReviewICR(ItemChangedDetailsAC itemChangedDetail)
        {
            try
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (MerchantContext.Permission.IsAllowedToReviewICR)
                    {
                        if (_iWorkFlowDetailsRepository.CheckLastActionPerform(itemChangedDetail.ParentRecordId, StringConstants.Initiate, MerchantContext.UserDetails.RoleId))
                        {
                            return(Ok(new { status = StringConstants.AlreadyActivityProcessed }));
                        }

                        var status = _icrWorkListContext.ReviewICR(itemChangedDetail, MerchantContext.UserDetails, MerchantContext.CompanyDetails, itemChangedDetail.ParentRecordId, itemChangedDetail.Comment);
                        return(Ok(new { status = status }));
                    }
                    else
                    {
                        var status = StringConstants.PermissionDenied;
                        return(Ok(new { status = status }));
                    }
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
Exemple #7
0
 /// <summary>
 /// this method is used for updating ICR.- JJ
 /// </summary>
 /// <param name="itemChangedDetail">object of ItemChangedDetailsAC</param>
 /// <param name="user">object of UserDetail</param>
 /// <param name="company">object of CompanyDetail</param>
 /// <param name="RecordId">Id of Parent Record</param>
 /// <return>status</return>
 public string UpdateICR(ItemChangedDetailsAC itemChangedDetail, UserDetail user, CompanyDetail company, int RecordId)
 {
     try
     {
         var log          = _workFlowLogContext.Fetch(x => x.RecordId == RecordId).ToList().Last();
         var workFlowLog  = new WorkFlowLog();
         var profitMargin = _itemProfileContext.Fetch(x => x.Id == itemChangedDetail.ItemId).FirstOrDefault().ProfitMargin;
         var total        = (itemChangedDetail.ModifyingCostPrice * (100 + profitMargin)) / 100;
         itemChangedDetail.CalculatedCostPrice = total;
         if (itemChangedDetail.Comment == ".")
         {
             itemChangedDetail.Comment = null;
         }
         if (log.WorkFlowDetail.AssignedId == user.RoleId)
         {
             if (itemChangedDetail.IsResubmit)
             {
                 workFlowLog = _IWorkFlowDetailsRepository.GetResubmitActionWorkFlow(RecordId, itemChangedDetail, itemChangedDetail, StringConstants.ReSubmitedAction, itemChangedDetail.Comment, user);
             }
             else
             {
                 workFlowLog = _IWorkFlowDetailsRepository.GetResubmitActionWorkFlow(RecordId, itemChangedDetail, itemChangedDetail, StringConstants.EditedAction, itemChangedDetail.Comment, user);
             }
             if (workFlowLog != null)
             {
                 var icrDetail = _icrDetailContext.Fetch(x => x.RecordId == RecordId).FirstOrDefault();
                 icrDetail.IsReturned           = false;
                 icrDetail.IsPriceChangeRequest = itemChangedDetail.IsPriceChangeRequest;
                 icrDetail.ModifiedDateTime     = DateTime.UtcNow;
                 _icrDetailContext.Update(icrDetail);
                 _icrDetailContext.SaveChanges();
                 bool modifyingCostPriceEditable = icrDetail.SPOItemId != null ? false : true;
                 return(AddICRPriceQuantity(itemChangedDetail, icrDetail.ItemId, icrDetail.Id, true, modifyingCostPriceEditable));
             }
             else
             {
                 return(StringConstants.WorkFlowNotCreated);
             }
         }
         else
         {
             return(StringConstants.WorkFlowNotCreated);
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
Exemple #8
0
 /// <summary>
 /// this method is used for adding ICR.- JJ
 /// </summary>
 /// <param name="company"></param>
 /// <param name="itemChangedDetail"></param>
 /// <param name="ParentRecordId"></param>
 /// <param name="user"></param>
 /// <param name="WorkFlowId"></param>
 /// <returns>status</returns>
 public string AddICR(ItemChangedDetailsAC itemChangedDetail, int ParentRecordId, int?WorkFlowId, CompanyDetail company, UserDetail user)
 {
     try
     {
         var item = _itemProfileContext.Find(itemChangedDetail.ItemId);
         if (item.IsItemChangeRequestGenerated && itemChangedDetail.IsInDirect)
         {
             return(StringConstants.ICRPriceGenerateError);
         }
         else
         {
             var icrDetail = new IcrDetail
             {
                 CreatedDateTime      = DateTime.UtcNow,
                 IsAddItemIcr         = itemChangedDetail.IsAddItemIcr,
                 IsPOItemIcr          = itemChangedDetail.IsPOItemIcr,
                 IsPriceChangeRequest = itemChangedDetail.IsPriceChangeRequest,
                 ItemId   = itemChangedDetail.ItemId,
                 RecordId = ParentRecordId
             };
             if (itemChangedDetail.POItemId > 0)
             {
                 icrDetail.SPOItemId = itemChangedDetail.POItemId;
             }
             _icrDetailContext.Add(icrDetail);
             _icrDetailContext.SaveChanges();
             string status   = AddICRPriceQuantity(itemChangedDetail, itemChangedDetail.ItemId, icrDetail.Id, false, true);
             var    workflow = _workFlowContext.Find(WorkFlowId);
             if (workflow.NextActivity.IsClosed)
             {
                 _IICRWorkListRepository.UpdateItem(ParentRecordId, true, company, user);
             }
             return(status);
         }
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
        private string InitiateICR(PurchaseOrderItem item, int RecordId, UserDetail currentUser, CompanyDetail company, int WorkFlowId)
        {
            ItemChangedDetailsAC itemChange = new ItemChangedDetailsAC
            {
                IsPOItemIcr          = true,
                IsPriceChangeRequest = true,
                ItemId              = item.ItemId,
                ModifyingCostPrice  = item.ReceivingCostPrice,
                ModifyingSellPrice  = item.ItemProfile.SellPrice,
                ModifyingSellPriceA = item.ItemProfile.SellPriceA,
                ModifyingSellPriceB = item.ItemProfile.SellPriceB,
                ModifyingSellPriceC = item.ItemProfile.SellPriceC,
                ModifyingSellPriceD = item.ItemProfile.SellPriceD,
                POItemId            = item.Id,
                RequestedDate       = DateTime.UtcNow,
                ParentRecordId      = RecordId,
                IsInDirect          = true
            };

            return(_iICRRepository.SaveICR(itemChange, currentUser, company, WorkFlowId));
        }
        /// <summary>
        /// this method is used for fetching Item Change Request Details.
        /// </summary>
        /// <param name="Id">Id of Icr</param>
        /// <returns>object of ItemChangedDetailsAC</returns>
        public ItemChangedDetailsAC GetICRDetail(int Id, string userId)
        {
            IcrDetail icrDetail           = _icrDetailContext.Find(Id);
            var       ModifyingCostPrice  = 0M;
            var       ModifyingSellPrice  = 0M;
            var       ModifyingSellPriceA = 0M;
            var       ModifyingSellPriceB = 0M;
            var       ModifyingSellPriceC = 0M;
            var       ModifyingSellPriceD = 0M;
            var       icrQuantity         = _icrQuantityContext.Fetch(x => x.IcrId == Id).ToList();

            if (icrDetail != null)
            {
                var logList      = _iWorkFlowDetailsRepository.GetAllWorkFlowActionList(icrDetail.RecordId);
                var quantityList = new List <IcrQuantityAC>();
                foreach (var quantity in icrQuantity)
                {
                    var icrQuantityAC = new IcrQuantityAC
                    {
                        BranchId          = quantity.BranchId,
                        BranchName        = quantity.BranchDetail.Name,
                        ActualQuantity    = quantity.SystemQuantity,
                        IcrId             = quantity.IcrId,
                        IsAddOperation    = quantity.IsAddOperation,
                        ModifyingQuantity = quantity.ModifyingQuantity
                    };
                    quantityList.Add(icrQuantityAC);
                }
                var icrPrice = _icrPriceContext.Fetch(x => x.IcrId == Id).FirstOrDefault();
                if (icrPrice != null)
                {
                    ModifyingCostPrice  = icrPrice.ModifyingCostPrice;
                    ModifyingSellPrice  = icrPrice.ModifyingSellPrice;
                    ModifyingSellPriceA = icrPrice.ModifyingSellPriceA;
                    ModifyingSellPriceB = icrPrice.ModifyingSellPriceB;
                    ModifyingSellPriceC = icrPrice.ModifyingSellPriceC;
                    ModifyingSellPriceD = icrPrice.ModifyingSellPriceD;
                }
                var hideQuantity =
                    userId != icrDetail.ParentRecord.InitiatorId;

                var icrDetailAC = new ItemChangedDetailsAC
                {
                    ItemProfile          = icrDetail.ItemProfile,
                    IcrQuantity          = quantityList,
                    WorkFlowLog          = logList,
                    Id                   = icrDetail.Id,
                    IsAddItemIcr         = icrDetail.IsAddItemIcr,
                    IsPOItemIcr          = icrDetail.IsPOItemIcr,
                    IsPriceChangeRequest = icrDetail.IsPriceChangeRequest,
                    ItemId               = icrDetail.ItemId,
                    ParentRecordId       = icrDetail.RecordId,
                    IsRejected           = icrDetail.IsRejected,
                    IsReturned           = icrDetail.IsReturned,
                    ModifyingCostPrice   = ModifyingCostPrice,
                    ModifyingSellPrice   = ModifyingSellPrice,
                    ModifyingSellPriceA  = ModifyingSellPriceA,
                    ModifyingSellPriceB  = ModifyingSellPriceB,
                    ModifyingSellPriceC  = ModifyingSellPriceC,
                    ModifyingSellPriceD  = ModifyingSellPriceD,
                    RequestedDate        = icrDetail.CreatedDateTime,
                    HideQuantity         = hideQuantity
                };
                if (icrDetail.SPOItemId != null)
                {
                    icrDetailAC.POItemId = (int)icrDetail.SPOItemId;
                }
                else
                {
                    icrDetailAC.POItemId = 0;
                }
                return(icrDetailAC);
            }
            else
            {
                return(null);
            }
        }
Exemple #11
0
        /// <summary>
        /// This method is used for receive an item of SPO. This is a private method called by ReceiveSPOItem - JJ
        /// </summary>
        /// <param name="SupplierItemAC">object of SupplierItemAC</param>
        /// <param name="currentUser">object of UserDetail</param>
        /// <param name="company">object of CompanyDetail</param>
        private int Receive(SupplierItemAC SupplierItemAC, UserDetail currentUser, CompanyDetail company)
        {
            PurchaseOrderItem poItem = _purchaseOrderItemContext.FirstOrDefault(x => x.ItemId == SupplierItemAC.ItemId && x.PurchaseOrderId == SupplierItemAC.PurchaseOrderId && x.SupplierPurchaseOrder.IsApproved && x.SupplierPurchaseOrder.IsSend);
            var  status     = "";
            bool icrCreated = false;

            poItem.ReceivingCostPrice = SupplierItemAC.ReceiveCostPrice;
            poItem.ReceivingQuantity  = SupplierItemAC.ReceiveQuantity;
            poItem.BillCostPrice      = SupplierItemAC.BillCostPrice;
            if (SupplierItemAC.ReceiveQuantity > SupplierItemAC.OrderQuantity)
            {
                poItem.SPOReceivingStatus = SPOReceivingStatus.PartiallyReceived;
            }

            var workflowLog = _iWorkFlowDetailsRepository.GetInitiationActionWorkFlow(StringConstants.SPOReceiving, StringConstants.ReceiveSPO, currentUser, company, poItem, null, poItem);

            if (workflowLog != null)
            {
                IcrDetail prevICR = _icrDetailContext.FirstOrDefault(x => x.SPOItemId == poItem.Id && !x.IsDeleted);
                if (prevICR != null)
                {
                    _iICRRepository.DeleteICR(prevICR.Id);
                }

                WorkFlowLog log            = (WorkFlowLog)workflowLog.Item1;
                var         workFlowDetail = (WorkFlowDetail)workflowLog.Item2;

                if (workFlowDetail.NextActivity.Id == 3)
                {
                    if (poItem.OrderQuantity > SupplierItemAC.ReceiveQuantity)
                    {
                        poItem.SPOReceivingStatus = SPOReceivingStatus.PartiallyReceived;
                    }
                    else
                    {
                        poItem.SPOReceivingStatus = SPOReceivingStatus.Received;
                    }
                }
                else
                {
                    poItem.SPOReceivingStatus = SPOReceivingStatus.NotReceived;
                }
                if (workFlowDetail.ParentPermission.Name == StringConstants.ItemChangeRequest && poItem.SPOReceivingStatus == SPOReceivingStatus.NotReceived)
                {
                    icrCreated = true;

                    ItemChangedDetailsAC itemChange = new ItemChangedDetailsAC
                    {
                        IsPOItemIcr          = true,
                        IsPriceChangeRequest = true,
                        ItemId              = SupplierItemAC.ItemId,
                        ModifyingCostPrice  = poItem.ReceivingCostPrice,
                        ModifyingSellPrice  = poItem.ItemProfile.SellPrice,
                        ModifyingSellPriceA = poItem.ItemProfile.SellPriceA,
                        ModifyingSellPriceB = poItem.ItemProfile.SellPriceB,
                        ModifyingSellPriceC = poItem.ItemProfile.SellPriceC,
                        ModifyingSellPriceD = poItem.ItemProfile.SellPriceD,
                        POItemId            = poItem.Id,
                        RequestedDate       = DateTime.UtcNow,
                        ParentRecordId      = log.RecordId,
                        IsInDirect          = true
                    };
                    status = _iICRRepository.SaveICR(itemChange, currentUser, company, workFlowDetail.Id);
                }
                if (status == "ok")
                {
                    var newICR = _icrDetailContext.Fetch(x => x.SPOItemId == poItem.Id && !x.IsDeleted).ToList().LastOrDefault();
                    if (newICR != null)
                    {
                        poItem.ICRDetailId = newICR.Id;
                        if (newICR.IsApproved && poItem.SPOReceivingStatus != SPOReceivingStatus.PartiallyReceived)
                        {
                            poItem.SPOReceivingStatus = SPOReceivingStatus.Received;
                        }
                    }
                }
                poItem.ModifiedDateTime = DateTime.UtcNow;
                _purchaseOrderItemContext.Update(poItem);
                _purchaseOrderItemContext.SaveChanges();
                if (icrCreated)
                {
                    return(300);
                }
                else
                {
                    return((int)poItem.SPOReceivingStatus);
                }
            }
            else
            {
                return(400);
            }
        }
Exemple #12
0
        /// <summary>
        /// this method is used for fetching ItemQuantity list.-JJ
        /// </summary>
        /// <param name="ItemId">Id of Item</param>
        /// <param name="BranchId">Id of current user's branch</param>
        /// <returns>list of object of ItemChangedDetailsAC</returns>
        public List <ItemChangedDetailsAC> GetItemQuantityList(int ItemId, int?BranchId)
        {
            try
            {
                var listAC           = new List <ItemChangedDetailsAC>();
                var itemQuantityList = new List <ItemQuantity>();
                var item             = _itemProfileContext.Find(ItemId);
                var itemId           = 0;
                if (item.IsParentItem)
                {
                    itemId = ItemId;
                }
                else
                {
                    itemId = (int)item.ParentItemId;
                }
                if (BranchId == null)
                {
                    itemQuantityList = _itemQuantityContext.Fetch(X => X.ItemId == itemId).ToList();
                }
                else
                {
                    itemQuantityList = _itemQuantityContext.Fetch(X => X.ItemId == itemId && X.BranchId == BranchId).ToList();
                }

                foreach (var quantity in itemQuantityList)
                {
                    var actualQuantity = 0M;
                    if (item.IsParentItem)
                    {
                        actualQuantity = quantity.ActualQuantity;
                    }
                    else
                    {
                        if (item.BaseUnit > 0)
                        {
                            actualQuantity = quantity != null?Math.Floor((decimal)(quantity.ActualQuantity / item.BaseUnit)) : 0;
                        }
                        else
                        {
                            actualQuantity = 0;
                        }
                    }
                    ItemChangedDetailsAC itemQuantity = new ItemChangedDetailsAC
                    {
                        Id             = quantity.Id,
                        BranchId       = quantity.BranchId,
                        BranchName     = quantity.Branch.Name,
                        ItemId         = ItemId,
                        MaxQuantity    = quantity.MaxQuantity,
                        MinQuantity    = quantity.MinQuantity,
                        ActualQuantity = (int)actualQuantity,
                        IsICRGenerated = quantity.IsICRGenerated
                    };
                    listAC.Add(itemQuantity);
                }
                return(listAC);
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
Exemple #13
0
        /// <summary>
        /// this method is used for adding ICR prices or quantity.- JJ
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="itemChangedDetail"></param>
        /// <param name="IcrId"></param>
        /// <returns>status</returns>
        private string AddICRPriceQuantity(ItemChangedDetailsAC itemChangedDetail, int itemId, int IcrId, bool isUpdate, bool modifyingCostPriceEditable)
        {
            try
            {
                var    item   = _itemProfileContext.Find(itemId);
                string status = "ok";
                if (itemChangedDetail.IsPriceChangeRequest)
                {
                    if (item.IsItemChangeRequestGenerated && !isUpdate)
                    {
                        status = StringConstants.ICRPriceGenerateError;
                    }
                    else
                    {
                        if (itemChangedDetail.IsPriceChangeRequest)
                        {
                            var oldItemPrice = _icrPriceContext.Fetch(x => x.IcrId == IcrId).FirstOrDefault();
                            if (oldItemPrice != null)
                            {
                                if (!modifyingCostPriceEditable)
                                {
                                    itemChangedDetail.ModifyingCostPrice = oldItemPrice.ModifyingCostPrice;
                                }
                                _icrPriceContext.Delete(oldItemPrice);
                                _icrPriceContext.SaveChanges();
                            }
                        }
                        var icrPrice = new IcrPrice
                        {
                            CreatedDateTime     = DateTime.UtcNow,
                            IcrId               = IcrId,
                            ModifyingCostPrice  = itemChangedDetail.ModifyingCostPrice,
                            ModifyingSellPrice  = itemChangedDetail.ModifyingSellPrice,
                            ModifyingSellPriceA = itemChangedDetail.ModifyingSellPriceA,
                            ModifyingSellPriceB = itemChangedDetail.ModifyingSellPriceB,
                            ModifyingSellPriceC = itemChangedDetail.ModifyingSellPriceC,
                            ModifyingSellPriceD = itemChangedDetail.ModifyingSellPriceD,
                            ModifiedDateTime    = DateTime.UtcNow
                        };
                        _icrPriceContext.Add(icrPrice);
                        _icrPriceContext.SaveChanges();
                        item.IsItemChangeRequestGenerated = true;
                        DeleteICRItem(IcrId, item);
                    }
                }
                if (itemChangedDetail.IcrQuantity != null)
                {
                    foreach (var quantity in itemChangedDetail.IcrQuantity)
                    {
                        ItemQuantity itemQuantity = new ItemQuantity();
                        if (item.IsParentItem)
                        {
                            itemQuantity = _itemQuantityContext.FirstOrDefault(x => x.ItemId == item.Id && x.BranchId == quantity.BranchId);
                        }
                        else
                        {
                            itemQuantity = _itemQuantityContext.FirstOrDefault(x => x.ItemId == item.ParentItemId && x.BranchId == quantity.BranchId);
                        }
                        if (itemQuantity.IsICRGenerated && !isUpdate && quantity.ModifyingQuantity > 0)
                        {
                            status = StringConstants.ICRQuantityGenerateError;
                        }
                        else
                        {
                            DeleteICRItem(IcrId, item);
                            var icrQuantity = new IcrQuantity
                            {
                                BranchId          = quantity.BranchId,
                                SystemQuantity    = quantity.ActualQuantity,
                                CreatedDateTime   = DateTime.UtcNow,
                                IcrId             = IcrId,
                                IsAddOperation    = quantity.IsAddOperation,
                                ModifyingQuantity = quantity.ModifyingQuantity
                            };
                            _icrQuantityContext.Add(icrQuantity);
                            _icrQuantityContext.SaveChanges();

                            if (quantity.ModifyingQuantity > 0)
                            {
                                itemQuantity.ModifiedDateTime = DateTime.UtcNow;
                                itemQuantity.IsICRGenerated   = true;
                                _itemQuantityContext.Update(itemQuantity);
                                _itemQuantityContext.SaveChanges();
                            }
                        }
                    }
                }
                if (status == "ok")
                {
                    item.ModifiedDateTime = DateTime.UtcNow;
                    _itemProfileContext.Update(item);
                    _itemProfileContext.SaveChanges();
                }
                return(status);
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }