Skip to content

Commit 53b1455

Browse files
Instrument scheduling improvements (#1116)
1 parent 7163d21 commit 53b1455

24 files changed

+963
-240
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2019 LabKey Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
SELECT
17+
Project.Id AS ProjectID,
18+
Project.LabDirector AS LabDirector,
19+
InstrumentOperator.DisplayName AS Researcher,
20+
i.Instrument.Name AS Instrument,
21+
Name AS RequestedBy,
22+
i.Id AS UsageBlockID,
23+
StartTime AS StartDate,
24+
EndTime AS EndDate,
25+
TIMESTAMPDIFF('SQL_TSI_HOUR', StartTime, EndTime) AS Hours,
26+
ir.Fee,
27+
ir.rateType.setupFee AS Setup_Cost,
28+
TIMESTAMPDIFF('SQL_TSI_HOUR', StartTime, EndTime) * ir.Fee + ir.rateType.setupFee AS TotalCost,
29+
iup.PaymentMethod.UWBudgetNumber AS Payment_Method,
30+
iup.PaymentMethod.Name AS Payment_Method_Name,
31+
iup.PercentPayment
32+
33+
FROM targetedms.InstrumentSchedule i
34+
LEFT OUTER JOIN targetedms.InstrumentRate ir ON i.Instrument = ir.Instrument
35+
LEFT OUTER JOIN targetedms.InstrumentUsagePayment iup ON i.Id = iup.InstrumentScheduleId
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2019 LabKey Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
PARAMETERS(StartBillDate TIMESTAMP)
17+
SELECT
18+
ProjectID,
19+
LabDirector,
20+
Researcher,
21+
Instrument,
22+
RequestedBy,
23+
UsageBlockID,
24+
StartDate,
25+
EndDate,
26+
Hours,
27+
HoursInRange,
28+
Fee,
29+
Setup_Cost,
30+
TotalCost,
31+
Payment_Method,
32+
Payment_Method_Name,
33+
PercentPayment,
34+
((HoursInRange * Fee + Setup_Cost) * PercentPayment / 100) AS AmountBilled
35+
36+
FROM
37+
(SELECT
38+
*,
39+
TIMESTAMPDIFF('SQL_TSI_HOUR',
40+
CASE WHEN StartDate <= StartBillDate THEN StartBillDate ELSE StartDate END,
41+
CASE WHEN EndDate >= TIMESTAMPADD('SQL_TSI_MONTH', 1, StartBillDate) THEN TIMESTAMPADD('SQL_TSI_MONTH', 1, StartBillDate) ELSE EndDate END
42+
) AS HoursInRange
43+
44+
FROM targetedms.InstrumentBilling i
45+
WHERE (StartDate >= StartBillDate AND StartDate <= TIMESTAMPADD('SQL_TSI_MONTH', 1, StartBillDate)) OR
46+
(EndDate >= StartBillDate AND EndDate <= TIMESTAMPADD('SQL_TSI_MONTH', 1, StartBillDate)) OR
47+
(StartDate <= StartBillDate AND EndDate >= TIMESTAMPADD('SQL_TSI_MONTH', 1, StartBillDate))
48+
) X
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="instrumentBilling" tableDbType="TABLE">
5+
<columns>
6+
<column columnName="Hours">
7+
<formatString>0.0</formatString>
8+
</column>
9+
<column columnName="TotalCost">
10+
<formatString>$#,##0.00</formatString>
11+
</column>
12+
</columns>
13+
</table>
14+
</tables>
15+
</metadata>
16+
</query>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<customView xmlns="http://labkey.org/data/xml/queryCustomView" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2+
<columns>
3+
<column name="Instrument" />
4+
<column name="LabDirector" />
5+
<column name="Researcher" />
6+
<column name="RequestedBy" />
7+
<column name="StartDate" />
8+
<column name="EndDate" />
9+
<column name="Hours" />
10+
<column name="TotalCost" />
11+
<column name="Payment_Method_Name" />
12+
<column name="PercentPayment" />
13+
</columns>
14+
<sorts>
15+
<sort column="StartDate" descending="true" />
16+
</sorts>
17+
</customView>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="instrumentBillingByMonth" tableDbType="TABLE">
5+
<columns>
6+
<column columnName="HoursInRange">
7+
<formatString>0.0</formatString>
8+
</column>
9+
<column columnName="AmountBilled">
10+
<formatString>$#,##0.00</formatString>
11+
</column>
12+
</columns>
13+
</table>
14+
</tables>
15+
</metadata>
16+
</query>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="instrumentSchedule" tableDbType="TABLE">
5+
<columns>
6+
<column columnName="InstrumentOperator">
7+
<fk>
8+
<fkDbSchema>core</fkDbSchema>
9+
<fkTable>Users</fkTable>
10+
<fkColumnName>UserId</fkColumnName>
11+
<fkDisplayColumnName>DisplayName</fkDisplayColumnName>
12+
</fk>
13+
</column>
14+
</columns>
15+
</table>
16+
</tables>
17+
</metadata>
18+
</query>

resources/queries/targetedms/msProject.query.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<column columnName="Id">
77
<url>/targetedms-msProjectDetails.view?project=${Id}</url>
88
</column>
9+
<column columnName="Title">
10+
<url>/targetedms-msProjectDetails.view?project=${Id}</url>
11+
</column>
912
</columns>
1013
</table>
1114
</tables>

resources/queries/targetedms/paymentMethodCostSummary.query.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

resources/queries/targetedms/paymentMethodCostSummary.sql

Lines changed: 0 additions & 17 deletions
This file was deleted.

resources/queries/targetedms/userProjects.query.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
<tables xmlns="http://labkey.org/data/xml">
44
<table tableName="userProjects" tableDbType="TABLE">
55
<columns>
6-
<column columnName="ViewLink">
7-
<columnTitle></columnTitle>
8-
<url>/targetedms-msProjectDetails.view?project=${Id}</url>
9-
</column>
106
</columns>
117
</table>
128
</tables>

0 commit comments

Comments
 (0)