Skip to content

Commit

Permalink
feat: Added Doing Business As
Browse files Browse the repository at this point in the history
  • Loading branch information
mamartinezmejia committed Jan 29, 2025
1 parent 1348225 commit d16c39c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 16 deletions.
10 changes: 8 additions & 2 deletions frontend/src/pages/ActivityLogPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<AuditLogResult[]>([]);
const detailsVisible = ref<{ [key: number]: boolean }>({});
Expand Down Expand Up @@ -91,6 +93,8 @@ const toggleDetails = (index: number) => {
<td style="width: 2rem !important;">
<span v-if="group[0].tableName === 'FOR_CLI_AUDIT'"><Avatar20 /></span>
<span v-if="group[0].tableName === 'CLI_LOCN_AUDIT'"><Location20 /></span>
<span v-if="group[0].tableName === 'CLI_CON_AUDIT'"><User20 /></span>
<span v-if="group[0].tableName === 'CLIENT_DOING_BUSINESS_AS_AUDIT'"><Multiple20 /></span>
</td>
<td class="label-02" style="vertical-align: middle;">
<h4>
Expand All @@ -103,9 +107,11 @@ const toggleDetails = (index: number) => {
<span v-if="group[0].tableName === 'CLI_CON_AUDIT'">
Contact "{{ group[0].identifierLabel }}"
</span>

<span v-if="group[0].tableName === 'CLIENT_DOING_BUSINESS_AS_AUDIT'">
Doing business as
</span>
<span v-if="group[0].changeType === 'UPDATE'">updated</span>
<span v-if="group[0].changeType === 'DELETE'">updated</span><!-- TBD based on the table -->
<span v-if="group[0].changeType === 'DELETE'">deleted</span>
<span v-if="group[0].changeType === 'INSERT'">added</span>

</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
)
Expand All @@ -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<AuditLogDto> findConctactAuditLogsByClientNumber(String clientNumber);
""")
Flux<AuditLogDto> 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<AuditLogDto> findDoingBusinessAsAuditLogsByClientNumber(String clientNumber);

}
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ public Flux<AuditLogDto> 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()
Expand Down

0 comments on commit d16c39c

Please sign in to comment.