public static IRoomBilling CreateRoomBillingFromDataRow(DataRow dr, bool isTemp) { // Using Convert.ToDecimal because values can be either decimal or double depending on if they are from RoomBilling or RoomBillingTemp. IRoomBilling item = CreateRoomBillingItem(isTemp); item.RoomBillingID = 0; item.Period = dr.Field <DateTime>("Period"); item.ClientID = dr.Field <int>("ClientID"); item.RoomID = dr.Field <int>("RoomID"); item.AccountID = dr.Field <int>("AccountID"); item.ChargeTypeID = dr.Field <int>("ChargeTypeID"); item.BillingTypeID = dr.Field <int>("BillingTypeID"); item.OrgID = dr.Field <int>("OrgID"); item.ChargeDays = Convert.ToDecimal(dr["ChargeDays"]); item.PhysicalDays = Convert.ToDecimal(dr["PhysicalDays"]); item.AccountDays = Convert.ToDecimal(dr["AccountDays"]); item.Entries = Convert.ToDecimal(dr["Entries"]); item.Hours = Convert.ToDecimal(dr["Hours"]); item.IsDefault = GetValueOrDefault(dr, "IsDefault", false); //column may not be present item.RoomRate = dr.Field <decimal>("RoomRate"); item.EntryRate = dr.Field <decimal>("EntryRate"); item.MonthlyRoomCharge = dr.Field <decimal>("MonthlyRoomCharge"); item.RoomCharge = dr.Field <decimal>("RoomCharge"); item.EntryCharge = dr.Field <decimal>("EntryCharge"); item.SubsidyDiscount = GetValueOrDefault(dr, "SubsidyDiscount", 0M); //column may not be present return(item); }
internal static decimal GetLineCost(IRoomBilling item) { int cleanRoomId = 6; int organicsBayId = 6; // [2015-11-13 jg] this is identical to the logic originally in: // 1) sselFinOps.AppCode.BLL.FormulaBL.ApplyRoomFormula (for External Invoice) // 2) sselIndReports.AppCode.Bll.RoomBillingBL.GetRoomBillingDataByClientID (for User Usage Summary) // 3) LNF.WebApi.Billing.Models.ReportUtility.ApplyRoomFormula (for SUB reports) decimal result; //1. Find out all Monthly type users and apply to Clean room if (BillingTypes.IsMonthlyUserBillingType(item.BillingTypeID)) { if (item.RoomID == cleanRoomId) //Clean Room { result = item.MonthlyRoomCharge; } else { result = item.TotalCharge; } } //2. The growers are charged with room fee only when they reserve and activate a tool else if (BillingTypes.IsGrowerUserBillingType(item.BillingTypeID)) { if (item.RoomID == organicsBayId) //Organics Bay { result = item.RoomCharge; //organics bay must be charged for growers as well } else { result = item.AccountDays * item.RoomRate + item.EntryCharge; } } else if (item.BillingTypeID == BillingTypes.Other) { result = 0; } else if (item.BillingTypeID == BillingTypes.Grower_Observer) { result = item.TotalCharge; } else { //Per Use types result = item.TotalCharge; } return(result); }
internal static void CalculateRoomLineCost(DataTable dt) { if (!dt.Columns.Contains("LineCost")) { dt.Columns.Add("LineCost", typeof(decimal)); } if (!dt.Columns.Contains("DailyFee")) { dt.Columns.Add("DailyFee", typeof(decimal)); } if (!dt.Columns.Contains("EntryFee")) { dt.Columns.Add("EntryFee", typeof(decimal)); } if (!dt.Columns.Contains("Room")) { dt.Columns.Add("Room", typeof(string)); } foreach (DataRow dr in dt.Rows) { IRoomBilling item = RoomBillingRepository.CreateRoomBillingFromDataRow(dr, false); dr.SetField("Room", Rooms.GetRoomDisplayName(item.RoomID)); if (item.RoomCharge > 0) { dr.SetField("DailyFee", item.RoomCharge); } if (item.EntryCharge > 0) { dr.SetField("EntryFee", item.EntryCharge); } dr.SetField("LineCost", GetLineCost(item)); } }
public static IOrg GetOrg(this IRoomBilling item) { return(ServiceProvider.Current.Data.Org.GetOrg(item.OrgID)); }
public static IAccount GetAccount(this IRoomBilling item) { return(ServiceProvider.Current.Data.Account.GetAccount(item.AccountID)); }
public decimal GetLineCost(IRoomBilling item) { throw new NotImplementedException(); }
/// <summary> /// The final billed amount based on BillingType and Room. /// </summary> public decimal GetLineCost(IRoomBilling item) => RoomBillingUtility.GetLineCost(item);
/*===== Room ============================================================================*/ public static RoomBillingItem CreateRoomBillingItem(this IRoomBilling item) => CreateRoomBillingItems(Utility.ToQueryable(item)).FirstOrDefault();