diff --git a/frontend/src/pages/ActivityLogPage.vue b/frontend/src/pages/ActivityLogPage.vue index 1b471fb0f..471ff737b 100644 --- a/frontend/src/pages/ActivityLogPage.vue +++ b/frontend/src/pages/ActivityLogPage.vue @@ -14,6 +14,8 @@ import "@carbon/web-components/es/components/tag/index"; import Avatar16 from "@carbon/icons-vue/es/user--avatar/16"; import Avatar20 from "@carbon/icons-vue/es/user--avatar/20"; import Location20 from "@carbon/icons-vue/es/location/20"; +import User20 from "@carbon/icons-vue/es/user/20"; +import Multiple20 from "@carbon/icons-vue/es/user--multiple/20"; const auditLogs = ref([]); const detailsVisible = ref<{ [key: number]: boolean }>({}); @@ -91,6 +93,8 @@ const toggleDetails = (index: number) => { + +

@@ -103,9 +107,11 @@ const toggleDetails = (index: number) => { Contact "{{ group[0].identifierLabel }}" - + + Doing business as + updated - updated + deleted added

diff --git a/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java index ecfe68ffd..299d29d8e 100644 --- a/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java +++ b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java @@ -795,7 +795,7 @@ WITH AUDIT_DATA AS ( A.UPDATE_USERID, CASE WHEN OLD_VALUE IS NULL AND TRIM(NEW_VALUE) IS NOT NULL THEN 'INSERT' - WHEN OLD_VALUE IS NOT NULL AND NEW_VALUE IS NULL THEN 'DELETE' + WHEN OLD_VALUE IS NOT NULL AND NEW_VALUE IS NULL THEN 'UPDATE' WHEN TRIM(OLD_VALUE) <> TRIM(NEW_VALUE) THEN 'UPDATE' END AS CHANGE_TYPE, REASON @@ -817,7 +817,8 @@ WITH AUDIT_DATA AS ( BUS_CONTACT_CODE AS NEW_VALUE, LAG(BUS_CONTACT_CODE) OVER (PARTITION BY CLIENT_CONTACT_ID ORDER BY UPDATE_TIMESTAMP) AS OLD_VALUE, UPDATE_TIMESTAMP, - UPDATE_USERID + UPDATE_USERID, + CLIENT_AUDIT_CODE FROM THE.CLI_CON_AUDIT WHERE CLIENT_NUMBER = :clientNumber @@ -830,7 +831,8 @@ WITH AUDIT_DATA AS ( CONTACT_NAME AS NEW_VALUE, LAG(CONTACT_NAME) OVER (PARTITION BY CLIENT_CONTACT_ID ORDER BY UPDATE_TIMESTAMP) AS OLD_VALUE, UPDATE_TIMESTAMP, - UPDATE_USERID + UPDATE_USERID, + CLIENT_AUDIT_CODE FROM THE.CLI_CON_AUDIT WHERE CLIENT_NUMBER = :clientNumber @@ -843,7 +845,8 @@ WITH AUDIT_DATA AS ( BUSINESS_PHONE AS NEW_VALUE, LAG(BUSINESS_PHONE) OVER (PARTITION BY CLIENT_CONTACT_ID ORDER BY UPDATE_TIMESTAMP) AS OLD_VALUE, UPDATE_TIMESTAMP, - UPDATE_USERID + UPDATE_USERID, + CLIENT_AUDIT_CODE FROM THE.CLI_CON_AUDIT WHERE CLIENT_NUMBER = :clientNumber @@ -856,7 +859,8 @@ WITH AUDIT_DATA AS ( CELL_PHONE AS NEW_VALUE, LAG(CELL_PHONE) OVER (PARTITION BY CLIENT_CONTACT_ID ORDER BY UPDATE_TIMESTAMP) AS OLD_VALUE, UPDATE_TIMESTAMP, - UPDATE_USERID + UPDATE_USERID, + CLIENT_AUDIT_CODE FROM THE.CLI_CON_AUDIT WHERE CLIENT_NUMBER = :clientNumber @@ -869,7 +873,8 @@ WITH AUDIT_DATA AS ( FAX_NUMBER AS NEW_VALUE, LAG(FAX_NUMBER) OVER (PARTITION BY CLIENT_CONTACT_ID ORDER BY UPDATE_TIMESTAMP) AS OLD_VALUE, UPDATE_TIMESTAMP, - UPDATE_USERID + UPDATE_USERID, + CLIENT_AUDIT_CODE FROM THE.CLI_CON_AUDIT WHERE CLIENT_NUMBER = :clientNumber @@ -882,7 +887,8 @@ WITH AUDIT_DATA AS ( EMAIL_ADDRESS AS NEW_VALUE, LAG(EMAIL_ADDRESS) OVER (PARTITION BY CLIENT_CONTACT_ID ORDER BY UPDATE_TIMESTAMP) AS OLD_VALUE, UPDATE_TIMESTAMP, - UPDATE_USERID + UPDATE_USERID, + CLIENT_AUDIT_CODE FROM THE.CLI_CON_AUDIT WHERE CLIENT_NUMBER = :clientNumber ) @@ -897,20 +903,69 @@ WITH AUDIT_DATA AS ( A.UPDATE_TIMESTAMP, A.UPDATE_USERID, CASE - WHEN OLD_VALUE IS NULL AND TRIM(NEW_VALUE) IS NOT NULL THEN 'INSERT' - WHEN OLD_VALUE IS NOT NULL AND NEW_VALUE IS NULL THEN 'DELETE' - WHEN TRIM(OLD_VALUE) <> TRIM(NEW_VALUE) THEN 'UPDATE' + WHEN C.CONTACT_NAME IS NULL THEN 'DELETE' + WHEN A.CLIENT_AUDIT_CODE = 'UPD' THEN 'UPDATE' + WHEN A.CLIENT_AUDIT_CODE = 'INS' THEN 'UPDATE' END AS CHANGE_TYPE, '' AS REASON FROM AUDIT_DATA A - INNER JOIN THE.CLIENT_CONTACT C + FULL OUTER JOIN THE.CLIENT_CONTACT C ON A.IDX = C.CLIENT_CONTACT_ID WHERE (OLD_VALUE IS NULL AND TRIM(NEW_VALUE) IS NOT NULL) OR (OLD_VALUE IS NOT NULL AND NEW_VALUE IS NULL) OR (TRIM(OLD_VALUE) <> TRIM(NEW_VALUE)) ORDER BY A.UPDATE_TIMESTAMP DESC - """) - Flux findConctactAuditLogsByClientNumber(String clientNumber); + """) + Flux findContactAuditLogsByClientNumber(String clientNumber); + + @Query(""" + WITH AUDIT_DATA AS ( + SELECT + 'CLIENT_DOING_BUSINESS_AS_AUDIT' AS TABLE_NAME, + CLIENT_DBA_ID AS IDX, + 'DOING_BUSINESS_AS_NAME' AS COLUMN_NAME, + DOING_BUSINESS_AS_NAME AS NEW_VALUE, + LAG(DOING_BUSINESS_AS_NAME) OVER ( + PARTITION BY CLIENT_NUMBER, CLIENT_DBA_ID + ORDER BY UPDATE_TIMESTAMP + ) AS OLD_VALUE, + LEAD(DOING_BUSINESS_AS_NAME) OVER ( + PARTITION BY CLIENT_NUMBER, CLIENT_DBA_ID + ORDER BY UPDATE_TIMESTAMP + ) AS NEXT_VALUE, + CLIENT_AUDIT_CODE, + UPDATE_TIMESTAMP, + UPDATE_USERID, + '' AS REASON + FROM THE.CLIENT_DOING_BUSINESS_AS_AUDIT + WHERE CLIENT_NUMBER = :clientNumber + ) + + SELECT + TABLE_NAME, + IDX, + '' AS IDENTIFIER_LABEL, + COLUMN_NAME, + OLD_VALUE, + NEW_VALUE, + A.UPDATE_TIMESTAMP, + A.UPDATE_USERID, + CASE + WHEN OLD_VALUE IS NULL AND TRIM(NEW_VALUE) IS NOT NULL THEN 'INSERT' + WHEN OLD_VALUE IS NOT NULL AND NEW_VALUE IS NULL THEN 'UPDATE' + WHEN TRIM(OLD_VALUE) <> TRIM(NEW_VALUE) THEN 'UPDATE' + WHEN OLD_VALUE IS NOT NULL AND NEXT_VALUE IS NULL THEN 'DELETE' + END AS CHANGE_TYPE, + REASON + FROM AUDIT_DATA A + WHERE + (OLD_VALUE IS NULL AND TRIM(NEW_VALUE) IS NOT NULL) + OR (OLD_VALUE IS NOT NULL AND NEW_VALUE IS NULL) + OR (TRIM(OLD_VALUE) <> TRIM(NEW_VALUE)) + OR (OLD_VALUE IS NOT NULL AND NEXT_VALUE IS NULL) + ORDER BY A.UPDATE_TIMESTAMP DESC, CHANGE_TYPE ASC + """) + Flux findDoingBusinessAsAuditLogsByClientNumber(String clientNumber); } \ No newline at end of file diff --git a/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java b/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java index c91631aa9..1e4744982 100644 --- a/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java +++ b/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java @@ -590,7 +590,8 @@ public Flux findAuditLogsByClientNumber(String clientNumber) { .merge( forestClientRepository.findLocationAuditLogsByClientNumber(clientNumber), forestClientRepository.findClientInformationAuditLogsByClientNumber(clientNumber), - forestClientRepository.findConctactAuditLogsByClientNumber(clientNumber) + forestClientRepository.findContactAuditLogsByClientNumber(clientNumber), + forestClientRepository.findDoingBusinessAsAuditLogsByClientNumber(clientNumber) ) .sort(Comparator .comparing(AuditLogDto::updateTimestamp, Comparator.nullsLast(Comparator.naturalOrder())).reversed()