public bool DeleteRation(Ration ration) { if(ration==null) return false; _unitOfWork.RationRepository.Delete(ration); _unitOfWork.Save(); return true; }
public ActionResult Create(Ration ration) { if (ration != null && ModelState.IsValid) { try { ration.CreatedBy = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID; ration.CreatedDate = DateTime.Today; _rationService.AddRation(ration); return RedirectToAction("Index"); } catch (Exception ex) { var log = new Logger(); log.LogAllErrorsMesseges(ex,_log); ModelState.AddModelError("Errors", ex.Message); } } return PartialView("_Create", ration); }
private RationViewModel BindRationViewModel(Ration ration) { var userPref = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DatePreference; if (ration == null) return null; var rationViewModel = new RationViewModel(); rationViewModel.RationID = ration.RationID; rationViewModel.IsDefaultRation = ration.IsDefaultRation; rationViewModel.CreatedBy = ration.CreatedBy; rationViewModel.CreatedDate = ration.CreatedDate; rationViewModel.UpdatedBy = ration.UpdatedBy; rationViewModel.UpdatedDate = ration.UpdatedDate; rationViewModel.ReferenceNumber = ration.RefrenceNumber; //rationViewModel.CreatedDateEC = ration.CreatedDate.HasValue // ? EthiopianDate.GregorianToEthiopian(ration.CreatedDate.Value) // : ""; rationViewModel.UpdatedDateEC = ration.UpdatedDate.HasValue ? EthiopianDate.GregorianToEthiopian(ration.UpdatedDate.Value) : ""; rationViewModel.DateCreated = ration.CreatedDate.ToCTSPreferedDateFormat(userPref);// RequistionDate.ToCTSPreferedDateFormat(UserAccountHelper.UserCalendarPreference()); return rationViewModel; }
public bool EditRation(Ration ration) { _unitOfWork.RationRepository.Edit(ration); _unitOfWork.Save(); return true; }
public void ShouldPostPSNPPlanTransaction() { //Act var regionalPSNPPlan = new RegionalPSNPPlan() { RegionalPSNPPlanID = 1, Year = 2014, Duration = 5, RationID = 1, StatusID = 1, PlanId = 1, RegionalPSNPPlanDetails = new List<RegionalPSNPPlanDetail>() { new RegionalPSNPPlanDetail() { RegionalPSNPPlanDetailID = 1, RegionalPSNPPlanID = 1, PlanedFDPID = 1, BeneficiaryCount = 200, FoodRatio = 3, CashRatio = 3, Item3Ratio = 0, Item4Ratio = 0 } } }; var ration = new Ration() { RationID = 1, CreatedDate = DateTime.Now, IsDefaultRation = true, RefrenceNumber = "Ration-Default", RationDetails = new List<RationDetail>() { new RationDetail() { RationDetailID = 1, RationID =1, CommodityID = 1, Amount = 20, }, new RationDetail() { RationDetailID = 2, RationID =1, CommodityID = 2, Amount = 20, } } }; var result = _accountTransactionService.PostPSNPPlan(regionalPSNPPlan, ration); //Assert Assert.IsInstanceOf<List<Models.Transaction>>(result); }
public bool AddRation(Ration ration) { _unitOfWork.RationRepository.Add(ration); _unitOfWork.Save(); return true; }
public void ShouldPostHRDPlanTransaction() { //Act var hrd = new HRD() { HRDID = 1, Year = 2014, CreatedDate = DateTime.Now, PublishedDate = DateTime.Now, RationID = 1, PlanID = 1, Ration = new Ration() { RationID = 1, CreatedDate = DateTime.Now, IsDefaultRation = true, RefrenceNumber = "Ration-Default", RationDetails = new List<RationDetail>() { new RationDetail() { RationDetailID = 1, RationID =1, CommodityID = 1, Amount = 20, }, new RationDetail() { RationDetailID = 2, RationID =1, CommodityID = 2, Amount = 20, } }, }, HRDDetails = new List<HRDDetail>() { new HRDDetail() { HRDDetailID = 1, HRDID = 1, WoredaID = 3, NumberOfBeneficiaries = 123, DurationOfAssistance = 6, StartingMonth = 6, AdminUnit = new AdminUnit() { AdminUnitID = 3, Name = "Woreda1", AdminUnitTypeID = 4, AdminUnit2 = new AdminUnit() { AdminUnitID = 2, Name = "Zone1", AdminUnitTypeID = 3, AdminUnit2 = new AdminUnit() { AdminUnitID = 1, Name = "Region1", AdminUnitTypeID = 2, } } } } } }; var ration = new Ration() { RationID = 1, CreatedDate = DateTime.Now, IsDefaultRation = true, RefrenceNumber = "Ration-Default", RationDetails = new List<RationDetail>() { new RationDetail() { RationDetailID = 1, RationID =1, CommodityID = 1, Amount = 20, }, new RationDetail() { RationDetailID = 2, RationID =1, CommodityID = 2, Amount = 20, } } }; var result = _accountTransactionService.PostHRDPlan(hrd, ration); //Assert Assert.IsInstanceOf<List<Models.Transaction>>(result); }
public List<Models.Transaction> PostPSNPPlan(RegionalPSNPPlan plan, Ration ration) { List<Models.Transaction> entries = new List<Models.Transaction>(); List<int> regionalBenCount = new List<int>(); for (int r = 0; r < plan.Duration; r++) { regionalBenCount.Add(0); } foreach (RegionalPSNPPlanDetail fdp in plan.RegionalPSNPPlanDetails) { for (int r = 0; r < fdp.FoodRatio; r++) { regionalBenCount[r] += (int)fdp.BeneficiaryCount; } } for (int r = 0; r < plan.Duration; r++) { int noben = regionalBenCount[r]; if (noben > 0) { Guid transactionGroupID = Guid.NewGuid(); DateTime transactionDate = DateTime.Now; foreach (RationDetail rd in ration.RationDetails) { decimal amount = rd.Amount * noben; Models.Transaction entry2 = new Models.Transaction { CommodityID = rd.CommodityID, Round = r + 1, ProgramID = TransactionConstants.Constants.PSNP_PROGRAM_ID, QuantityInUnit = amount, UnitID=1, QuantityInMT = amount, LedgerID = Cats.Models.Ledger.Constants.REQUIRMENT_DOCUMENT_PALN, // previously 200 TransactionDate = transactionDate, TransactionGroupID = transactionGroupID, PlanId = plan.PlanId, TransactionID = Guid.NewGuid(), }; Models.Transaction entry1 = new Models.Transaction { CommodityID = rd.CommodityID, Round = r + 1, ProgramID = TransactionConstants.Constants.PSNP_PROGRAM_ID, QuantityInUnit = -amount, UnitID = 1, QuantityInMT = -amount, LedgerID = Cats.Models.Ledger.Constants.REQUIRMENT_DOCUMENT, //previously 100 TransactionDate = transactionDate, TransactionGroupID = transactionGroupID, PlanId = plan.PlanId, TransactionID = Guid.NewGuid(), }; _unitOfWork.TransactionRepository.Add(entry1); _unitOfWork.TransactionRepository.Add(entry2); _unitOfWork.Save(); entries.Add(entry1); entries.Add(entry2); } plan.TransactionGroupID = transactionGroupID; _unitOfWork.RegionalPSNPPlanRepository.Edit(plan); } } return entries; }
public List<Models.Transaction> PostHRDPlan(HRD hrd, Ration ration) { List<Models.Transaction> entries = new List<Models.Transaction>(); List<int> regionalBenCount = new List<int>(); ration = hrd.Ration; int RegionID=0; for (int r = 0; r < 12; r++) { regionalBenCount.Add(0); } foreach (HRDDetail fdp in hrd.HRDDetails) { for (int r = 0; r < fdp.DurationOfAssistance; r++) { regionalBenCount[r] += (int)fdp.NumberOfBeneficiaries; RegionID = fdp.AdminUnit.AdminUnit2.AdminUnit2.AdminUnitID; } } for (int r = 0; r < 12; r++) { int noben = regionalBenCount[r]; if (noben > 0) { Guid transactionGroupID = Guid.NewGuid(); DateTime transactionDate = DateTime.Now; _unitOfWork.TransactionGroupRepository.Add(new TransactionGroup() { PartitionID = 0, TransactionGroupID = transactionGroupID }); foreach (RationDetail rd in ration.RationDetails) { decimal amount = (rd.Amount/1000)*noben; var entry2 = new Models.Transaction { RegionID = RegionID, CommodityID = rd.CommodityID, Round = r + 1, ProgramID = TransactionConstants.Constants.HRD_PROGRAM_ID, QuantityInUnit = amount, UnitID = 1, QuantityInMT = amount, LedgerID = Cats.Models.Ledger.Constants.REQUIRMENT_DOCUMENT_PALN, // previously 200 TransactionDate = transactionDate, TransactionGroupID = transactionGroupID, PlanId = hrd.PlanID, TransactionID = Guid.NewGuid(), }; var entry1 = new Models.Transaction { RegionID = RegionID, CommodityID = rd.CommodityID, Round = r + 1, ProgramID = TransactionConstants.Constants.HRD_PROGRAM_ID, QuantityInUnit = -amount, UnitID = 1, QuantityInMT = -amount, LedgerID = Cats.Models.Ledger.Constants.REQUIRMENT_DOCUMENT, //previously 100 TransactionDate = transactionDate, TransactionGroupID = transactionGroupID, PlanId = hrd.PlanID, TransactionID = Guid.NewGuid(), }; _unitOfWork.TransactionRepository.Add(entry1); _unitOfWork.TransactionRepository.Add(entry2); entries.Add(entry1); entries.Add(entry2); //hrd.TransactionGroupID = transactionGroupID; //_unitOfWork.HRDRepository.Edit(hrd); _unitOfWork.Save(); } } } return entries; }
public List<Models.Transaction> PostPSNPPlan(RegionalPSNPPlan plan, Ration ration) { List<Models.Transaction> entries = new List<Models.Transaction>(); List<int> regionalBenCount = new List<int>(); for (int r = 0; r < plan.Duration; r++) { regionalBenCount.Add(0); } foreach (RegionalPSNPPlanDetail fdp in plan.RegionalPSNPPlanDetails) { for (int r = 0; r < fdp.FoodRatio; r++) { regionalBenCount[r] += (int)fdp.BeneficiaryCount; } } for (int r = 0; r < plan.Duration; r++) { int noben = regionalBenCount[r]; if (noben > 0) { foreach (RationDetail rd in ration.RationDetails) { decimal amount = rd.Amount * noben; Models.Transaction entry2 = new Models.Transaction { CommodityID = rd.CommodityID, Round = r + 1, ProgramID = 2, QuantityInUnit = -amount, UnitID=1, QuantityInMT = -amount, LedgerID = 200 }; Models.Transaction entry1 = new Models.Transaction { CommodityID = rd.CommodityID, Round = r + 1, ProgramID = 2, QuantityInUnit = amount, UnitID = 1, QuantityInMT = amount, LedgerID = 100 }; entries.Add(entry1); entries.Add(entry2); } } } PostTransaction(entries); return entries; }
public List<Models.Transaction> PostHRDPlan(HRD hrd, Ration ration) { List<Models.Transaction> entries = new List<Models.Transaction>(); List<int> regionalBenCount = new List<int>(); ration = hrd.Ration; int RegionID=0; for (int r = 0; r < 12; r++) { regionalBenCount.Add(0); } foreach (HRDDetail fdp in hrd.HRDDetails) { for (int r = 0; r < fdp.DurationOfAssistance; r++) { regionalBenCount[r] += (int)fdp.NumberOfBeneficiaries; RegionID = fdp.AdminUnit.AdminUnit2.AdminUnit2.AdminUnitID; } } for (int r = 0; r < 12; r++) { int noben = regionalBenCount[r]; if (noben > 0) { foreach (RationDetail rd in ration.RationDetails) { decimal amount = rd.Amount * noben; Models.Transaction entry2 = new Models.Transaction { RegionID = RegionID, CommodityID = rd.CommodityID, Round = r + 1, ProgramID = 2, QuantityInUnit = -amount, UnitID = 1, QuantityInMT = -amount, LedgerID = 200 }; Models.Transaction entry1 = new Models.Transaction { RegionID = RegionID, CommodityID = rd.CommodityID, Round = r + 1, ProgramID = 2, QuantityInUnit = amount, UnitID = 1, QuantityInMT = amount, LedgerID = 100 }; entries.Add(entry1); entries.Add(entry2); } } } return entries; }