public IHttpActionResult Post(FixedCost baseRequest) { baseRequest.OrgId = SecurityHelper.CurrentPrincipal.OrgId; var response = service.SaveFixedCost(baseRequest); return(Ok(response)); }
public FixedCostViewModel(FixedCost model) { this.Model = model; if (this.Model.CostEstimate == null) { this.Model.CostEstimate = new Estimate(); } this.CostEstimate = new EstimateViewModel(this.Model.CostEstimate); }
public BaseResponse <List <FixedCost> > SaveFixedCost(int groupId, int regNo, long feeNo, DateTime?StartDate, DateTime?EndDate) { BaseResponse <List <FixedCost> > response = new BaseResponse <List <FixedCost> >(); response.Data = new List <FixedCost>(); var costGroup = this.GetCostGroupExtend(groupId); if (costGroup.ResultCode == 0) { string orgId = SecurityHelper.CurrentPrincipal.OrgId; unitOfWork.BeginTransaction(); costGroup.Data.GroupItems.ForEach(it => { var newItem = new FixedCost() { OrgId = orgId, RegNo = regNo, FeeNo = feeNo, CostItemId = it.CostItemId, ItemUnit = it.ItemUnit, CostItemNo = it.CostItemNo, CostName = it.CostName, Price = it.Price, Period = it.Period, RepeatCount = it.RepeatCount, StartDate = StartDate, EndDate = EndDate, IsEndCharGes = false }; base.Save <LTC_FIXEDCOST, FixedCost>(newItem, (q) => q.ID == newItem.Id); response.Data.Add(newItem); }); unitOfWork.Commit(); } if (response.Data != null && response.Data.Count > 0) { response.ResultCode = 1002; } else { response.ResultCode = 1001; } return(response); }
public async Task <string> AddFixedCost([FromBody] FixedCost fixedcost) { if (ModelState.IsValid) { var headers = new Dictionary <string, string>(); var tokenGenerated = HttpContext.Session.GetHmacToken(); headers.Add("X-Hmac", tokenGenerated); headers.Add("X-PublicKey", HttpContext.Session.GetUserPublicKey()); string queryStr = _queryCreater.GetQueryStringFromObject(fixedcost); var response = await HttpClientRequestFactory.Get("http://proxy.mansis.co.za:18443/SlimProxyBoot.php?" + queryStr, headers); var data = response.Content.ReadAsStringAsync().Result; return(data.ToString()); } else { throw new Exception("Model state is not valid"); } }
public BaseResponse <IList <FixedCost> > QueryFixedCost(BaseRequest <FixedCostFilter> request) { BaseResponse <IList <FixedCost> > response = new BaseResponse <IList <FixedCost> >(); var q = from n in unitOfWork.GetRepository <LTC_FIXEDCOST>().dbSet select new { FixedCost = n }; if (!string.IsNullOrEmpty(request.Data.OrgId)) { q = q.Where(m => m.FixedCost.ORGID == request.Data.OrgId); } if (request.Data.FeeNo >= 0) { q = q.Where(m => m.FixedCost.FEENO == request.Data.FeeNo); } q = q.OrderBy(m => m.FixedCost.COSTITEMNO); response.RecordsCount = q.Count(); Action <IList> mapperResponse = (IList list) => { response.Data = new List <FixedCost>(); foreach (dynamic item in list) { FixedCost newItem = Mapper.DynamicMap <FixedCost>(item.FixedCost); response.Data.Add(newItem); } }; if (request != null && request.PageSize > 0) { var list = q.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize).ToList(); response.PagesCount = GetPagesCount(request.PageSize, response.RecordsCount); mapperResponse(list); } else { var list = q.ToList(); mapperResponse(list); } return(response); }
private static async Task InsertFixedCostsAsync(BudgetPlanDbContext dbContext, Guid userId) { if (await dbContext.FixedCost.AnyAsync()) { return; } var fixedCost1 = new FixedCost(userId, "Flat", 600, Duration.Monthly, CostCategory.FlatAndOperating); var fixedCost2 = new FixedCost(userId, "Netflix", 12, Duration.Monthly, CostCategory.FlatAndOperating); var fixedCost3 = new FixedCost(userId, "Tires", 300, Duration.Year, CostCategory.MotorVehicle); var fixedCost4 = new FixedCost(userId, "Accident Insurance", 12, Duration.Year, CostCategory.Insurance); var fixedCost5 = new FixedCost(userId, "Retirement", 30, Duration.QuarterYear, CostCategory.Insurance); await dbContext.FixedCost.AddAsync(fixedCost1); await dbContext.FixedCost.AddAsync(fixedCost2); await dbContext.FixedCost.AddAsync(fixedCost3); await dbContext.FixedCost.AddAsync(fixedCost4); await dbContext.FixedCost.AddAsync(fixedCost5); }
public IHttpActionResult PostGroup(FixedCost request) { var response = service.SaveFixedCost(request.Id, request.RegNo, request.FeeNo, request.StartDate, request.EndDate); return(Ok(response)); }
/// <summary> /// 生成账单价格 /// </summary> /// <param name="billRelated">生成账单的住民</param> /// <param name="nowDate">当前时间</param> /// <param name="minByMonth">最小月份时间</param> /// <param name="maxByMonth">最大月份时间</param> /// <param name="days">时间</param> /// <param name="fixedCostByDay">固定费用录入(日)</param> /// <param name="fixedCostByMonth">固定费用录入(月)</param> /// <param name="costDtl">费用录入</param> /// <param name="leavehospList">离院记录</param> /// <returns>价格</returns> private CalculateList CalculateCost(BillRelated billRelated, DateTime nowDate, DateTime minByMonth, DateTime maxByMonth, int days, List <LTC_FIXEDCOST> fixedCostByDay, List <LTC_FIXEDCOST> fixedCostByMonth, List <LTC_COSTDTL> costDtl, List <LTC_LEAVEHOSP> leavehospList) { long feeNo = billRelated.FEENO; decimal dtlCost = 0; decimal fixedDayCost = 0; decimal fixedMonthCost = 0; decimal totalcost = 0; DateTime repeatStartDate; DateTime repeatDayDate; CalculateList calculateList = new CalculateList(); List <FixedCost> returnDayFixedCost = new List <FixedCost>(); List <FixedCost> returnMonthFixedCost = new List <FixedCost>(); #region 费用录入价格 billRelated.CostDtlList = costDtl.FindAll(m => m.FEENO == feeNo && m.BILLID == 0); dtlCost += billRelated.CostDtlList.Sum(m => m.TOTALPRICE ?? 0); #endregion #region 累加按天的固定收費 var fixedCostByDayFeeNo = fixedCostByDay.FindAll(m => m.FEENO == feeNo); fixedCostByDayFeeNo.ForEach(m => { int leaveDay = 0; int repeatCount = 0; repeatDayDate = nowDate; if (!Convert.ToBoolean(m.ISENDCHARGES)) { if (m.ENDDATE.HasValue && m.ENDDATE != null) { if (m.REPEATCOUNT == null || m.REPEATCOUNT == 0) { repeatCount = DateDiff(Convert.ToDateTime(m.STARTDATE), Convert.ToDateTime(m.ENDDATE)); repeatDayDate = Convert.ToDateTime(m.STARTDATE); //leaveDay = LeaveDays(leavehospList, Convert.ToDateTime(m.STARTDATE), repeatCount); } else if (m.REPEATCOUNT.HasValue && m.REPEATCOUNT != 0) { DateTime RePeatDay = m.STARTDATE.AddDays(Convert.ToDouble(m.REPEATCOUNT)); if (RePeatDay >= Convert.ToDateTime(m.ENDDATE)) { repeatCount = 0; //leaveDay = 0; } else { repeatCount = DateDiff(Convert.ToDateTime(RePeatDay), Convert.ToDateTime(m.ENDDATE)); repeatDayDate = Convert.ToDateTime(RePeatDay); //leaveDay = LeaveDays(leavehospList, RePeatDay, repeatCount); } } } else { if (m.REPEATCOUNT == null || m.REPEATCOUNT == 0) { repeatCount = DateDiff(Convert.ToDateTime(m.STARTDATE), nowDate); repeatDayDate = Convert.ToDateTime(m.STARTDATE); //leaveDay = LeaveDays(leavehospList, Convert.ToDateTime(m.STARTDATE), repeatCount); } else if (m.REPEATCOUNT.HasValue && m.REPEATCOUNT != 0) { DateTime RePeatDay = m.STARTDATE.AddDays(Convert.ToDouble(m.REPEATCOUNT)); if (RePeatDay >= nowDate) { repeatCount = 0; //leaveDay = 0; } else { repeatCount = DateDiff(RePeatDay, nowDate); repeatDayDate = Convert.ToDateTime(RePeatDay); // leaveDay = LeaveDays(leavehospList, RePeatDay, repeatCount); } } } } if (m.PRICE.HasValue && m.PRICE != null) { var total = Convert.ToDecimal(m.PRICE) * repeatCount; fixedDayCost += total; } else { var total = 0 * repeatCount; fixedDayCost += total; } m.GENERATEDATE = nowDate; m.REPEATCOUNT += repeatCount; unitOfWork.GetRepository <LTC_FIXEDCOST>().Update(m); FixedCost fixDay = new FixedCost(); fixDay.CostItemNo = m.COSTITEMNO; fixDay.CostName = m.COSTNAME; fixDay.Period = m.PERIOD; fixDay.GenerateDate = nowDate; fixDay.RegNo = m.REGNO; fixDay.FeeNo = m.FEENO; fixDay.OrgId = m.ORGID; fixDay.Price = m.PRICE; fixDay.StartDate = repeatDayDate; fixDay.RepeatCount = repeatCount; returnDayFixedCost.Add(fixDay); }); #endregion #region 累加按月固定收费 var fixedCostByMonthFeeNo = fixedCostByMonth.FindAll(m => m.FEENO == feeNo); fixedCostByMonthFeeNo.ForEach(m => { int leaveDay = 0; int repeatCount = 0; repeatStartDate = new DateTime(1900, 1, 1); if (!Convert.ToBoolean(m.ISENDCHARGES)) { if (m.ENDDATE.HasValue && m.ENDDATE != null) { if (m.REPEATCOUNT == null || m.REPEATCOUNT == 0) { repeatCount = DiffDateMonth(Convert.ToDateTime(m.STARTDATE), Convert.ToDateTime(m.ENDDATE)); repeatStartDate = Convert.ToDateTime(m.STARTDATE); //repeatCount = DateDiffMonth(ReturnStartDate(Convert.ToDateTime(m.STARTDATE)), ReturnEndDate(Convert.ToDateTime(m.ENDDATE))); //leaveDay = LeaveDays(leavehospList, Convert.ToDateTime(m.STARTDATE), repeatCount); } else if (m.REPEATCOUNT.HasValue && m.REPEATCOUNT != 0) { //DateTime RePeatDay = ReturnStartDate(Convert.ToDateTime(m.STARTDATE)).AddMonths(Convert.ToInt32(m.REPEATCOUNT)); DateTime RePeatDay = Convert.ToDateTime(m.STARTDATE).AddMonths(Convert.ToInt32(m.REPEATCOUNT)); if (RePeatDay > Convert.ToDateTime(m.ENDDATE)) { repeatCount = 0; //leaveDay = 0; } else { repeatCount = DiffDateMonth(Convert.ToDateTime(RePeatDay), Convert.ToDateTime(m.ENDDATE)); repeatStartDate = Convert.ToDateTime(RePeatDay); // repeatCount = DateDiffMonth(Convert.ToDateTime(RePeatDay), ReturnEndDate(Convert.ToDateTime(m.ENDDATE))); //leaveDay = LeaveDays(leavehospList, RePeatDay, repeatCount); } } } else { if (m.REPEATCOUNT == null || m.REPEATCOUNT == 0) { repeatCount = DiffDateMonth(Convert.ToDateTime(m.STARTDATE), nowDate); repeatStartDate = Convert.ToDateTime(Convert.ToDateTime(m.STARTDATE)); //repeatCount = DateDiffMonth(ReturnStartDate(Convert.ToDateTime(m.STARTDATE)), ReturnEndDate(nowDate)); //leaveDay = LeaveDays(leavehospList, Convert.ToDateTime(m.STARTDATE), repeatCount); } else if (m.REPEATCOUNT.HasValue && m.REPEATCOUNT != 0) { DateTime RePeatDay = Convert.ToDateTime(m.STARTDATE).AddMonths(Convert.ToInt32(m.REPEATCOUNT)); //DateTime RePeatDay = ReturnStartDate(Convert.ToDateTime(m.STARTDATE)).AddMonths(Convert.ToInt32(m.REPEATCOUNT)); if (RePeatDay > nowDate) { repeatCount = 0; //leaveDay = 0; } else { repeatCount = DiffDateMonth(RePeatDay, nowDate); repeatStartDate = RePeatDay; //repeatCount = DateDiffMonth(RePeatDay, ReturnEndDate(nowDate)); // leaveDay = LeaveDays(leavehospList, RePeatDay, repeatCount); } } } } if (m.PRICE.HasValue && m.PRICE != null) { var total = Convert.ToDecimal(m.PRICE) * repeatCount; fixedMonthCost += total; } else { var total = 0 * repeatCount; fixedMonthCost += total; } m.GENERATEDATE = nowDate; m.REPEATCOUNT += repeatCount; unitOfWork.GetRepository <LTC_FIXEDCOST>().Update(m); FixedCost fixMonth = new FixedCost(); fixMonth.CostItemNo = m.COSTITEMNO; fixMonth.CostName = m.COSTNAME; fixMonth.Period = m.PERIOD; fixMonth.GenerateDate = nowDate; fixMonth.RegNo = m.REGNO; fixMonth.FeeNo = m.FEENO; fixMonth.OrgId = m.ORGID; fixMonth.Price = m.PRICE; fixMonth.RepeatCount = repeatCount; fixMonth.StartDate = repeatStartDate; returnMonthFixedCost.Add(fixMonth); }); #endregion calculateList.Cost = dtlCost + fixedDayCost + fixedMonthCost; //账单总价 calculateList.FixedDayCost = fixedDayCost; calculateList.FixedMonthCost = fixedMonthCost; calculateList.ReturnDayFixedCost = returnDayFixedCost; calculateList.ReturnMonthFixedCost = returnMonthFixedCost; return(calculateList); }
public BaseResponse <FixedCost> SaveFixedCost(FixedCost request) { return(base.Save <LTC_FIXEDCOST, FixedCost>(request, (q) => q.ID == request.Id)); }