public JsonResult GetTransportContractExecution() { var contracts = _transportOrderService.FindBy(t => t.StatusID >= 3); var requisitions = from contract in contracts select new { contract.TransportOrderNo, details = from detail in _transportOrderDetailService.FindBy( d => d.TransportOrderID == contract.TransportOrderID) select new { detail.RequisitionID, detail.FDP.Name, sum = from dispatch in _dispatchService.FindBy(r => r.RequisitionNo == detail.ReliefRequisition.RequisitionNo) group dispatch by dispatch.RequisitionNo into d select new { d.Key, d } } }; //from requisition in requisitions //select requisition.details. return(Json(requisitions, JsonRequestBehavior.AllowGet)); }
public JsonResult GetDispatches(int transportOrderId) { var transportOrderDetail = _transportOrderDetailService.FindBy(t => t.TransportOrderID == transportOrderId).Select(r => new { fdp = r.FDP.Name, zone = r.FDP.AdminUnit.AdminUnit2.Name, woreda = r.FDP.AdminUnit.Name, region = r.FDP.AdminUnit.AdminUnit2.AdminUnit2.Name, hub = _hubService.FindById(r.SourceWarehouseID).Name, amount = r.QuantityQtl, requisitionNo = r.ReliefRequisition.RequisitionNo, tariff = r.TariffPerQtl, commodity = r.Commodity.Name, //zone = r.AdminUnit.Name }); return(Json(transportOrderDetail, JsonRequestBehavior.AllowGet)); }
public List <TransporterPaymentRequestViewModel> TransporterPaymentRequestViewModelBinder(List <TransporterPaymentRequest> transporterPaymentRequests) { var transporterPaymentRequestViewModels = new List <TransporterPaymentRequestViewModel>(); foreach (var transporterPaymentRequest in transporterPaymentRequests) { var request = transporterPaymentRequest; var dispatch = _dispatchService.Get(t => t.DispatchID == request.Delivery.DispatchID, null, "Hub, FDP").FirstOrDefault(); var transportOrderdetail = _transportOrderDetailService.FindBy( m => m.TransportOrderID == request.TransportOrderID && m.SourceWarehouseID == dispatch.HubID && m.FdpID == dispatch.FDPID).FirstOrDefault(); //var firstOrDefault = _bidWinnerService.Get(t => t.SourceID == dispatch.HubID && t.DestinationID == dispatch.FDPID // && t.TransporterID == request.TransportOrder.TransporterID && t.Bid.BidNumber == dispatch.BidNumber).FirstOrDefault(); var tarrif = (decimal)0.00; if (transportOrderdetail != null) { tarrif = (decimal)transportOrderdetail.TariffPerQtl; } if (dispatch != null && request.Delivery.DeliveryDetails.FirstOrDefault() != null) { var deliveryDetail = request.Delivery.DeliveryDetails.FirstOrDefault(); var businessProcess = _businessProcessService.FindById(request.BusinessProcessID); if (request.LabourCost == null) { request.LabourCost = (decimal)0.00; } if (request.RejectedAmount == null) { request.RejectedAmount = (decimal)0.00; } if (deliveryDetail != null) { var transporterPaymentRequestViewModel = new TransporterPaymentRequestViewModel() { RequisitionNo = dispatch.RequisitionNo, GIN = request.Delivery.InvoiceNo, GRN = request.Delivery.ReceivingNumber, Commodity = deliveryDetail.Commodity.Name, Source = dispatch.Hub.Name, Destination = dispatch.FDP.Name, ReceivedQty = deliveryDetail.ReceivedQuantity.ToQuintal(), Tarrif = tarrif, ShortageQty = deliveryDetail.SentQuantity.ToQuintal() - deliveryDetail.ReceivedQuantity.ToQuintal(), ShortageBirr = request.ShortageBirr, SentQty = deliveryDetail.SentQuantity, BusinessProcessID = request.BusinessProcessID, DeliveryID = request.DeliveryID, ReferenceNo = request.ReferenceNo, TransportOrderID = request.TransportOrderID, TransporterPaymentRequestID = request.TransporterPaymentRequestID, FreightCharge = (decimal)(request.ShortageBirr != null ? (deliveryDetail.ReceivedQuantity.ToQuintal() * tarrif) - request.ShortageBirr + request.LabourCost - request.RejectedAmount : (deliveryDetail.ReceivedQuantity.ToQuintal() * tarrif) + request.LabourCost - request.RejectedAmount), BusinessProcess = businessProcess, LabourCost = request.LabourCost, LabourCostRate = request.LabourCostRate, RejectedAmount = request.RejectedAmount, RejectionReason = request.RejectionReason, RequestedDate = request.RequestedDate, Transporter = dispatch.Transporter }; transporterPaymentRequestViewModels.Add(transporterPaymentRequestViewModel); } } } return(transporterPaymentRequestViewModels); }
public List <TransporterPaymentRequestViewModel> TransporterPaymentRequestViewModelBinder( List <TransporterPaymentRequest> transporterPaymentRequests) { var currentUser = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name); var datePref = currentUser.DatePreference; var transporterPaymentRequestViewModels = new List <TransporterPaymentRequestViewModel>(); foreach (var transporterPaymentRequest in transporterPaymentRequests) { var request = transporterPaymentRequest; var dispatch = _dispatchService.Get(t => t.DispatchID == request.Delivery.DispatchID, null, "Hub, FDP"). FirstOrDefault(); var transportOrderdetail = _transportOrderDetailService.FindBy( m => m.TransportOrderID == request.TransportOrderID && m.SourceWarehouseID == dispatch.HubID && m.FdpID == dispatch.FDPID).FirstOrDefault(); //var firstOrDefault = _bidWinnerService.Get(t => t.SourceID == dispatch.HubID && t.DestinationID == dispatch.FDPID // && t.TransporterID == request.TransportOrder.TransporterID && t.Bid.BidNumber == dispatch.BidNumber).FirstOrDefault(); var tarrif = (decimal)0.00; var bidDocNo = string.Empty; if (transportOrderdetail != null) { tarrif = (decimal)transportOrderdetail.TariffPerQtl; bidDocNo = transportOrderdetail.TransportOrder.BidDocumentNo; } if (dispatch != null && request.Delivery.DeliveryDetails.FirstOrDefault() != null) { { var dispathedAmount = (decimal)0.0; var childCommodity = string.Empty; var firstOrDefault = dispatch.DispatchDetails.FirstOrDefault(); if (firstOrDefault != null) { dispathedAmount = firstOrDefault.DispatchedQuantityInMT.ToQuintal(); } var dispatchedDate = dispatch.DispatchDate.Date; var dispatchDetail = dispatch.DispatchDetails.FirstOrDefault(); if (dispatchDetail != null) { var childCommodityId = dispatchDetail.CommodityChildID; var orDefault = _commodityService.GetCommodities(c => c.CommodityID == childCommodityId).FirstOrDefault(); if (orDefault != null) { childCommodity = orDefault.Name; } } var deliveryDetail = request.Delivery.DeliveryDetails.FirstOrDefault(); var businessProcess = _BusinessProcessService.FindById(request.BusinessProcessID); if (request.LabourCost == null) { request.LabourCost = (decimal)0.00; } if (request.RejectedAmount == null) { request.RejectedAmount = (decimal)0.00; } if (deliveryDetail != null) { var transporterPaymentRequestViewModel = new TransporterPaymentRequestViewModel() { RequisitionNo = dispatch.RequisitionNo, GIN = request.Delivery.InvoiceNo, GRN = request.Delivery.ReceivingNumber, Commodity = deliveryDetail.Commodity.Name, Source = dispatch.Hub.Name, Destination = dispatch.FDP.Name, Region = dispatch.FDP.AdminUnit.AdminUnit2.AdminUnit2.Name, ReceivedQty = deliveryDetail.ReceivedQuantity. ToQuintal(), Tarrif = tarrif, ShortageQty = request.ShortageQty != null ? (decimal)(request.ShortageQty) : (deliveryDetail.SentQuantity.ToQuintal()) - (deliveryDetail.ReceivedQuantity. ToQuintal()), ShortageBirr = request.ShortageBirr, SentQty = deliveryDetail.SentQuantity, BusinessProcessID = request.BusinessProcessID, DeliveryID = request.DeliveryID, ReferenceNo = request.ReferenceNo, TransportOrderID = request.TransportOrderID, TransporterPaymentRequestID = request.TransporterPaymentRequestID, FreightCharge = (decimal) (request.ShortageBirr != null ? (Math.Min(deliveryDetail.ReceivedQuantity .ToQuintal(), dispathedAmount) * tarrif) - ( request.ShortageBirr + request.LabourCost - request.RejectedAmount) : (deliveryDetail.ReceivedQuantity .ToQuintal() * tarrif) + request.LabourCost - request.RejectedAmount), BusinessProcess = businessProcess, LabourCost = request.LabourCost, LabourCostRate = request.LabourCostRate, RejectedAmount = request.RejectedAmount, RejectionReason = request.RejectionReason, RequestedDate = request.RequestedDate, Program = dispatch.DispatchAllocation.Program, Transporter = dispatch.Transporter, ChildCommodity = childCommodity, DispatchDate = dispatchedDate.ToCTSPreferedDateFormat(datePref), DispatchedAmount = dispathedAmount, BidDocumentNo = bidDocNo, Checked = false, ContractNumber = _TransportOrderService.FindBy(t => t.TransportOrderID == dispatch.DispatchAllocation.TransportOrderID).FirstOrDefault().ContractNumber }; transporterPaymentRequestViewModels.Add(transporterPaymentRequestViewModel); } } } } return(transporterPaymentRequestViewModels); }