Exemplo n.º 1
0
        public ExternalInvoiceUsage GetMiscUsage()
        {
            var dt = Command()
                     .Param("Action", "ForInvoice")
                     .Param("StartPeriod", StartDate)
                     .Param("EndPeriod", EndDate)
                     .Param("IsInternal", false)
                     .Param("AccountID", AccountID > 0, AccountID)
                     .FillDataTable("dbo.MiscBillingCharge_Select");

            dt.Columns.Add("LineCost", typeof(double), "Quantity * Cost");

            var result = new ExternalInvoiceUsage();

            //Aggregate the report based on ClientID
            foreach (DataRow dr in dt.Rows)
            {
                ValidPeriodCheck(dr, Misc);
                double totalFee = Convert.ToDouble(dr.Field <decimal>("Cost"));
                string desc     = ExternalInvoiceUtility.GetMiscDescription(dr);
                result.Add(ExternalInvoiceUtility.CreateInvoiceLineItem(dr, dr.Field <double>("Quantity"), totalFee, desc));
            }

            return(result);
        }
Exemplo n.º 2
0
        public ExternalInvoiceUsage GetExternalRoomUsage()
        {
            var ds = Command()
                     .Param("Action", "ForInvoice")
                     .Param("StartPeriod", StartDate)
                     .Param("EndPeriod", EndDate)
                     .Param("IsInternal", false)
                     .Param("AccountID", AccountID > 0, AccountID)
                     .Param("BillingTypeID", !ShowRemote, BillingTypes.Remote)
                     .FillDataSet("dbo.RoomApportionmentInDaysMonthly_Select");

            ds.Tables[0].Columns.Add("LineCost", typeof(double));

            //Calculate the true cost based on billing types
            BillingTypeRepository.CalculateRoomLineCost(ds.Tables[0]);

            DataTable dt       = ds.Tables[0];
            DataTable dtClient = ds.Tables[1];

            var result = new ExternalInvoiceUsage();

            //Aggregate the report based on ClientID
            foreach (DataRow dr in dtClient.Rows)
            {
                ValidPeriodCheck(dr, Room);
                string    filter   = GetFilter(dr);
                double    totalFee = Convert.ToDouble(dt.Compute("SUM(LineCost)", filter));
                DataRow[] rows     = dt.Select(filter);
                string    desc     = ExternalInvoiceUtility.GetRoomDescription(rows[0]);
                result.Add(ExternalInvoiceUtility.CreateInvoiceLineItem(rows[0], 1, totalFee, desc));
            }

            return(result);
        }
Exemplo n.º 3
0
        public ExternalInvoiceUsage GetStoreUsage()
        {
            var ds = Command()
                     .Param("Action", "ForInvoice")
                     .Param("StartPeriod", StartDate)
                     .Param("EndPeriod", EndDate)
                     .Param("IsInternal", false)
                     .Param("AccountID", AccountID > 0, AccountID)
                     .FillDataSet("dbo.StoreBilling_Select");

            var dt       = ds.Tables[0];
            var dtClient = ds.Tables[1];

            var result = new ExternalInvoiceUsage();

            //Aggregate the report based on ClientID
            foreach (DataRow dr in dtClient.Rows)
            {
                ValidPeriodCheck(dr, Store);
                string    filter   = GetFilter(dr);
                double    totalFee = Convert.ToDouble(dt.Compute("SUM(LineCost)", filter));
                DataRow[] rows     = dt.Select(filter);
                string    desc     = ExternalInvoiceUtility.GetStoreDescription(rows[0]);
                result.Add(ExternalInvoiceUtility.CreateInvoiceLineItem(rows[0], 1, totalFee, desc));
            }

            return(result);
        }
Exemplo n.º 4
0
        public ExternalInvoiceUsage GetToolUsage()
        {
            var ds = Command()
                     .Param("Action", "ForInvoice")
                     .Param("StartPeriod", StartDate)
                     .Param("EndPeriod", EndDate)
                     .Param("IsInternal", false)
                     .Param("AccountID", AccountID > 0, AccountID)
                     .Param("BillingTypeID", !ShowRemote, BillingTypes.Remote)
                     .FillDataSet("dbo.ToolBilling_Select");

            // It will return a dataset with two tables inside
            // table #1: the data table contains individual tool usage
            // table #2: the client table contains all users who has used the tools on this account

            ds.Tables[0].Columns.Add("LineCost", typeof(double));

            //Calculate the true cost based on billing types
            BillingTypeRepository.CalculateToolLineCost(ds.Tables[0]);

            var dt       = ds.Tables[0];
            var dtClient = ds.Tables[1];

            var result = new ExternalInvoiceUsage();

            //Aggregate the report based on ClientID
            foreach (DataRow dr in dtClient.Rows)
            {
                ValidPeriodCheck(dr, Tool);
                string    filter   = GetFilter(dr);
                double    totalFee = Convert.ToDouble(dt.Compute("SUM(LineCost)", filter));
                DataRow[] rows     = dt.Select(filter);
                string    desc     = ExternalInvoiceUtility.GetToolDescription(rows[0]);
                result.Add(ExternalInvoiceUtility.CreateInvoiceLineItem(rows[0], 1, totalFee, desc));
            }

            return(result);
        }