From c57aedcb4339d177997fb417e9031b03b9b913b8 Mon Sep 17 00:00:00 2001 From: zgong-gov <123983557+zgong-gov@users.noreply.github.com> Date: Fri, 8 Nov 2024 09:21:46 -0800 Subject: [PATCH 1/3] ORV2-2991 - Fix application form/review incorrect datetime display (#1659) --- frontend/src/common/helpers/formatDate.ts | 28 +++++++++++-------- frontend/src/common/helpers/tableHelper.ts | 12 +++++--- .../table/PermitSearchResultColumnDef.tsx | 4 +-- .../features/permits/apiManager/permitsAPI.ts | 3 ++ .../components/permit-list/Columns.tsx | 4 +-- .../src/features/permits/helpers/equality.ts | 2 +- .../Amend/components/AmendPermitForm.tsx | 4 +-- .../Application/components/form/LOATable.tsx | 2 +- .../components/ShoppingCartItem.tsx | 4 +-- .../Void/components/VoidPermitHeader.tsx | 2 ++ .../LOA/list/LOAListColumnDef.tsx | 4 +-- 11 files changed, 42 insertions(+), 27 deletions(-) diff --git a/frontend/src/common/helpers/formatDate.ts b/frontend/src/common/helpers/formatDate.ts index 5771c02da..ca9888669 100644 --- a/frontend/src/common/helpers/formatDate.ts +++ b/frontend/src/common/helpers/formatDate.ts @@ -35,22 +35,22 @@ export const now = () => dayjs(); export const nowUtc = () => dayjs.utc(); /** - * Get local datetime string in a specified format for a given DayJS object. - * @param dayjsObj DayJS object that could be in any timezone + * Get local datetime string in a specified format for a given local DayJS object. + * @param localDayjs Local DayJS object * @param formatStr datetime format to display the datetime in (default ISO-8601) * @returns datetime string representing local datetime in the format specified */ -export const dayjsToLocalStr = (dayjsObj: Dayjs, formatStr?: string) => - dayjs(dayjsObj).local().format(formatStr); +export const dayjsToLocalStr = (localDayjs: Dayjs, formatStr?: string) => + dayjs(localDayjs).format(formatStr); /** - * Get UTC datetime string in a specified format for a given DayJS object. - * @param dayjsObj DayJS object that could be in any timezone + * Get UTC datetime string in a specified format for a given local DayJS object. + * @param localDayjs Local DayJS object * @param formatStr datetime format to display the datetime in (default ISO-8601) * @returns datetime string representing UTC datetime in the format specified */ -export const dayjsToUtcStr = (dayjsObj: Dayjs, formatStr?: string) => - dayjs(dayjsObj).utc().format(formatStr); +export const dayjsToUtcStr = (localDayjs: Dayjs, formatStr?: string) => + dayjs(localDayjs).utc().format(formatStr); /** * Get UTC datetime string in a specified format for a given datetime string @@ -65,10 +65,16 @@ export const toUtc = (dateTimeStr: string, formatStr?: string) => * Get local datetime string in a specified format for a given datetime string * @param dateTimeStr datetime string that could be in any timezone * @param formatStr datetime format to display in (default ISO-8601) + * @param isDateTimeStrLocal Whether or not the provided datetime string is already local * @returns datetime string representing local datetime in the format specified */ -export const toLocal = (dateTimeStr: string, formatStr?: string) => - dayjs(dateTimeStr).local().format(formatStr); +export const toLocal = ( + dateTimeStr: string, + formatStr?: string, + isDateTimeStrLocal?: boolean, +) => isDateTimeStrLocal + ? dayjs(dateTimeStr).format(formatStr) + : dayjs(dateTimeStr).local().format(formatStr); /** * Get local DayJS object for a given UTC datetime string @@ -106,7 +112,7 @@ export const toTimeZone = ( ) => ianaId ? dayjs(datetimeStr).tz(ianaId).format(formatStr) - : toLocal(datetimeStr, formatStr); + : toLocal(datetimeStr, formatStr, true); /** * Gets the number of days between two datetimes (should both be in the same timezone). diff --git a/frontend/src/common/helpers/tableHelper.ts b/frontend/src/common/helpers/tableHelper.ts index 3d131fcd6..342c7350e 100644 --- a/frontend/src/common/helpers/tableHelper.ts +++ b/frontend/src/common/helpers/tableHelper.ts @@ -7,13 +7,17 @@ import { PermitListItem } from "../../features/permits/types/permit"; import { Nullable } from "../types/common"; /** - * Format a given datetime string to a format that we can display - * @param rawDateTime + * Format a datetime string in a table cell to a given display format. + * @param rawDateTime Provided datetime string, if any + * @param isDateTimeLocal Whether or not the provided datetime is local * @returns datetime string for display or "NA" if invalid date given */ -export const formatCellValuetoDatetime = (rawDateTime: Nullable) => { +export const formatCellValuetoDatetime = ( + rawDateTime: Nullable, + isDateTimeLocal?: boolean, +) => { return applyWhenNotNullable( - (dt) => toLocal(dt, DATE_FORMATS.DATEONLY_ABBR_MONTH), + (dt) => toLocal(dt, DATE_FORMATS.DATEONLY_ABBR_MONTH, isDateTimeLocal), rawDateTime, "NA", ); diff --git a/frontend/src/features/idir/search/table/PermitSearchResultColumnDef.tsx b/frontend/src/features/idir/search/table/PermitSearchResultColumnDef.tsx index 8d956e1ca..253ee9a5f 100644 --- a/frontend/src/features/idir/search/table/PermitSearchResultColumnDef.tsx +++ b/frontend/src/features/idir/search/table/PermitSearchResultColumnDef.tsx @@ -105,7 +105,7 @@ export const PermitSearchResultColumnDef = ( enableSorting: true, sortingFn: dateTimeStringSortingFn, Cell: (props: { cell: any }) => { - const formattedDate = formatCellValuetoDatetime(props.cell.getValue()); + const formattedDate = formatCellValuetoDatetime(props.cell.getValue(), true); return formattedDate; }, }, @@ -115,7 +115,7 @@ export const PermitSearchResultColumnDef = ( enableSorting: true, sortingFn: dateTimeStringSortingFn, Cell: (props: { cell: any }) => { - const formattedDate = formatCellValuetoDatetime(props.cell.getValue()); + const formattedDate = formatCellValuetoDatetime(props.cell.getValue(), true); return formattedDate; }, }, diff --git a/frontend/src/features/permits/apiManager/permitsAPI.ts b/frontend/src/features/permits/apiManager/permitsAPI.ts index 52ac62117..3131adfea 100644 --- a/frontend/src/features/permits/apiManager/permitsAPI.ts +++ b/frontend/src/features/permits/apiManager/permitsAPI.ts @@ -196,6 +196,7 @@ export const getApplications = async ( startDate: toLocal( application?.startDate, DATE_FORMATS.DATEONLY_SHORT_NAME, + true, ), } as ApplicationListItem; }); @@ -494,10 +495,12 @@ export const getPermits = async ( startDate: toLocal( permit.startDate, DATE_FORMATS.DATEONLY_SHORT_NAME, + true, ), expiryDate: toLocal( permit.expiryDate, DATE_FORMATS.DATEONLY_SHORT_NAME, + true, ), } as PermitListItem; }, diff --git a/frontend/src/features/permits/components/permit-list/Columns.tsx b/frontend/src/features/permits/components/permit-list/Columns.tsx index c27bd3ee6..177cb6699 100644 --- a/frontend/src/features/permits/components/permit-list/Columns.tsx +++ b/frontend/src/features/permits/components/permit-list/Columns.tsx @@ -71,7 +71,7 @@ export const PermitsColumnDefinition = ( header: "Permit Start Date", enableSorting: true, Cell: (props: { cell: any }) => { - const formattedDate = formatCellValuetoDatetime(props.cell.getValue()); + const formattedDate = formatCellValuetoDatetime(props.cell.getValue(), true); return formattedDate; }, }, @@ -81,7 +81,7 @@ export const PermitsColumnDefinition = ( id: "expiryDate", enableSorting: true, Cell: (props: { cell: any }) => { - const formattedDate = formatCellValuetoDatetime(props.cell.getValue()); + const formattedDate = formatCellValuetoDatetime(props.cell.getValue(), true); return formattedDate; }, }, diff --git a/frontend/src/features/permits/helpers/equality.ts b/frontend/src/features/permits/helpers/equality.ts index e1d2ddb0f..1987ec74a 100644 --- a/frontend/src/features/permits/helpers/equality.ts +++ b/frontend/src/features/permits/helpers/equality.ts @@ -6,11 +6,11 @@ import { PermitVehicleDetails } from "../types/PermitVehicleDetails"; import { PermitData } from "../types/PermitData"; import { PermitCondition } from "../types/PermitCondition"; import { arePermitLOADetailsEqual, PermitLOA } from "../types/PermitLOA"; +import { doUniqueArraysHaveSameObjects } from "../../../common/helpers/equality"; import { DATE_FORMATS, dayjsToLocalStr, } from "../../../common/helpers/formatDate"; -import { doUniqueArraysHaveSameObjects } from "../../../common/helpers/equality"; /** * Compare whether or not two mailing addresses are equal. diff --git a/frontend/src/features/permits/pages/Amend/components/AmendPermitForm.tsx b/frontend/src/features/permits/pages/Amend/components/AmendPermitForm.tsx index 5e4a44f4b..326c1e1d0 100644 --- a/frontend/src/features/permits/pages/Amend/components/AmendPermitForm.tsx +++ b/frontend/src/features/permits/pages/Amend/components/AmendPermitForm.tsx @@ -24,7 +24,7 @@ import { useFetchSpecialAuthorizations } from "../../../../settings/hooks/specia import { filterLOAsForPermitType, filterNonExpiredLOAs } from "../../../helpers/permitLOA"; import { dayjsToUtcStr, - nowUtc, + now, } from "../../../../../common/helpers/formatDate"; import { @@ -213,7 +213,7 @@ export const AmendPermitForm = () => { comment: getDefaultRequiredVal("", history.comment), name: history.commentUsername, revisionDateTime: getDefaultRequiredVal( - dayjsToUtcStr(nowUtc()), + dayjsToUtcStr(now()), history.transactionSubmitDate, ), })); diff --git a/frontend/src/features/permits/pages/Application/components/form/LOATable.tsx b/frontend/src/features/permits/pages/Application/components/form/LOATable.tsx index ce6d0dd6d..93aa7371e 100644 --- a/frontend/src/features/permits/pages/Application/components/form/LOATable.tsx +++ b/frontend/src/features/permits/pages/Application/components/form/LOATable.tsx @@ -85,7 +85,7 @@ export const LOATable = ({ scope="row" > {applyWhenNotNullable( - expiryDate => toLocal(expiryDate, DATE_FORMATS.DATEONLY_SLASH), + expiryDate => toLocal(expiryDate, DATE_FORMATS.DATEONLY_SLASH, true), selectableLOA.loa.expiryDate, "Never expires", )} diff --git a/frontend/src/features/permits/pages/ShoppingCart/components/ShoppingCartItem.tsx b/frontend/src/features/permits/pages/ShoppingCart/components/ShoppingCartItem.tsx index 1689e3535..47238ff57 100644 --- a/frontend/src/features/permits/pages/ShoppingCart/components/ShoppingCartItem.tsx +++ b/frontend/src/features/permits/pages/ShoppingCart/components/ShoppingCartItem.tsx @@ -83,7 +83,7 @@ export const ShoppingCartItem = ({ - {toLocal(cartItemData.startDate, DATE_FORMATS.DATEONLY_ABBR_MONTH)} + {toLocal(cartItemData.startDate, DATE_FORMATS.DATEONLY_ABBR_MONTH, true)} @@ -113,7 +113,7 @@ export const ShoppingCartItem = ({ - {toLocal(cartItemData.expiryDate, DATE_FORMATS.DATEONLY_ABBR_MONTH)} + {toLocal(cartItemData.expiryDate, DATE_FORMATS.DATEONLY_ABBR_MONTH, true)} diff --git a/frontend/src/features/permits/pages/Void/components/VoidPermitHeader.tsx b/frontend/src/features/permits/pages/Void/components/VoidPermitHeader.tsx index af5f3e07e..bb338612d 100644 --- a/frontend/src/features/permits/pages/Void/components/VoidPermitHeader.tsx +++ b/frontend/src/features/permits/pages/Void/components/VoidPermitHeader.tsx @@ -47,6 +47,7 @@ export const VoidPermitHeader = ({ permit }: { permit: Nullable }) => { {toLocal( permit.permitData.startDate, DATE_FORMATS.DATEONLY_ABBR_MONTH, + true, )} @@ -62,6 +63,7 @@ export const VoidPermitHeader = ({ permit }: { permit: Nullable }) => { {toLocal( permit.permitData.expiryDate, DATE_FORMATS.DATEONLY_ABBR_MONTH, + true, )} diff --git a/frontend/src/features/settings/components/SpecialAuthorizations/LOA/list/LOAListColumnDef.tsx b/frontend/src/features/settings/components/SpecialAuthorizations/LOA/list/LOAListColumnDef.tsx index ea09f28e4..a8d3e8e7e 100644 --- a/frontend/src/features/settings/components/SpecialAuthorizations/LOA/list/LOAListColumnDef.tsx +++ b/frontend/src/features/settings/components/SpecialAuthorizations/LOA/list/LOAListColumnDef.tsx @@ -36,7 +36,7 @@ export const LOAListColumnDef = ( }, { accessorFn: (originalRow) => { - return toLocal(originalRow.startDate, DATE_FORMATS.DATEONLY_SLASH); + return toLocal(originalRow.startDate, DATE_FORMATS.DATEONLY_SLASH, true); }, id: "startDate", header: "Start Date", @@ -54,7 +54,7 @@ export const LOAListColumnDef = ( { accessorFn: (originalRow) => applyWhenNotNullable( - (expiryDate) => toLocal(expiryDate, DATE_FORMATS.DATEONLY_SLASH), + (expiryDate) => toLocal(expiryDate, DATE_FORMATS.DATEONLY_SLASH, true), originalRow.expiryDate, "Never expires", ) as string, From 2a81a2587bf6f10b1c5803af9e2374c2acd878fa Mon Sep 17 00:00:00 2001 From: Praveen Raju <80779423+praju-aot@users.noreply.github.com> Date: Fri, 8 Nov 2024 13:16:28 -0500 Subject: [PATCH 2/3] fix:ORV2-2977 - Incorrect PermitFee amount in Permit Document and formatting (#1661) --- vehicles/src/common/constants/api.constant.ts | 3 +-- .../src/common/helper/format-template-data.helper.ts | 10 +++++++--- .../src/common/helper/permit-application.helper.ts | 9 ++++++--- vehicles/src/common/helper/permit-fee.helper.ts | 4 ++-- .../application/application.service.ts | 4 ++-- .../payment/payment.service.ts | 11 ++++++++--- 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/vehicles/src/common/constants/api.constant.ts b/vehicles/src/common/constants/api.constant.ts index b15b80cbe..ffcbeb052 100644 --- a/vehicles/src/common/constants/api.constant.ts +++ b/vehicles/src/common/constants/api.constant.ts @@ -8,6 +8,5 @@ export const CRYPTO_ALGORITHM_MD5 = 'md5'; export const CRYPTO_ALGORITHM_SHA256 = 'sha256'; export const TOKEN_EXPIRY_BUFFER = 15; export const PERMISSIONS_KEY = 'permissions'; -export const TIMEZONE_PACIFIC = "America/Vancouver"; +export const TIMEZONE_PACIFIC = 'America/Vancouver'; export const GL_PROJ_CODE_PLACEHOLDER = 'PROJECT'; - diff --git a/vehicles/src/common/helper/format-template-data.helper.ts b/vehicles/src/common/helper/format-template-data.helper.ts index a82101252..8181ef3d8 100644 --- a/vehicles/src/common/helper/format-template-data.helper.ts +++ b/vehicles/src/common/helper/format-template-data.helper.ts @@ -9,6 +9,7 @@ import { PermitTemplateData, } from '../interface/permit.template.interface'; import { FullNamesForDgen } from '../interface/full-names-for-dgen.interface'; +import { formatAmount } from './payment.helper'; /** * Formats the permit data so that it can be used in the templated word documents @@ -87,9 +88,12 @@ export const formatTemplateData = ( template.companyAlternateName = companyInfo.alternateName; // Format Fee Summary - template.permitData.feeSummary = permit.permitTransactions - ?.at(0) - ?.transactionAmount.toString(); + const transcation = permit.permitTransactions?.at(0)?.transaction; + + template.permitData.feeSummary = formatAmount( + transcation.transactionTypeId, + permit.permitTransactions?.at(0)?.transactionAmount, + ).toString(); revisionHistory?.forEach((revision) => { if ( diff --git a/vehicles/src/common/helper/permit-application.helper.ts b/vehicles/src/common/helper/permit-application.helper.ts index b572f57e9..96d3b53e4 100644 --- a/vehicles/src/common/helper/permit-application.helper.ts +++ b/vehicles/src/common/helper/permit-application.helper.ts @@ -268,9 +268,12 @@ export const isPermitTypeEligibleForQueue = ( return PERMIT_TYPES_FOR_QUEUE.includes(permitType); }; -export const validApplicationDates = (application: Permit, timezone: string): boolean => { +export const validApplicationDates = ( + application: Permit, + timezone: string, +): boolean => { const todayUTC = dayjs(new Date()); - const todayPacific = todayUTC.tz(timezone).format("YYYY-MM-DD"); + const todayPacific = todayUTC.tz(timezone).format('YYYY-MM-DD'); const { startDate, expiryDate } = application.permitData; return startDate >= todayPacific && startDate <= expiryDate; -} +}; diff --git a/vehicles/src/common/helper/permit-fee.helper.ts b/vehicles/src/common/helper/permit-fee.helper.ts index 8e2314c02..dc14bf979 100644 --- a/vehicles/src/common/helper/permit-fee.helper.ts +++ b/vehicles/src/common/helper/permit-fee.helper.ts @@ -205,7 +205,7 @@ export const validAmount = ( calculatedAmount: number, receivedAmount: number, transactionType: TransactionType, -): boolean =>{ +): boolean => { const isAmountValid = receivedAmount.toFixed(2) === Math.abs(calculatedAmount).toFixed(2); @@ -218,4 +218,4 @@ export const validAmount = ( isAmountValid && (isRefundValid || transactionType !== TransactionType.REFUND) ); -} +}; diff --git a/vehicles/src/modules/permit-application-payment/application/application.service.ts b/vehicles/src/modules/permit-application-payment/application/application.service.ts index 81f29aef6..5cde7daa3 100644 --- a/vehicles/src/modules/permit-application-payment/application/application.service.ts +++ b/vehicles/src/modules/permit-application-payment/application/application.service.ts @@ -1236,8 +1236,8 @@ export class ApplicationService { company: { companyId: permit.company.companyId }, }, }); - if(loaDetails.length != loaIdsToInsert.length) - throw new BadRequestException('One or more loa(s) does not exist') + if (loaDetails.length != loaIdsToInsert.length) + throw new BadRequestException('One or more loa(s) does not exist'); // Transform the permit LOA IDs from an array of numbers into individual records. const singlePermitLoa = loaIdsToInsert.map((loaId) => ({ permitId, diff --git a/vehicles/src/modules/permit-application-payment/payment/payment.service.ts b/vehicles/src/modules/permit-application-payment/payment/payment.service.ts index e4a061f1a..e511f1ced 100644 --- a/vehicles/src/modules/permit-application-payment/payment/payment.service.ts +++ b/vehicles/src/modules/permit-application-payment/payment/payment.service.ts @@ -51,7 +51,10 @@ import { } from 'src/common/helper/permit-fee.helper'; import { CfsTransactionDetail } from './entities/cfs-transaction.entity'; import { CfsFileStatus } from 'src/common/enum/cfs-file-status.enum'; -import { isAmendmentApplication, validApplicationDates } from '../../../common/helper/permit-application.helper'; +import { + isAmendmentApplication, + validApplicationDates, +} from '../../../common/helper/permit-application.helper'; import { isCfsPaymentMethodType } from 'src/common/helper/payment.helper'; import { PgApprovesStatus } from 'src/common/enum/pg-approved-status-type.enum'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; @@ -513,8 +516,10 @@ export class PaymentService { // Calculate and add amount for each requested application, as per the available backend data. for (const application of applications) { //Check if each application has a valid start date and valid expiry date. - if (isCVClientUser && !validApplicationDates(application, TIMEZONE_PACIFIC)) - { + if ( + isCVClientUser && + !validApplicationDates(application, TIMEZONE_PACIFIC) + ) { throw new UnprocessableEntityException( `Atleast one of the application has invalid startDate or expiryDate.`, ); From b6a7322af03fff1f8aedf13b694be619757f4f69 Mon Sep 17 00:00:00 2001 From: Praveen Raju <80779423+praju-aot@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:40:57 -0500 Subject: [PATCH 3/3] feat:ORV2-2950 - Update MFP name to Motive Fuel User Permit (#1662) Co-authored-by: John Fletcher --- .../versions/revert/v_47_ddl_revert.sql | 38 +++++++++++++++++ database/mssql/scripts/versions/v_47_ddl.sql | 42 +++++++++++++++++++ database/mssql/test/versions/v_47_1_test.sql | 5 +++ database/mssql/test/versions/v_47_test.sh | 16 +++++++ 4 files changed, 101 insertions(+) create mode 100644 database/mssql/scripts/versions/revert/v_47_ddl_revert.sql create mode 100644 database/mssql/scripts/versions/v_47_ddl.sql create mode 100644 database/mssql/test/versions/v_47_1_test.sql create mode 100644 database/mssql/test/versions/v_47_test.sh diff --git a/database/mssql/scripts/versions/revert/v_47_ddl_revert.sql b/database/mssql/scripts/versions/revert/v_47_ddl_revert.sql new file mode 100644 index 000000000..da54853eb --- /dev/null +++ b/database/mssql/scripts/versions/revert/v_47_ddl_revert.sql @@ -0,0 +1,38 @@ +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 [permit].[ORBC_PERMIT_TYPE] SET NAME='Motive Fuel User',[DB_LAST_UPDATE_TIMESTAMP] =getutcdate() WHERE PERMIT_TYPE='MFP'; + +DECLARE @VersionDescription VARCHAR(255) +SET @VersionDescription = 'Reverting permit name update for MFP' + +INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (46, @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 diff --git a/database/mssql/scripts/versions/v_47_ddl.sql b/database/mssql/scripts/versions/v_47_ddl.sql new file mode 100644 index 000000000..d1c0a7334 --- /dev/null +++ b/database/mssql/scripts/versions/v_47_ddl.sql @@ -0,0 +1,42 @@ +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 [permit].[ORBC_PERMIT_TYPE] SET NAME='Motive Fuel User Permit',[DB_LAST_UPDATE_TIMESTAMP] =getutcdate() WHERE PERMIT_TYPE='MFP'; + +IF @@ERROR <> 0 SET NOEXEC ON +GO + +DECLARE @VersionDescription VARCHAR(255) +SET @VersionDescription = 'Update permit name of permit type MFP' + +INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [UPDATE_SCRIPT], [REVERT_SCRIPT], [RELEASE_DATE]) VALUES (47, @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 + diff --git a/database/mssql/test/versions/v_47_1_test.sql b/database/mssql/test/versions/v_47_1_test.sql new file mode 100644 index 000000000..a6976c848 --- /dev/null +++ b/database/mssql/test/versions/v_47_1_test.sql @@ -0,0 +1,5 @@ +-- Test that the permit name has been configured correctly +SET NOCOUNT ON + +SELECT COUNT(*) FROM $(DB_NAME).[permit].[ORBC_PERMIT_TYPE] +WHERE NAME='Motive Fuel User Permit' \ No newline at end of file diff --git a/database/mssql/test/versions/v_47_test.sh b/database/mssql/test/versions/v_47_test.sh new file mode 100644 index 000000000..a0be927ff --- /dev/null +++ b/database/mssql/test/versions/v_47_test.sh @@ -0,0 +1,16 @@ +#!/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 47 are run from this shell script. +# TESTS_DIR variable set by the calling test-runner script. + +TEST_47_1_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_47_1_test.sql | xargs) +if [[ $TEST_47_1_RESULT -eq 1 ]]; then + echo "Test 47.1 passed: MFP Permit name update successful." +else + echo "******** Test 47.1 failed: MFP Permit name update failed." +fi