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); }
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); }