예제 #1
0
 public ActionResult AddPPItemsToPO(Model.ProcurementPlan pp)
 {
     Model.PurchaseOrder       po = poService.GetPurchaseOrderById(pp.PurchaseOrderId);
     Model.PurchaseOrderItem   poItem;
     Model.ProcurementPlanItem item;
     if (po.TotalAmount == null)
     {
         po.TotalAmount = 0;
     }
     foreach (var ppItem in pp.PPItemList)
     {
         if (ppItem.AddedToOR)
         {
             item   = ppService.GetProcurementPlanItemById(ppItem.Id);
             poItem = new PurchaseOrderItem
             {
                 BudgetLineId          = item.BudgetLineId,
                 ProcurementPlanItemId = item.Id,
                 PurchaseOrderId       = po.Id,
                 Quantity   = ppItem.QuantityToOrder,
                 TotalPrice = ppItem.TotalCost,
                 UnitPrice  = (double)ppItem.UnitCost
             };
             po.TotalAmount += ppItem.TotalCost;
             poService.SavePOItem(poItem);
         }
     }
     poService.SaveReviewedPO(po);
     return(LoadPOItems(po.Id));
 }
예제 #2
0
        public ActionResult AddPPItems2OR(ProcurementPlan model)
        {
            Model.OrderRequest     or = UserSession.CurrentSession.NewOR != null ? UserSession.CurrentSession.NewOR : orderRequestService.GetOrderRequestById(model.OrderRequestId);
            Model.OrderRequestItem orItem;
            ProcurementPlanItem    ppItem;

            foreach (ProcurementPlanItem ppItemModel in model.PPItemList)
            {
                if (!ppItemModel.AddedToOR)
                {
                    continue;
                }
                ppItem = ppService.GetProcurementPlanItemById(ppItemModel.Id);
                orItem = new OrderRequestItem();
                orItem.BudgetLineId          = ppItem.BudgetLineId;
                orItem.EstimatedUnitPrice    = exchangeRateService.GetForeignCurrencyValue(or.CurrencyId, ppItem.CurrencyId, ppItemModel.UnitCost, countryProg.Id);
                orItem.EstimatedPrice        = orItem.EstimatedUnitPrice * ppItemModel.QuantityToOrder;
                orItem.Quantity              = ppItemModel.QuantityToOrder;
                orItem.ItemDescription       = ppItem.ItemDescription;
                orItem.ItemId                = ppItem.ItemId;
                orItem.OrderRequestId        = model.OrderRequestId;
                orItem.ProcurementPlanItemId = ppItem.Id;
                orderRequestService.AddOrderRequstItem(orItem, UserSession.CurrentSession.NewOR);
                if (UserSession.CurrentSession.NewOR != null)
                {
                    UserSession.CurrentSession.NewOR = null;
                }
            }

            return(ViewOrderRequestItems(model.OrderRequestId));
        }
예제 #3
0
        public ActionResult EditPPItem(Guid id)
        {
            ProcurementPlanItem model = ppService.GetProcurementPlanItemById(id);

            model.Items       = new SelectList(orService.GetItems(), "Id", "Name", model.ItemId);
            model.BudgetLines = new SelectList(orService.GetProjectBugdetLines(model.ProcurementPlan.ProjectDonorId), "Id", "Description", model.BudgetLineId);
            model.UnitCost    = Math.Round(model.UnitCost, 2);
            model.TotalCost   = Math.Round(model.TotalCost, 2);
            model.Currencies  = new SelectList(orService.GetCurrencies(), "Id", "ShortName", model.CurrencyId);
            ViewBag.Action    = Resources.Global_String_Update;
            model.EditMode    = true;
            return(View("CreatePPItem", model));
        }