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; } }
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 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); } }