Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public static void ApplyRoomFormula(DataTable dt)
        {
            if (!dt.Columns.Contains("LineCost"))
            {
                dt.Columns.Add("LineCost", typeof(double));
            }

            int billingTypeId;
            int roomId = 0;

            foreach (DataRow dr in dt.Rows)
            {
                billingTypeId = dr.Field <int>("BillingTypeID");
                roomId        = dr.Field <int>("RoomID");

                //1. Find out all Monthly type users and apply to Clean room
                if (BillingTypes.IsMonthlyUserBillingType(billingTypeId))
                {
                    if (roomId == 6)
                    {
                        dr["LineCost"] = dr.Field <decimal>("MonthlyRoomCharge");
                    }
                    else
                    {
                        dr["LineCost"] = dr.Field <decimal>("RoomCharge") + dr.Field <decimal>("EntryCharge");
                    }
                }
                //2. The growers are charged with room fee only when they reserve and activate a tool
                else if (BillingTypes.IsGrowerUserBillingType(billingTypeId))
                {
                    if (roomId == 4)
                    {
                        dr["LineCost"] = dr.Field <decimal>("RoomCharge"); //Organics bay must be charged for growers as well
                    }
                    else
                    {
                        dr["LineCost"] = (dr.Field <decimal>("AccountDays") * dr.Field <decimal>("RoomRate")) + dr.Field <decimal>("EntryCharge");
                    }
                }
                else if (billingTypeId == BillingTypes.Other)
                {
                    dr["LineCost"] = 0;
                }
                else
                {
                    //Per Use types
                    dr["LineCost"] = dr.Field <decimal>("RoomCharge") + dr.Field <decimal>("EntryCharge");
                }
            }
        }
        private DataTable GetRoomBillingDataByClientID(DateTime period, int clientId)
        {
            DataTable dt;

            if (period.Month == DateTime.Now.Month && period.Year == DateTime.Now.Year)
            {
                dt = RoomBillingDA.GetRoomBillingTempDataByClientID(period, clientId);
            }
            else
            {
                dt = RoomBillingDA.GetRoomBillingDataByClientID(period, clientId);
            }

            if (!dt.Columns.Contains("LineCost"))
            {
                dt.Columns.Add("LineCost", typeof(double));
            }

            // Part I: Get the true cost based on billing types
            foreach (DataRow dr in dt.Rows)
            {
                int billingTypeId = dr.Field <int>("BillingTypeID");
                var room          = Rooms.GetRoom(dr.Field <int>("RoomID"));

                if (billingTypeId == BillingTypes.Other)
                {
                    dr["LineCost"] = 0;
                }
                else if (BillingTypes.IsGrowerUserBillingType(billingTypeId))
                {
                    if (room == LabRoom.OrganicsBay)
                    {
                        //Organics bay must be charged for growers as well
                        dr["LineCost"] = dr.Field <decimal>("RoomCharge");
                    }
                    else
                    {
                        dr["LineCost"] = dr.Field <decimal>("AccountDays") * dr.Field <decimal>("RoomRate") + dr.Field <decimal>("EntryCharge");
                    }
                }
                else
                {
                    //Per Use types
                    dr["LineCost"] = dr.Field <decimal>("RoomCharge") + dr.Field <decimal>("EntryCharge");
                }
            }

            return(dt);
        }
Esempio n. 4
0
        public static void ApplyRoomFormula(DataTable dtIn)
        {
            int billingTypeId;
            LabRoom room;

            foreach (DataRow dr in dtIn.Rows)
            {
                billingTypeId = dr.Field<int>("BillingTypeID");
                room = (LabRoom)dr.Field<int>("RoomID");

                //1. Find out all Monthly type users and apply to Clean room
                if (BillingTypes.IsMonthlyUserBillingType(billingTypeId))
                {
                    if (room == LabRoom.CleanRoom)
                        dr["LineCost"] = dr["MonthlyRoomCharge"];
                    else
                        dr["LineCost"] = dr.Field<decimal>("RoomCharge") + dr.Field<decimal>("EntryCharge");
                }
                //2. The growers are charged with room fee only when they reserve and activate a tool
                else if (BillingTypes.IsGrowerUserBillingType(billingTypeId))
                {
                    if (room == LabRoom.Organics)
                    {
                        //Organics bay must be charged for growers as well
                        dr["LineCost"] = dr["RoomCharge"];
                    }
                    else
                        dr["LineCost"] = (dr.Field<decimal>("AccountDays") * dr.Field<decimal>("RoomRate")) + dr.Field<decimal>("EntryCharge");
                }
                else if (billingTypeId == BillingTypes.Other)
                {
                    dr["LineCost"] = 0;
                }
                else
                {
                    //Per Use types
                    dr["LineCost"] = dr.Field<decimal>("RoomCharge") + dr.Field<decimal>("EntryCharge");
                }
            }
        }