public bool Delete(Int64 Id) { FloorRentInfoManager floorInfoManager = new FloorRentInfoManager(); BillingReceivedInfoManager billingReceivedManager = new BillingReceivedInfoManager(); BillingInfoPerMonthManager billingInfoManager = new BillingInfoPerMonthManager(); var exist = Repository.GetById(Id); exist.UpdatedBy = Log.UserId.ToString(); exist.UpdatedOn = new LoginInfo().CurrentTime; exist.IsActive = false; exist.IsCurrent = false; Repository.SaveOrUpdate(exist); var floorRentExist = floorInfoManager.GetAll().Where(x => x.TenantInfoId == Id && x.IsActive).ToList(); var billingReceivedExist = billingReceivedManager.GetAll().Where(x => x.TenantInfoId == Id && x.IsActive).ToList(); var billingInfoExist = billingInfoManager.GetAll().Where(x => x.TenantInfoId == Id && x.IsActive).ToList(); foreach (var floors in floorRentExist) { var existFloor = floorInfoManager.GetById(floors.Id); floors.IsActive = false; floors.IsCurrent = false; floors.UpdatedBy = Log.UserId.ToString(); floors.UpdatedOn = new LoginInfo().CurrentTime; floorInfoManager.SaveOrUpdateDelete(existFloor); } foreach (var billingReceive in billingReceivedExist) { var existBillingReceive = billingReceivedManager.GetById(billingReceive.Id); billingReceive.IsActive = false; billingReceive.UpdatedBy = Log.UserId.ToString(); billingReceive.UpdatedOn = new LoginInfo().CurrentTime; billingReceivedManager.SaveOrUpdateDelete(existBillingReceive); } foreach (var billingInfo in billingInfoExist) { var existBillingInfo = billingInfoManager.GetById(billingInfo.Id); billingInfo.IsActive = false; billingInfo.UpdatedBy = Log.UserId.ToString(); billingInfo.UpdatedOn = new LoginInfo().CurrentTime; billingInfoManager.SaveOrUpdateDelete(existBillingInfo); } return(Repository.Done()); }
public bool Saved(BillingReceivedInfoInput model) { decimal rentBill = 0; decimal commonBill = 0; decimal electricityBill = 0; decimal emElectricityBill = 0; decimal wasaBill = 0; BillingInfoPerMonth billingInfo = new BillingInfoPerMonth(); BillingInfoPerMonthManager billingInfoManager = new BillingInfoPerMonthManager(); for (var i = 0; i < model.Amount.Length; i++) { if (model.Amount[i] < 1) { continue; } var entity = new BillingReceivedInfo() { TenantInfoId = model.TenantInfoId, Date = model.Date, CreatedOn = new LoginInfo().CurrentTime, CreatedBy = Log.UserId.ToString(), IsActive = true, Amount = model.Amount[i], Note = model.Note[i], Purpose = model.Purpose[i] }; if (i == 0) { rentBill = model.Amount[i]; } else if (i == 1) { commonBill = model.Amount[i]; } else if (i == 2) { electricityBill = model.Amount[i]; } else if (i == 3) { emElectricityBill = model.Amount[i]; } else { wasaBill = model.Amount[i]; } Repository.SaveOrUpdate(entity); } billingInfo.Month = Convert.ToString(model.Date.Month); billingInfo.Year = Convert.ToString(model.Date.Year); billingInfo.TenantInfoId = model.TenantInfoId; var dateYearExist = billingInfoManager.GetAll().Where(x => x.Month == billingInfo.Month && x.Year == billingInfo.Year && x.TenantInfoId == billingInfo.TenantInfoId && x.IsActive).LastOrDefault(); var exist = billingInfoManager.GetAll().Where(x => x.TenantInfoId == billingInfo.TenantInfoId && x.IsActive).LastOrDefault(); if (dateYearExist == null) { billingInfo.RentBill = rentBill; billingInfo.CommonBill = commonBill; billingInfo.ElectricityBill = electricityBill; billingInfo.EmElectricityBill = emElectricityBill; billingInfo.WasaBill = wasaBill; } else { billingInfo.Id = dateYearExist.Id; billingInfo.RentBill = dateYearExist.RentBill + rentBill; billingInfo.CommonBill = dateYearExist.CommonBill + commonBill; billingInfo.ElectricityBill = dateYearExist.ElectricityBill + electricityBill; billingInfo.EmElectricityBill = dateYearExist.EmElectricityBill + emElectricityBill; billingInfo.WasaBill = dateYearExist.WasaBill + wasaBill; billingInfo.CurrentDuesRent = dateYearExist.CurrentDuesRent; billingInfo.CurrentDuesCommon = dateYearExist.CurrentDuesCommon; billingInfo.CurrentDuesElectricity = dateYearExist.CurrentDuesElectricity; billingInfo.CurrentDuesEmElectricity = dateYearExist.CurrentDuesEmElectricity; billingInfo.CurrentDuesWasa = dateYearExist.CurrentDuesWasa; billingInfo.OpeningBalanceRent = dateYearExist.OpeningBalanceRent; billingInfo.OpeningBalanceCommon = dateYearExist.OpeningBalanceCommon; billingInfo.OpeningBalanceElectricity = dateYearExist.OpeningBalanceElectricity; billingInfo.OpeningBalanceEmElectricity = dateYearExist.OpeningBalanceEmElectricity; billingInfo.OpeningBalanceWasa = dateYearExist.OpeningBalanceWasa; billingInfo.RemarksRent = dateYearExist.RemarksRent; billingInfo.RemarksCommon = dateYearExist.RemarksCommon; billingInfo.RemarksElectricity = dateYearExist.RemarksElectricity; billingInfo.RemarksEmElectricity = dateYearExist.RemarksEmElectricity; billingInfo.RemarksWasa = dateYearExist.RemarksWasa; billingInfo.CreatedBy = dateYearExist.CreatedBy; billingInfo.CreatedOn = dateYearExist.CreatedOn; billingInfo.UpdatedBy = Log.UserId.ToString(); billingInfo.UpdatedOn = System.DateTime.Now; billingInfo.IsActive = true; exist = null; billingInfoManager.SaveOrUpdate(billingInfo); } if (exist != null) { billingInfo.CurrentDuesRent = exist.CurrentDuesRent; billingInfo.CurrentDuesCommon = exist.CurrentDuesCommon; billingInfo.CurrentDuesElectricity = exist.CurrentDuesElectricity; billingInfo.CurrentDuesEmElectricity = exist.CurrentDuesEmElectricity; billingInfo.CurrentDuesWasa = exist.CurrentDuesWasa; billingInfo.OpeningBalanceRent = exist.CurrentDuesRent + exist.OpeningBalanceRent; billingInfo.OpeningBalanceCommon = exist.CurrentDuesCommon + exist.OpeningBalanceCommon; billingInfo.OpeningBalanceElectricity = exist.CurrentDuesElectricity + exist.OpeningBalanceElectricity; billingInfo.OpeningBalanceEmElectricity = exist.CurrentDuesEmElectricity + exist.OpeningBalanceEmElectricity; billingInfo.OpeningBalanceWasa = exist.CurrentDuesWasa + exist.OpeningBalanceWasa; billingInfo.RemarksRent = exist.RemarksRent; billingInfo.RemarksCommon = exist.RemarksCommon; billingInfo.RemarksElectricity = exist.RemarksElectricity; billingInfo.RemarksEmElectricity = exist.RemarksEmElectricity; billingInfo.RemarksWasa = exist.RemarksWasa; billingInfo.CreatedBy = exist.CreatedBy; billingInfo.CreatedOn = exist.CreatedOn; billingInfo.UpdatedBy = Log.UserId.ToString(); billingInfo.UpdatedOn = System.DateTime.Now; billingInfo.IsActive = true; billingInfoManager.SaveOrUpdate(billingInfo); } return(Repository.Done()); }
public bool Delete(Int64 Id) { BillingReceivedInfoManager billingReceivedManager = new BillingReceivedInfoManager(); BillingInfoPerMonthManager billingInfoManager = new BillingInfoPerMonthManager(); var exist = Repository.GetById(Id); var multipleFloorExist = Repository.GetAll().Where(x => x.TenantInfoId == exist.TenantInfoId && x.IsActive && x.IsCurrent).ToList(); exist.UpdatedBy = Log.UserId.ToString(); exist.UpdatedOn = new LoginInfo().CurrentTime; exist.IsActive = false; exist.IsCurrent = false; Repository.SaveOrUpdate(exist); if (multipleFloorExist.Count == 1) { var billingReceivedExist = billingReceivedManager.GetAll().Where(x => x.TenantInfoId == exist.TenantInfoId && x.IsActive).ToList(); var billingInfoExist = billingInfoManager.GetAll().Where(x => x.TenantInfoId == exist.TenantInfoId && x.IsActive).ToList(); foreach (var billingReceive in billingReceivedExist) { var existBillingReceive = billingReceivedManager.GetById(billingReceive.Id); billingReceive.IsActive = false; billingReceive.UpdatedBy = Log.UserId.ToString(); billingReceive.UpdatedOn = new LoginInfo().CurrentTime; billingReceivedManager.SaveOrUpdateDelete(existBillingReceive); } foreach (var billingInfo in billingInfoExist) { var existBillingInfo = billingInfoManager.GetById(billingInfo.Id); billingInfo.IsActive = false; billingInfo.UpdatedBy = Log.UserId.ToString(); billingInfo.UpdatedOn = new LoginInfo().CurrentTime; billingInfoManager.SaveOrUpdateDelete(existBillingInfo); } } else { var TotalRent = (exist.RentSpaceSFT * exist.SftRate); var TotalAIT = (TotalRent * exist.LessAITPercent) / 100; var CurrentDues = TotalRent - TotalAIT - exist.AdvancePay; var CommonDues = (exist.RentSpaceSFT * exist.CommonBillRateSFT); var billingInfoExist = billingInfoManager.GetAll().Where(x => x.TenantInfoId == exist.TenantInfoId && x.IsActive).FirstOrDefault(); var existBillingInfo = billingInfoManager.GetById(billingInfoExist.Id); existBillingInfo.IsActive = true; existBillingInfo.UpdatedBy = Log.UserId.ToString(); existBillingInfo.UpdatedOn = new LoginInfo().CurrentTime; existBillingInfo.CurrentDuesRent = existBillingInfo.CurrentDuesRent - CurrentDues; existBillingInfo.CurrentDuesRent = Math.Abs(existBillingInfo.CurrentDuesRent); existBillingInfo.CurrentDuesCommon = existBillingInfo.CurrentDuesCommon - CommonDues; existBillingInfo.CurrentDuesCommon = Math.Abs(existBillingInfo.CurrentDuesCommon); billingInfoManager.SaveOrUpdateDelete(existBillingInfo); } return(Repository.Done()); }
public bool Updating(BillingReceivedInfo entity) { var exist = Repository.GetById(entity.Id); BillingInfoPerMonth billingInfo = new BillingInfoPerMonth(); BillingInfoPerMonthManager billingInfoManager = new BillingInfoPerMonthManager(); billingInfo.Month = Convert.ToString(entity.Date.Month); billingInfo.Year = Convert.ToString(entity.Date.Year); billingInfo.TenantInfoId = entity.TenantInfoId; var dateYearExist = billingInfoManager.GetAll().Where(x => x.Month == billingInfo.Month && x.Year == billingInfo.Year && x.TenantInfoId == billingInfo.TenantInfoId && x.IsActive).LastOrDefault(); if (exist != null) { entity.CreatedBy = exist.CreatedBy; entity.CreatedOn = exist.CreatedOn; entity.IsActive = exist.IsActive; entity.UpdatedBy = Log.UserId.ToString(); entity.UpdatedOn = new LoginInfo().CurrentTime; Repository.SaveOrUpdate(entity); if (entity.Purpose == "Rent") { billingInfo.RentBill = entity.Amount + dateYearExist.RentBill; billingInfo.CommonBill = dateYearExist.CommonBill; billingInfo.ElectricityBill = dateYearExist.ElectricityBill; billingInfo.EmElectricityBill = dateYearExist.EmElectricityBill; billingInfo.WasaBill = dateYearExist.WasaBill; } else if (entity.Purpose == "Common Bill") { billingInfo.CommonBill = entity.Amount + dateYearExist.CommonBill; billingInfo.RentBill = dateYearExist.RentBill; billingInfo.ElectricityBill = dateYearExist.ElectricityBill; billingInfo.EmElectricityBill = dateYearExist.EmElectricityBill; billingInfo.WasaBill = dateYearExist.WasaBill; } else if (entity.Purpose == "Electricity Bill") { billingInfo.ElectricityBill = entity.Amount + dateYearExist.ElectricityBill; billingInfo.RentBill = dateYearExist.RentBill; billingInfo.CommonBill = dateYearExist.CommonBill; billingInfo.EmElectricityBill = dateYearExist.EmElectricityBill; billingInfo.WasaBill = dateYearExist.WasaBill; } else if (entity.Purpose == "Emergency Electricity Bill") { billingInfo.EmElectricityBill = entity.Amount + dateYearExist.EmElectricityBill; billingInfo.RentBill = dateYearExist.RentBill; billingInfo.CommonBill = dateYearExist.CommonBill; billingInfo.ElectricityBill = dateYearExist.ElectricityBill; billingInfo.WasaBill = dateYearExist.WasaBill; } else { billingInfo.WasaBill = entity.Amount + dateYearExist.WasaBill; billingInfo.RentBill = dateYearExist.RentBill; billingInfo.CommonBill = dateYearExist.CommonBill; billingInfo.ElectricityBill = dateYearExist.ElectricityBill; billingInfo.EmElectricityBill = dateYearExist.EmElectricityBill; } billingInfo.Id = dateYearExist.Id; billingInfo.CurrentDuesRent = dateYearExist.CurrentDuesRent; billingInfo.CurrentDuesCommon = dateYearExist.CurrentDuesCommon; billingInfo.CurrentDuesElectricity = dateYearExist.CurrentDuesElectricity; billingInfo.CurrentDuesEmElectricity = dateYearExist.CurrentDuesEmElectricity; billingInfo.CurrentDuesWasa = dateYearExist.CurrentDuesWasa; billingInfo.OpeningBalanceRent = dateYearExist.OpeningBalanceRent; billingInfo.OpeningBalanceCommon = dateYearExist.OpeningBalanceCommon; billingInfo.OpeningBalanceElectricity = dateYearExist.OpeningBalanceElectricity; billingInfo.OpeningBalanceEmElectricity = dateYearExist.OpeningBalanceEmElectricity; billingInfo.OpeningBalanceWasa = dateYearExist.OpeningBalanceWasa; billingInfo.RemarksRent = dateYearExist.RemarksRent; billingInfo.RemarksCommon = dateYearExist.RemarksCommon; billingInfo.RemarksElectricity = dateYearExist.RemarksElectricity; billingInfo.RemarksEmElectricity = dateYearExist.RemarksEmElectricity; billingInfo.RemarksWasa = dateYearExist.RemarksWasa; billingInfo.CreatedBy = dateYearExist.CreatedBy; billingInfo.CreatedOn = dateYearExist.CreatedOn; billingInfo.UpdatedBy = Log.UserId.ToString(); billingInfo.UpdatedOn = System.DateTime.Now; billingInfo.IsActive = true; billingInfoManager.SaveOrUpdate(billingInfo); } return(Repository.Done()); }