Skip to content

Commit

Permalink
feature: ORV2-2841 MFP Permit Template and BE changes (#1619)
Browse files Browse the repository at this point in the history
  • Loading branch information
praju-aot authored Sep 25, 2024
1 parent 7a63703 commit 945a352
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 1 deletion.
31 changes: 31 additions & 0 deletions database/mssql/scripts/versions/revert/v_44_ddl_revert.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET NOCOUNT ON
GO

SET XACT_ABORT ON

BEGIN TRY
BEGIN TRANSACTION

DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] WHERE DOCUMENT_ID IN (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME='mfp-template-v1.docx')
DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] WHERE DOCUMENT_ID IN (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME='mfp-void-template-v1.docx')
DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] WHERE DOCUMENT_ID IN (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME='mfp-revoked-template-v1.docx')
DELETE [dops].[ORBC_DOCUMENT] WHERE FILE_NAME='mfp-template-v1.docx'
DELETE [dops].[ORBC_DOCUMENT] WHERE FILE_NAME='mfp-void-template-v1.docx'
DELETE [dops].[ORBC_DOCUMENT] WHERE FILE_NAME='mfp-revoked-template-v1.docx'
COMMIT
END TRY

BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK;
THROW
END CATCH

DECLARE @VersionDescription VARCHAR(255)
SET @VersionDescription = 'Revert MFP templates'

INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (42, @VersionDescription, getutcdate())
60 changes: 60 additions & 0 deletions database/mssql/scripts/versions/v_44_ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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
INSERT [dops].[ORBC_DOCUMENT] ( [S3_OBJECT_ID], [S3_VERSION_ID], [S3_LOCATION], [OBJECT_MIME_TYPE], [FILE_NAME], [DMS_VERSION_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES ( N'FF765BCC-7778-471C-9468-B788E358A07A', NULL, N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev%40moti-int.objectstore.gov.bc.ca/ff765bcc-7778-471c-9468-b788e358a07a', N'application/vnd.openxmlformats-officedocument.wordprocessingml.document',N'mfp-template-v1.docx',1, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [dops].[ORBC_DOCUMENT] ( [S3_OBJECT_ID], [S3_VERSION_ID], [S3_LOCATION], [OBJECT_MIME_TYPE], [FILE_NAME], [DMS_VERSION_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES ( N'FF765BCC-7778-471C-9468-B788E358A07A', NULL, N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev%40moti-int.objectstore.gov.bc.ca/ff765bcc-7778-471c-9468-b788e358a07a', N'application/vnd.openxmlformats-officedocument.wordprocessingml.document',N'mfp-void-template-v1.docx',1, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [dops].[ORBC_DOCUMENT] ( [S3_OBJECT_ID], [S3_VERSION_ID], [S3_LOCATION], [OBJECT_MIME_TYPE], [FILE_NAME], [DMS_VERSION_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES ( N'BCF467A3-23D0-4E1F-8CA1-EC47656F483E', NULL, N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev%40moti-int.objectstore.gov.bc.ca/bcf467a3-23d0-4e1f-8ca1-ec47656f483e', N'application/vnd.openxmlformats-officedocument.wordprocessingml.document',N'mfp-revoked-template-v1.docx',1, 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())

IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( [TEMPLATE_NAME], [TEMPLATE_VERSION], [DOCUMENT_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES ( N'PERMIT_MFP', 1, (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME='mfp-template-v1.docx'), 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( [TEMPLATE_NAME], [TEMPLATE_VERSION], [DOCUMENT_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES ( N'PERMIT_MFP_VOID', 1, (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME='mfp-void-template-v1.docx'), 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())
IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( [TEMPLATE_NAME], [TEMPLATE_VERSION], [DOCUMENT_ID], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES ( N'PERMIT_MFP_REVOKED', 1, (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME='mfp-revoked-template-v1.docx'), 1, N'dops', GETUTCDATE(), N'dops', GETUTCDATE())

IF @@ERROR <> 0 SET NOEXEC ON
GO

DECLARE @VersionDescription VARCHAR(255)
SET @VersionDescription = 'MFP permit templates.'

INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [UPDATE_SCRIPT], [REVERT_SCRIPT], [RELEASE_DATE]) VALUES (43, @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

5 changes: 5 additions & 0 deletions database/mssql/test/versions/v_44_1_test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Test that the permit template have been configured correctly
SET NOCOUNT ON

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

SELECT COUNT(*) FROM $(DB_NAME).[dops].[ORBC_DOCUMENT]
WHERE ID IN (SELECT DOCUMENT_ID FROM $(DB_NAME).[dops].[ORBC_DOCUMENT_TEMPLATE]
WHERE TEMPLATE_NAME IN ('PERMIT','PERMIT_MFP_VOID','PERMIT_MFP_REVOKED'))
24 changes: 24 additions & 0 deletions database/mssql/test/versions/v_44_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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 44 are run from this shell script.
# TESTS_DIR variable set by the calling test-runner script.

TEST_44_1_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_44_1_test.sql | xargs)
if [[ $TEST_44_1_RESULT -eq 3 ]]; then
echo "Test 44.1 passed: MFP templates setup successfully in ORBC_DOCUMENT_TEMPLATE"
else
echo "******** Test 44.1 failed: Failed to setup MFP permit templates"
fi


TEST_44_2_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_44_2_test.sql | xargs)
if [[ $TEST_44_2_RESULT -eq 3 ]]; then
echo "Test 44.2 passed: MFP templates setup successfully in ORBC_DOCUMENT"
else
echo "******** Test 44.2 failed: Failed to setup MFP permit templates"
fi
3 changes: 3 additions & 0 deletions dops/src/enum/template-name.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export enum TemplateName {
PERMIT_STOS = 'PERMIT_STOS',
PERMIT_STOS_VOID = 'PERMIT_STOS_VOID',
PERMIT_STOS_REVOKED = 'PERMIT_STOS_REVOKED',
PERMIT_MFP = 'PERMIT_MFP',
PERMIT_MFP_VOID = 'PERMIT_MFP_VOID',
PERMIT_MFP_REVOKED = 'PERMIT_MFP_REVOKED',
}
3 changes: 3 additions & 0 deletions vehicles/src/common/enum/template-name.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export enum TemplateName {
PERMIT_STOS = 'PERMIT_STOS',
PERMIT_STOS_VOID = 'PERMIT_STOS_VOID',
PERMIT_STOS_REVOKED = 'PERMIT_STOS_REVOKED',
PERMIT_MFP = 'PERMIT_MFP',
PERMIT_MFP_VOID = 'PERMIT_MFP_VOID',
PERMIT_MFP_REVOKED = 'PERMIT_MFP_REVOKED',
}

export type PermitTemplateMapping = {
Expand Down
3 changes: 3 additions & 0 deletions vehicles/src/common/helper/template.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ export const getPermitTemplateName = (
const templateMapping: PermitTemplateMapping = {
[ApplicationStatus.ISSUED]: {
[PermitType.SINGLE_TRIP_OVERSIZE]: TemplateName.PERMIT_STOS,
[PermitType.MOTIVE_FUEL_USER]: TemplateName.PERMIT_MFP,
default: TemplateName.PERMIT,
},
[ApplicationStatus.VOIDED]: {
[PermitType.SINGLE_TRIP_OVERSIZE]: TemplateName.PERMIT_STOS_VOID,
[PermitType.MOTIVE_FUEL_USER]: TemplateName.PERMIT_MFP_VOID,
default: TemplateName.PERMIT_VOID,
},
[ApplicationStatus.REVOKED]: {
[PermitType.SINGLE_TRIP_OVERSIZE]: TemplateName.PERMIT_STOS_REVOKED,
[PermitType.MOTIVE_FUEL_USER]: TemplateName.PERMIT_MFP_REVOKED,
default: TemplateName.PERMIT_REVOKED,
},
};
Expand Down
4 changes: 3 additions & 1 deletion vehicles/src/common/interface/permit.template.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ interface PermittedCommodity {
interface ManualRoute {
origin: string;
destination: string;
highwaySequence: string[];
exitPoint?: string;
totalDistance?: number;
highwaySequence?: string[];
}

interface MailingAddress {
Expand Down

0 comments on commit 945a352

Please sign in to comment.