diff --git a/WNPRC_EHR/resources/views/wnprcUnits.html b/WNPRC_EHR/resources/views/wnprcUnits.html
index 44880afb1..e5c9551b8 100644
--- a/WNPRC_EHR/resources/views/wnprcUnits.html
+++ b/WNPRC_EHR/resources/views/wnprcUnits.html
@@ -97,7 +97,9 @@
]},
{header: 'Purchasing Services',
items: [
- {name: 'Issue Tracker', url: '<%=contextPath%>/project/WNPRC/WNPRC_Units/Operation_Services/Purchasing/Issue_Tracker/start.view?'}
+ {name: 'Issue Tracker', url: '<%=contextPath%>/project/WNPRC/WNPRC_Units/Operation_Services/Purchasing/Issue_Tracker/start.view?'},
+ {name: 'Purchasing Requests', url: '<%=contextPath%>/WNPRC/WNPRC_Units/Operation_Services/Purchasing/WNPRC_Purchasing-requester.view?'},
+ {name: 'Purchasing Admin', url: '<%=contextPath%>/WNPRC/WNPRC_Units/Operation_Services/Purchasing/WNPRC_Purchasing-purchaseAdmin.view?'}
]}
]
});
diff --git a/WNPRC_Purchasing/resources/data/paymentOptions.tsv b/WNPRC_Purchasing/resources/data/paymentOptions.tsv
new file mode 100644
index 000000000..23754406d
--- /dev/null
+++ b/WNPRC_Purchasing/resources/data/paymentOptions.tsv
@@ -0,0 +1,7 @@
+paymentOption
+Internal PO
+External PO
+MDS
+Blanket Order
+Direct Payment
+Purchasing Card
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/lineItems/.qview.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/lineItems/.qview.xml
new file mode 100644
index 000000000..883803ca1
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/lineItems/.qview.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/myOpenRequests.query.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/myOpenRequests.query.xml
new file mode 100644
index 000000000..a4c61646b
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/myOpenRequests.query.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/myOpenRequests.sql b/WNPRC_Purchasing/resources/queries/ehr_purchasing/myOpenRequests.sql
new file mode 100644
index 000000000..fe08bddef
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/myOpenRequests.sql
@@ -0,0 +1,12 @@
+-- open requests assigned to the current purchase admin user
+SELECT
+ pr.rowId AS requestNum,
+ pr.created AS requestDate,
+ pr.vendorId,
+ pr.totalCost,
+ pr.account || pr.otherAcctAndInves AS account,
+ pr.qcState AS requestStatus,
+ pr.createdBy AS requester,
+ pr.assignedTo
+FROM ehr_purchasing.purchasingRequests pr
+WHERE ISMEMBEROF(pr.assignedTo)
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/pCard.query.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/pCard.query.xml
new file mode 100644
index 000000000..cb80a55d7
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/pCard.query.xml
@@ -0,0 +1,55 @@
+
+
+
+
+ P-Card View
+
+
+ Vendor
+ false
+
+ ehr_purchasing
+ vendor
+
+
+
+
+ Business purpose
+
+
+ yyyy-MM-dd
+
+
+ yyyy-MM-dd
+ Post Date
+
+
+ ###,##0.00
+
+
+ Acct code
+
+ ehr_billingLinked
+ aliases
+
+
+
+ Prog
+
+
+ Requested by
+
+
+ Notes/Internal Ref#
+
+
+ Invoice No
+
+
+ Payment Option
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/pCard.sql b/WNPRC_Purchasing/resources/queries/ehr_purchasing/pCard.sql
new file mode 100644
index 000000000..e4e0ec210
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/pCard.sql
@@ -0,0 +1,25 @@
+SELECT
+ pr.vendorId,
+ items.description,
+ pr.justification,
+ pr.orderDate,
+ pr.cardPostDate,
+ pr.totalCost,
+ pr.account,
+
+ pr.program,
+ pr.createdBy,
+ pr.comments,
+ pr.rowId AS orderNum,
+ pr.invoiceNum,
+ pr.paymentOptionId
+
+FROM ehr_purchasing.purchasingRequests pr
+LEFT JOIN
+ (
+ SELECT requestRowId,
+ group_concat(item, ', ') AS description
+ FROM ehr_purchasing.lineItems
+ GROUP BY requestRowId
+ ) items
+ON pr.rowId = items.requestRowId
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/pCard/.qview.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/pCard/.qview.xml
new file mode 100644
index 000000000..e1976beca
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/pCard/.qview.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequests.query.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequests.query.xml
index 75b385205..8bd04f8ec 100644
--- a/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequests.query.xml
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequests.query.xml
@@ -47,10 +47,10 @@
false
-
+
wnprc_purchasing
- creditCardOptions
+ paymentOptions
rowId
@@ -59,6 +59,13 @@
+
+
+ core
+ Users
+ UserId
+
+
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverview.sql b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverview.sql
index 4b4325149..c40e1c6c4 100644
--- a/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverview.sql
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverview.sql
@@ -1,3 +1,4 @@
+-- this is the query that displays on the requesters page
SELECT
pr.rowId,
pr.vendorId,
@@ -6,14 +7,6 @@ SELECT
pr.qcState AS requestStatus,
pr.created AS requestDate,
pr.createdBy AS requester,
- items.totalCost
+ pr.totalCost
FROM ehr_purchasing.purchasingRequests pr
-LEFT JOIN
- (
- SELECT requestRowId,
- round(sum(quantity * unitCost), 2) AS totalCost
- FROM ehr_purchasing.lineItems
- GROUP BY requestRowId
- ) items
-ON pr.rowId = items.requestRowId
-WHERE ISMEMBEROF(pr.createdBy)
\ No newline at end of file
+WHERE ISMEMBEROF(pr.createdBy) -- only sees requests created by the current user/requester
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins.query.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins.query.xml
new file mode 100644
index 000000000..eb7f7bec1
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins.query.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins.sql b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins.sql
new file mode 100644
index 000000000..7c464388f
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins.sql
@@ -0,0 +1,11 @@
+SELECT
+ pr.rowId AS requestNum,
+ pr.vendorId,
+ pr.account,
+ pr.otherAcctAndInves,
+ pr.qcState AS requestStatus,
+ pr.created AS requestDate,
+ pr.createdBy AS requester,
+ pr.totalCost,
+ pr.assignedTo
+FROM ehr_purchasing.purchasingRequests pr
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins/AllOpenRequests.qview.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins/AllOpenRequests.qview.xml
new file mode 100644
index 000000000..d0ae0bd3d
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins/AllOpenRequests.qview.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins/CompletedRequests.qview.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins/CompletedRequests.qview.xml
new file mode 100644
index 000000000..c2b7790ed
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/purchasingRequestsOverviewForAdmins/CompletedRequests.qview.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/shippingInfo/.qview.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/shippingInfo/.qview.xml
new file mode 100644
index 000000000..2fd5ea9b4
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/shippingInfo/.qview.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/userAccountAssociations/.qview.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/userAccountAssociations/.qview.xml
new file mode 100644
index 000000000..91ed1df35
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/userAccountAssociations/.qview.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/queries/ehr_purchasing/vendor/.qview.xml b/WNPRC_Purchasing/resources/queries/ehr_purchasing/vendor/.qview.xml
new file mode 100644
index 000000000..d75374fa1
--- /dev/null
+++ b/WNPRC_Purchasing/resources/queries/ehr_purchasing/vendor/.qview.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/schemas/dbscripts/postgresql/wnprc_purchasing-21.001-21.002.sql b/WNPRC_Purchasing/resources/schemas/dbscripts/postgresql/wnprc_purchasing-21.001-21.002.sql
new file mode 100644
index 000000000..453099e48
--- /dev/null
+++ b/WNPRC_Purchasing/resources/schemas/dbscripts/postgresql/wnprc_purchasing-21.001-21.002.sql
@@ -0,0 +1,17 @@
+DROP TABLE wnprc_purchasing.creditCardOptions;
+
+CREATE TABLE wnprc_purchasing.paymentOptions
+(
+ rowId serial,
+ paymentOption varchar(500),
+ container ENTITYID NOT NULL,
+ createdBy USERID,
+ created timestamp,
+ modifiedBy USERID,
+ modified timestamp,
+
+ CONSTRAINT PK_WNPRC_PURCHASING_PAYMENT_OPTIONS PRIMARY KEY (rowId),
+ CONSTRAINT FK_WNPRC_PURCHASING_PAYMENT_OPTIONS_CONTAINER FOREIGN KEY (Container) REFERENCES core.Containers (EntityId)
+);
+
+CREATE INDEX IDX_WNPRC_PURCHASING_PAYMENT_OPTIONS_CONTAINER ON wnprc_purchasing.paymentOptions(Container);
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/schemas/ehr_billingLinked.template.xml b/WNPRC_Purchasing/resources/schemas/ehr_billingLinked.template.xml
new file mode 100644
index 000000000..8a1ce775e
--- /dev/null
+++ b/WNPRC_Purchasing/resources/schemas/ehr_billingLinked.template.xml
@@ -0,0 +1,10 @@
+
+
+
+
+ aliases
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/schemas/wnprc_purchasing.xml b/WNPRC_Purchasing/resources/schemas/wnprc_purchasing.xml
index 4fb769561..9dcf2b101 100644
--- a/WNPRC_Purchasing/resources/schemas/wnprc_purchasing.xml
+++ b/WNPRC_Purchasing/resources/schemas/wnprc_purchasing.xml
@@ -1,13 +1,13 @@
-
- Credit Card Options
- cardOption
+
+ Payment Options
+ paymentOption
DETAILED
-
+
diff --git a/WNPRC_Purchasing/resources/views/purchasingAdmin.html b/WNPRC_Purchasing/resources/views/purchasingAdmin.html
new file mode 100644
index 000000000..834287598
--- /dev/null
+++ b/WNPRC_Purchasing/resources/views/purchasingAdmin.html
@@ -0,0 +1,62 @@
+
+
+
+Purchasing Requests
+
+
+
+
+
+
+
+Reference Tables
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/views/purchasingAdmin.view.xml b/WNPRC_Purchasing/resources/views/purchasingAdmin.view.xml
new file mode 100644
index 000000000..190b76cb7
--- /dev/null
+++ b/WNPRC_Purchasing/resources/views/purchasingAdmin.view.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/views/purchasingLandingPage.webpart.xml b/WNPRC_Purchasing/resources/views/purchasingAdmin.webpart.xml
similarity index 71%
rename from WNPRC_Purchasing/resources/views/purchasingLandingPage.webpart.xml
rename to WNPRC_Purchasing/resources/views/purchasingAdmin.webpart.xml
index e0921a2a7..162009505 100644
--- a/WNPRC_Purchasing/resources/views/purchasingLandingPage.webpart.xml
+++ b/WNPRC_Purchasing/resources/views/purchasingAdmin.webpart.xml
@@ -1,5 +1,5 @@
-
-
+
+
diff --git a/WNPRC_Purchasing/resources/views/purchasingLanding.html b/WNPRC_Purchasing/resources/views/purchasingLanding.html
new file mode 100644
index 000000000..ee02293db
--- /dev/null
+++ b/WNPRC_Purchasing/resources/views/purchasingLanding.html
@@ -0,0 +1,16 @@
+
+
+
+WNPRC Purchasing Portal
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/views/purchasingLandingPage.view.xml b/WNPRC_Purchasing/resources/views/purchasingLanding.view.xml
similarity index 100%
rename from WNPRC_Purchasing/resources/views/purchasingLandingPage.view.xml
rename to WNPRC_Purchasing/resources/views/purchasingLanding.view.xml
diff --git a/WNPRC_Purchasing/resources/views/purchasingLanding.webpart.xml b/WNPRC_Purchasing/resources/views/purchasingLanding.webpart.xml
new file mode 100644
index 000000000..59c87eccc
--- /dev/null
+++ b/WNPRC_Purchasing/resources/views/purchasingLanding.webpart.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/views/purchasingLandingPage.html b/WNPRC_Purchasing/resources/views/purchasingRequester.html
similarity index 95%
rename from WNPRC_Purchasing/resources/views/purchasingLandingPage.html
rename to WNPRC_Purchasing/resources/views/purchasingRequester.html
index 282e72e4f..ca6186655 100644
--- a/WNPRC_Purchasing/resources/views/purchasingLandingPage.html
+++ b/WNPRC_Purchasing/resources/views/purchasingRequester.html
@@ -12,7 +12,7 @@
LABKEY.QueryWebPart.standardButtons.exportRows,
LABKEY.QueryWebPart.standardButtons.print,
LABKEY.QueryWebPart.standardButtons.pageSize,
- {text: 'Create Request', url: LABKEY.ActionURL.buildURL('WNPRC_Purchasing', 'purchasingRequest', null, {isNewRequest: true})}
+ {text: 'Create Request', url: LABKEY.ActionURL.buildURL('WNPRC_Purchasing', 'purchasingRequest', null, {isNewRequest: true, returnUrl:window.location})}
]}
});
qwp.render();
diff --git a/WNPRC_Purchasing/resources/views/purchasingRequester.view.xml b/WNPRC_Purchasing/resources/views/purchasingRequester.view.xml
new file mode 100644
index 000000000..e702c0006
--- /dev/null
+++ b/WNPRC_Purchasing/resources/views/purchasingRequester.view.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/resources/views/purchasingRequester.webpart.xml b/WNPRC_Purchasing/resources/views/purchasingRequester.webpart.xml
new file mode 100644
index 000000000..38b9c0893
--- /dev/null
+++ b/WNPRC_Purchasing/resources/views/purchasingRequester.webpart.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WNPRC_Purchasing/src/client/RequestEntry/RequestEntry.scss b/WNPRC_Purchasing/src/client/RequestEntry/RequestEntry.scss
index ae70114c0..9e7c4580e 100644
--- a/WNPRC_Purchasing/src/client/RequestEntry/RequestEntry.scss
+++ b/WNPRC_Purchasing/src/client/RequestEntry/RequestEntry.scss
@@ -74,7 +74,7 @@
white-space: pre-wrap;
}
-.account-input, .vendor-input, .shipping-dest-input, .assigned-to-input, .credit-card-option-input, .status-input {
+.account-input, .vendor-input, .shipping-dest-input, .assigned-to-input, .payment-option-input, .status-input {
resize: none;
width: 140%;
}
diff --git a/WNPRC_Purchasing/src/client/RequestEntry/RequestEntry.tsx b/WNPRC_Purchasing/src/client/RequestEntry/RequestEntry.tsx
index 695891d6f..ccfeda558 100644
--- a/WNPRC_Purchasing/src/client/RequestEntry/RequestEntry.tsx
+++ b/WNPRC_Purchasing/src/client/RequestEntry/RequestEntry.tsx
@@ -81,7 +81,7 @@ export const App: FC = memo(() => {
setPurchaseAdminModel(
PurchaseAdminModel.create({
assignedTo: vals[0].assignedTo,
- creditCardOption: vals[0].creditCardOptionId,
+ paymentOption: vals[0].paymentOptionId,
qcState: vals[0].qcState,
program: vals[0].program,
confirmationNum: vals[0].confirmationNum,
@@ -206,17 +206,8 @@ export const App: FC = memo(() => {
setIsDirty(false);
event.preventDefault();
const returnUrl = ActionURL.getParameter('returnUrl');
+ window.location.href = returnUrl || ActionURL.buildURL('project', 'begin', getServerContext().container.path);
- // TODO: this is temporary until purchasing admin page is created, then change it to get routed to the admin page
- if (!!requestId && hasPurchasingAdminPermission) {
- window.location.href = ActionURL.buildURL('query', 'executeQuery', getServerContext().container.path, {
- schemaName: 'ehr_purchasing',
- 'query.queryName': 'purchasingRequests',
- });
- } else {
- window.location.href =
- returnUrl || ActionURL.buildURL('project', 'begin', getServerContext().container.path);
- }
},
[isDirty, requestId, hasPurchasingAdminPermission]
);
@@ -238,22 +229,8 @@ export const App: FC = memo(() => {
)
.then(r => {
if (r.success) {
- // TODO: this is temporary until purchasing admin page is created, then change it to get routed to the admin page
- if (requestId) {
- window.location.href = ActionURL.buildURL(
- 'query',
- 'executeQuery',
- getServerContext().container.path,
- { schemaName: 'ehr_purchasing', 'query.queryName': 'purchasingRequests' }
- );
- } else {
- // navigate to purchasing overview grid/main page
- window.location.href = ActionURL.buildURL(
- 'project',
- 'begin',
- getServerContext().container.path
- );
- }
+ const returnUrl = ActionURL.getParameter('returnUrl');
+ window.location.href = returnUrl || ActionURL.buildURL('project', 'begin', getServerContext().container.path);
}
})
.catch(reject => {
diff --git a/WNPRC_Purchasing/src/client/actions.ts b/WNPRC_Purchasing/src/client/actions.ts
index de690844b..f45d6dd72 100644
--- a/WNPRC_Purchasing/src/client/actions.ts
+++ b/WNPRC_Purchasing/src/client/actions.ts
@@ -60,7 +60,7 @@ export async function submitRequest(
comments: requestOrder.comments,
qcState: purchasingAdminModel?.qcState || requestOrder.qcState,
assignedTo: purchasingAdminModel?.assignedTo,
- creditCardOption: purchasingAdminModel?.creditCardOption,
+ paymentOption: purchasingAdminModel?.paymentOption,
program: purchasingAdminModel?.program ? purchasingAdminModel.program : '4',
confirmNum: purchasingAdminModel?.confirmationNum,
invoiceNum: purchasingAdminModel?.invoiceNum,
diff --git a/WNPRC_Purchasing/src/client/components/PurchaseAdminPanel.tsx b/WNPRC_Purchasing/src/client/components/PurchaseAdminPanel.tsx
index 4b99dac8c..eb8c7d7f9 100644
--- a/WNPRC_Purchasing/src/client/components/PurchaseAdminPanel.tsx
+++ b/WNPRC_Purchasing/src/client/components/PurchaseAdminPanel.tsx
@@ -7,7 +7,7 @@ import { PurchaseAdminModel } from '../model';
import {
AssignedToInput,
- CreditCardOptionInput,
+ PaymentOptionInput,
ConfirmationInput,
InvoiceInput,
ProgramInput,
@@ -55,7 +55,7 @@ export const PurchaseAdminPanel: FC = memo(props => {
-
+
diff --git a/WNPRC_Purchasing/src/client/components/PurchaseAdminPanelInputs.tsx b/WNPRC_Purchasing/src/client/components/PurchaseAdminPanelInputs.tsx
index e0accdc75..7f7a89aee 100644
--- a/WNPRC_Purchasing/src/client/components/PurchaseAdminPanelInputs.tsx
+++ b/WNPRC_Purchasing/src/client/components/PurchaseAdminPanelInputs.tsx
@@ -49,30 +49,30 @@ export const AssignedToInput: FC = memo(props => {
);
});
-export const CreditCardOptionInput: FC = memo(props => {
+export const PaymentOptionInput: FC = memo(props => {
const { onChange, value, hasError } = props;
const [dropDownVals, setDropDownVals] = useState();
useEffect(() => {
- getData('wnprc_purchasing', 'creditCardOptions', 'rowId, cardOption', 'cardOption').then(vals => {
+ getData('wnprc_purchasing', 'paymentOptions', 'rowId, paymentOption', 'paymentOption').then(vals => {
setDropDownVals(vals);
});
}, []);
- const options = useMemo(() => createOptions(dropDownVals, 'rowId', 'cardOption'), [dropDownVals]);
+ const options = useMemo(() => createOptions(dropDownVals, 'rowId', 'paymentOption'), [dropDownVals]);
const onValueChange = useCallback(
evt => {
- onChange('creditCardOption', evt.target.value);
+ onChange('paymentOption', evt.target.value);
},
[onChange]
);
return (
-
+
diff --git a/WNPRC_Purchasing/src/client/model.ts b/WNPRC_Purchasing/src/client/model.ts
index e3fa0780c..4fedfa6da 100644
--- a/WNPRC_Purchasing/src/client/model.ts
+++ b/WNPRC_Purchasing/src/client/model.ts
@@ -84,7 +84,7 @@ export class PurchaseAdminModel {
readonly rowId?: number;
readonly assignedTo: number;
- readonly creditCardOption: number;
+ readonly paymentOption: number;
readonly qcState: number;
readonly program: string = '4';
readonly confirmationNum?: string;
diff --git a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingContainerListener.java b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingContainerListener.java
index a47434917..f7b84a000 100644
--- a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingContainerListener.java
+++ b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingContainerListener.java
@@ -19,6 +19,7 @@
import org.jetbrains.annotations.NotNull;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager.ContainerListener;
+import org.labkey.api.data.DatabaseTableType;
import org.labkey.api.data.DbScope;
import org.labkey.api.data.SimpleFilter;
import org.labkey.api.data.Table;
@@ -44,9 +45,11 @@ public void containerDeleted(Container c, User user)
SimpleFilter containerFilter = SimpleFilter.createContainerFilter(c);
try (DbScope.Transaction transaction = scope.ensureTransaction())
{
- TableInfo creditCardOptionsTable = WNPRC_PurchasingSchema.getInstance().getCreditCardOptionsTable();
- Table.delete(creditCardOptionsTable, containerFilter);
-
+ TableInfo paymentOptionsTable = WNPRC_PurchasingSchema.getInstance().getPaymentOptionsTable();
+ if (null != paymentOptionsTable && paymentOptionsTable.getTableType() == DatabaseTableType.TABLE)
+ {
+ Table.delete(paymentOptionsTable, containerFilter);
+ }
transaction.commit();
}
}
diff --git a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingController.java b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingController.java
index cdb3807b2..cac63c190 100644
--- a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingController.java
+++ b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingController.java
@@ -27,9 +27,12 @@
import org.labkey.api.query.BatchValidationException;
import org.labkey.api.query.ValidationException;
import org.labkey.api.security.RequiresPermission;
+import org.labkey.api.security.permissions.AdminPermission;
import org.labkey.api.security.permissions.InsertPermission;
import org.labkey.api.security.permissions.ReadPermission;
import org.labkey.api.view.NavTree;
+import org.labkey.api.view.Portal;
+import org.labkey.api.view.WebPartFactory;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
@@ -46,6 +49,32 @@ public WNPRC_PurchasingController()
setActionResolver(_actionResolver);
}
+ @RequiresPermission(ReadPermission.class)
+ public class RequesterAction extends SimpleViewAction
+ {
+ public ModelAndView getView(Object o, BindException errors)
+ {
+ WebPartFactory factory = Portal.getPortalPartCaseInsensitive("WNPRC Purchasing Requester");
+ Portal.WebPart part = factory.createWebPart();
+ return Portal.getWebPartViewSafe(factory, getViewContext(), part);
+ }
+
+ public void addNavTrail(NavTree root) { }
+ }
+
+ @RequiresPermission(AdminPermission.class)
+ public class PurchaseAdminAction extends SimpleViewAction
+ {
+ public ModelAndView getView(Object o, BindException errors)
+ {
+ WebPartFactory factory = Portal.getPortalPartCaseInsensitive("WNPRC Purchasing Admin");
+ Portal.WebPart part = factory.createWebPart();
+ return Portal.getWebPartViewSafe(factory, getViewContext(), part);
+ }
+
+ public void addNavTrail(NavTree root) { }
+ }
+
@RequiresPermission(ReadPermission.class)
public class PurchasingRequestAction extends SimpleViewAction
{
@@ -95,7 +124,7 @@ public static class RequestForm
String _comments;
String _qcState;
Integer _assignedTo;
- Integer _creditCardOption;
+ Integer _paymentOption;
String _program;
String _confirmNum;
String _invoiceNum;
@@ -234,14 +263,14 @@ public void setAssignedTo(Integer assignedTo)
_assignedTo = assignedTo;
}
- public Integer getCreditCardOption()
+ public Integer getPaymentOption()
{
- return _creditCardOption;
+ return _paymentOption;
}
- public void setCreditCardOption(Integer creditCardOption)
+ public void setPaymentOption(Integer paymentOption)
{
- _creditCardOption = creditCardOption;
+ _paymentOption = paymentOption;
}
public String getProgram()
diff --git a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingFolderType.java b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingFolderType.java
index e92b5af33..c2c2c03a6 100644
--- a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingFolderType.java
+++ b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingFolderType.java
@@ -19,15 +19,15 @@ public WNPRC_PurchasingFolderType(Module module)
{
super(NAME,
"Folder type used for WNPRC Purchasing Requests",
+ Arrays.asList(createWebPart("WNPRC Purchasing Landing Page")),
Collections.emptyList(),
- Arrays.asList(createWebPart("WNPRC Purchasing")),
getDefaultModuleSet(getModule("EHR_Purchasing"), module),
module);
}
private static @Nullable Portal.WebPart createWebPart(String name)
{
- WebPartFactory factory = Portal.getPortalPart(name);
+ WebPartFactory factory = Portal.getPortalPartCaseInsensitive(name);
return null != factory ? factory.createWebPart(WebPartFactory.LOCATION_BODY) : null;
}
@@ -41,6 +41,7 @@ public void configureContainer(Container c, User user)
//Add extensibleColumns
WNPRC_PurchasingManager.get().addExtensibleColumns(c, user);
+ WNPRC_PurchasingManager.get().addPaymentOptions(c, user);
}
}
diff --git a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingManager.java b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingManager.java
index 3d22e0f34..70e24e1ed 100644
--- a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingManager.java
+++ b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingManager.java
@@ -72,6 +72,11 @@ public void addItemUnits(Container c, User user)
addData(c, user, "ehr_purchasing", "itemUnits", "itemUnits.tsv");
}
+ public void addPaymentOptions(Container c, User user)
+ {
+ addData(c, user, "wnprc_purchasing", "paymentOptions", "paymentOptions.tsv");
+ }
+
public void addQCStatus(Container c, User user)
{
addData(c, user, "core", "QCState", "QCStatus.tsv");
@@ -190,10 +195,9 @@ else if (null != requestForm.getVendor() && newVendorData.size() == 0)
//otherwise, continue adding non-required values
row.put("comments", requestForm.getComments());
- //TODO: update assignedTo
- row.put("assignedTo", null != requestForm.getAssignedTo() ? requestForm.getAssignedTo() : user.getUserId());
+ row.put("assignedTo", requestForm.getAssignedTo());
row.put("qcState", requestForm.getQcState());
- row.put("creditCardOptionId", requestForm.getCreditCardOption());
+ row.put("paymentOptionId", requestForm.getPaymentOption());
row.put("program", requestForm.getProgram());
row.put("confirmationNum", requestForm.getConfirmNum());
row.put("invoiceNum", requestForm.getInvoiceNum());
@@ -347,7 +351,7 @@ private void addPurchasingRequestsCols(Container container, User user)
extensibleCols.add(otherAcctAndInves);
GWTPropertyDescriptor ccOptionId = new GWTPropertyDescriptor();
- ccOptionId.setName("creditCardOptionId");
+ ccOptionId.setName("paymentOptionId");
ccOptionId.setRangeURI("int");
extensibleCols.add(ccOptionId);
diff --git a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingSchema.java b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingSchema.java
index 22ba5db77..0ffa9916e 100644
--- a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingSchema.java
+++ b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingSchema.java
@@ -27,7 +27,7 @@ public class WNPRC_PurchasingSchema
public static final String NAME = "wnprc_purchasing";
//wnprc_purchasing tables
- public static final String CREDIT_CARD_OPTIONS_TABLE = "creditCardOptions";
+ public static final String PAYMENT_OPTIONS_TABLE = "paymentOptions";
public static WNPRC_PurchasingSchema getInstance()
{
@@ -51,8 +51,8 @@ public SqlDialect getSqlDialect()
return getSchema().getSqlDialect();
}
- public TableInfo getCreditCardOptionsTable()
+ public TableInfo getPaymentOptionsTable()
{
- return getSchema().getTable(CREDIT_CARD_OPTIONS_TABLE);
+ return getSchema().getTable(PAYMENT_OPTIONS_TABLE);
}
}
diff --git a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingUserSchema.java b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingUserSchema.java
index 9a73d3934..db91ffbbf 100644
--- a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingUserSchema.java
+++ b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/WNPRC_PurchasingUserSchema.java
@@ -19,14 +19,14 @@ public WNPRC_PurchasingUserSchema(String name, User user, Container container)
public enum TableType
{
- creditCardOptions
+ paymentOptions
{
@Override
public TableInfo createTable(WNPRC_PurchasingUserSchema schema, ContainerFilter cf)
{
SimpleUserSchema.SimpleTable table =
new SimpleUserSchema.SimpleTable<>(
- schema, WNPRC_PurchasingSchema.getInstance().getCreditCardOptionsTable(), cf).init();
+ schema, WNPRC_PurchasingSchema.getInstance().getPaymentOptionsTable(), cf).init();
return table;
}
};
diff --git a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/table/WNPRC_PurchasingCustomizer.java b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/table/WNPRC_PurchasingCustomizer.java
index 403e017cd..9c822fbc1 100644
--- a/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/table/WNPRC_PurchasingCustomizer.java
+++ b/WNPRC_Purchasing/src/org/labkey/wnprc_purchasing/table/WNPRC_PurchasingCustomizer.java
@@ -23,6 +23,7 @@ public void customize(TableInfo tableInfo)
{
addAttachmentsCol((AbstractTableInfo) tableInfo);
addRequestLink((AbstractTableInfo) tableInfo);
+ addTotalCostColumn((AbstractTableInfo) tableInfo);
}
}
}
@@ -48,4 +49,19 @@ private void addAttachmentsCol(AbstractTableInfo purchasingRequestsTable)
col.setDisplayColumnFactory(new AttachmentDisplayColumnFactory());
}
}
+
+ private void addTotalCostColumn(AbstractTableInfo purchasingRequestsTable)
+ {
+ String name = "totalCost";
+ if (purchasingRequestsTable.getColumn(name) == null)
+ {
+ SQLFragment sql = new SQLFragment("(SELECT x.totalCost FROM (SELECT requestRowId, sum(quantity * unitCost) AS totalCost FROM ehr_purchasing.lineItems items GROUP BY items.requestRowId) x ");
+ sql.append("WHERE " + ExprColumn.STR_TABLE_ALIAS + ".rowId = x.requestRowId)");
+ ExprColumn col = new ExprColumn(purchasingRequestsTable, name, sql, JdbcType.DECIMAL);
+ col.setFormat("$###,##0.00");
+ col.setLabel("Total Cost");
+ col.setUserEditable(false);
+ purchasingRequestsTable.addColumn(col);
+ }
+ }
}
diff --git a/WNPRC_Purchasing/test/sampledata/wnprc_purchasing/vendor.tsv b/WNPRC_Purchasing/test/sampledata/wnprc_purchasing/vendor.tsv
index 81d790b99..ce7f09531 100644
--- a/WNPRC_Purchasing/test/sampledata/wnprc_purchasing/vendor.tsv
+++ b/WNPRC_Purchasing/test/sampledata/wnprc_purchasing/vendor.tsv
@@ -1,3 +1,4 @@
vendorName streetAddress city state country zip phoneNumber email
Real Santa Claus 123 Claus St Claus City North Pole Fun 00000 1234567890 claus@realclaus.org
-Stuff, Inc 111 Hollywood rd Los Angeles CA USA 90210 3101111111 buystuff@stuff.com
\ No newline at end of file
+Stuff, Inc 111 Hollywood rd Los Angeles CA USA 90210 3101111111 buystuff@stuff.com
+Dunder Mifflin 1725 Slough Avenue Scranton PA USA 18505 8006270114 narddog@dundermifflin.com
\ No newline at end of file
diff --git a/WNPRC_Purchasing/test/src/org/labkey/test/Pages/CreateRequestPage.java b/WNPRC_Purchasing/test/src/org/labkey/test/Pages/CreateRequestPage.java
index 68497f2dc..619d4d217 100644
--- a/WNPRC_Purchasing/test/src/org/labkey/test/Pages/CreateRequestPage.java
+++ b/WNPRC_Purchasing/test/src/org/labkey/test/Pages/CreateRequestPage.java
@@ -4,7 +4,6 @@
import org.labkey.test.components.html.Input;
import org.labkey.test.components.html.SelectWrapper;
import org.labkey.test.pages.LabKeyPage;
-import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
@@ -204,6 +203,50 @@ public CreateRequestPage setStatus(String status)
return this;
}
+ public CreateRequestPage setAssignedTo(String value)
+ {
+ SelectWrapper.Select(Locator.byClass("assigned-to-input form-control"))
+ .findWhenNeeded(getDriver()).selectByVisibleText(value);
+ return this;
+ }
+
+ public String getPurchaseOptions()
+ {
+ return SelectWrapper.Select(Locator.byClass("payment-option-input form-control"))
+ .findWhenNeeded(getDriver())
+ .getFirstSelectedOption()
+ .getText();
+ }
+
+ public CreateRequestPage setPurchaseOptions(String value)
+ {
+ SelectWrapper.Select(Locator.byClass("payment-option-input form-control"))
+ .findWhenNeeded(getDriver()).selectByVisibleText(value);
+ return this;
+ }
+
+ public String getOrderDate()
+ {
+ return Locator.id("order-date-id").findElement(getDriver()).getText();
+ }
+
+ public CreateRequestPage setOrderDate(String date)
+ {
+ setFormElement(Locator.id("order-date-id"), date);
+ return this;
+ }
+
+ public String getCardPostDate()
+ {
+ return Locator.id("card-post-date-id").findElement(getDriver()).getText();
+ }
+
+ public CreateRequestPage setCardPostDate(String date)
+ {
+ setFormElement(Locator.id("card-post-date-id"), date);
+ return this;
+ }
+
public String getConfirmationNo()
{
return Locator.tagWithText("textarea", "confirmation-input-id").findElement(getDriver()).getText();
diff --git a/WNPRC_Purchasing/test/src/org/labkey/test/tests/wnprc_purchasing/WNPRC_PurchasingTest.java b/WNPRC_Purchasing/test/src/org/labkey/test/tests/wnprc_purchasing/WNPRC_PurchasingTest.java
index aad37ae60..d4a4edb3d 100644
--- a/WNPRC_Purchasing/test/src/org/labkey/test/tests/wnprc_purchasing/WNPRC_PurchasingTest.java
+++ b/WNPRC_Purchasing/test/src/org/labkey/test/tests/wnprc_purchasing/WNPRC_PurchasingTest.java
@@ -16,6 +16,7 @@
package org.labkey.test.tests.wnprc_purchasing;
+import org.jetbrains.annotations.Nullable;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -24,6 +25,7 @@
import org.labkey.remoteapi.Connection;
import org.labkey.remoteapi.query.InsertRowsCommand;
import org.labkey.remoteapi.query.SaveRowsResponse;
+import org.labkey.remoteapi.query.TruncateTableCommand;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.Pages.CreateRequestPage;
@@ -45,6 +47,8 @@
import java.io.File;
import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -62,13 +66,14 @@ public class WNPRC_PurchasingTest extends BaseWebDriverTest implements PostgresO
//folders
private static final String FOLDER_TYPE = "WNPRC Purchasing";
private static final String BILLING_FOLDER = "WNPRC Billing";
+ private static final String FOLDER_FOR_REQUESTERS = "WNPRC Purchasing Requester";
//users
private static final String REQUESTER_USER = "purchaserequester@test.com";
private static final String requesterName = "purchaserequester";
private static final String ADMIN_USER = "purchaseadmin@test.com";
//other properties
- private static int requestCnt = 0;
+
//sample data
private final File ALIASES_TSV = TestFileUtils.getSampleData("wnprc_purchasing/aliases.tsv");
private final File SHIPPING_INFO_TSV = TestFileUtils.getSampleData("wnprc_purchasing/shippingInfo.tsv");
@@ -101,7 +106,17 @@ protected void doCleanup(boolean afterTest) throws TestTimeoutException
private void doSetup() throws IOException, CommandException
{
- log("Creating 'WNPRC Billing' folder");
+ goToHome();
+
+ log("Create a purchasing admin user");
+ _adminUserId = _userHelper.createUser(ADMIN_USER).getUserId().intValue();
+
+ log("Create a purchasing requester user");
+ _requesterUserId = _userHelper.createUser(REQUESTER_USER).getUserId().intValue();
+
+ goToHome();
+
+ log("Create 'WNPRC Billing' folder");
_containerHelper.createProject(BILLING_FOLDER, FOLDER_TYPE);
_containerHelper.enableModules(Arrays.asList("EHR_Billing"));
@@ -111,41 +126,47 @@ private void doSetup() throws IOException, CommandException
goToHome();
- log("Creating a 'WNPRC Purchasing' folder");
+ log("Create a 'WNPRC Purchasing' folder");
_containerHelper.createProject(getProjectName(), FOLDER_TYPE);
- goToProjectHome();
-
- log("Creating a purchasing admin user");
- _adminUserId = _userHelper.createUser(ADMIN_USER).getUserId().intValue();
-
- log("Creating a purchasing requester user");
- _requesterUserId = _userHelper.createUser(REQUESTER_USER).getUserId().intValue();
-
- goToProjectHome();
-
- log("Adding WNPRC Purchasing webpart");
+ log("Add WNPRC Purchasing Landing page webpart");
new SiteNavBar(getDriver()).enterPageAdminMode();
- (new PortalHelper(this)).addWebPart("WNPRC Purchasing");
+ (new PortalHelper(this)).addWebPart("WNPRC Purchasing Landing Page");
new SiteNavBar(getDriver()).exitPageAdminMode();
- log("Uploading purchasing data");
+ goToProjectHome();
+
+ log("Upload purchasing data");
uploadPurchasingData();
- log("Creating user-account associations");
+ log("Create user-account associations");
createUserAccountAssociations();
log("Create ehrBillingLinked schema");
- _schemaHelper.createLinkedSchema(getProjectName(), "ehr_billingLinked", BILLING_FOLDER, null, "ehr_billing", "aliases", null);
+ _schemaHelper.createLinkedSchema(getProjectName(), "ehr_billingLinked", BILLING_FOLDER, "ehr_billingLinked", null, null, null);
addUsersToPurchasingFolder();
+
+ goToHome();
}
private void addUsersToPurchasingFolder()
{
+ goToProjectHome();
_permissionsHelper.setUserPermissions(ADMIN_USER, "Project Administrator");
- _permissionsHelper.setUserPermissions(REQUESTER_USER, "Reader");
+ _permissionsHelper.setUserPermissions(getCurrentUser(), "Project Administrator");
_permissionsHelper.setUserPermissions(REQUESTER_USER, "Submitter");
+ _permissionsHelper.setUserPermissions(REQUESTER_USER, "Reader");
+ }
+
+ private void goToPurchaseAdminPage()
+ {
+ beginAt(buildRelativeUrl("WNPRC_Purchasing", getProjectName(), "purchaseAdmin"));
+ }
+
+ private void goToRequesterPage()
+ {
+ beginAt(buildRelativeUrl("WNPRC_Purchasing", getProjectName(), "requester"));
}
private void createUserAccountAssociations() throws IOException, CommandException
@@ -205,9 +226,11 @@ public void preTest()
}
@Test
- public void testCreateRequest()
+ public void testCreateRequest() throws IOException, CommandException
{
- goToProjectHome();
+ clearAllRequest();
+ goToRequesterPage();
+ impersonate(REQUESTER_USER);
clickButton("Create Request");
CreateRequestPage requestPage = new CreateRequestPage(getDriver());
@@ -231,15 +254,18 @@ public void testCreateRequest()
log("Verifying the request created");
waitForElement(Locator.tagWithAttribute("h3", "title", "Purchase Requests"));
DataRegionTable table = DataRegionTable.DataRegion(getDriver()).find();
- checker().verifyEquals("Invalid number of requests ", ++requestCnt, table.getDataRowCount());
+ checker().verifyEquals("Invalid number of requests ", 1, table.getDataRowCount());
checker().verifyEquals("Invalid request status ", "Review Pending",
table.getDataAsText(0, "requestStatus"));
+ stopImpersonating();
}
@Test
- public void testOtherVendorRequest()
+ public void testOtherVendorRequest() throws IOException, CommandException
{
- goToProjectHome();
+ clearAllRequest();
+ goToRequesterPage();
+ impersonate(REQUESTER_USER);
clickButton("Create Request");
CreateRequestPage requestPage = new CreateRequestPage(getDriver());
requestPage.setVendor("Other");
@@ -275,24 +301,27 @@ public void testOtherVendorRequest()
log("Verifying the request created");
waitForElement(Locator.tagWithAttribute("h3", "title", "Purchase Requests"));
DataRegionTable table = DataRegionTable.DataRegion(getDriver()).find();
- checker().verifyEquals("Invalid number of requests ", ++requestCnt, table.getDataRowCount());
+ checker().verifyEquals("Invalid number of requests ", 1, table.getDataRowCount());
checker().verifyEquals("Invalid request status ", "Review Pending",
table.getDataAsText(0, "requestStatus"));
checker().verifyEquals("Invalid Vendor ", "Test1", table.getDataAsText(0, "vendorId"));
+ stopImpersonating();
}
@Test
- public void testPurchaseAdminWorkflow()
+ public void testPurchaseAdminWorkflow() throws IOException, CommandException
{
File jpgFile = new File(TestFileUtils.getSampleData("fileTypes"), "jpg_sample.jpg");
File pdfFile = new File(TestFileUtils.getSampleData("fileTypes"), "pdf_sample.pdf");
+ clearAllRequest();
+
log("-----Create request as lab end user-----");
log("Impersonate as " + REQUESTER_USER);
impersonate(REQUESTER_USER);
log("Create new Request - START");
- goToProjectHome();
+ goToRequesterPage();
clickButton("Create Request");
CreateRequestPage requestPage = new CreateRequestPage(getDriver());
@@ -322,15 +351,14 @@ public void testPurchaseAdminWorkflow()
stopImpersonating();
log("-----Update request as Purchasing Admin-----");
- goToProjectHome();
- goToSchemaBrowser();
- DataRegionTable requestsTable = viewQueryData("ehr_purchasing", "purchasingRequests");
-
+ goToPurchaseAdminPage();
log("Impersonate as " + ADMIN_USER);
impersonate(ADMIN_USER);
- requestsTable.setFilter("rowId", "Equals", requestID);
+ clickAndWait(Locator.linkContainingText("All Open Requests"));
+ DataRegionTable requestsQueryForAdmins = new DataRegionTable("query", getDriver());
+ requestsQueryForAdmins.setFilter("requestNum", "Equals", requestID);
- checker().verifyEquals("Admin is not seeing the request " + requestID, 1, requestsTable.getDataRowCount());
+ checker().verifyEquals("Admin is not seeing the request " + requestID, 1, requestsQueryForAdmins.getDataRowCount());
clickAndWait(Locator.linkWithText(requestID));
requestPage = new CreateRequestPage(getDriver());
@@ -352,7 +380,7 @@ public void testPurchaseAdminWorkflow()
requestPage.addAttachment(pdfFile);
log("Verify Status in 'Purchase Admin' panel is 'Review Pending'");
- checker().verifyEquals("Invalid Assigned to value ", requesterName, requestPage.getAssignedTo());
+ checker().verifyEquals("Invalid Assigned to value ", "Select", requestPage.getAssignedTo());
checker().verifyEquals("Invalid Program value", "4", requestPage.getProgram());
checker().verifyEquals("Invalid status ", "Review Pending", requestPage.getStatus());
@@ -362,17 +390,189 @@ public void testPurchaseAdminWorkflow()
stopImpersonating(false);
+ beginAt(buildRelativeUrl("WNPRC_Purchasing", getProjectName(), "requestEntry", Maps.of("requestRowId", requestID)));
log("Impersonate as " + REQUESTER_USER);
impersonate(REQUESTER_USER);
- clickAndWait(Locator.linkWithText(requestID));
- checker().verifyFalse("Requester should not be able to edit the request ",
- isElementPresent(Locator.tagWithAttribute("div", "class", "panel-title").withText("Request Order")));
-
- beginAt(buildRelativeUrl("WNPRC_Purchasing", getProjectName(), "requestEntry", Maps.of("requestRowId", requestID)));
assertTextPresent("You do not have sufficient permissions to update this request.");
stopImpersonating();
}
+ @Test
+ public void testReferenceTables()
+ {
+ goToProjectHome();
+ clickAndWait(Locator.linkWithText("Purchasing Admin"));
+
+ log("Checking if the link is present on the Purchasing Admin page");
+ checker().verifyTrue("Vendors reference is not present", isElementPresent(Locator.linkWithText("Vendors")));
+ checker().verifyTrue("User Account Associations reference is not present", isElementPresent(Locator.linkWithText("User Account Associations")));
+ checker().verifyTrue("Shipping Info reference is not present", isElementPresent(Locator.linkWithText("Shipping Info")));
+ checker().verifyTrue("Item Units reference is not present", isElementPresent(Locator.linkWithText("Item Units")));
+ checker().verifyTrue("Line Items reference is not present", isElementPresent(Locator.linkWithText("Line Items")));
+
+ log("Verifying if link navigates to correct query");
+ checker().verifyEquals("Incorrect link for Vendors", "Vendor", getQueryName("Vendors"));
+ checker().verifyEquals("Incorrect link for User Account Associations", "User Account Associations",
+ getQueryName("User Account Associations"));
+ checker().verifyEquals("Incorrect link for Shipping Info", "Shipping Info", getQueryName("Shipping Info"));
+ checker().verifyEquals("Incorrect link for Item Units", "Item Units", getQueryName("Item Units"));
+ checker().verifyEquals("Incorrect link for Line Items", "Line Items", getQueryName("Line Items"));
+ }
+
+ @Test
+ public void testAdminPage() throws IOException, CommandException
+ {
+ clearAllRequest();
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+ LocalDateTime date = LocalDateTime.now();
+
+ log("Verifying requester does not access to admin web part");
+ goToProjectHome();
+ impersonate(REQUESTER_USER);
+ goToPurchaseAdminPage();
+ checker().verifyTrue(REQUESTER_USER + "user should not permission for admin page",
+ isElementPresent(Locator.tagWithClass("div", "labkey-error-subheading")
+ .withText("You do not have the permissions required to access this page.")));
+ goBack();
+
+ log("Creating request as " + REQUESTER_USER);
+ goToRequesterPage();
+ clickAndWait(Locator.linkWithText("Create Request"));
+ Map requesterRequest = new HashMap<>();
+ requesterRequest.put("Account to charge", "acct100");
+ requesterRequest.put("Shipping destination", "456 Thompson lane (Math bldg)");
+ requesterRequest.put("Vendor", "Dunder Mifflin");
+ requesterRequest.put("Delivery attention to", "testing the workflow");
+ requesterRequest.put("Business purpose", "regression test");
+ requesterRequest.put("Item description", "Item1");
+ requesterRequest.put("Unit", "Term");
+ requesterRequest.put("Unit Cost", "10");
+ requesterRequest.put("Quantity", "6");
+
+ String requestId1 = createRequest(requesterRequest, null);
+ stopImpersonating();
+
+ log("Creating request as " + ADMIN_USER);
+ impersonate(ADMIN_USER);
+ goToPurchaseAdminPage();
+ Map adminRequest = new HashMap<>();
+ adminRequest.put("Account to charge", "acct101");
+ adminRequest.put("Shipping destination", "456 Thompson lane (Math bldg)");
+ adminRequest.put("Vendor", "Real Santa Claus");
+ adminRequest.put("Delivery attention to", "testing the workflow - Admin");
+ adminRequest.put("Business purpose", "regression test -Admin request");
+ adminRequest.put("Item description", "Item1");
+ adminRequest.put("Unit", "Term");
+ adminRequest.put("Unit Cost", "20");
+ adminRequest.put("Quantity", "3");
+ clickAndWait(Locator.linkWithText("Enter Request"));
+ String requestId2 = createRequest(requesterRequest, null);
+
+ log("Verifying all open requests");
+ goToPurchaseAdminPage();
+ clickAndWait(Locator.linkWithText("All Open Requests"));
+ DataRegionTable table = new DataRegionTable("query", getDriver());
+ checker().verifyEquals("Incorrect request Id's", Arrays.asList(requestId1, requestId2),
+ table.getColumnDataAsText("requestNum"));
+ checker().verifyEquals("Incorrect requester's", Arrays.asList("purchaserequester", "purchaseadmin"),
+ table.getColumnDataAsText("requester"));
+
+ log("Changing the assignment of the request");
+ clickAndWait(Locator.linkWithText(requestId1));
+ CreateRequestPage requestPage = new CreateRequestPage(getDriver());
+ requestPage.setAssignedTo("purchaseadmin")
+ .setPurchaseOptions("Direct Payment")
+ .setStatus("Request Approved")
+ .setOrderDate(dtf.format(date))
+ .setCardPostDate(dtf.format(date))
+ .submit();
+
+ goToPurchaseAdminPage();
+ waitAndClickAndWait(Locator.linkWithText("My Open Requests"));
+ table = new DataRegionTable("query", getDriver());
+
+ checker().verifyEquals("Incorrect request in my open request", requestId1,
+ table.getDataAsText(0, "requestNum"));
+ checker().verifyEquals("Incorrect status", "Request Approved",
+ table.getDataAsText(0, "requestStatus"));
+
+ log("Completing the order");
+ goToPurchaseAdminPage();
+ waitAndClickAndWait(Locator.linkWithText("All Open Requests"));
+ clickAndWait(Locator.linkWithText(requestId2));
+ requestPage = new CreateRequestPage(getDriver());
+ requestPage.setStatus("Order Complete").submit();
+
+ waitAndClickAndWait(Locator.linkWithText("Purchasing Admin"));
+ clickAndWait(Locator.linkWithText("Completed Requests"));
+ table = new DataRegionTable("query", getDriver());
+ checker().verifyEquals("Incorrect request in my open request", requestId2,
+ table.getDataAsText(0, "requestNum"));
+ checker().verifyEquals("Incorrect status", "Order Complete",
+ table.getDataAsText(0, "requestStatus"));
+
+ goToPurchaseAdminPage();
+ clickAndWait(Locator.linkWithText("All Open Requests"));
+ table = new DataRegionTable("query", getDriver());
+ checker().verifyEquals("Completed order should not be present", Arrays.asList(requestId1),
+ table.getColumnDataAsText("requestNum"));
+ stopImpersonating();
+
+ log("Verifying the P-Card view");
+ goToPurchaseAdminPage();
+ clickAndWait(Locator.linkWithText("P-Card View"));
+ table = new DataRegionTable("query", getDriver());
+ checker().verifyEquals("Incorrect number of rows in P-Card view", 2, table.getDataRowCount());
+ }
+
+ private String getQueryName(String linkName)
+ {
+ clickAndWait(Locator.linkWithText(linkName));
+ String retVal = Locator.tag("h3").findElement(getDriver()).getText();
+ goBack();
+
+ return retVal;
+ }
+
+ private String createRequest(Map request, @Nullable File fileName)
+ {
+ CreateRequestPage requestPage = new CreateRequestPage(getDriver());
+
+ requestPage.setAccountsToCharge(request.get("Account to charge"))
+ .setVendor(request.get("Vendor"))
+ .setBusinessPurpose(request.get("Business purpose"))
+ .setShippingDestination(request.get("Shipping destination"))
+ .setDeliveryAttentionTo(request.get("Delivery attention to"))
+ .setItemDesc(request.get("Item description"))
+ .setUnitInput(request.get("Unit"))
+ .setUnitCost(request.get("Unit Cost"))
+ .setQuantity(request.get("Quantity"));
+
+ if (request.containsKey("Special instructions"))
+ requestPage.setSpecialInstructions(request.get("Special instructions"));
+
+ if (fileName != null)
+ requestPage.addAttachment(fileName);
+
+ requestPage.submitForReview();
+ if (getCurrentUser().equals("purchaseadmin@test.com"))
+ {
+ clickAndWait(Locator.linkWithText("All Open Requests"));
+ DataRegionTable table = new DataRegionTable("query", getDriver());
+ table.setFilter("requester", "Equals", "purchaseadmin");
+ return table.getDataAsText(0, "requestNum");
+ }
+ else
+ return DataRegionTable.DataRegion(getDriver()).find().getDataAsText(0, "rowId");
+ }
+
+ private void clearAllRequest() throws IOException, CommandException
+ {
+ Connection cn = createDefaultConnection();
+ new TruncateTableCommand("ehr_purchasing", "lineItems").execute(cn, getProjectName());
+ new TruncateTableCommand("ehr_purchasing", "purchasingRequests").execute(cn, getProjectName());
+ }
+
@Override
protected BrowserType bestBrowser()
{