Exemplo n.º 1
0
 public bool DeleteLoanReciptPlan(LoanReciptPlan entity)
 {
     if(entity==null) return false;
        _unitOfWork.LoanReciptPlanRepository.Delete(entity);
        _unitOfWork.Save();
        return true;
 }
Exemplo n.º 2
0
        public bool ApproveRecieptPlan(LoanReciptPlan loanReciptPlan)
        {
            if (loanReciptPlan != null)
               {
               loanReciptPlan.StatusID = (int)LocalPurchaseStatus.Approved;
               _unitOfWork.LoanReciptPlanRepository.Edit(loanReciptPlan);
               _unitOfWork.Save();
               var loanReceiptPlanDetail =
                   _unitOfWork.LoanReciptPlanDetailRepository.FindBy(
                       l => l.LoanReciptPlanID == loanReciptPlan.LoanReciptPlanID);
               if (loanReceiptPlanDetail != null)
                   foreach (var loan in loanReceiptPlanDetail)
                   {
                       var parentID = _unitOfWork.CommodityRepository.FindById(loanReciptPlan.CommodityID).ParentID ??
                                      loanReciptPlan.CommodityID;

                       var reciptAllocaltion = new ReceiptAllocation()
                                                   {
                                                       ReceiptAllocationID = Guid.NewGuid(),
                                                       ProgramID = loanReciptPlan.ProgramID,
                                                       CommodityID = (int) parentID,
                                                       ETA = loanReciptPlan.CreatedDate,
                                                       SINumber = loanReciptPlan.ShippingInstruction.Value,
                                                       QuantityInMT = loan.RecievedQuantity,
                                                       HubID = loan.HubID,
                                                       CommoditySourceID = loanReciptPlan.CommoditySourceID,
                                                       ProjectNumber = loanReciptPlan.ProjectCode,
                                                       //SourceHubID = loanReciptPlan.SourceHubID,
                                                       DonorID = int.Parse(loanReciptPlan.LoanSource),
                                                       PartitionId = 0,
                                                       IsCommited = false,
                                                       IsFalseGRN = loanReciptPlan.IsFalseGRN,
                                                       ReceiptPlanID = loan.LoanReciptPlanDetailID
                                                   };

                       _unitOfWork.ReceiptAllocationReository.Add(reciptAllocaltion);

                       _unitOfWork.Save();
                   }
               return true;

               }
               return false;
        }
Exemplo n.º 3
0
 public bool EditLoanReciptPlan(LoanReciptPlan entity)
 {
     _unitOfWork.LoanReciptPlanRepository.Edit(entity);
        _unitOfWork.Save();
        return true;
 }
 private LoanReciptPlan GetLoanReciptPlan(LoanReciptPlanViewModel loanReciptPlanViewModel)
 {
     var loanReciptPlan = new LoanReciptPlan()
             {
                 ProgramID = loanReciptPlanViewModel.ProgramID,
                 CommodityID = loanReciptPlanViewModel.ProgramID,
                 CommoditySourceID = loanReciptPlanViewModel.CommoditySourceID,
                 ShippingInstructionID = _commonService.GetShippingInstruction(loanReciptPlanViewModel.SiNumber),
                 SourceHubID = loanReciptPlanViewModel.SourceHubID,
                 ProjectCode = loanReciptPlanViewModel.ProjectCode,
                 ReferenceNumber = loanReciptPlanViewModel.RefeenceNumber,
                 Quantity = loanReciptPlanViewModel.Quantity,
                 CreatedDate = DateTime.Today
             };
         return loanReciptPlan;
 }
 private LoanReciptPlan GetLoanReciptPlan(LoanReciptPlanViewModel loanReciptPlanViewModel)
 {
     var loanReciptPlan = new LoanReciptPlan()
             {
                 ProgramID = loanReciptPlanViewModel.ProgramID,
                 CommodityID = loanReciptPlanViewModel.ProgramID,
                 CommoditySourceID = 2,//only for loan
                 ShippingInstructionID = _commonService.GetShippingInstruction(loanReciptPlanViewModel.SiNumber),
                 LoanSource = loanReciptPlanViewModel.LoanSource,
                 //HubID = loanReciptPlanViewModel.HubID,
                 ProjectCode = loanReciptPlanViewModel.ProjectCode,
                 ReferenceNumber = loanReciptPlanViewModel.RefeenceNumber,
                 Quantity = loanReciptPlanViewModel.Quantity,
                 CreatedDate = DateTime.Today,
                 StatusID = (int)LocalPurchaseStatus.Draft
             };
         return loanReciptPlan;
 }
 public ActionResult Edit(LoanReciptPlan loanReciptPlan)
 {
     if (ModelState.IsValid && loanReciptPlan!=null )
     {
         _loanReciptPlanService.EditLoanReciptPlan(loanReciptPlan);
         return RedirectToAction("Detail",new {id=loanReciptPlan.LoanReciptPlanID});
     }
     ModelState.AddModelError("Errors",@"Unable to update please check fields");
     ViewBag.ProgramID = new SelectList(_commonService.GetPrograms(), "ProgramID", "Name", loanReciptPlan.ProgramID);
     ViewBag.CommodityID = new SelectList(_commonService.GetCommodities(), "CommodityID", "Name", loanReciptPlan.CommodityID);
     ViewBag.CommodityTypeID = new SelectList(_commonService.GetCommodityTypes(), "CommodityTypeID", "Name");
     ViewBag.CommoditySourceID = new SelectList(_commonService.GetCommoditySource(), "CommoditySourceID", "Name", loanReciptPlan.CommoditySourceID);
     return View(loanReciptPlan);
 }
Exemplo n.º 7
0
        public bool DeleteLoanReciptAllocation(LoanReciptPlan loanReciptPlan)
        {
            try
               {
               var receiptAllocation =
                   _unitOfWork.ReceiptAllocationReository.FindBy(
                       c => c.CommoditySourceID == CommoditySourceConst.Constants.LOAN && c.SINumber == loanReciptPlan.ShippingInstruction.Value
                               && c.ProjectNumber == loanReciptPlan.ProjectCode);

               foreach (var allocation in receiptAllocation)
               {
                   _unitOfWork.ReceiptAllocationReository.Delete(allocation);
               }

               _unitOfWork.Save();
               return true;
               }
               catch (Exception)
               {

               return false;
               }
        }
Exemplo n.º 8
0
        public bool DeleteLoanWithDetail(LoanReciptPlan loanReciptPlan)
        {
            try
               {
               var loanReciptPlanDetails =
                   _unitOfWork.LoanReciptPlanDetailRepository.FindBy(
                       d => d.LoanReciptPlanID == loanReciptPlan.LoanReciptPlanID);
               foreach (var loanReciptPlanDetail in loanReciptPlanDetails)
               {
                   _unitOfWork.LoanReciptPlanDetailRepository.Delete(loanReciptPlanDetail);
               }
               _unitOfWork.LoanReciptPlanRepository.Delete(loanReciptPlan);
               _unitOfWork.Save();
               return true;
               }
               catch (Exception)
               {

               return false;
               }
        }
Exemplo n.º 9
0
        public bool PostLoan(LoanReciptPlan loanReciptPlan)
        {
            var transactionGroup = Guid.NewGuid();
            var transactionDate = DateTime.Now;

            _unitOfWork.TransactionGroupRepository.Add(new TransactionGroup()
            {
                PartitionID = 0,
                TransactionGroupID = transactionGroup
            });

            foreach (var loan in loanReciptPlan.LoanReciptPlanDetails)
            {

                var transaction = new Models.Transaction()
                                            {
                                                TransactionID = Guid.NewGuid(),
                                                CommoditySourceID =Models.Constant.CommoditySourceConst.Constants.LOAN,
                                                CommodityID = loan.LoanReciptPlan.CommodityID,
                                                ParentCommodityID = loan.LoanReciptPlan.Commodity.ParentID,
                                                ShippingInstructionID = loanReciptPlan.ShippingInstruction.ShippingInstructionID,
                                                QuantityInMT = loan.RecievedQuantity,
                                                HubID = loan.HubID,
                                                TransactionDate = transactionDate,
                                                TransactionGroupID = transactionGroup
                                               // LedgerID = Cats.Models.Ledger.Constants
                                            };

                _unitOfWork.TransactionRepository.Add(transaction);

                transaction = new Models.Transaction()
                {
                    TransactionID = Guid.NewGuid(),
                    CommoditySourceID = Models.Constant.CommoditySourceConst.Constants.LOAN,
                    CommodityID = loan.LoanReciptPlan.CommodityID,
                    ParentCommodityID = loan.LoanReciptPlan.Commodity.ParentID,
                    ShippingInstructionID = loanReciptPlan.ShippingInstruction.ShippingInstructionID,
                    QuantityInMT = loan.RecievedQuantity,
                    HubID = loan.HubID,
                    TransactionDate = transactionDate,
                    TransactionGroupID = transactionGroup
                    // LedgerID = Cats.Models.Ledger.Constants
                };

                _unitOfWork.TransactionRepository.Add(transaction);

            }

            try
            {
                _unitOfWork.Save();
                return true;
            }
            catch (Exception)
            {

                return false;
            }
            return true;
        }