public JsonResult UpdateBillGroupItem([FromBody] BillGroupDetail input) { var result = BusinessService.UpdateBillGroupItem(input); var ret = $"{{\"msg\":\"{result}\"}}"; return(new JsonResult(ret)); }
private void GenerateBillGroupDetail(BillGenerateInput input, int month, int year) { var bgids = (from us in UnitSummary where us.divisionid == Convert.ToInt32(input.DivisionId) select us.billgroupid).Distinct(); var bgs = from bg in BillGroup join bgid in bgids on bg.Id equals bgid select bg; var bglist = new List <BillGroupDetail>(); foreach (var bg in bgs) { var bgdetail = from bgd in BillGroupDetail where bgd.BillGroupId == bg.Id && bgd.BillMonth == month && bgd.BillYear == year select bgd; if (!bgdetail.Any()) { var addThis = false; DateTime startDate = new DateTime(year, month, (int)bg.StartDay); DateTime endDate = startDate;// = startDate.AddMonths(2); DateTime billDate = startDate.AddDays(1); DateTime dueDate = billDate.AddDays(bg.DueDays); if (bg.BiMonthly && month % 2 == (bg.BiMonthlyEven ? 0 : 1)) { addThis = true; endDate = startDate.AddMonths(2).AddDays(-1); } if (!bg.BiMonthly) { addThis = true; endDate = startDate.AddMonths(1).AddDays(-1); } if (addThis) { bglist.Add(new DataModels.Billing.BillGroupDetail() { BillDate = billDate, BillGroupId = bg.Id, BillMonth = month, BillYear = year, DivisionId = Convert.ToInt32(input.DivisionId), DueDate = dueDate, StartDate = startDate, EndDate = endDate, Status = "Created" }); } } } if (bglist.Count > 0) { BillGroupDetail.AddRange(bglist); } this.SaveChanges(); }
private void processPayment(ProcessInput input) { var userid = Context.GetUser(); var emp = (from empl in Employee where empl.employeeid == userid select empl).FirstOrDefault(); var emplog = (from empl in EmployeeLoginMapping where empl.employeeid == userid select empl).FirstOrDefault(); if (emp.divisionid != null) { var bgd = (from bg in BillGroupDetail where bg.Id == input.GroupId select bg).FirstOrDefault(); if (bgd == null) { throw new Exception("Bill Group Not Generated"); } var now = DateTime.Now; var qry = from bill in Bill join us in UnitSummary on bill.UnitId equals us.id where us.divisionid == emp.divisionid && us.billgroupid == bgd.BillGroupId && bill.MonthYear == input.MonthYear join pay in PaymentDetail on bill.Id equals pay.BillNo into pd from p in pd.DefaultIfEmpty() //from p in pd.Where(o=>o.Canceled==false).DefaultIfEmpty() //where p.Canceled == false group new { Bill = bill, Pay = p } by bill.Id into g select new PaymentProcess { Amount = g.First().Bill.TotalAmount, BillNo = g.First().Bill.Id, Paid = g.Sum(p => p.Pay == null ? 0 : p.Pay.Canceled ?0 : p.Pay.Amount), }; var qryLst = qry.ToList(); foreach (var item in qryLst) { item.Balance = Convert.ToDouble(item.Paid) - item.Amount; item.OverPay = item.Balance > 0; item.ProcessedAt = DateTime.Now; item.ProcessedBy = emplog.loginname; } PaymentProcess.AddRange(qryLst); bgd.Status = "Closed"; BillGroupDetail.Update(bgd); this.SaveChanges(); } }
public string UpdateBillGroupItem(BillGroupDetail input) { var result = "Success"; try { var item = (from bg in BillGroupDetail where bg.Id == input.Id select bg).FirstOrDefault(); if (item != null) { item.DueDate = input.DueDate; item.BillDate = input.BillDate; BillGroupDetail.Update(item); this.SaveChanges(); } } catch (Exception ex) { return("Failed :" + ex.Message); } return(result); }
public string GenerateBillBGWise(long BillGroupDetailId) { var result = "Success"; var billsToAdd = new List <Bill>(); var bgDetail = GetBillGroup(BillGroupDetailId); var monthYear = bgDetail.BillMonth.ToString("00") + bgDetail.BillYear.ToString(); var units = from unit in UnitSummary where unit.billgroupid == bgDetail.BillGroupId && unit.divisionid == bgDetail.DivisionId select unit; var exist = (from bill in Bills join ui in units on bill.UnitId equals ui.id where bill.MonthYear == monthYear select ui).Any(); if (exist) { return("Already Bill Generated for this Period."); } foreach (var unit in units.ToList()) { billsToAdd.Add(GenerateBillForUnit(bgDetail, unit, monthYear)); } Bills.AddRange(billsToAdd); SaveChanges(); var bgd = (from bg in BillGroupDetail where bg.Id == BillGroupDetailId select bg).FirstOrDefault(); bgd.Status = "Generated"; BillGroupDetail.Update(bgd); SaveChanges(); return(result); }
public string UpdateBillGroupItem(BillGroupDetail input) { return(Repository.UpdateBillGroupItem(Mapper.Map <DataModels.Billing.BillGroupDetail>(input))); }