Add acquisitions-unit-assignments.recordId to orders views
Description
Environment
Potential Workaround
has to be done before
is cloned by
Checklist
hideTestRail: Results
Activity
Kruthi VuppalaJuly 11, 2019 at 2:29 PM
Verified on folio-testing:
1. Create an Order
curl -X POST \
https://folio-testing-okapi.aws.indexdata.com:443/orders/composite-orders \
-H 'Content-Type: application/json' \
-H 'X-Okapi-Tenant: diku' \
-H 'x-okapi-token: $OKAPITOKEN' \
-d '{
"approved": true,
"assignedTo": "ab18897b-0e40-4f31-896b-9c9adc979a88",
"notes": [
"ABCDEFGHIJKLMNO",
"ABCDEFGHIJKLMNOPQRST",
"ABCDEFGHIJKLMNOPQRSTUV"
],
"orderType": "One-Time",
"reEncumber": false,
"totalEstimatedPrice": 47.98,
"totalItems": 2,
"vendor": "7aaeba01-1a91-4511-b46f-c033e8b8cbe8",
"workflowStatus": "Pending",
"compositePoLines": [
{
"acquisitionMethod": "Purchase At Vendor System",
"cost": {
"listUnitPrice": 24.99,
"currency": "USD",
"quantityPhysical": 1
},
"orderFormat": "Physical Resource",
"physical": {
"createInventory": "None"
},
"source": {
"code": "ABCDEFGHIJKLMNOPQRSTUVWXYZABC",
"description": "ABCDEFGHIJKLMNO"
},
"title": "Kayak Fishing in the Northern Gulf Coast"
}
]
}'
RESPONSE
{
"id": "99905b8c-2f8b-4803-bc12-009c65ba0ce8",
"approved": true,
"assignedTo": "ab18897b-0e40-4f31-896b-9c9adc979a88",
"notes": [
"ABCDEFGHIJKLMNO",
"ABCDEFGHIJKLMNOPQRST",
"ABCDEFGHIJKLMNOPQRSTUV"
],
"poNumber": "10032",
"orderType": "One-Time",
"reEncumber": false,
"totalEstimatedPrice": 24.99,
"totalItems": 1,
"vendor": "7aaeba01-1a91-4511-b46f-c033e8b8cbe8",
"workflowStatus": "Pending",
"compositePoLines": [
{
"id": "66ac9c0e-9f6d-4134-8081-1becd6773181",
"checkinItems": false,
"acquisitionMethod": "Purchase At Vendor System",
"alerts": [],
"claims": [],
"contributors": [],
"cost": {
"listUnitPrice": 24.99,
"currency": "USD",
"discountType": "percentage",
"quantityPhysical": 1,
"poLineEstimatedPrice": 24.99
},
"fundDistribution": [],
"locations": [],
"orderFormat": "Physical Resource",
"paymentStatus": "Pending",
"physical": {
"createInventory": "None",
"volumes": []
},
"poLineNumber": "10032-1",
"purchaseOrderId": "99905b8c-2f8b-4803-bc12-009c65ba0ce8",
"receiptStatus": "Pending",
"reportingCodes": [],
"source": {
"code": "ABCDEFGHIJKLMNOPQRSTUVWXYZABC",
"description": "ABCDEFGHIJKLMNO"
},
"tags": [],
"title": "Kayak Fishing in the Northern Gulf Coast"
}
],
"metadata": {
"createdDate": "2019-07-11T14:15:55.931+0000",
"createdByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51",
"updatedDate": "2019-07-11T14:15:55.931+0000",
"updatedByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51"
}
}
2. Create another Order in Closed Status
curl -X POST \
https://folio-testing-okapi.aws.indexdata.com:443/orders/composite-orders \
-H 'X-Okapi-Tenant: diku' \
-H 'x-okapi-token: $OKAPITOKEN' \
-d '{
"approved": true,
"assignedTo": "ab18897b-0e40-4f31-896b-9c9adc979a88",
"notes": [
"ABCDEFGHIJKLMNO",
"ABCDEFGHIJKLMNOPQRST",
"ABCDEFGHIJKLMNOPQRSTUV"
],
"orderType": "One-Time",
"reEncumber": false,
"totalEstimatedPrice": 47.98,
"totalItems": 2,
"vendor": "7aaeba01-1a91-4511-b46f-c033e8b8cbe8",
"poNumber": "testMODORDSTOR94",
"workflowStatus": "Closed",
"compositePoLines": [
{
"acquisitionMethod": "Purchase At Vendor System",
"cost": {
"listUnitPrice": 2,
"currency": "USD",
"quantityPhysical": 2
},
"orderFormat": "Physical Resource",
"physical": {
"createInventory": "None"
},
"source": {
"code": "ABCDEFGHIJKLMNOPQRSTUVWXYZABC",
"description": "ABCDEFGHIJKLMNO"
},
"title": "Testing MODORDSTOR-94"
}
]
}'
RESPONSE:
{
"id": "0134436b-cc97-4ec9-861c-16371099b749",
"approved": true,
"assignedTo": "ab18897b-0e40-4f31-896b-9c9adc979a88",
"notes": [
"ABCDEFGHIJKLMNO",
"ABCDEFGHIJKLMNOPQRST",
"ABCDEFGHIJKLMNOPQRSTUV"
],
"poNumber": "testMODORDSTOR94",
"orderType": "One-Time",
"reEncumber": false,
"totalEstimatedPrice": 4.0,
"totalItems": 2,
"vendor": "7aaeba01-1a91-4511-b46f-c033e8b8cbe8",
"workflowStatus": "Closed",
"compositePoLines": [
{
"id": "df89a3ce-8bdb-4ca2-8d80-c3a477b7e3c1",
"checkinItems": false,
"acquisitionMethod": "Purchase At Vendor System",
"alerts": [],
"claims": [],
"contributors": [],
"cost": {
"listUnitPrice": 2.0,
"currency": "USD",
"discountType": "percentage",
"quantityPhysical": 2,
"poLineEstimatedPrice": 4.0
},
"fundDistribution": [],
"locations": [],
"orderFormat": "Physical Resource",
"paymentStatus": "Pending",
"physical": {
"createInventory": "None",
"volumes": []
},
"poLineNumber": "testMODORDSTOR94-1",
"purchaseOrderId": "0134436b-cc97-4ec9-861c-16371099b749",
"receiptStatus": "Pending",
"reportingCodes": [],
"source": {
"code": "ABCDEFGHIJKLMNOPQRSTUVWXYZABC",
"description": "ABCDEFGHIJKLMNO"
},
"tags": [],
"title": "Testing MODORDSTOR-94"
}
],
"metadata": {
"createdDate": "2019-07-11T14:18:45.901+0000",
"createdByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51",
"updatedDate": "2019-07-11T14:18:45.901+0000",
"updatedByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51"
}
}
3. Create an acquisition Unit
curl -X POST \
https://folio-testing-okapi.aws.indexdata.com:443/acquisitions-units-storage/units \
-H 'Content-Type: application/json' \
-H 'X-Okapi-Tenant: diku' \
-H 'x-okapi-token: ' \
-d '{
"name": "Testing Order Query",
"protectCreate": true,
"protectRead": false,
"protectUpdate": true,
"protectDelete": true
}'
RESPONSE:
{
"id": "12bc73c8-af8d-452e-a368-fad2bfcf84b3",
"name": "Testing Order Query",
"protectCreate": true,
"protectRead": false,
"protectUpdate": true,
"protectDelete": true,
"metadata": {
"createdDate": "2019-07-11T14:21:16.213+0000",
"createdByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51",
"updatedDate": "2019-07-11T14:21:16.213+0000",
"updatedByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51"
}
}
4. Assign First Order to Acquisition Unit
curl -X POST \
https://folio-testing-okapi.aws.indexdata.com:443/orders-storage/acquisitions-unit-assignments \
-H 'Content-Type: application/json' \
-H 'X-Okapi-Tenant: diku' \
-H 'x-okapi-token: $OKAPITOKEN' \
-d '{
"recordId": "99905b8c-2f8b-4803-bc12-009c65ba0ce8",
"acquisitionsUnitId": "12bc73c8-af8d-452e-a368-fad2bfcf84b3"
}'
{
"id": "0d18fc40-cd1d-40dd-bedb-bac37bdfe3a0",
"recordId": "99905b8c-2f8b-4803-bc12-009c65ba0ce8",
"acquisitionsUnitId": "12bc73c8-af8d-452e-a368-fad2bfcf84b3",
"metadata": {
"createdDate": "2019-07-11T14:23:35.740+0000",
"createdByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51",
"updatedDate": "2019-07-11T14:23:35.740+0000",
"updatedByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51"
}
}
5. Run Query For Acquisition Unit
curl -X GET \
'https://folio-testing-okapi.aws.indexdata.com:443/orders-storage/purchase-orders?query=acquisitionsUnitId=12bc73c8-af8d-452e-a368-fad2bfcf84b3%20and%20workflowStatus=Pending' \
-H 'Content-Type: application/json' \
-H 'X-Okapi-Tenant: diku' \
-H 'x-okapi-token: $OKAPITOKEN' \
RESPONSE:
{
"purchaseOrders": [
{
"id": "99905b8c-2f8b-4803-bc12-009c65ba0ce8",
"approved": true,
"assignedTo": "ab18897b-0e40-4f31-896b-9c9adc979a88",
"notes": [
"ABCDEFGHIJKLMNO",
"ABCDEFGHIJKLMNOPQRST",
"ABCDEFGHIJKLMNOPQRSTUV"
],
"poNumber": "10032",
"orderType": "One-Time",
"reEncumber": false,
"vendor": "7aaeba01-1a91-4511-b46f-c033e8b8cbe8",
"workflowStatus": "Pending",
"metadata": {
"createdDate": "2019-07-11T14:15:56.002+0000",
"createdByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51",
"updatedDate": "2019-07-11T14:15:56.002+0000",
"updatedByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51"
}
}
],
"totalRecords": 1
}
6. Add Acquisition Unit to Other Order
curl -X POST \
https://folio-testing-okapi.aws.indexdata.com:443/orders-storage/acquisitions-unit-assignments \
-H 'Content-Type: application/json' \
-H 'X-Okapi-Tenant: diku' \
-H 'x-okapi-token: $OKAPITOKEN' \
-d '{
"recordId": "0134436b-cc97-4ec9-861c-16371099b749",
"acquisitionsUnitId": "12bc73c8-af8d-452e-a368-fad2bfcf84b3"
}'
7. Query /Orders
curl -X GET \
'https://folio-testing-okapi.aws.indexdata.com:443/orders-storage/orders?query=acquisitionsUnitId=12bc73c8-af8d-452e-a368-fad2bfcf84b3' \
-H 'Content-Type: application/json' \
-H 'X-Okapi-Tenant: diku' \
-H 'x-okapi-token: $OKAPITOKEN'
RESPONSE
{
"purchaseOrders": [
{
"id": "99905b8c-2f8b-4803-bc12-009c65ba0ce8",
"approved": true,
"assignedTo": "ab18897b-0e40-4f31-896b-9c9adc979a88",
"notes": [
"ABCDEFGHIJKLMNO",
"ABCDEFGHIJKLMNOPQRST",
"ABCDEFGHIJKLMNOPQRSTUV"
],
"poNumber": "10032",
"orderType": "One-Time",
"reEncumber": false,
"vendor": "7aaeba01-1a91-4511-b46f-c033e8b8cbe8",
"workflowStatus": "Pending",
"metadata": {
"createdDate": "2019-07-11T14:15:56.002+0000",
"createdByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51",
"updatedDate": "2019-07-11T14:15:56.002+0000",
"updatedByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51"
}
},
{
"id": "0134436b-cc97-4ec9-861c-16371099b749",
"approved": true,
"assignedTo": "ab18897b-0e40-4f31-896b-9c9adc979a88",
"notes": [
"ABCDEFGHIJKLMNO",
"ABCDEFGHIJKLMNOPQRST",
"ABCDEFGHIJKLMNOPQRSTUV"
],
"poNumber": "testMODORDSTOR94",
"orderType": "One-Time",
"reEncumber": false,
"vendor": "7aaeba01-1a91-4511-b46f-c033e8b8cbe8",
"workflowStatus": "Closed",
"metadata": {
"createdDate": "2019-07-11T14:18:45.943+0000",
"createdByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51",
"updatedDate": "2019-07-11T14:18:45.943+0000",
"updatedByUserId": "149c86d7-77ba-5c09-90ea-877f0079fd51"
}
}
],
"totalRecords": 2
}
Piotr KalashukJuly 4, 2019 at 10:14 AMEdited
Verified on folio-testing environment
Set up environment variables
export OKAPITOKEN=... export OKAPI=https://folio-testing-okapi.aws.indexdata.com
Create 2 acq units
Request 1curl -X POST $OKAPI/acquisitions-units-storage/units \ -H 'Content-Type: application/json' \ -H "x-okapi-token: $OKAPITOKEN" \ -d '{ "name": "Test unit 1" }' -w '\n'
Response
{ "id" : "b440f482-0fd1-4a91-b90b-621dfeb2341e", "name" : "Test unit 1", "protectCreate" : true, "protectRead" : false, "protectUpdate" : true, "protectDelete" : true, "metadata" : { "createdDate" : "2019-07-04T08:29:37.926+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T08:29:37.926+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }
Request 2
curl -X POST $OKAPI/acquisitions-units-storage/units \ -H 'Content-Type: application/json' \ -H "x-okapi-token: $OKAPITOKEN" \ -d '{ "name": "Test unit 2" }' -w '\n'
Response
{ "id" : "145e2ab6-4df2-4bcd-a8f5-ea06d919cc0a", "name" : "Test unit 2", "protectCreate" : true, "protectRead" : false, "protectUpdate" : true, "protectDelete" : true, "metadata" : { "createdDate" : "2019-07-04T08:33:43.953+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T08:33:43.953+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }
Create 2 orders (different vendors)
Request 1curl -X POST $OKAPI/orders-storage/purchase-orders \ -H 'Content-Type: application/json' \ -H "x-okapi-token: $OKAPITOKEN" \ -d '{ "orderType": "One-Time", "notes": [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber": "TESTVIEWS1", "vendor": "50fb6ae0-cdf1-11e8-a8d5-f2801f1b9fd1" }' -w '\n'
Response
{ "id" : "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "orderType" : "One-Time", "poNumber": "TESTVIEWS1", "reEncumber" : false, "vendor" : "50fb6ae0-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:15:24.036+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T09:15:24.036+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }
Request 2
curl -X POST $OKAPI/orders-storage/purchase-orders \ -H 'Content-Type: application/json' \ -H "x-okapi-token: $OKAPITOKEN" \ -d '{ "orderType": "One-Time", "notes": [ "MODORDSTOR-94", "MODORDSTOR-95" ], "vendor": "e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1" }' -w '\n'
Response
{ "id" : "79a1b92b-24b7-4a00-bb2b-d158a6f4a136", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "orderType" : "One-Time", "poNumber": "TESTVIEWS2", "reEncumber" : false, "vendor" : "e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:18:23.244+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T09:18:23.244+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }
Create one line for each order
Request 1curl -X POST $OKAPI/orders-storage/po-lines \ -H 'Content-Type: application/json' \ -H "x-okapi-token: $OKAPITOKEN" \ -d '{ "acquisitionMethod": "Purchase", "purchaseOrderId": "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "source": { "code": "FOLIO" }, "orderFormat": "Physical Resource", "physical":{ "createInventory": "None" }, "cost":{ "currency":"USD", "listUnitPrice": 1, "quantityPhysical":1 }, "title": "Line for the first order" }' -w '\n'
Response
{ "id" : "9c0c2884-2e07-45e3-b522-a0e93bebfba4", "checkinItems" : false, "acquisitionMethod" : "Purchase", "alerts" : [ ], "claims" : [ ], "collection" : false, "contributors" : [ ], "cost" : { "listUnitPrice" : 1.0, "currency" : "USD", "discountType" : "percentage", "quantityPhysical" : 1 }, "fundDistribution" : [ ], "locations" : [ ], "orderFormat" : "Physical Resource", "paymentStatus" : "Pending", "physical" : { "createInventory" : "None", "volumes" : [ ] }, "purchaseOrderId" : "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "receiptStatus" : "Pending", "reportingCodes" : [ ], "rush" : false, "source" : { "code" : "FOLIO" }, "tags" : [ ], "title" : "Line for the first order", "metadata" : { "createdDate" : "2019-07-04T09:30:38.090+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T09:30:38.090+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }
Request 1
curl -X POST $OKAPI/orders-storage/po-lines \ -H 'Content-Type: application/json' \ -H "x-okapi-token: $OKAPITOKEN" \ -d '{ "acquisitionMethod": "Purchase", "purchaseOrderId": "79a1b92b-24b7-4a00-bb2b-d158a6f4a136", "source": { "code": "FOLIO" }, "orderFormat": "Physical Resource", "physical":{ "createInventory": "None" }, "cost":{ "currency":"USD", "listUnitPrice": 1, "quantityPhysical":1 }, "title": "Line for the second order" }' -w '\n'
Response
{ "id" : "a386efb8-ce04-461d-b534-eb40d21bffce", "checkinItems" : false, "acquisitionMethod" : "Purchase", "alerts" : [ ], "claims" : [ ], "collection" : false, "contributors" : [ ], "cost" : { "listUnitPrice" : 1.0, "currency" : "USD", "discountType" : "percentage", "quantityPhysical" : 1 }, "fundDistribution" : [ ], "locations" : [ ], "orderFormat" : "Physical Resource", "paymentStatus" : "Pending", "physical" : { "createInventory" : "None", "volumes" : [ ] }, "purchaseOrderId" : "79a1b92b-24b7-4a00-bb2b-d158a6f4a136", "receiptStatus" : "Pending", "reportingCodes" : [ ], "rush" : false, "source" : { "code" : "FOLIO" }, "tags" : [ ], "title" : "Line for the second order", "metadata" : { "createdDate" : "2019-07-04T09:31:37.974+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T09:31:37.974+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }
Assign both units to the first order
Request 1curl -X POST $OKAPI/orders-storage/acquisitions-unit-assignments \ -H 'Content-Type: application/json' \ -H "x-okapi-token: $OKAPITOKEN" \ -d '{ "recordId": "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "acquisitionsUnitId": "b440f482-0fd1-4a91-b90b-621dfeb2341e" }' -w '\n'
Response
{ "id" : "9c9911c4-4a0b-4256-8f26-aea52e18088c", "recordId" : "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "acquisitionsUnitId" : "b440f482-0fd1-4a91-b90b-621dfeb2341e", "metadata" : { "createdDate" : "2019-07-04T09:24:14.861+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T09:24:14.861+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }
Request 2
curl -X POST $OKAPI/orders-storage/acquisitions-unit-assignments \ -H 'Content-Type: application/json' \ -H "x-okapi-token: $OKAPITOKEN" \ -d '{ "recordId": "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "acquisitionsUnitId": "145e2ab6-4df2-4bcd-a8f5-ea06d919cc0a" }' -w '\n'
Response
{ "id" : "57b648c6-f7fd-43a1-855f-fae57ff4d824", "recordId" : "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "acquisitionsUnitId" : "145e2ab6-4df2-4bcd-a8f5-ea06d919cc0a", "metadata" : { "createdDate" : "2019-07-04T09:24:46.817+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T09:24:46.817+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }
Assign only one unit to the second order
Requestcurl -X POST $OKAPI/orders-storage/acquisitions-unit-assignments \ -H 'Content-Type: application/json' \ -H "x-okapi-token: $OKAPITOKEN" \ -d '{ "recordId": "79a1b92b-24b7-4a00-bb2b-d158a6f4a136", "acquisitionsUnitId": "b440f482-0fd1-4a91-b90b-621dfeb2341e" }' -w '\n'
Response
{ "id" : "26f15038-cb75-47d5-9d18-b4f6668575e1", "recordId" : "79a1b92b-24b7-4a00-bb2b-d158a6f4a136", "acquisitionsUnitId" : "b440f482-0fd1-4a91-b90b-621dfeb2341e", "metadata" : { "createdDate" : "2019-07-04T09:25:49.397+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T09:25:49.397+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }
Search for orders using
/orders-storage/purchase-orders
endpointGet orders for the first unit
Requestcurl $OKAPI/orders-storage/purchase-orders --data-urlencode 'query=acquisitionsUnitId==b440f482-0fd1-4a91-b90b-621dfeb2341e' -H "X-Okapi-Token: $OKAPITOKEN" -w '\n' -G -s
Response
{ "purchaseOrders" : [ { "id" : "79a1b92b-24b7-4a00-bb2b-d158a6f4a136", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber" : "TESTVIEWS2", "orderType" : "One-Time", "reEncumber" : false, "vendor" : "e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:18:23.244+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T10:07:28.863+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }, { "id" : "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber" : "TESTVIEWS1", "orderType" : "One-Time", "reEncumber" : false, "vendor" : "50fb6ae0-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:15:24.036+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T10:06:40.077+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } } ], "totalRecords" : 2 }
Get orders for the first unit and for specific vendor
Requestcurl $OKAPI/orders-storage/purchase-orders --data-urlencode 'query=acquisitionsUnitId==b440f482-0fd1-4a91-b90b-621dfeb2341e and vendor==e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1' -H "X-Okapi-Token: $OKAPITOKEN" -w '\n' -G -s
Response
{ "purchaseOrders" : [ { "id" : "79a1b92b-24b7-4a00-bb2b-d158a6f4a136", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber" : "TESTVIEWS2", "orderType" : "One-Time", "reEncumber" : false, "vendor" : "e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:18:23.244+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T10:07:28.863+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } } ], "totalRecords" : 1 }
Get orders for the first unit including POL criteria (this endpoint does not support such queries)
Requestcurl $OKAPI/orders-storage/purchase-orders --data-urlencode 'query=acquisitionsUnitId==b440f482-0fd1-4a91-b90b-621dfeb2341e and acquisitionMethod==Purchase' -H "X-Okapi-Token: $OKAPITOKEN" -w '\n' -G -s
Response
{ "purchaseOrders" : [ ], "totalRecords" : 0 }
Get orders for the second unit
Requestcurl $OKAPI/orders-storage/purchase-orders --data-urlencode 'query=acquisitionsUnitId==145e2ab6-4df2-4bcd-a8f5-ea06d919cc0a' -H "X-Okapi-Token: $OKAPITOKEN" -w '\n' -G -s
Response
{ "purchaseOrders" : [ { "id" : "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber" : "TESTVIEWS1", "orderType" : "One-Time", "reEncumber" : false, "vendor" : "50fb6ae0-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:15:24.036+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T10:06:40.077+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } } ], "totalRecords" : 1 }
Search for orders using
/orders-storage/orders
endpointGet orders for the first unit
Requestcurl $OKAPI/orders-storage/orders --data-urlencode 'query=acquisitionsUnitId==b440f482-0fd1-4a91-b90b-621dfeb2341e' -H "X-Okapi-Token: $OKAPITOKEN" -w '\n' -G -s
Response
{ "purchaseOrders" : [ { "id" : "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber" : "TESTVIEWS1", "orderType" : "One-Time", "reEncumber" : false, "vendor" : "50fb6ae0-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:15:24.036+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T10:06:40.077+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } }, { "id" : "79a1b92b-24b7-4a00-bb2b-d158a6f4a136", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber" : "TESTVIEWS2", "orderType" : "One-Time", "reEncumber" : false, "vendor" : "e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:18:23.244+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T10:07:28.863+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } } ], "totalRecords" : 2 }
Get orders for the first unit and for specific vendor
Requestcurl $OKAPI/orders-storage/orders --data-urlencode 'query=acquisitionsUnitId==b440f482-0fd1-4a91-b90b-621dfeb2341e and vendor==e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1' -H "X-Okapi-Token: $OKAPITOKEN" -w '\n' -G -s
Response
{ "purchaseOrders" : [ { "id" : "79a1b92b-24b7-4a00-bb2b-d158a6f4a136", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber" : "TESTVIEWS2", "orderType" : "One-Time", "reEncumber" : false, "vendor" : "e0fb5df2-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:18:23.244+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T10:07:28.863+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } } ], "totalRecords" : 1 }
Get orders for the first unit including POL criteria
Requestcurl $OKAPI/orders-storage/orders --data-urlencode 'query=acquisitionsUnitId==b440f482-0fd1-4a91-b90b-621dfeb2341e and title=first' -H "X-Okapi-Token: $OKAPITOKEN" -w '\n' -G -s
Response
{ "purchaseOrders" : [ { "id" : "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber" : "TESTVIEWS1", "orderType" : "One-Time", "reEncumber" : false, "vendor" : "50fb6ae0-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:15:24.036+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T10:06:40.077+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } } ], "totalRecords" : 1 }
Get orders for the second unit
Requestcurl $OKAPI/orders-storage/orders --data-urlencode 'query=acquisitionsUnitId==145e2ab6-4df2-4bcd-a8f5-ea06d919cc0a' -H "X-Okapi-Token: $OKAPITOKEN" -w '\n' -G -s
Response
{ "purchaseOrders" : [ { "id" : "f660e48d-42fa-44d9-b17b-59c3b4bffca0", "approved" : false, "notes" : [ "MODORDSTOR-94", "MODORDSTOR-95" ], "poNumber" : "TESTVIEWS1", "orderType" : "One-Time", "reEncumber" : false, "vendor" : "50fb6ae0-cdf1-11e8-a8d5-f2801f1b9fd1", "workflowStatus" : "Pending", "metadata" : { "createdDate" : "2019-07-04T09:15:24.036+0000", "createdByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd", "updatedDate" : "2019-07-04T10:06:40.077+0000", "updatedByUserId" : "7ad1799c-6255-595b-966e-911b6ed351dd" } } ], "totalRecords" : 1 }
Delete created records
Requestcurl -i -XDELETE $OKAPI/orders-storage/po-lines/9c0c2884-2e07-45e3-b522-a0e93bebfba4 -H "x-okapi-token: $OKAPITOKEN" -w '\n' curl -i -XDELETE $OKAPI/orders-storage/po-lines/a386efb8-ce04-461d-b534-eb40d21bffce -H "x-okapi-token: $OKAPITOKEN" -w '\n' curl -i -XDELETE $OKAPI/orders-storage/purchase-orders/f660e48d-42fa-44d9-b17b-59c3b4bffca0 -H "x-okapi-token: $OKAPITOKEN" -w '\n' curl -i -XDELETE $OKAPI/orders-storage/purchase-orders/79a1b92b-24b7-4a00-bb2b-d158a6f4a136 -H "x-okapi-token: $OKAPITOKEN" -w '\n' curl -i -XDELETE $OKAPI/acquisitions-units-storage/units/b440f482-0fd1-4a91-b90b-621dfeb2341e -H "x-okapi-token: $OKAPITOKEN" -w '\n' curl -i -XDELETE $OKAPI/acquisitions-units-storage/units/145e2ab6-4df2-4bcd-a8f5-ea06d919cc0a -H "x-okapi-token: $OKAPITOKEN" -w '\n'
Response
HTTP/2 204 ... HTTP/2 204 ... HTTP/2 204 ... HTTP/2 204 ... HTTP/2 204 ... HTTP/2 204 ...
Overview
As part of the acquisitions unit effort, the acquisitions unit assignments table needs to be integrated into the view used for querying orders.
Approach
Currently we have the ability to query the purchase orders table directly (
GET /orders-storage/purchase-orders?query=...
). Instead this should query a new view that joins the purchase-order and acquisitions-unit-assignments tables onpurchase-order.id == acquisitions-unit-assignment.recordId
.NOTE: DISTINCT ON is required here to avoid duplicate rows
We also have the ability to query a view which combines purchase-order, po-line, etc. tables (
GET /orders-storage/orders?query=...
). This should also be updated to include acquisitions-unit-assignments.Additional background can be found on the wiki
Acceptance Criteria
The new view is created and used when querying purchase-orders
The existing "orders" view is updated
Unit tests are updated