diff --git a/README.md b/README.md index 97a06e869..404dfb699 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@ This is the Invoice business logic module. ## Additional information NOTE: Only in case an acquisition unit has to be assigned to the Invoice, it is required that user should have an -extra permission `invoices.acquisitions-units-assignments.assign` to create an invoice. +extra permission `invoices.acquisitions-units-assignments.create.execute` to create an invoice. NOTE: Only in case an acquisition units list has to be changed for the Invoice, it is required that user should have an -extra permission `invoices.acquisitions-units-assignments.manage` to update an invoice. +extra permission `invoices.acquisitions-units-assignments.manage.execute` to update an invoice. ### Integration diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 9bee81f3f..54237666c 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -24,7 +24,7 @@ "methods": ["POST"], "pathPattern": "/invoice/invoices", "permissionsRequired": ["invoice.invoices.item.post"], - "permissionsDesired": ["invoices.acquisitions-units-assignments.assign"], + "permissionsDesired": ["invoices.acquisitions-units-assignments.create.execute"], "modulePermissions": [ "invoice-storage.invoices.item.post", "invoice-storage.invoice-number.get", @@ -55,7 +55,7 @@ "pathPattern": "/invoice/invoices/{id}", "permissionsRequired": ["invoice.invoices.item.put"], "permissionsDesired": [ - "invoices.acquisitions-units-assignments.manage", + "invoices.acquisitions-units-assignments.manage.execute", "invoices.fiscal-year.update.execute", "invoice.item.approve.execute", "invoice.item.pay.execute", @@ -932,22 +932,24 @@ "replaces": ["invoices.bypass-acquisition-units"] }, { - "permissionName": "invoices.acquisitions-units-assignments.assign", + "permissionName": "invoices.acquisitions-units-assignments.create.execute", "displayName": "Acquisitions unit assignment - create unit assignment", - "description": "Assign new invoice to acquisitions units" + "description": "Assign new invoice to acquisitions units", + "replaces": ["invoices.acquisitions-units-assignments.assign"] }, { - "permissionName": "invoices.acquisitions-units-assignments.manage", + "permissionName": "invoices.acquisitions-units-assignments.manage.execute", "displayName": "Acquisitions units assignment - manage unit assignments", - "description": "Manage unit assignments during invoice update" + "description": "Manage unit assignments during invoice update", + "replaces": ["invoices.acquisitions-units-assignments.manage"] }, { "permissionName": "invoices.acquisitions-units-assignments.all", "displayName": "All invoice acquisitions-unit-assignments permissions", "description": "All permissions for the acquisitions-unit-assignments", "subPermissions": [ - "invoices.acquisitions-units-assignments.assign", - "invoices.acquisitions-units-assignments.manage" + "invoices.acquisitions-units-assignments.create.execute", + "invoices.acquisitions-units-assignments.manage.execute" ] }, { @@ -1090,16 +1092,6 @@ "batch-voucher.batch-voucher-exports.all" ], "visible": false - }, - { - "permissionName": "invoices.acquisitions-units-assignments.assign", - "displayName": "Ability to assign acquisition unit and create invoice", - "description": "Ability to assign acquisition unit and create invoice" - }, - { - "permissionName": "invoices.acquisitions-units-assignments.manage", - "displayName": "Ability to manage acquisition unit and update invoice", - "description": "Ability to manage acquisition unit and update invoice" } ], "metadata": { diff --git a/ramls/invoice.raml b/ramls/invoice.raml index 4f66bdf15..66e609177 100644 --- a/ramls/invoice.raml +++ b/ramls/invoice.raml @@ -46,7 +46,7 @@ resourceTypes: exampleItem: !include acq-models/mod-invoice-storage/examples/invoice.sample post: - description: Post invoice. Only in case an acquisition unit has to be assigned to the invoice, it is required that user should have extra permission invoices.acquisitions-units-assignments.assign to create an Invoice. + description: Post invoice. Only in case an acquisition unit has to be assigned to the invoice, it is required that user should have extra permission invoices.acquisitions-units-assignments.create.execute to create an Invoice. is: [validate] get: is: [ pageable, searchable: {description: "using CQL (indexes for invoice)", example: "invoiceLineStatus==\"Open\""}, validate ] @@ -64,7 +64,7 @@ resourceTypes: get: description: Return an invoice with given {id} put: - description: Update invoice. Only in case an acquisition units list has to be changed, it is required that user should have extra permission invoices.acquisitions-units-assignments.manage to update an Invoice. + description: Update invoice. Only in case an acquisition units list has to be changed, it is required that user should have extra permission invoices.acquisitions-units-assignments.manage.execute to update an Invoice. queryParameters: poLinePaymentStatus: description: how to update the payment status of po lines when approving or cancelling the invoice; diff --git a/src/main/java/org/folio/invoices/utils/AcqDesiredPermissions.java b/src/main/java/org/folio/invoices/utils/AcqDesiredPermissions.java index 604cf20c8..672790241 100644 --- a/src/main/java/org/folio/invoices/utils/AcqDesiredPermissions.java +++ b/src/main/java/org/folio/invoices/utils/AcqDesiredPermissions.java @@ -6,8 +6,8 @@ import java.util.stream.Collectors; public enum AcqDesiredPermissions { - ASSIGN("invoices.acquisitions-units-assignments.assign"), - MANAGE("invoices.acquisitions-units-assignments.manage"), + ASSIGN("invoices.acquisitions-units-assignments.create.execute"), + MANAGE("invoices.acquisitions-units-assignments.manage.execute"), APPROVE("invoice.item.approve.execute"), PAY("invoice.item.pay.execute"), CANCEL("invoice.item.cancel.execute"), diff --git a/src/test/java/org/folio/dataimport/utils/DataImportUtilsTest.java b/src/test/java/org/folio/dataimport/utils/DataImportUtilsTest.java index 5e0139043..fcb4ac830 100644 --- a/src/test/java/org/folio/dataimport/utils/DataImportUtilsTest.java +++ b/src/test/java/org/folio/dataimport/utils/DataImportUtilsTest.java @@ -18,7 +18,7 @@ public class DataImportUtilsTest { private static final String TENANT = "diku"; private static final String TOKEN = "token"; private static final String OKAPI_URL = "okapi_url"; - private static final String PERMISSIONS_ARRAY = "[\"invoices.acquisitions-units-assignments.assign\"]"; + private static final String PERMISSIONS_ARRAY = "[\"invoices.acquisitions-units-assignments.create.execute\"]"; private static final String USER_ID = "userId"; @Test diff --git a/src/test/java/org/folio/rest/impl/ApiTestBase.java b/src/test/java/org/folio/rest/impl/ApiTestBase.java index afcf15eef..21affe406 100644 --- a/src/test/java/org/folio/rest/impl/ApiTestBase.java +++ b/src/test/java/org/folio/rest/impl/ApiTestBase.java @@ -98,8 +98,8 @@ public class ApiTestBase { "invoice.item.approve.execute", "invoice.item.pay.execute", "invoice.invoices.item.put", - "invoices.acquisitions-units-assignments.manage", - "invoices.acquisitions-units-assignments.assign", + "invoices.acquisitions-units-assignments.manage.execute", + "invoices.acquisitions-units-assignments.create.execute", "invoices.fiscal-year.update.execute" ); @@ -107,8 +107,8 @@ public class ApiTestBase { public static final List permissionsWithoutApproveAndPayList = Arrays.asList( "invoice.invoices.item.put", - "invoices.acquisitions-units-assignments.manage", - "invoices.acquisitions-units-assignments.assign", + "invoices.acquisitions-units-assignments.manage.execute", + "invoices.acquisitions-units-assignments.create.execute", "invoices.fiscal-year.update.execute" ); @@ -119,8 +119,8 @@ public class ApiTestBase { public static final List permissionsWithoutPaidList = Arrays.asList( "invoice.item.approve.execute", "invoice.invoices.item.put", - "invoices.acquisitions-units-assignments.manage", - "invoices.acquisitions-units-assignments.assign", + "invoices.acquisitions-units-assignments.manage.execute", + "invoices.acquisitions-units-assignments.create.execute", "invoices.fiscal-year.update.execute" ); diff --git a/src/test/java/org/folio/utils/UserPermissionsUtilTest.java b/src/test/java/org/folio/utils/UserPermissionsUtilTest.java index e3a8afb8a..3199f5d88 100644 --- a/src/test/java/org/folio/utils/UserPermissionsUtilTest.java +++ b/src/test/java/org/folio/utils/UserPermissionsUtilTest.java @@ -43,7 +43,7 @@ void shouldNotThrowExceptionWhenApprovePermissionIsInPosition() { void shouldThrowExceptionWhenApprovePermissionIsAbsent() { List permissionsList = Arrays.asList( "invoice.invoices.item.put", - "invoices.acquisitions-units-assignments.manage", + "invoices.acquisitions-units-assignments.manage.execute", "invoices.fiscal-year.update.execute" ); @@ -82,7 +82,7 @@ void shouldNotThrowExceptionWhenPayPermissionIsInPosition() { void shouldThrowCorrectErrorCodeWhenPayPermissionIsAbsent() { List permissionsList = Arrays.asList( "invoice.invoices.item.put", - "invoices.acquisitions-units-assignments.manage", + "invoices.acquisitions-units-assignments.manage.execute", "invoices.fiscal-year.update.execute" ); @@ -143,7 +143,7 @@ void shouldThrowCorrectErrorCodeWhenCancelPermissionIsAbsent() { void shouldThrowCorrectErrorCodeWhenAssignPermissionIsAbsent() { List permissionsList = Arrays.asList( "invoice.invoices.item.put", - "invoices.acquisitions-units-assignments.manage", + "invoices.acquisitions-units-assignments.manage.execute", "invoices.fiscal-year.update.execute" ); @@ -169,9 +169,9 @@ void shouldNotThrowExceptionWhenAssignPermissionIsAssigned() { List permissionsList = Arrays.asList( "invoice.invoices.item.put", - "invoices.acquisitions-units-assignments.manage", + "invoices.acquisitions-units-assignments.manage.execute", "invoices.fiscal-year.update.execute", - "invoices.acquisitions-units-assignments.assign" + "invoices.acquisitions-units-assignments.create.execute" ); String permissionsJsonArrayString = new JsonArray(permissionsList).encode(); @@ -192,7 +192,7 @@ void shouldNotThrowExceptionWhenAssignPermissionIsAssigned() { @DisplayName("should throw exception when manage permission is absent") void shouldThrowExceptionWhenManagePermissionIsAbsent() { List permissionsList = List.of( - "invoices.acquisitions-units-assignments.assign" + "invoices.acquisitions-units-assignments.create.execute" ); String permissionsJsonArrayString = new JsonArray(permissionsList).encode(); @@ -215,8 +215,8 @@ void shouldThrowExceptionWhenManagePermissionIsAbsent() { void shouldNotThrowExceptionWhenManagePermissionIsAssigned() { // Create a list of permissions List permissionsList = Arrays.asList( - "invoices.acquisitions-units-assignments.manage", - "invoices.acquisitions-units-assignments.assign" + "invoices.acquisitions-units-assignments.manage.execute", + "invoices.acquisitions-units-assignments.create.execute" ); String permissionsJsonArrayString = new JsonArray(permissionsList).encode(); @@ -237,7 +237,7 @@ void shouldNotThrowExceptionWhenManagePermissionIsAssigned() { @DisplayName("should throw exception when fiscal year update permission is absent") void shouldThrowExceptionWhenFiscalYearUpdatePermissionIsAbsent() { List permissionsList = List.of( - "invoices.acquisitions-units-assignments.assign" + "invoices.acquisitions-units-assignments.create.execute" ); String permissionsJsonArrayString = new JsonArray(permissionsList).encode(); @@ -261,7 +261,7 @@ void shouldNotThrowExceptionWhenFiscalYearUpdatePermissionIsAssigned() { // Create a list of permissions List permissionsList = Arrays.asList( "invoices.fiscal-year.update.execute", - "invoices.acquisitions-units-assignments.assign" + "invoices.acquisitions-units-assignments.create.execute" ); String permissionsJsonArrayString = new JsonArray(permissionsList).encode();