Skip to content

Commit

Permalink
fix: ORV2-2083 - Update Permit template names to generic ones. (#1258)
Browse files Browse the repository at this point in the history
Co-authored-by: John Fletcher <[email protected]>
  • Loading branch information
praju-aot and john-fletcher-aot authored Mar 11, 2024
1 parent 5c780be commit 6ae4e51
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 11 deletions.
59 changes: 59 additions & 0 deletions database/mssql/scripts/versions/revert/v_24_ddl_revert.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET NOCOUNT ON
GO

SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO

UPDATE [dops].[ORBC_DOCUMENT_TEMPLATE] SET TEMPLATE_NAME='PERMIT_TROS',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE TEMPLATE_NAME='PERMIT'

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT_TEMPLATE] SET TEMPLATE_NAME='PERMIT_TROS_VOID',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE TEMPLATE_NAME='PERMIT_VOID'

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT_TEMPLATE] SET TEMPLATE_NAME='PERMIT_TROS_REVOKED',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE TEMPLATE_NAME='PERMIT_REVOKED'

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT] SET FILE_NAME='tros-template-v1.docx',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE ID IN (SELECT DOCUMENT_ID FROM [dops].[ORBC_DOCUMENT_TEMPLATE] WHERE TEMPLATE_NAME='PERMIT_TROS')

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT] SET FILE_NAME='tros-template-void-template-v1.docx',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE ID IN (SELECT DOCUMENT_ID FROM [dops].[ORBC_DOCUMENT_TEMPLATE] WHERE TEMPLATE_NAME='PERMIT_TROS_VOID')

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT] SET FILE_NAME='tros-template-revoked-template-v1.docx',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE ID IN (SELECT DOCUMENT_ID FROM [dops].[ORBC_DOCUMENT_TEMPLATE] WHERE TEMPLATE_NAME='PERMIT_TROS_REVOKED')

DECLARE @VersionDescription VARCHAR(255)
SET @VersionDescription = 'Revert the name of permit template documents'

INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (23, @VersionDescription, getutcdate())
IF @@ERROR <> 0 SET NOEXEC ON
GO

COMMIT TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DECLARE @Success AS BIT
SET @Success = 1
SET NOEXEC OFF
IF (@Success = 1) PRINT 'The database update succeeded'
ELSE BEGIN
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
PRINT 'The database update failed'
END
GO

63 changes: 63 additions & 0 deletions database/mssql/scripts/versions/v_24_ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET NOCOUNT ON
GO

SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT_TEMPLATE] SET TEMPLATE_NAME='PERMIT',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE TEMPLATE_NAME='PERMIT_TROS'

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT_TEMPLATE] SET TEMPLATE_NAME='PERMIT_VOID',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE TEMPLATE_NAME='PERMIT_TROS_VOID'

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT_TEMPLATE] SET TEMPLATE_NAME='PERMIT_REVOKED',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE TEMPLATE_NAME='PERMIT_TROS_REVOKED'

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT] SET FILE_NAME='permit-template-v1.docx',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE ID IN (SELECT DOCUMENT_ID FROM [dops].[ORBC_DOCUMENT_TEMPLATE] WHERE TEMPLATE_NAME='PERMIT')

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT] SET FILE_NAME='permit-template-void-template-v1.docx',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE ID IN (SELECT DOCUMENT_ID FROM [dops].[ORBC_DOCUMENT_TEMPLATE] WHERE TEMPLATE_NAME='PERMIT_VOID')

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dops].[ORBC_DOCUMENT] SET FILE_NAME='permit-template-revoked-template-v1.docx',DB_LAST_UPDATE_TIMESTAMP=GETUTCDATE() WHERE ID IN (SELECT DOCUMENT_ID FROM [dops].[ORBC_DOCUMENT_TEMPLATE] WHERE TEMPLATE_NAME='PERMIT_REVOKED')



IF @@ERROR <> 0 SET NOEXEC ON
GO

DECLARE @VersionDescription VARCHAR(255)
SET @VersionDescription = 'Update the name of permit template documents'

INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [UPDATE_SCRIPT], [REVERT_SCRIPT], [RELEASE_DATE]) VALUES (24, @VersionDescription, '$(UPDATE_SCRIPT)', '$(REVERT_SCRIPT)', getutcdate())
IF @@ERROR <> 0 SET NOEXEC ON
GO

COMMIT TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DECLARE @Success AS BIT
SET @Success = 1
SET NOEXEC OFF
IF (@Success = 1) PRINT 'The database update succeeded'
ELSE BEGIN
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
PRINT 'The database update failed'
END
GO
File renamed without changes.
5 changes: 5 additions & 0 deletions database/mssql/test/versions/v_24_1_test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Test that the permit template names have been updated correctly
SET NOCOUNT ON

SELECT COUNT(*) FROM $(DB_NAME).[dops].[ORBC_DOCUMENT_TEMPLATE]
WHERE TEMPLATE_NAME IN ('PERMIT','PERMIT_VOID','PERMIT_REVOKED')
5 changes: 5 additions & 0 deletions database/mssql/test/versions/v_24_2_test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Test that the template file names have been updated correctly
SET NOCOUNT ON

SELECT COUNT(*) FROM $(DB_NAME).[dops].[ORBC_DOCUMENT]
WHERE FILE_NAME IN ('permit-template-v1.docx','permit-template-void-template-v1.docx','permit-template-revoked-template-v1.docx')
23 changes: 23 additions & 0 deletions database/mssql/test/versions/v_24_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Retrieve arguments
source ${SCRIPT_DIR}/utility/getopt.sh
USAGE="-u USER -p PASS -s SERVER -d DATABASE"
parse_options "${USAGE}" ${@}

# All database tests for database version 24 are run from this shell script.
# TESTS_DIR variable set by the calling test-runner script.

TEST_24_1_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_24_1_test.sql | xargs)
if [[ $TEST_24_1_RESULT -eq 3 ]]; then
echo "Test 24.1 passed: Template names updated correctly"
else
echo "******** Test 24.1 failed: Template names not updated correctly"
fi

TEST_24_2_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_24_2_test.sql | xargs)
if [[ $TEST_24_2_RESULT -eq 3 ]]; then
echo "Test 24.2 passed: File names updated correctly"
else
echo "******** Test 24.2 failed: File names not updated correctly"
fi
6 changes: 3 additions & 3 deletions dops/src/enum/template-name.enum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export enum TemplateName {
PERMIT_TROS = 'PERMIT_TROS',
PERMIT = 'PERMIT',
PAYMENT_RECEIPT = 'PAYMENT_RECEIPT',
PERMIT_TROS_VOID = 'PERMIT_TROS_VOID',
PERMIT_TROS_REVOKED = 'PERMIT_TROS_REVOKED',
PERMIT_VOID = 'PERMIT_VOID',
PERMIT_REVOKED = 'PERMIT_REVOKED',
}
6 changes: 5 additions & 1 deletion dops/src/helper/auth.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { Directory } from '../enum/directory.enum';
import { IDP } from '../enum/idp.enum';
import { Role } from '../enum/roles.enum';
import { IUserJWT } from '../interface/user-jwt.interface';
import { UserAuthGroup, ClientUserAuthGroup, IDIRUserAuthGroup } from '../enum/user-auth-group.enum';
import {
UserAuthGroup,
ClientUserAuthGroup,
IDIRUserAuthGroup,
} from '../enum/user-auth-group.enum';

/**
* Determines the directory type based on the identity provider of the user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class CreateGeneratedDocumentDto {
@AutoMap()
@ApiProperty({
enum: TemplateName,
example: TemplateName.PERMIT_TROS,
example: TemplateName.PERMIT,
description: 'The template that will be used to render the document.',
})
@IsEnum(TemplateName)
Expand Down
6 changes: 3 additions & 3 deletions vehicles/src/common/enum/template-name.enum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export enum TemplateName {
PERMIT_TROS = 'PERMIT_TROS',
PERMIT = 'PERMIT',
PAYMENT_RECEIPT = 'PAYMENT_RECEIPT',
PERMIT_TROS_VOID = 'PERMIT_TROS_VOID',
PERMIT_TROS_REVOKED = 'PERMIT_TROS_REVOKED',
PERMIT_VOID = 'PERMIT_VOID',
PERMIT_REVOKED = 'PERMIT_REVOKED',
}
2 changes: 1 addition & 1 deletion vehicles/src/modules/permit/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export class ApplicationService {
await queryRunner.startTransaction();
try {
let dopsRequestData: DopsGeneratedDocument = {
templateName: TemplateName.PERMIT_TROS,
templateName: TemplateName.PERMIT,
generatedDocumentFileName: permitDataForTemplate.permitNumber,
templateData: permitDataForTemplate,
documentsToMerge: permitDataForTemplate.permitData.commodities.map(
Expand Down
4 changes: 2 additions & 2 deletions vehicles/src/modules/permit/permit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,8 @@ export class PermitService {
let dopsRequestData: DopsGeneratedDocument = {
templateName:
voidPermitDto.status == ApplicationStatus.VOIDED
? TemplateName.PERMIT_TROS_VOID
: TemplateName.PERMIT_TROS_REVOKED,
? TemplateName.PERMIT_VOID
: TemplateName.PERMIT_REVOKED,
generatedDocumentFileName: permitDataForTemplate.permitNumber,
templateData: permitDataForTemplate,
documentsToMerge: permitDataForTemplate.permitData.commodities.map(
Expand Down

0 comments on commit 6ae4e51

Please sign in to comment.