From 1bc9d0901d9cdefa50f791d14f216df3fd45b7a4 Mon Sep 17 00:00:00 2001 From: Nitesh Yadav Date: Thu, 27 Aug 2026 18:41:42 +0530 Subject: [PATCH] feat(savings): facility charge mapping admin API, enforce mapped-charge validation, INR-only currency, GL chart backfill Adds the admin read/write API for m_facility_charge_mapping (list, template, update) so facilities can be pointed at a real charge instead of relying on the seeder's implicit auto-link, and makes enable-on-account paths (activation and edit-approval, both savings and current accounts) throw instead of silently skipping the charge when a facility isn't mapped or is inactive. Migrations 0497-0509 back this up: reset all facility mappings to unmapped/inactive by default, backfill lost roles/permissions/charges, enforce INR as the only organisation currency, backfill the full real-world chart of accounts (44 core + 60 priority GL heads) with standardized gl_codes, and retire the unused system-defined payment types (Share Redemption Transfer and friends) in favor of Cash/Transfer only, matching the teller dashboard's simplified payment-type flow. Co-Authored-By: Claude Sonnet 5 --- .../service/CommandWrapperBuilder.java | 8 + ...lerkShareWithdrawalRequestApiResource.java | 6 +- .../FacilityChargeMappingsApiResource.java | 94 +++ ...teFacilityChargeMappingCommandHandler.java | 42 ++ ...urrentAccountWritePlatformServiceImpl.java | 17 +- .../src/main/resources/application.properties | 4 +- .../db/changelog/tenant/changelog-tenant.xml | 3 + .../tenant/final-changelog-tenant.xml | 10 + .../tenant/parts/0497_backfill_lost_roles.xml | 218 ++++++ .../parts/0498_backfill_required_charges.xml | 106 +++ ...dd_facility_charge_mapping_permissions.xml | 55 ++ ...t_facility_charge_mappings_to_unmapped.xml | 40 ++ ...enforce_inr_only_organisation_currency.xml | 50 ++ .../0502_backfill_core_chart_of_accounts.xml | 196 +++++ .../0503_standardize_gl_account_codes.xml | 89 +++ .../parts/0504_add_priority_gl_accounts.xml | 200 ++++++ ...backfill_missing_codes_and_code_values.xml | 674 ++++++++++++++++++ ..._context_default_client_kyc_migrations.xml | 534 ++++++++++++++ .../0507_simplify_teller_payment_types.xml | 72 ++ ...share_redemption_transfer_payment_type.xml | 60 ++ ...etire_all_system_defined_payment_types.xml | 69 ++ .../data/FacilityChargeMappingData.java | 83 +++ ...acilityChargeMappingNotFoundException.java | 28 + .../FacilityChargeAutoApplyService.java | 78 +- ...ilityChargeMappingReadPlatformService.java | 32 + ...yChargeMappingReadPlatformServiceImpl.java | 78 ++ ...lityChargeMappingWritePlatformService.java | 27 + ...ChargeMappingWritePlatformServiceImpl.java | 102 +++ .../service/FacilityChargeSeederService.java | 52 +- 29 files changed, 2957 insertions(+), 70 deletions(-) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FacilityChargeMappingsApiResource.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/handler/UpdateFacilityChargeMappingCommandHandler.java create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0497_backfill_lost_roles.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0498_backfill_required_charges.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0499_add_facility_charge_mapping_permissions.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0500_reset_facility_charge_mappings_to_unmapped.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0501_enforce_inr_only_organisation_currency.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0502_backfill_core_chart_of_accounts.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0503_standardize_gl_account_codes.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0504_add_priority_gl_accounts.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0505_backfill_missing_codes_and_code_values.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0506_catchup_context_default_client_kyc_migrations.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0507_simplify_teller_payment_types.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0508_retire_share_redemption_transfer_payment_type.xml create mode 100644 fineract-provider/src/main/resources/db/changelog/tenant/parts/0509_retire_all_system_defined_payment_types.xml create mode 100644 fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/data/FacilityChargeMappingData.java create mode 100644 fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/exception/FacilityChargeMappingNotFoundException.java create mode 100644 fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingReadPlatformService.java create mode 100644 fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingReadPlatformServiceImpl.java create mode 100644 fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingWritePlatformService.java create mode 100644 fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingWritePlatformServiceImpl.java diff --git a/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java b/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java index ae8f7d0b9..24adb21c5 100644 --- a/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java +++ b/fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java @@ -3112,6 +3112,14 @@ public class CommandWrapperBuilder { return this; } + public CommandWrapperBuilder updateFacilityChargeMapping(final Long mappingId) { + this.actionName = "UPDATE"; + this.entityName = "FACILITYCHARGEMAPPING"; + this.entityId = mappingId; + this.href = "/facilitychargemappings/" + mappingId; + return this; + } + public CommandWrapperBuilder deleteOfficeToGLAccountMapping(final Long mappingId) { this.actionName = "DELETE"; this.entityName = "FINANCIALACTIVITYACCOUNT"; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/clerkwithdrawal/api/ClerkShareWithdrawalRequestApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/clerkwithdrawal/api/ClerkShareWithdrawalRequestApiResource.java index 75f97f2a4..30dbe7b23 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/clerkwithdrawal/api/ClerkShareWithdrawalRequestApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/clerkwithdrawal/api/ClerkShareWithdrawalRequestApiResource.java @@ -91,7 +91,11 @@ public class ClerkShareWithdrawalRequestApiResource { "(SELECT value FROM m_payment_type WHERE id = settlement_payment_type_id) AS settlement_payment_type_name", "settlement_amount", "settlement_savings_transaction_id", "settlement_row_snapshot" }; - private static final String SHARE_REDEMPTION_PAYMENT_TYPE_CODE = "SHARE_REDEMPTION_TRANSFER"; + // "Share Redemption Transfer" (a dedicated, teller-hidden payment type) was retired in favour of + // the plain "Transfer" type every settlement now uses -- this fallback code name follows it, so a + // pre-settlement_payment_type_id-column legacy request still resolves to a real payment type + // instead of silently posting its settlement with none at all. + private static final String SHARE_REDEMPTION_PAYMENT_TYPE_CODE = "TRANSFER"; // ── POST /v1/clerk/share-withdrawal-requests ── Clerk submits new request ─── diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FacilityChargeMappingsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FacilityChargeMappingsApiResource.java new file mode 100644 index 000000000..a09b6c09d --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FacilityChargeMappingsApiResource.java @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.api; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.PUT; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.apache.fineract.commands.domain.CommandWrapper; +import org.apache.fineract.commands.service.CommandWrapperBuilder; +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; +import org.apache.fineract.portfolio.savings.data.FacilityChargeMappingData; +import org.apache.fineract.portfolio.savings.service.FacilityChargeMappingReadPlatformService; +import org.springframework.stereotype.Component; + +/** + * Admin screen backing API for {@code m_facility_charge_mapping}: which {@link org.apache.fineract.portfolio.charge.domain.Charge} + * is applied when a named account facility (ATM_FACILITY, UPI_FACILITY, ...) is enabled on a savings/current + * account. The 16 facility rows themselves are fixed and auto-seeded by FacilityChargeSeederService at startup, + * so this resource only ever reads them and updates which charge one maps to -- there is no create/delete. + */ +@Path("/v1/facilitychargemappings") +@Component +@Tag(name = "Facility Charge Mappings", description = """ + Which charge is applied when a named account facility (ATM Facility, UPI Facility, Cheque Book, ...) \ + is enabled on a savings or current account. Enabling a facility whose mapping has no charge configured \ + is rejected -- configure the mapping here first.""") +@RequiredArgsConstructor +public class FacilityChargeMappingsApiResource { + + private static final String RESOURCE_NAME_FOR_PERMISSION = "FACILITYCHARGEMAPPING"; + + private final PlatformSecurityContext context; + private final FacilityChargeMappingReadPlatformService readPlatformService; + private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; + + @GET + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + @Operation(summary = "List Facility Charge Mappings", description = "Example Requests: facilitychargemappings") + public List retrieveAll() { + context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION); + return readPlatformService.retrieveAll(); + } + + @GET + @Path("template") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + @Operation(summary = "Retrieve Facility Charge Mapping Template", description = "Charge options available for mapping to a facility") + public FacilityChargeMappingData retrieveTemplate() { + context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION); + return readPlatformService.retrieveTemplate(); + } + + @PUT + @Path("{mappingId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + @Operation(summary = "Update a Facility Charge Mapping", description = "Changes which charge is applied when the facility is enabled") + public CommandProcessingResult update(@PathParam("mappingId") @Parameter(description = "mappingId") final Long mappingId, + @Parameter(hidden = true) final String apiRequestBodyAsJson) { + final CommandWrapper commandRequest = new CommandWrapperBuilder().updateFacilityChargeMapping(mappingId) + .withJson(apiRequestBodyAsJson).build(); + + return commandsSourceWritePlatformService.logCommandSource(commandRequest); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/handler/UpdateFacilityChargeMappingCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/handler/UpdateFacilityChargeMappingCommandHandler.java new file mode 100644 index 000000000..76ec0e396 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/handler/UpdateFacilityChargeMappingCommandHandler.java @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.handler; + +import lombok.RequiredArgsConstructor; +import org.apache.fineract.commands.annotation.CommandType; +import org.apache.fineract.commands.handler.NewCommandSourceHandler; +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.portfolio.savings.service.FacilityChargeMappingWritePlatformService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "FACILITYCHARGEMAPPING", action = "UPDATE") +@RequiredArgsConstructor +public class UpdateFacilityChargeMappingCommandHandler implements NewCommandSourceHandler { + + private final FacilityChargeMappingWritePlatformService writePlatformService; + + @Transactional + @Override + public CommandProcessingResult processCommand(final JsonCommand command) { + return this.writePlatformService.updateMapping(command.entityId(), command); + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/CurrentAccountWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/CurrentAccountWritePlatformServiceImpl.java index a5a221774..c6ee7f823 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/CurrentAccountWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/CurrentAccountWritePlatformServiceImpl.java @@ -28,6 +28,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; +import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; @@ -636,14 +637,20 @@ public class CurrentAccountWritePlatformServiceImpl implements CurrentAccountWri for (final String facilityType : newlyEnabledFacilityTypes) { final var mappingOpt = facilityChargeMappingRepository.findByFacilityType(facilityType); - if (mappingOpt.isEmpty()) { - log.warn("[FacilityCharge] {} newly-enabled via edit-approval but NO mapping found in m_facility_charge_mapping", + // An inactive mapping is treated the same as an unmapped one -- see FacilityChargeAutoApplyService's + // requireMappedCharge for why. + if (mappingOpt.isEmpty() || mappingOpt.get().getCharge() == null || !Boolean.TRUE.equals(mappingOpt.get().getIsActive())) { + throw new GeneralPlatformDomainRuleException("error.msg.facility.charge.not.mapped", + "A charge has not been mapped for the '" + facilityType + + "' facility. Configure it under Products > Facility Charge Mappings before enabling it.", facilityType); - continue; } final org.apache.fineract.portfolio.charge.domain.Charge charge = mappingOpt.get().getCharge(); - if (charge == null) { - continue; + if (charge.isDeleted() || !charge.isActive()) { + throw new GeneralPlatformDomainRuleException("error.msg.facility.charge.deleted", + "The charge mapped to the '" + facilityType + + "' facility has been deleted or deactivated. Update the mapping under Products > Facility Charge Mappings before enabling it.", + facilityType); } final org.apache.fineract.portfolio.currentaccount.domain.CurrentAccountCharge newCharge = org.apache.fineract.portfolio.currentaccount.domain.CurrentAccountCharge.createFromFacility(account, charge); diff --git a/fineract-provider/src/main/resources/application.properties b/fineract-provider/src/main/resources/application.properties index 70fbe79ba..e39a6cdd6 100644 --- a/fineract-provider/src/main/resources/application.properties +++ b/fineract-provider/src/main/resources/application.properties @@ -46,7 +46,7 @@ fineract.security.oauth2.client.registrations.frontend-client.require-authorizat fineract.tenant.host=${FINERACT_DEFAULT_TENANTDB_HOSTNAME:localhost} fineract.tenant.port=${FINERACT_DEFAULT_TENANTDB_PORT:5432} fineract.tenant.username=${FINERACT_DEFAULT_TENANTDB_UID:postgres} -fineract.tenant.password=${FINERACT_DEFAULT_TENANTDB_PWD:Keshav@898966} +fineract.tenant.password=${FINERACT_DEFAULT_TENANTDB_PWD:313863} fineract.tenant.parameters=${FINERACT_DEFAULT_TENANTDB_CONN_PARAMS:} fineract.tenant.timezone=${FINERACT_DEFAULT_TENANTDB_TIMEZONE:Asia/Kolkata} fineract.tenant.identifier=${FINERACT_DEFAULT_TENANTDB_IDENTIFIER:default} @@ -407,7 +407,7 @@ server.tomcat.mbeanregistry.enabled=${FINERACT_SERVER_TOMCAT_MBEANREGISTRY_ENABL spring.datasource.hikari.driverClassName=${FINERACT_HIKARI_DRIVER_SOURCE_CLASS_NAME:org.postgresql.Driver} spring.datasource.hikari.jdbcUrl=${FINERACT_HIKARI_JDBC_URL:jdbc:postgresql://localhost:5432/fineract_tenants} spring.datasource.hikari.username=${FINERACT_HIKARI_USERNAME:postgres} -spring.datasource.hikari.password=${FINERACT_HIKARI_PASSWORD:Keshav@898966} +spring.datasource.hikari.password=${FINERACT_HIKARI_PASSWORD:313863} spring.datasource.hikari.minimumIdle=${FINERACT_HIKARI_MINIMUM_IDLE:3} spring.datasource.hikari.maximumPoolSize=${FINERACT_HIKARI_MAXIMUM_POOL_SIZE:10} spring.datasource.hikari.idleTimeout=${FINERACT_HIKARI_IDLE_TIMEOUT:60000} diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml index 3e40835df..f51d9bc71 100644 --- a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml +++ b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml @@ -571,4 +571,7 @@ + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/final-changelog-tenant.xml b/fineract-provider/src/main/resources/db/changelog/tenant/final-changelog-tenant.xml index 27b3335ca..fceb9115a 100644 --- a/fineract-provider/src/main/resources/db/changelog/tenant/final-changelog-tenant.xml +++ b/fineract-provider/src/main/resources/db/changelog/tenant/final-changelog-tenant.xml @@ -23,4 +23,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd"> + + + + + + + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0497_backfill_lost_roles.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0497_backfill_lost_roles.xml new file mode 100644 index 000000000..b4b138625 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0497_backfill_lost_roles.xml @@ -0,0 +1,218 @@ + + + + + + + + + SELECT COUNT(*) FROM m_role WHERE name = 'Teller' + + + + + + + + + + + SELECT COUNT(*) FROM m_role WHERE name = 'Loan Officer' + + + + + + + + + + + SELECT COUNT(*) FROM m_role WHERE name = 'As Manager' + + + + + + + + + + + SELECT COUNT(*) FROM m_role WHERE name = 'ALL HEADER MENU' + + + + + + + + + + + SELECT COUNT(*) FROM m_role WHERE name = 'LEDGER' + + + + + + + + + + + SELECT COUNT(*) FROM m_role WHERE name = 'Teller' + + SELECT COUNT(*) FROM m_role_permission + WHERE role_id = (SELECT id FROM m_role WHERE name = 'Teller') + + + + INSERT INTO m_role_permission (role_id, permission_id) + SELECT (SELECT id FROM m_role WHERE name = 'Teller'), p.id + FROM m_permission p + WHERE p.code IN ( + 'ALLOCATECASHIER_TELLER', + 'ALLOCATECASHIER_TELLER_CHECKER', + 'ALLOCATECASHTOCASHIER_TELLER', + 'ALLOCATECASHTOCASHIER_TELLER_CHECKER', + 'CREATE_TELLER', + 'CREATE_TELLER_CHECKER', + 'DELETE_TELLER', + 'DELETE_TELLER_CHECKER', + 'DELETECASHIERALLOCATION_TELLER', + 'DELETECASHIERALLOCATION_TELLER_CHECKER', + 'SETTLECASHFROMCASHIER_TELLER', + 'SETTLECASHFROMCASHIER_TELLER_CHECKER', + 'UPDATE_TELLER', + 'UPDATE_TELLER_CHECKER', + 'UPDATECASHIERALLOCATION_TELLER', + 'UPDATECASHIERALLOCATION_TELLER_CHECKER' + ); + + + + + + SELECT COUNT(*) FROM m_role WHERE name = 'As Manager' + + SELECT COUNT(*) FROM m_role_permission + WHERE role_id = (SELECT id FROM m_role WHERE name = 'As Manager') + + + + INSERT INTO m_role_permission (role_id, permission_id) + SELECT (SELECT id FROM m_role WHERE name = 'As Manager'), p.id + FROM m_permission p + WHERE p.code IN ( + 'ADJUST_LOAN', + 'ADJUST_LOAN_CHECKER', + 'ALLOCATECASHIER_TELLER', + 'ALLOCATECASHIER_TELLER_CHECKER', + 'ALLOCATECASHTOCASHIER_TELLER', + 'ALLOCATECASHTOCASHIER_TELLER_CHECKER', + 'APPROVE_LOAN', + 'APPROVE_LOAN_CHECKER', + 'BULKREASSIGN_LOAN', + 'BULKREASSIGN_LOAN_CHECKER', + 'CLOSE_LOAN', + 'CLOSE_LOAN_CHECKER', + 'CLOSEASRESCHEDULED_LOAN', + 'CLOSEASRESCHEDULED_LOAN_CHECKER', + 'CREATE_TELLER', + 'CREATE_TELLER_CHECKER', + 'DELETE_TELLER', + 'DELETE_TELLER_CHECKER', + 'DELETECASHIERALLOCATION_TELLER', + 'DELETECASHIERALLOCATION_TELLER_CHECKER', + 'DISBURSALLASTUNDO_LOAN', + 'DISBURSALLASTUNDO_LOAN_CHECKER', + 'DISBURSALUNDO_LOAN', + 'DISBURSALUNDO_LOAN_CHECKER', + 'DISBURSE_LOAN', + 'DISBURSE_LOAN_CHECKER', + 'DISBURSETOSAVINGS_LOAN', + 'MENU_BRANCH_OPS', + 'RECOVERYPAYMENT_LOAN', + 'REFUNDBYCASH_LOAN', + 'REFUNDBYCASH_LOAN_CHECKER', + 'REJECT_LOAN', + 'REJECT_LOAN_CHECKER', + 'REMOVELOANOFFICER_LOAN', + 'REMOVELOANOFFICER_LOAN_CHECKER', + 'REPAYMENT_LOAN', + 'REPAYMENT_LOAN_CHECKER', + 'SETTLECASHFROMCASHIER_TELLER', + 'SETTLECASHFROMCASHIER_TELLER_CHECKER', + 'UNDOWRITEOFF_LOAN', + 'UPDATE_TELLER', + 'UPDATE_TELLER_CHECKER', + 'UPDATECASHIERALLOCATION_TELLER', + 'UPDATECASHIERALLOCATION_TELLER_CHECKER', + 'UPDATELOANOFFICER_LOAN', + 'UPDATELOANOFFICER_LOAN_CHECKER', + 'WAIVEINTERESTPORTION_LOAN', + 'WAIVEINTERESTPORTION_LOAN_CHECKER', + 'WITHDRAW_LOAN', + 'WITHDRAW_LOAN_CHECKER', + 'WRITEOFF_LOAN', + 'WRITEOFF_LOAN_CHECKER' + ); + + + + + + SELECT COUNT(*) FROM m_role WHERE name = 'LEDGER' + + SELECT COUNT(*) FROM m_role_permission + WHERE role_id = (SELECT id FROM m_role WHERE name = 'LEDGER') + + + + INSERT INTO m_role_permission (role_id, permission_id) + SELECT (SELECT id FROM m_role WHERE name = 'LEDGER'), p.id + FROM m_permission p + WHERE p.code IN ( + 'MENU_GENERAL_LEDGER', + 'MENU_SUB_LEDGER' + ); + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0498_backfill_required_charges.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0498_backfill_required_charges.xml new file mode 100644 index 000000000..a78497b7b --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0498_backfill_required_charges.xml @@ -0,0 +1,106 @@ + + + + + + + + + SELECT COUNT(*) FROM m_charge WHERE name = 'PROCESSING FEES' + + + + + + + + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM m_charge WHERE name = 'CHQ BOOK CHARGES' + + + + + + + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM m_charge WHERE name = 'entry fee' + + + + + + + + + + + + + + + + + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0499_add_facility_charge_mapping_permissions.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0499_add_facility_charge_mapping_permissions.xml new file mode 100644 index 000000000..26768ab7a --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0499_add_facility_charge_mapping_permissions.xml @@ -0,0 +1,55 @@ + + + + + + + + + SELECT COUNT(*) FROM m_permission WHERE code = 'READ_FACILITYCHARGEMAPPING' + + + + + + + + + + + + + + + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0500_reset_facility_charge_mappings_to_unmapped.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0500_reset_facility_charge_mappings_to_unmapped.xml new file mode 100644 index 000000000..630271816 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0500_reset_facility_charge_mappings_to_unmapped.xml @@ -0,0 +1,40 @@ + + + + + + + + UPDATE m_facility_charge_mapping SET charge_id = NULL, is_active = false WHERE charge_id IS NOT NULL; + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0501_enforce_inr_only_organisation_currency.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0501_enforce_inr_only_organisation_currency.xml new file mode 100644 index 000000000..07a186f47 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0501_enforce_inr_only_organisation_currency.xml @@ -0,0 +1,50 @@ + + + + + + + + SELECT COUNT(*) FROM m_organisation_currency WHERE code = 'INR' + + + INSERT INTO m_organisation_currency (code, decimal_places, name, display_symbol, internationalized_name_code) + VALUES ('INR', 2, 'Indian Rupee', convert_from(decode('e282b9', 'hex'), 'UTF8'), 'currency.INR'); + + + + + + DELETE FROM m_organisation_currency WHERE code <> 'INR'; + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0502_backfill_core_chart_of_accounts.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0502_backfill_core_chart_of_accounts.xml new file mode 100644 index 000000000..c1c78f4cb --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0502_backfill_core_chart_of_accounts.xml @@ -0,0 +1,196 @@ + + + + + + + + + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'BANKS CURRENT ACCOUNT', '3', false, true, 1, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '3'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'SHORT TERM LOAN', '4', false, true, 1, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '4'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'MEDIUM TERM LOAN', '5', false, true, 1, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '5'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'LONG TERM LOAN', '6', false, true, 1, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '6'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'DEPOSITE ACCOUNT', '8', false, true, 2, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '8'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'OTHER LIABILITY', '9', false, true, 2, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '9'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'SHARE CAPITAL', '7', false, true, 3, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '7'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'INCOME HEAD', '10', false, true, 4, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '10'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'EXPENSES', '11', false, true, 5, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '11'); + + + + + + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy, description) + SELECT 'Cash at Vault', '1', false, true, 1, 1, '.', 'Test' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '1'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Cash at Tellers', '2', false, true, 1, 1, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '2'); + + + + + + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage) + SELECT 'Liability Transfer Suspense', '200800', false, true, 2, 1 WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200800'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, description) + SELECT 'Share Sundry', 'SHASUN001', false, true, 2, 1, 'Holding account for share amounts pending activation' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = 'SHASUN001'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, description) + SELECT 'Escheat Liability Account', '200900', false, true, 2, 1, 'Holds funds from accounts escheated to the regulator after prolonged dormancy.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200900'); + + + + + + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'IDBI BANK', '3.1', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '3') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '3.1'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'YES BANK', '3.2', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '3') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '3.2'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'LOAN AGAINST DEPOSITE', '4.1', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '4') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '4.1'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'WARE HOUSE RECEIPT', '4.2', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '4') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '4.2'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'CASH CREDIT', '4.3', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '4') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '4.3'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'LOAN AGAINST PROPERTY', '5.1', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '5') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '5.1'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'PERSONAL LOAN', '5.3', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '5') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '5.3'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'HOUSE LOAN', '6.1', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '6') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '6.1'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'SAVING INDIVIDUAL', '200200', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '8') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200200'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'CURRENT ACCOUNT', '300300', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '8') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '300300'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'FIXED DEPOSITE', '400400', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '8') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400400'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'RD ACCOUNT', '500500', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '9') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500500'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'INTEREST PAYABLE', '9.2', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '9') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '9.2'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id, description) + SELECT 'Sponsor DD Payable - SBI', '9.3', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '9'), + 'Liability owed to SBI for sponsor bank demand drafts issued on their behalf, pending clearing.' + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '9.3'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id, description) + SELECT 'DD Cash Received - Pending Approval', '9.4', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '9'), + 'Interim liability for cash physically received from a walk-in DD purchaser at submission time, pending manager approval of the issuance request. Cleared into Sponsor DD Payable + Charges Income on approval, or reversed back to Cash at Tellers on rejection.' + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '9.4'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'LINK SHARE', '7.1', false, true, 3, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '7') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '7.1'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'SHARE', '7.2', false, true, 3, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '7') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '7.2'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'INCOME FROM LOAN', '10.1', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '10') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '10.1'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'INCOME FROM ALL', '10.2', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '10') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '10.2'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id, description) + SELECT 'GST Payable on DD Charges', '9.5', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '10'), + 'GST collected from customers/purchasers on Sponsor DD issuance charges, held pending remittance to the government - not bank income.' + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '9.5'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id, description) + SELECT 'Share Entry', 'SE8978', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '10'), 'Done' + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = 'SE8978'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'EXPENSES FOR ALL', '11.1', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '11') + WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '11.1'); + + + + + + + UPDATE acc_gl_account SET hierarchy = '.' || id || '.' + WHERE hierarchy IS NULL AND gl_code IN ( + '3.1', '3.2', '4.1', '4.2', '4.3', '5.1', '5.3', '6.1', '200200', '300300', '400400', + '500500', '9.2', '9.3', '9.4', '7.1', '7.2', '10.1', '10.2', '9.5', 'SE8978', '11.1' + ); + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0503_standardize_gl_account_codes.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0503_standardize_gl_account_codes.xml new file mode 100644 index 000000000..c9b77d8be --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0503_standardize_gl_account_codes.xml @@ -0,0 +1,89 @@ + + + + + + + + UPDATE acc_gl_account SET gl_code = '100101' WHERE name = 'Cash at Vault'; + UPDATE acc_gl_account SET gl_code = '100102' WHERE name = 'Cash at Tellers'; + UPDATE acc_gl_account SET gl_code = '100200' WHERE name = 'BANKS CURRENT ACCOUNT'; + UPDATE acc_gl_account SET gl_code = '100201' WHERE name = 'IDBI BANK'; + UPDATE acc_gl_account SET gl_code = '100202' WHERE name = 'YES BANK'; + UPDATE acc_gl_account SET gl_code = '100300' WHERE name = 'SHORT TERM LOAN'; + UPDATE acc_gl_account SET gl_code = '100301' WHERE name = 'LOAN AGAINST DEPOSITE'; + UPDATE acc_gl_account SET gl_code = '100302' WHERE name = 'WARE HOUSE RECEIPT'; + UPDATE acc_gl_account SET gl_code = '100303' WHERE name = 'CASH CREDIT'; + UPDATE acc_gl_account SET gl_code = '100400' WHERE name = 'MEDIUM TERM LOAN'; + UPDATE acc_gl_account SET gl_code = '100401' WHERE name = 'LOAN AGAINST PROPERTY'; + UPDATE acc_gl_account SET gl_code = '100402' WHERE name = 'PERSONAL LOAN'; + UPDATE acc_gl_account SET gl_code = '100500' WHERE name = 'LONG TERM LOAN'; + UPDATE acc_gl_account SET gl_code = '100501' WHERE name = 'HOUSE LOAN'; + + UPDATE acc_gl_account SET gl_code = '200100' WHERE TRIM(name) = 'DEPOSITE ACCOUNT'; + UPDATE acc_gl_account SET gl_code = '200101' WHERE name = 'SAVING INDIVIDUAL'; + UPDATE acc_gl_account SET gl_code = '200102' WHERE name = 'CURRENT ACCOUNT'; + UPDATE acc_gl_account SET gl_code = '200103' WHERE name = 'FIXED DEPOSITE'; + UPDATE acc_gl_account SET gl_code = '200200' WHERE name = 'OTHER LIABILITY'; + UPDATE acc_gl_account SET gl_code = '200201' WHERE name = 'RD ACCOUNT'; + UPDATE acc_gl_account SET gl_code = '200202' WHERE name = 'INTEREST PAYABLE'; + UPDATE acc_gl_account SET gl_code = '200203' WHERE name = 'Sponsor DD Payable - SBI'; + UPDATE acc_gl_account SET gl_code = '200204' WHERE name = 'DD Cash Received - Pending Approval'; + UPDATE acc_gl_account SET gl_code = '200901' WHERE name = 'Liability Transfer Suspense'; + UPDATE acc_gl_account SET gl_code = '200902' WHERE name = 'Share Sundry'; + UPDATE acc_gl_account SET gl_code = '200903' WHERE name = 'Dividend Payable'; + UPDATE acc_gl_account SET gl_code = '200904' WHERE name = 'Escheat Liability Account'; + UPDATE acc_gl_account SET gl_code = '200905' WHERE name = 'Education Fund Payable'; + UPDATE acc_gl_account SET gl_code = '200906' WHERE name = 'Dividend Paid'; + + UPDATE acc_gl_account SET gl_code = '300100' WHERE name = 'SHARE CAPITAL'; + UPDATE acc_gl_account SET gl_code = '300101' WHERE name = 'LINK SHARE'; + UPDATE acc_gl_account SET gl_code = '300102' WHERE name = 'SHARE'; + UPDATE acc_gl_account SET gl_code = '300901' WHERE name = 'Reserve for Dividend'; + UPDATE acc_gl_account SET gl_code = '300902' WHERE name = 'Statutory Reserve Fund'; + UPDATE acc_gl_account SET gl_code = '300903' WHERE name = 'Bank Profit (Non-Distributable)'; + + UPDATE acc_gl_account SET gl_code = '400100' WHERE name = 'INCOME HEAD'; + UPDATE acc_gl_account SET gl_code = '400101' WHERE name = 'INCOME FROM LOAN'; + UPDATE acc_gl_account SET gl_code = '400102' WHERE name = 'INCOME FROM ALL'; + UPDATE acc_gl_account SET gl_code = '400103' WHERE name = 'DD Issuance Charges Income'; + UPDATE acc_gl_account SET gl_code = '400104' WHERE name = 'GST Payable on DD Charges'; + UPDATE acc_gl_account SET gl_code = '400105' WHERE name = 'Share Entry'; + UPDATE acc_gl_account SET gl_code = '400901' WHERE name = 'Dividend Forfeited Income'; + + UPDATE acc_gl_account SET gl_code = '500100' WHERE name = 'EXPENSES'; + UPDATE acc_gl_account SET gl_code = '500101' WHERE name = 'EXPENSES FOR ALL'; + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0504_add_priority_gl_accounts.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0504_add_priority_gl_accounts.xml new file mode 100644 index 000000000..ec7256371 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0504_add_priority_gl_accounts.xml @@ -0,0 +1,200 @@ + + + + + + + + + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Interest & Other Receivables', '100600', false, true, 1, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '100600'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Interest Payable on Deposits', '200300', false, true, 2, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200300'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Statutory Dues Payable', '200400', false, true, 2, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200400'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Clearing & Settlement Suspense', '200500', false, true, 2, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200500'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Facility & Service Charges Income', '400200', false, true, 4, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400200'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Interest Income on Loans', '400300', false, true, 4, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400300'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Interest Expense on Deposits', '500200', false, true, 5, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500200'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Staff Cost', '500300', false, true, 5, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500300'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Administrative & Operating Expenses', '500400', false, true, 5, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500400'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, hierarchy) + SELECT 'Provisions & Write-offs', '500500', false, true, 5, 2, '.' WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500500'); + + + + + + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Receivable on Loans', '100601', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '100600') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '100601'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'TDS Receivable (Advance Tax)', '100602', false, true, 1, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '100600') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '100602'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Payable - Savings Account', '200301', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200300') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200301'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Payable - Fixed Deposit', '200302', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200300') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200302'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Payable - RD Account', '200303', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200300') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200303'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'TDS Payable', '200401', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200401'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'GST Payable', '200402', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200402'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'NEFT Inward Suspense', '200501', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200500') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200501'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'NEFT Outward Suspense', '200502', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200500') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200502'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'RTGS Suspense', '200503', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200500') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200503'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Cheque Clearing Suspense', '200504', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200500') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200504'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'ATM Settlement Suspense', '200505', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200500') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200505'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'UPI Settlement Suspense', '200506', false, true, 2, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '200500') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '200506'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from ATM Facility Charges', '400201', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400201'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from ATM Withdrawal Charges', '400202', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400202'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from UPI Facility Charges', '400203', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400203'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from POS Transaction Charges', '400204', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400204'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from Cheque Book Charges', '400205', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400205'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from IMPS Facility Charges', '400206', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400206'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from SMS Alert Charges', '400207', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400207'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from BBPS Facility Charges', '400208', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400208'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from Insurance Cover Charges', '400209', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400209'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from BEPG Facility Charges', '400210', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400210'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from NEFT Facility Charges', '400211', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400211'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from RTGS Facility Charges', '400212', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400212'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from Inter-Bank Cap Charges', '400213', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400213'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from Withdrawal Facility Charges', '400214', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400214'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from Deposit KYC Charges', '400215', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400215'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Income from Virtual Debit Card Charges', '400216', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400216'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Income - Short Term Loan', '400301', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400300') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400301'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Income - Medium Term Loan', '400302', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400300') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400302'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Income - Long Term Loan', '400303', false, true, 4, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '400300') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '400303'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Paid - Savings Account', '500201', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500201'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Paid - Fixed Deposit', '500202', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500202'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Interest Paid - RD Account', '500203', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500200') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500203'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Salaries & Wages', '500301', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500300') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500301'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Staff Welfare Expenses', '500302', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500300') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500302'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Provident Fund Contribution', '500303', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500300') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500303'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Rent, Rates & Taxes', '500401', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500401'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Electricity & Water Charges', '500402', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500402'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Printing & Stationery', '500403', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500403'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Telephone & Internet Expenses', '500404', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500404'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Audit Fees', '500405', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500405'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Legal & Professional Charges', '500406', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500406'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Insurance Premium', '500407', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500407'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Repairs & Maintenance', '500408', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500408'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Depreciation', '500409', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500400') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500409'); + + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Provision for NPA', '500501', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500500') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500501'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Provision for Standard Assets', '500502', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500500') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500502'); + INSERT INTO acc_gl_account (name, gl_code, disabled, manual_journal_entries_allowed, classification_enum, account_usage, parent_id) + SELECT 'Bad Debts Written Off', '500503', false, true, 5, 1, (SELECT id FROM acc_gl_account WHERE gl_code = '500500') WHERE NOT EXISTS (SELECT 1 FROM acc_gl_account WHERE gl_code = '500503'); + + + + + + + UPDATE acc_gl_account SET hierarchy = '.' || id || '.' + WHERE hierarchy IS NULL AND gl_code IN ( + '100601','100602', + '200301','200302','200303','200401','200402', + '200501','200502','200503','200504','200505','200506', + '400201','400202','400203','400204','400205','400206','400207','400208','400209','400210', + '400211','400212','400213','400214','400215','400216', + '400301','400302','400303', + '500201','500202','500203', + '500301','500302','500303', + '500401','500402','500403','500404','500405','500406','500407','500408','500409', + '500501','500502','500503' + ); + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0505_backfill_missing_codes_and_code_values.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0505_backfill_missing_codes_and_code_values.xml new file mode 100644 index 000000000..65e8eb4ab --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0505_backfill_missing_codes_and_code_values.xml @@ -0,0 +1,674 @@ + + + + + + + INSERT INTO m_code (code_name, is_system_defined) SELECT 'ADDRESS_TYPE', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ADDRESS_TYPE'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'AssetAccountTags', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'AssetAccountTags'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'buydown_fee_transaction_classification', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'buydown_fee_transaction_classification'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'capitalized_income_transaction_classification', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'capitalized_income_transaction_classification'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'CenterClosureReason', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'CenterClosureReason'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'ChargeOffReasons', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ChargeOffReasons'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'ClientClosureReason', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ClientClosureReason'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'ClientRejectReason', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ClientRejectReason'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'ClientSubStatus', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ClientSubStatus'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'ClientType', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ClientType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'ClientWithdrawReason', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ClientWithdrawReason'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Constitution', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Constitution'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Constitution2', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Constitution2'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'COUNTRY', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'COUNTRY'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'CreditTransactionFreezeReasons', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'CreditTransactionFreezeReasons'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'CurrentProductAccountType', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'CurrentProductAccountType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'CurrentProductCustomerSegment', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'CurrentProductCustomerSegment'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Customer Documents', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Customer Documents'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Customer Identifier', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Customer Identifier'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'DebitTransactionFreezeReasons', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'DebitTransactionFreezeReasons'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'DegreeQualification', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'DegreeQualification'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'DirectorDesignation', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'DirectorDesignation'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'EducationLevel', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'EducationLevel'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Entity to Entity Access Types', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Entity to Entity Access Types'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'EquityAccountTags', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'EquityAccountTags'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'ExpenseAccountTags', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ExpenseAccountTags'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'FixedDepositProductAccountType', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'FixedDepositProductAccountType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'FixedDepositProductCustomerSegment', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'FixedDepositProductCustomerSegment'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'FORM_60_PURPOSE', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'FORM_60_PURPOSE'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Gender', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Gender'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'GroupClosureReason', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'GroupClosureReason'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'GROUPROLE', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'GROUPROLE'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'GuarantorRelationship', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'GuarantorRelationship'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'IncomeAccountTags', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'IncomeAccountTags'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'InterestCalculationTypeOption', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'InterestCalculationTypeOption'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'KYCAddressProofType', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'KYCAddressProofType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'KYCIdProofType', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'KYCIdProofType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'LiabilityAccountTags', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'LiabilityAccountTags'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'LoanCollateral', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'LoanCollateral'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'LoanOriginationChannelType', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'LoanOriginationChannelType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'LoanOriginatorType', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'LoanOriginatorType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'LoanPurpose', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'LoanPurpose'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'LoanRescheduleReason', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'LoanRescheduleReason'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Main Business Line', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Main Business Line'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'MARITAL STATUS', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'MARITAL STATUS'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'MaritalStatus', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'MaritalStatus'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Occupation', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Occupation'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'OccupationCategory', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'OccupationCategory'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'PaymentType', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'PaymentType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'PeriodFrequency', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'PeriodFrequency'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'PROFESSION', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'PROFESSION'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'PwdCategory', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'PwdCategory'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'ReAgeReasons', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ReAgeReasons'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'ReAmortizationReasons', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'ReAmortizationReasons'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'RecurringDepositProductAccountType', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'RecurringDepositProductAccountType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'RecurringDepositProductCustomerSegment', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'RecurringDepositProductCustomerSegment'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'RELATIONSHIP', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'RELATIONSHIP'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Religion', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Religion'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'Salutation', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'Salutation'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'SavingsAccountBlockReasons', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'SavingsAccountBlockReasons'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'SavingsProductAccountType', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'SavingsProductAccountType'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'SavingsProductCustomerSegment', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'SavingsProductCustomerSegment'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'SavingsTransactionFreezeReasons', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'SavingsTransactionFreezeReasons'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'SocialCategory', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'SocialCategory'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'STATE', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'STATE'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'SubCaste', false WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'SubCaste'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'WriteOffReasons', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'WriteOffReasons'); +INSERT INTO m_code (code_name, is_system_defined) SELECT 'YesNo', true WHERE NOT EXISTS (SELECT 1 FROM m_code WHERE code_name = 'YesNo'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Correspondence', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'ADDRESS_TYPE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ADDRESS_TYPE' AND v.code_value = 'Correspondence'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Current / Residential', 'Current Address', 2, NULL, true, false FROM m_code WHERE code_name = 'ADDRESS_TYPE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ADDRESS_TYPE' AND v.code_value = 'Current / Residential'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Office / Work', 'Office Address', 3, NULL, true, false FROM m_code WHERE code_name = 'ADDRESS_TYPE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ADDRESS_TYPE' AND v.code_value = 'Office / Work'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Permanent Address', 'Permanent Address', 1, NULL, true, false FROM m_code WHERE code_name = 'ADDRESS_TYPE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ADDRESS_TYPE' AND v.code_value = 'Permanent Address'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CURRENT_ASSET', 'Current Asset', 1, NULL, true, false FROM m_code WHERE code_name = 'AssetAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'AssetAccountTags' AND v.code_value = 'CURRENT_ASSET'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FIXED_ASSET', 'Fixed Asset', 2, NULL, true, false FROM m_code WHERE code_name = 'AssetAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'AssetAccountTags' AND v.code_value = 'FIXED_ASSET'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BUYDOWN_ADJUSTMENT', 'Buydown Adjustment Entry', 3, NULL, true, false FROM m_code WHERE code_name = 'buydown_fee_transaction_classification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'buydown_fee_transaction_classification' AND v.code_value = 'BUYDOWN_ADJUSTMENT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BUYDOWN_INTEREST_SUBSIDY', 'Buydown Interest Subsidy', 2, NULL, true, false FROM m_code WHERE code_name = 'buydown_fee_transaction_classification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'buydown_fee_transaction_classification' AND v.code_value = 'BUYDOWN_INTEREST_SUBSIDY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BUYDOWN_PROCESSING_FEE', 'Buydown Processing Fee', 1, NULL, true, false FROM m_code WHERE code_name = 'buydown_fee_transaction_classification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'buydown_fee_transaction_classification' AND v.code_value = 'BUYDOWN_PROCESSING_FEE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CAPITALIZED_FEES', 'Capitalized Fees', 3, NULL, true, false FROM m_code WHERE code_name = 'capitalized_income_transaction_classification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'capitalized_income_transaction_classification' AND v.code_value = 'CAPITALIZED_FEES'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CAPITALIZED_INTEREST', 'Capitalized Interest Income', 1, NULL, true, false FROM m_code WHERE code_name = 'capitalized_income_transaction_classification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'capitalized_income_transaction_classification' AND v.code_value = 'CAPITALIZED_INTEREST'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CAPITALIZED_PENAL_INTEREST', 'Capitalized Penal Interest', 2, NULL, true, false FROM m_code WHERE code_name = 'capitalized_income_transaction_classification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'capitalized_income_transaction_classification' AND v.code_value = 'CAPITALIZED_PENAL_INTEREST'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CENTER_INACTIVE', 'Center Inactive', 1, NULL, true, false FROM m_code WHERE code_name = 'CenterClosureReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'CenterClosureReason' AND v.code_value = 'CENTER_INACTIVE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MERGED', 'Merged with another center', 2, NULL, true, false FROM m_code WHERE code_name = 'CenterClosureReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'CenterClosureReason' AND v.code_value = 'MERGED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DECEASED', 'Borrower Deceased', 4, NULL, true, false FROM m_code WHERE code_name = 'ChargeOffReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ChargeOffReasons' AND v.code_value = 'DECEASED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FRAUD', 'Fraudulent Account Charge Off', 3, NULL, true, false FROM m_code WHERE code_name = 'ChargeOffReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ChargeOffReasons' AND v.code_value = 'FRAUD'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'INSOLVENCY', 'Insolvency / Bankruptcy', 5, NULL, true, false FROM m_code WHERE code_name = 'ChargeOffReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ChargeOffReasons' AND v.code_value = 'INSOLVENCY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SETTLED', 'Account Settled', 2, NULL, true, false FROM m_code WHERE code_name = 'ChargeOffReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ChargeOffReasons' AND v.code_value = 'SETTLED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'WRITTEN_OFF', 'Account Written Off', 1, NULL, true, false FROM m_code WHERE code_name = 'ChargeOffReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ChargeOffReasons' AND v.code_value = 'WRITTEN_OFF'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CUSTOMER_REQUEST', 'Closed on customer request', 1, NULL, true, false FROM m_code WHERE code_name = 'ClientClosureReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientClosureReason' AND v.code_value = 'CUSTOMER_REQUEST'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DECEASED', 'Customer Deceased', 2, NULL, true, false FROM m_code WHERE code_name = 'ClientClosureReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientClosureReason' AND v.code_value = 'DECEASED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DORMANT', 'Dormant Closure', 4, NULL, true, false FROM m_code WHERE code_name = 'ClientClosureReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientClosureReason' AND v.code_value = 'DORMANT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FRAUD', 'Fraudulent Account', 3, NULL, true, false FROM m_code WHERE code_name = 'ClientClosureReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientClosureReason' AND v.code_value = 'FRAUD'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DOCUMENT_INCOMPLETE', 'Incomplete Documents', 3, NULL, true, false FROM m_code WHERE code_name = 'ClientRejectReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientRejectReason' AND v.code_value = 'DOCUMENT_INCOMPLETE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'KYC_FAILED', 'KYC Verification Failed', 1, NULL, true, false FROM m_code WHERE code_name = 'ClientRejectReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientRejectReason' AND v.code_value = 'KYC_FAILED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'LOW_CIBIL', 'Low Credit Score', 2, NULL, true, false FROM m_code WHERE code_name = 'ClientRejectReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientRejectReason' AND v.code_value = 'LOW_CIBIL'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'ACTIVE', 'Active Customer', 1, NULL, true, false FROM m_code WHERE code_name = 'ClientSubStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientSubStatus' AND v.code_value = 'ACTIVE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BLOCKED', 'Blocked Account', 4, NULL, true, false FROM m_code WHERE code_name = 'ClientSubStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientSubStatus' AND v.code_value = 'BLOCKED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DORMANT', 'Dormant Status', 3, NULL, true, false FROM m_code WHERE code_name = 'ClientSubStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientSubStatus' AND v.code_value = 'DORMANT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'INACTIVE', 'Inactive Customer', 2, NULL, true, false FROM m_code WHERE code_name = 'ClientSubStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientSubStatus' AND v.code_value = 'INACTIVE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CORPORATE', 'Corporate / Large Business Entity', 15, 10, true, false FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'CORPORATE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'GOVERNMENT', 'Government / Semi-Government Entity', 12, 10, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'GOVERNMENT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'INSTITUTIONAL', 'Institutional Account (School, College, etc.)', 13, 8, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'INSTITUTIONAL'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'LLP', 'Limited Liability Partnership', 7, 9, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'LLP'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MINOR', 'Minor Account (Operated by Guardian)', 3, 8, true, false FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'MINOR'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MSME', 'Micro, Small & Medium Enterprise', 14, 9, true, false FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'MSME'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NRI CUSTOMER', 'Non-Resident Individual Customer', 2, 9, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'NRI CUSTOMER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PARTNERSHIP', 'Partnership Firm', 6, 9, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'PARTNERSHIP'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PRIVATE LIMITED', 'Private Limited Company', 8, 10, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'PRIVATE LIMITED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PROPRIETORSHIP', 'Proprietorship Firm', 5, 9, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'PROPRIETORSHIP'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PUBLIC LIMITED', 'Public Limited Company', 9, 10, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'PUBLIC LIMITED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'RESIDENT INDIVIDUAL', 'Resident Individual Customer', 1, 10, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'RESIDENT INDIVIDUAL'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SENIOR CITIZEN', 'Senior Citizen Customer', 4, 7, true, false FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'SENIOR CITIZEN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SOCIETY', 'Society / Association / Club', 11, 8, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'SOCIETY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'TRUST', 'Trust Account', 10, 8, true, true FROM m_code WHERE code_name = 'ClientType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientType' AND v.code_value = 'TRUST'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NON_COMPLIANCE', 'Compliance Failure', 2, NULL, true, false FROM m_code WHERE code_name = 'ClientWithdrawReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientWithdrawReason' AND v.code_value = 'NON_COMPLIANCE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'VOLUNTARY', 'Voluntary Withdrawal', 1, NULL, true, false FROM m_code WHERE code_name = 'ClientWithdrawReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ClientWithdrawReason' AND v.code_value = 'VOLUNTARY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'HUF (Hindu Undivided Family)', 'Hindu Undivided Family', 1, NULL, true, false FROM m_code WHERE code_name = 'Constitution' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Constitution' AND v.code_value = 'HUF (Hindu Undivided Family)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'LLP', 'Limited Liability Partnership', 14, NULL, true, true FROM m_code WHERE code_name = 'Constitution' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Constitution' AND v.code_value = 'LLP'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PARTNERSHIP', 'Partnership firm', 11, NULL, true, true FROM m_code WHERE code_name = 'Constitution' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Constitution' AND v.code_value = 'PARTNERSHIP'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PRIVATE LIMITED COMPANY', 'Private limited company', 12, NULL, true, true FROM m_code WHERE code_name = 'Constitution' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Constitution' AND v.code_value = 'PRIVATE LIMITED COMPANY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PROPRIETOR SHIP', 'Sole proprietorship business', 10, NULL, true, true FROM m_code WHERE code_name = 'Constitution' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Constitution' AND v.code_value = 'PROPRIETOR SHIP'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PUBLIC LIMITED COMPANY', 'Public limited company', 13, NULL, true, true FROM m_code WHERE code_name = 'Constitution' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Constitution' AND v.code_value = 'PUBLIC LIMITED COMPANY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SOCIETY', 'Registered society / association', 16, NULL, true, true FROM m_code WHERE code_name = 'Constitution' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Constitution' AND v.code_value = 'SOCIETY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'TRUST', 'Registered trust entity', 15, NULL, true, true FROM m_code WHERE code_name = 'Constitution' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Constitution' AND v.code_value = 'TRUST'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'INDIA', 'Republic of India', 1, NULL, true, false FROM m_code WHERE code_name = 'COUNTRY' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'COUNTRY' AND v.code_value = 'INDIA'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'COMPLIANCE_HOLD', 'Compliance Hold', 1, NULL, true, false FROM m_code WHERE code_name = 'CreditTransactionFreezeReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'CreditTransactionFreezeReasons' AND v.code_value = 'COMPLIANCE_HOLD'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Basic Account', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'CurrentProductAccountType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'CurrentProductAccountType' AND v.code_value = 'Basic Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Premium Current Account', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'CurrentProductAccountType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'CurrentProductAccountType' AND v.code_value = 'Premium Current Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Standard Account', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'CurrentProductAccountType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'CurrentProductAccountType' AND v.code_value = 'Standard Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Individual', 'Individual', 1, NULL, true, false FROM m_code WHERE code_name = 'CurrentProductCustomerSegment' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'CurrentProductCustomerSegment' AND v.code_value = 'Individual'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Non Individual', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'CurrentProductCustomerSegment' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'CurrentProductCustomerSegment' AND v.code_value = 'Non Individual'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'AADHAR', 'Aadhar Card', 1, NULL, true, false FROM m_code WHERE code_name = 'Customer Documents' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Documents' AND v.code_value = 'AADHAR'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN', 'PAN Card', 2, NULL, true, false FROM m_code WHERE code_name = 'Customer Documents' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Documents' AND v.code_value = 'PAN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PASSPORT', 'Passport', 4, NULL, true, false FROM m_code WHERE code_name = 'Customer Documents' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Documents' AND v.code_value = 'PASSPORT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'VOTER_ID', 'Voter ID Card', 3, NULL, true, false FROM m_code WHERE code_name = 'Customer Documents' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Documents' AND v.code_value = 'VOTER_ID'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'AADHAAR', 'Aadhaar Card', 1, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'AADHAAR'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Any Other ID', 'Any Other ID', 18, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'Any Other ID'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CENTRAL STATE ID', 'Central/State Govt Employee Card', 11, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'CENTRAL STATE ID'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'COMPANY EMP ID', 'Company Employee ID', 13, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'COMPANY EMP ID'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DEFENCE ID', 'Defence / Armed Forces ID', 7, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'DEFENCE ID'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Drivers License', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'Drivers License'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'GOVT EMP ID', 'Government Employee ID', 6, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'GOVT EMP ID'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'KISAN PASSBOOK', 'Kisan Photo Passbook', 10, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'KISAN PASSBOOK'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MUNICIPAL ID', 'Municipal ID Card', 17, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'MUNICIPAL ID'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NPR', 'NPR Card', 4, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'NPR'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NREGA', 'NREGA Job Card', 3, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'NREGA'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'OCI', 'OCI Card', 14, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'OCI'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN', 'PAN Card', 2, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'PAN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Passport', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'Passport'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PIO', 'PIO Card', 15, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'PIO'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PPO', 'Pension Payment Order (PPO)', 8, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'PPO'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'RATION', 'Ration Card', 5, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'RATION'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'RESIDENCE CERT', 'Residence Certificate', 16, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'RESIDENCE CERT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SENIOR CITIZEN', 'Senior Citizen Card', 9, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'SENIOR CITIZEN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'STUDENT ID', 'Student ID', 12, 0, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'STUDENT ID'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Voter ID', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'Customer Identifier' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Customer Identifier' AND v.code_value = 'Voter ID'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'INSUFFICIENT_FUNDS', 'Insufficient Balance', 1, NULL, true, false FROM m_code WHERE code_name = 'DebitTransactionFreezeReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DebitTransactionFreezeReasons' AND v.code_value = 'INSUFFICIENT_FUNDS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, '10th / SSC / Matriculation', 'School', 2, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = '10th / SSC / Matriculation'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, '12th / HSC / Intermediate', 'School', 3, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = '12th / HSC / Intermediate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'B.A. (Bachelor of Arts)', 'Undergraduate', 6, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'B.A. (Bachelor of Arts)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'B.Arch', 'Undergraduate', 19, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'B.Arch'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'B.Com. (Bachelor of Commerce)', 'Undergraduate', 8, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'B.Com. (Bachelor of Commerce)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'B.Ed. (Education)', 'Undergraduate', 12, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'B.Ed. (Education)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'B.Pharm', 'Undergraduate', 18, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'B.Pharm'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'B.Sc. (Bachelor of Science)', 'Undergraduate', 7, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'B.Sc. (Bachelor of Science)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'B.Sc. Nursing', 'Undergraduate', 22, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'B.Sc. Nursing'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'B.Tech / B.E. (Engineering)', 'Undergraduate', 11, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'B.Tech / B.E. (Engineering)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BAMS', 'Undergraduate', 16, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'BAMS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BBA (Business Administration)', 'Undergraduate', 9, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'BBA (Business Administration)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BCA (Computer Applications)', 'Undergraduate', 10, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'BCA (Computer Applications)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BDS', 'Undergraduate', 15, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'BDS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Below 10th', 'School', 1, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Below 10th'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BFA (Fine Arts)', 'Undergraduate', 20, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'BFA (Fine Arts)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BHM (Hotel Management)', 'Undergraduate', 21, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'BHM (Hotel Management)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BHMS', 'Undergraduate', 17, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'BHMS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CA (Chartered Accountant)', 'Doctorate / Professional', 43, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'CA (Chartered Accountant)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CFA', 'Doctorate / Professional', 46, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'CFA'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CMA (Cost & Mgmt Accountant)', 'Doctorate / Professional', 45, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'CMA (Cost & Mgmt Accountant)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CS (Company Secretary)', 'Doctorate / Professional', 44, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'CS (Company Secretary)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'D.Litt.', 'Doctorate / Professional', 41, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'D.Litt.'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'D.Sc.', 'Doctorate / Professional', 42, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'D.Sc.'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Diploma', 'School', 4, NULL, false, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Diploma'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Diploma in Automobile Engineering', 'Diploma', 53, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Diploma in Automobile Engineering'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Diploma in Civil Engineering', 'Diploma', 49, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Diploma in Civil Engineering'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Diploma in Computer Science / IT', 'Diploma', 52, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Diploma in Computer Science / IT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Diploma in Electrical Engineering', 'Diploma', 50, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Diploma in Electrical Engineering'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Diploma in Electronics & Communication', 'Diploma', 51, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Diploma in Electronics & Communication'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Diploma in Mechanical Engineering', 'Diploma', 48, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Diploma in Mechanical Engineering'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'ITI', 'School', 5, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'ITI'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'ITI Certificate', 'Diploma', 54, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'ITI Certificate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'LLB (Laws)', 'Undergraduate', 13, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'LLB (Laws)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'LLM (Laws)', 'Postgraduate', 31, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'LLM (Laws)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'M.A. (Master of Arts)', 'Postgraduate', 24, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'M.A. (Master of Arts)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'M.Arch', 'Postgraduate', 36, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'M.Arch'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'M.Com. (Master of Commerce)', 'Postgraduate', 26, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'M.Com. (Master of Commerce)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'M.Ed. (Education)', 'Postgraduate', 30, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'M.Ed. (Education)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'M.Pharm', 'Postgraduate', 35, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'M.Pharm'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'M.Sc. (Master of Science)', 'Postgraduate', 25, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'M.Sc. (Master of Science)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'M.Tech / M.E. (Engineering)', 'Postgraduate', 29, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'M.Tech / M.E. (Engineering)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MBA (Business Administration)', 'Postgraduate', 27, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'MBA (Business Administration)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MBBS', 'Undergraduate', 14, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'MBBS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MCA (Computer Applications)', 'Postgraduate', 28, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'MCA (Computer Applications)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MD (Medicine)', 'Postgraduate', 32, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'MD (Medicine)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MDS', 'Postgraduate', 34, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'MDS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MFA (Fine Arts)', 'Postgraduate', 37, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'MFA (Fine Arts)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MS (Surgery)', 'Postgraduate', 33, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'MS (Surgery)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MSW (Social Work)', 'Postgraduate', 38, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'MSW (Social Work)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other Diploma', 'Diploma', 56, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Other Diploma'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other PG', 'Postgraduate', 39, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Other PG'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other Professional', 'Doctorate / Professional', 47, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Other Professional'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other UG', 'Undergraduate', 23, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Other UG'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Ph.D. (Doctor of Philosophy)', 'Doctorate / Professional', 40, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Ph.D. (Doctor of Philosophy)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Polytechnic Diploma (Other)', 'Diploma', 55, NULL, true, false FROM m_code WHERE code_name = 'DegreeQualification' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DegreeQualification' AND v.code_value = 'Polytechnic Diploma (Other)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Chairman', NULL, 1, 1, true, true FROM m_code WHERE code_name = 'DirectorDesignation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DirectorDesignation' AND v.code_value = 'Chairman'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Director', NULL, 5, NULL, true, false FROM m_code WHERE code_name = 'DirectorDesignation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DirectorDesignation' AND v.code_value = 'Director'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Principal Director', NULL, 6, 2, true, false FROM m_code WHERE code_name = 'DirectorDesignation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DirectorDesignation' AND v.code_value = 'Principal Director'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Secretary', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'DirectorDesignation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DirectorDesignation' AND v.code_value = 'Secretary'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Treasurer', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'DirectorDesignation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DirectorDesignation' AND v.code_value = 'Treasurer'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Vice Chairman', NULL, 2, 1, true, true FROM m_code WHERE code_name = 'DirectorDesignation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'DirectorDesignation' AND v.code_value = 'Vice Chairman'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Diploma', NULL, 5, NULL, true, false FROM m_code WHERE code_name = 'EducationLevel' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'EducationLevel' AND v.code_value = 'Diploma'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Doctorate / Professional', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'EducationLevel' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'EducationLevel' AND v.code_value = 'Doctorate / Professional'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Graduate', NULL, 6, NULL, true, false FROM m_code WHERE code_name = 'EducationLevel' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'EducationLevel' AND v.code_value = 'Graduate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Postgraduate', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'EducationLevel' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'EducationLevel' AND v.code_value = 'Postgraduate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'School', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'EducationLevel' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'EducationLevel' AND v.code_value = 'School'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Undergraduate', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'EducationLevel' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'EducationLevel' AND v.code_value = 'Undergraduate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Office Access to Fees/Charges', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'Entity to Entity Access Types' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Entity to Entity Access Types' AND v.code_value = 'Office Access to Fees/Charges'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Office Access to Loan Products', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'Entity to Entity Access Types' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Entity to Entity Access Types' AND v.code_value = 'Office Access to Loan Products'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Office Access to Savings Products', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'Entity to Entity Access Types' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Entity to Entity Access Types' AND v.code_value = 'Office Access to Savings Products'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'OWNER_EQUITY', 'Owner Equity', 1, NULL, true, false FROM m_code WHERE code_name = 'EquityAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'EquityAccountTags' AND v.code_value = 'OWNER_EQUITY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'RETAINED_EARNINGS', 'Retained Earnings', 2, NULL, true, false FROM m_code WHERE code_name = 'EquityAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'EquityAccountTags' AND v.code_value = 'RETAINED_EARNINGS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'INTEREST_EXPENSE', 'Interest Expense', 2, NULL, true, false FROM m_code WHERE code_name = 'ExpenseAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ExpenseAccountTags' AND v.code_value = 'INTEREST_EXPENSE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'OPERATING_EXPENSE', 'Operating Expense', 1, NULL, true, false FROM m_code WHERE code_name = 'ExpenseAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ExpenseAccountTags' AND v.code_value = 'OPERATING_EXPENSE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Fd Account', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'FixedDepositProductAccountType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FixedDepositProductAccountType' AND v.code_value = 'Fd Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Individual', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'FixedDepositProductCustomerSegment' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FixedDepositProductCustomerSegment' AND v.code_value = 'Individual'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Non-Individual', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'FixedDepositProductCustomerSegment' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FixedDepositProductCustomerSegment' AND v.code_value = 'Non-Individual'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Agricultural Gold Loan', NULL, 26, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Agricultural Gold Loan'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Agricultural Loan', NULL, 15, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Agricultural Loan'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Business Loan', NULL, 14, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Business Loan'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Cash Deposit in Bank', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Cash Deposit in Bank'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Cash Withdrawal from Bank', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Cash Withdrawal from Bank'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Credit Card Application', NULL, 7, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Credit Card Application'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Debit Card Application', NULL, 8, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Debit Card Application'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Digital Gold Purchase', NULL, 47, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Digital Gold Purchase'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Education Loan', NULL, 13, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Education Loan'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Fixed Deposit / Term Deposit', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Fixed Deposit / Term Deposit'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Foreign Travel Payment', NULL, 34, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Foreign Travel Payment'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Deposit Scheme', NULL, 49, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Deposit Scheme'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold ETF Investment', NULL, 46, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold ETF Investment'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Investment Purchase', NULL, 44, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Investment Purchase'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Loan - Closure / Settlement', NULL, 19, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Loan - Closure / Settlement'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Loan - Interest Payment', NULL, 20, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Loan - Interest Payment'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Loan - New Loan', NULL, 16, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Loan - New Loan'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Loan - Partial Payment', NULL, 21, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Loan - Partial Payment'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Loan - Pledge of Gold Jewellery', NULL, 22, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Loan - Pledge of Gold Jewellery'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Loan - Release of Gold Jewellery', NULL, 23, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Loan - Release of Gold Jewellery'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Loan - Renewal', NULL, 17, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Loan - Renewal'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Loan - Top Up', NULL, 18, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Loan - Top Up'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gold Savings Scheme', NULL, 48, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Gold Savings Scheme'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'High Value Financial Transaction', NULL, 54, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'High Value Financial Transaction'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Home Loan', NULL, 11, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Home Loan'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Hotel or Restaurant Payment above prescribed limit', NULL, 36, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Hotel or Restaurant Payment above prescribed limit'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Investment in Bonds / Debentures', NULL, 50, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Investment in Bonds / Debentures'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Large Cash Transaction', NULL, 53, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Large Cash Transaction'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Life Insurance Premium Payment', NULL, 33, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Life Insurance Premium Payment'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Loan Against Gold Coins', NULL, 24, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Loan Against Gold Coins'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Loan Against Gold Ornaments', NULL, 25, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Loan Against Gold Ornaments'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Loan Application', NULL, 9, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Loan Application'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Opening Bank Account', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Opening Bank Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Opening Demat Account', NULL, 32, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Opening Demat Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Opening Post Office Savings Account', NULL, 51, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Opening Post Office Savings Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Opening Trading Account', NULL, 52, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Opening Trading Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other Financial Transaction', NULL, 55, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Other Financial Transaction'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Personal Loan', NULL, 10, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Personal Loan'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Bank Draft / Pay Order / Bankers Cheque', NULL, 6, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Bank Draft / Pay Order / Bankers Cheque'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Foreign Currency / Forex', NULL, 35, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Foreign Currency / Forex'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Gold Bullion', NULL, 40, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Gold Bullion'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Gold Coins', NULL, 39, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Gold Coins'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Gold Jewellery', NULL, 38, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Gold Jewellery'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Goods or Services above prescribed limit', NULL, 37, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Goods or Services above prescribed limit'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Immovable Property', NULL, 28, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Immovable Property'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Motor Vehicle', NULL, 27, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Motor Vehicle'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Mutual Funds', NULL, 31, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Mutual Funds'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Purchase of Securities / Shares', NULL, 30, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Purchase of Securities / Shares'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Recurring Deposit', NULL, 5, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Recurring Deposit'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sale of Gold Bullion', NULL, 43, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Sale of Gold Bullion'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sale of Gold Coins', NULL, 42, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Sale of Gold Coins'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sale of Gold Jewellery', NULL, 41, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Sale of Gold Jewellery'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sale of Immovable Property', NULL, 29, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Sale of Immovable Property'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sovereign Gold Bond Purchase', NULL, 45, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Sovereign Gold Bond Purchase'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Vehicle Loan', NULL, 12, NULL, true, false FROM m_code WHERE code_name = 'FORM_60_PURPOSE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'FORM_60_PURPOSE' AND v.code_value = 'Vehicle Loan'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FEMALE', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'Gender' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Gender' AND v.code_value = 'FEMALE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MALE', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'Gender' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Gender' AND v.code_value = 'MALE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'OTHER', 'Other', 4, 0, true, false FROM m_code WHERE code_name = 'Gender' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Gender' AND v.code_value = 'OTHER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'TRANSGENDER', 'Transgender', 3, 0, true, false FROM m_code WHERE code_name = 'Gender' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Gender' AND v.code_value = 'TRANSGENDER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'GROUP_COMPLETED', 'Group Objective Completed', 1, NULL, true, false FROM m_code WHERE code_name = 'GroupClosureReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'GroupClosureReason' AND v.code_value = 'GROUP_COMPLETED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'INACTIVE', 'Group Inactive', 2, NULL, true, false FROM m_code WHERE code_name = 'GroupClosureReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'GroupClosureReason' AND v.code_value = 'INACTIVE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Leader', 'Group Leader Role', 1, NULL, true, false FROM m_code WHERE code_name = 'GROUPROLE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'GROUPROLE' AND v.code_value = 'Leader'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Business Associate', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'GuarantorRelationship' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'GuarantorRelationship' AND v.code_value = 'Business Associate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'GuarantorRelationship' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'GuarantorRelationship' AND v.code_value = 'Other'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Parent', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'GuarantorRelationship' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'GuarantorRelationship' AND v.code_value = 'Parent'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sibling', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'GuarantorRelationship' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'GuarantorRelationship' AND v.code_value = 'Sibling'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Spouse', NULL, 0, NULL, true, false FROM m_code WHERE code_name = 'GuarantorRelationship' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'GuarantorRelationship' AND v.code_value = 'Spouse'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FEE_INCOME', 'Fee Income', 2, NULL, true, false FROM m_code WHERE code_name = 'IncomeAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'IncomeAccountTags' AND v.code_value = 'FEE_INCOME'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'INTEREST_INCOME', 'Interest Income', 1, NULL, true, false FROM m_code WHERE code_name = 'IncomeAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'IncomeAccountTags' AND v.code_value = 'INTEREST_INCOME'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Accrual', 'Accrual', 2, NULL, true, false FROM m_code WHERE code_name = 'InterestCalculationTypeOption' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'InterestCalculationTypeOption' AND v.code_value = 'Accrual'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Compounding', 'Compounding', 1, NULL, true, false FROM m_code WHERE code_name = 'InterestCalculationTypeOption' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'InterestCalculationTypeOption' AND v.code_value = 'Compounding'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Aadhaar Card', 'AADHAAR', 1, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Aadhaar Card'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Bank Account Statement / Passbook', 'BANK_STATEMENT', 10, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Bank Account Statement / Passbook'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Driving License', 'DRIVING_LICENSE', 3, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Driving License'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Electricity Bill', 'ELECTRICITY_BILL', 6, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Electricity Bill'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Employer Letter (for salaried employees)', 'EMPLOYER_LETTER', 14, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Employer Letter (for salaried employees)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gas Bill', 'GAS_BILL', 8, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Gas Bill'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Internet Bill', 'INTERNET_BILL', 9, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Internet Bill'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Passport', 'PASSPORT', 2, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Passport'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Pension Payment Orders (for retirees)', 'PENSION_PAYMENT_ORDER', 15, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Pension Payment Orders (for retirees)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Postpaid Mobile Bill', 'POSTPAID_MOBILE_BILL', 11, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Postpaid Mobile Bill'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Property Tax Receipt', 'PROPERTY_TAX_RECEIPT', 13, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Property Tax Receipt'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Registered Rent Agreement', 'RENT_AGREEMENT', 12, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Registered Rent Agreement'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Utility Bills', 'UTILITY_BILL', 5, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Utility Bills'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Voter ID Card', 'VOTER_ID', 4, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Voter ID Card'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Water Bill', 'WATER_BILL', 7, NULL, true, false FROM m_code WHERE code_name = 'KYCAddressProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCAddressProofType' AND v.code_value = 'Water Bill'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Aadhaar Card', 'AADHAAR', 2, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Aadhaar Card'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Authorized Signatory KYC', 'Authorized Signatory KYC', 10, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Authorized Signatory KYC'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Birth Certificate', 'BIRTH_CERTIFICATE', 8, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Birth Certificate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Board Resolution (authorizing signatories)', 'Board Resolution (authorizing signatories)', 11, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Board Resolution (authorizing signatories)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Board Resolution / Authorization Letter', 'Board Resolution / Authorization Letter', 12, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Board Resolution / Authorization Letter'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Certificate of Incorporation', 'Certificate of Incorporation', 13, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Certificate of Incorporation'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Certificate of Incorporation / Registration Certificate', 'Certificate of Incorporation / Registration Certificate', 14, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Certificate of Incorporation / Registration Certificate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Declaration by Karta (with name, address & HUF member details)', 'Declaration by Karta (with name, address & HUF member details)', 15, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Declaration by Karta (with name, address & HUF member details)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Designated Partners Resolution', 'Designated Partners Resolution', 16, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Designated Partners Resolution'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Driving License', 'DRIVING_LICENSE', 5, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Driving License'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Government Notification / Order', 'Government Notification / Order', 17, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Government Notification / Order'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'GST Registration Certificate', 'GST Registration Certificate', 18, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'GST Registration Certificate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'KYC of Authorized Signatories', 'KYC of Authorized Signatories', 19, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'KYC of Authorized Signatories'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'KYC of Authorized Signatory / Power of Attorney Holder', 'KYC of Authorized Signatory / Power of Attorney Holder', 20, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'KYC of Authorized Signatory / Power of Attorney Holder'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'KYC of Designated Partners / Authorized Signatories', 'KYC of Designated Partners / Authorized Signatories', 21, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'KYC of Designated Partners / Authorized Signatories'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'KYC of Karta (OVDs + PAN + Photo)', 'KYC of Karta (OVDs + PAN + Photo)', 22, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'KYC of Karta (OVDs + PAN + Photo)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'KYC of Trustees / Authorized Signatories', 'KYC of Trustees / Authorized Signatories', 23, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'KYC of Trustees / Authorized Signatories'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Letter issued by National Population Register (NPR)', 'NPR_LETTER', 7, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Letter issued by National Population Register (NPR)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'LLP Agreement', 'LLP Agreement', 24, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'LLP Agreement'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Memorandum & Articles of Association', 'Memorandum & Articles of Association', 25, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Memorandum & Articles of Association'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Memorandum & Articles of Association / Partnership Deed / Trust Deed', 'Memorandum & Articles of Association / Partnership Deed / Trust Deed', 26, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Memorandum & Articles of Association / Partnership Deed / Trust Deed'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NREGA Job Card (signed by government authority)', 'NREGA_JOB_CARD', 6, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'NREGA Job Card (signed by government authority)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN', 'PAN', 27, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN (if applicable)', 'PAN (if applicable)', 28, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN (if applicable)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN Card', 'PAN', 1, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN Card'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN Card of Entity', 'PAN Card of Entity', 29, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN Card of Entity'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN Card of HUF', 'PAN Card of HUF', 30, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN Card of HUF'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN of Company', 'PAN of Company', 31, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN of Company'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN of Firm', 'PAN of Firm', 32, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN of Firm'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN of LLP', 'PAN of LLP', 33, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN of LLP'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN of Proprietor', 'PAN of Proprietor', 34, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN of Proprietor'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN of Society', 'PAN of Society', 35, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN of Society'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PAN of Trust', 'PAN of Trust', 36, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'PAN of Trust'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Partnership Deed', 'Partnership Deed', 37, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Partnership Deed'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Passport', 'PASSPORT', 3, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Passport'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Proof of Address of HUF', 'Proof of Address of HUF', 38, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Proof of Address of HUF'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Proof of Business Existence (GST Certificate / Shop License)', 'Proof of Business Existence (GST Certificate / Shop License)', 39, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Proof of Business Existence (GST Certificate / Shop License)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Proprietor''s KYC (OVDs + PAN + Photo)', 'Proprietor''s KYC (OVDs + PAN + Photo)', 40, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Proprietor''s KYC (OVDs + PAN + Photo)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Registration Certificate', 'Registration Certificate', 41, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Registration Certificate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Resolution authorizing signatories', 'Resolution authorizing signatories', 42, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Resolution authorizing signatories'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'School ID Card', 'SCHOOL_ID_CARD', 9, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'School ID Card'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Trust Deed', 'Trust Deed', 43, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Trust Deed'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Voter ID Card (EPIC)', 'VOTER_ID', 4, NULL, true, false FROM m_code WHERE code_name = 'KYCIdProofType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'KYCIdProofType' AND v.code_value = 'Voter ID Card (EPIC)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CURRENT_LIABILITY', 'Current Liability', 1, NULL, true, false FROM m_code WHERE code_name = 'LiabilityAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LiabilityAccountTags' AND v.code_value = 'CURRENT_LIABILITY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'LONG_TERM_LIABILITY', 'Long Term Liability', 2, NULL, true, false FROM m_code WHERE code_name = 'LiabilityAccountTags' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LiabilityAccountTags' AND v.code_value = 'LONG_TERM_LIABILITY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FD', 'Fixed Deposit Lien', 4, NULL, true, false FROM m_code WHERE code_name = 'LoanCollateral' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanCollateral' AND v.code_value = 'FD'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'GOLD', 'Gold Pledge', 3, NULL, true, false FROM m_code WHERE code_name = 'LoanCollateral' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanCollateral' AND v.code_value = 'GOLD'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'GUARANTEE', 'Third Party Guarantee', 5, NULL, true, false FROM m_code WHERE code_name = 'LoanCollateral' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanCollateral' AND v.code_value = 'GUARANTEE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PROPERTY', 'Immovable Property (Land/Building)', 1, NULL, true, false FROM m_code WHERE code_name = 'LoanCollateral' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanCollateral' AND v.code_value = 'PROPERTY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'STOCK', 'Stock & Inventory Hypothecation', 6, NULL, true, false FROM m_code WHERE code_name = 'LoanCollateral' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanCollateral' AND v.code_value = 'STOCK'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'VEHICLE', 'Vehicle Hypothecation', 2, NULL, true, false FROM m_code WHERE code_name = 'LoanCollateral' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanCollateral' AND v.code_value = 'VEHICLE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'AGGREGATOR', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'LoanOriginationChannelType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanOriginationChannelType' AND v.code_value = 'AGGREGATOR'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'API', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'LoanOriginationChannelType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanOriginationChannelType' AND v.code_value = 'API'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'IN_STORE', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'LoanOriginationChannelType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanOriginationChannelType' AND v.code_value = 'IN_STORE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'ONLINE', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'LoanOriginationChannelType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanOriginationChannelType' AND v.code_value = 'ONLINE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'AFFILIATE', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'LoanOriginatorType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanOriginatorType' AND v.code_value = 'AFFILIATE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BROKER', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'LoanOriginatorType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanOriginatorType' AND v.code_value = 'BROKER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MERCHANT', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'LoanOriginatorType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanOriginatorType' AND v.code_value = 'MERCHANT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PLATFORM', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'LoanOriginatorType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanOriginatorType' AND v.code_value = 'PLATFORM'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'AGRICULTURE_LOAN', 'Agriculture Loan', 6, NULL, true, false FROM m_code WHERE code_name = 'LoanPurpose' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanPurpose' AND v.code_value = 'AGRICULTURE_LOAN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BUSINESS_LOAN', 'Business Loan', 5, NULL, true, false FROM m_code WHERE code_name = 'LoanPurpose' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanPurpose' AND v.code_value = 'BUSINESS_LOAN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'EDUCATION_LOAN', 'Education Loan', 3, NULL, true, false FROM m_code WHERE code_name = 'LoanPurpose' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanPurpose' AND v.code_value = 'EDUCATION_LOAN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'HOME_LOAN', 'Housing Loan', 1, NULL, true, false FROM m_code WHERE code_name = 'LoanPurpose' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanPurpose' AND v.code_value = 'HOME_LOAN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PERSONAL_LOAN', 'Personal Loan', 4, NULL, true, false FROM m_code WHERE code_name = 'LoanPurpose' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanPurpose' AND v.code_value = 'PERSONAL_LOAN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'VEHICLE_LOAN', 'Vehicle Loan', 2, NULL, true, false FROM m_code WHERE code_name = 'LoanPurpose' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanPurpose' AND v.code_value = 'VEHICLE_LOAN'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'WORKING_CAPITAL', 'Working Capital Loan', 7, NULL, true, false FROM m_code WHERE code_name = 'LoanPurpose' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanPurpose' AND v.code_value = 'WORKING_CAPITAL'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BUSINESS_LOSS', 'Business Loss', 3, NULL, true, false FROM m_code WHERE code_name = 'LoanRescheduleReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanRescheduleReason' AND v.code_value = 'BUSINESS_LOSS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FINANCIAL_DIFFICULTY', 'Customer facing financial issues', 1, NULL, true, false FROM m_code WHERE code_name = 'LoanRescheduleReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanRescheduleReason' AND v.code_value = 'FINANCIAL_DIFFICULTY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NATURAL_CALAMITY', 'Natural disaster impact', 2, NULL, true, false FROM m_code WHERE code_name = 'LoanRescheduleReason' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'LoanRescheduleReason' AND v.code_value = 'NATURAL_CALAMITY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'AGRICULTURE', 'Agriculture', 4, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'AGRICULTURE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CONSTRUCTION', 'Construction Business', 5, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'CONSTRUCTION'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CONSULTING', 'Consulting / Professional Services', 15, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'CONSULTING'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'EDUCATION', 'Education Services', 11, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'EDUCATION'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'ENERGY', 'Energy / Power Sector', 19, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'ENERGY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'EXPORT_IMPORT', 'Export / Import Business', 16, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'EXPORT_IMPORT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FINANCIAL_SERVICES', 'Financial Services', 14, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'FINANCIAL_SERVICES'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FREELANCER', 'Freelancer / Self Employed', 23, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'FREELANCER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'GOVT_CONTRACTOR', 'Government Contractor', 22, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'GOVT_CONTRACTOR'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'HANDICRAFT', 'Handicraft / Artisan', 17, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'HANDICRAFT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'HEALTHCARE', 'Healthcare / Medical Services', 12, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'HEALTHCARE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'HOSPITALITY', 'Hotel / Restaurant / Hospitality', 13, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'HOSPITALITY'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'IT_SOFTWARE', 'IT / Software Services', 10, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'IT_SOFTWARE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MANUFACTURING', 'Manufacturing Industry', 1, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'MANUFACTURING'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MEDIA', 'Media / Advertising', 20, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'MEDIA'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MINING', 'Mining / Quarrying', 18, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'MINING'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NGO', 'NGO / Non-Profit Organization', 21, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'NGO'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'OTHERS', 'Other Business Activity', 24, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'OTHERS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'REAL_ESTATE', 'Real Estate', 9, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'REAL_ESTATE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'RETAIL', 'Retail Business', 6, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'RETAIL'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SERVICES', 'Service Sector', 3, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'SERVICES'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'TRADING', 'Trading Business', 2, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'TRADING'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'TRANSPORT', 'Transport & Logistics', 8, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'TRANSPORT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'WHOLESALE', 'Wholesale Business', 7, NULL, true, false FROM m_code WHERE code_name = 'Main Business Line' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Main Business Line' AND v.code_value = 'WHOLESALE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DIVORCED', 'Divorced', 3, NULL, true, false FROM m_code WHERE code_name = 'MARITAL STATUS' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MARITAL STATUS' AND v.code_value = 'DIVORCED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MARRIED', 'Married', 2, NULL, true, false FROM m_code WHERE code_name = 'MARITAL STATUS' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MARITAL STATUS' AND v.code_value = 'MARRIED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SINGLE', 'Unmarried', 1, NULL, true, false FROM m_code WHERE code_name = 'MARITAL STATUS' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MARITAL STATUS' AND v.code_value = 'SINGLE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'WIDOWED', 'Widowed', 4, NULL, true, false FROM m_code WHERE code_name = 'MARITAL STATUS' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MARITAL STATUS' AND v.code_value = 'WIDOWED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Annulled', NULL, 7, NULL, true, false FROM m_code WHERE code_name = 'MaritalStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MaritalStatus' AND v.code_value = 'Annulled'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Divorced', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'MaritalStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MaritalStatus' AND v.code_value = 'Divorced'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Married', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'MaritalStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MaritalStatus' AND v.code_value = 'Married'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Not Disclosed', NULL, 10, NULL, true, false FROM m_code WHERE code_name = 'MaritalStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MaritalStatus' AND v.code_value = 'Not Disclosed'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other', NULL, 9, NULL, true, false FROM m_code WHERE code_name = 'MaritalStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MaritalStatus' AND v.code_value = 'Other'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Separated', NULL, 6, NULL, true, false FROM m_code WHERE code_name = 'MaritalStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MaritalStatus' AND v.code_value = 'Separated'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Single', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'MaritalStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MaritalStatus' AND v.code_value = 'Single'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Unmarried', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'MaritalStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MaritalStatus' AND v.code_value = 'Unmarried'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Widowed', NULL, 5, NULL, true, false FROM m_code WHERE code_name = 'MaritalStatus' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'MaritalStatus' AND v.code_value = 'Widowed'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Agri Allied Activities', NULL, 38, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Agri Allied Activities'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Agricultural Labourer', NULL, 33, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Agricultural Labourer'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Architect', NULL, 25, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Architect'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Artisan / Craftsman', NULL, 50, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Artisan / Craftsman'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Auditor', NULL, 30, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Auditor'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Bank Employee', NULL, 9, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Bank Employee'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Business Owner / Proprietor', NULL, 11, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Business Owner / Proprietor'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Chartered Accountant', NULL, 23, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Chartered Accountant'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Commission Agent', NULL, 19, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Commission Agent'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Company Secretary', NULL, 24, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Company Secretary'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Consultant', NULL, 26, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Consultant'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Contractor', NULL, 14, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Contractor'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Dairy / Animal Husbandry', NULL, 35, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Dairy / Animal Husbandry'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Defence / Armed Forces Personnel', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Defence / Armed Forces Personnel'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Dependent / Minor', NULL, 41, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Dependent / Minor'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Doctor (Private Practice)', NULL, 21, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Doctor (Private Practice)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Doctor (Salaried)', NULL, 7, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Doctor (Salaried)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Domestic Worker', NULL, 52, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Domestic Worker'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Driver / Operator', NULL, 53, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Driver / Operator'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Engineer (Salaried)', NULL, 8, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Engineer (Salaried)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Engineer (Self Employed)', NULL, 27, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Engineer (Self Employed)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Farmer (Own Land)', NULL, 31, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Farmer (Own Land)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Financial Advisor', NULL, 29, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Financial Advisor'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Fisherman', NULL, 36, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Fisherman'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Government Employee', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Government Employee'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Horticulture / Floriculture', NULL, 34, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Horticulture / Floriculture'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Housewife / Homemaker', NULL, 40, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Housewife / Homemaker'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Importer / Exporter', NULL, 18, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Importer / Exporter'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'IT Professional / Freelancer', NULL, 28, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'IT Professional / Freelancer'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Labourer / Daily Wage', NULL, 51, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Labourer / Daily Wage'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Lawyer / Advocate', NULL, 22, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Lawyer / Advocate'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Manufacturer', NULL, 13, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Manufacturer'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NGO / Social Worker', NULL, 49, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'NGO / Social Worker'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NRI (Non-Resident Indian)', NULL, 45, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'NRI (Non-Resident Indian)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Others', NULL, 54, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Others'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PIO / OCI', NULL, 46, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'PIO / OCI'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Police / Paramilitary', NULL, 5, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Police / Paramilitary'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Politician / Elected Representative', NULL, 47, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Politician / Elected Representative'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Poultry Farmer', NULL, 37, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Poultry Farmer'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Private Sector Employee', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Private Sector Employee'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Public Sector Undertaking (PSU) Employee', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Public Sector Undertaking (PSU) Employee'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Railway Employee', NULL, 10, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Railway Employee'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Real Estate / Property Dealer', NULL, 15, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Real Estate / Property Dealer'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Religious / Trust Worker', NULL, 48, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Religious / Trust Worker'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Retailer', NULL, 16, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Retailer'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Retired (Non-Pension)', NULL, 44, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Retired (Non-Pension)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Retired (Pension)', NULL, 43, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Retired (Pension)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Student', NULL, 39, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Student'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Teacher / Professor', NULL, 6, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Teacher / Professor'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Tenant Farmer', NULL, 32, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Tenant Farmer'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Trader / Merchant', NULL, 12, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Trader / Merchant'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Transport / Logistics Owner', NULL, 20, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Transport / Logistics Owner'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Unemployed', NULL, 42, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Unemployed'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Wholesaler', NULL, 17, NULL, true, false FROM m_code WHERE code_name = 'Occupation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Occupation' AND v.code_value = 'Wholesaler'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Agriculture', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'OccupationCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'OccupationCategory' AND v.code_value = 'Agriculture'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Business / Self Employed', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'OccupationCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'OccupationCategory' AND v.code_value = 'Business / Self Employed'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Others', NULL, 6, NULL, true, false FROM m_code WHERE code_name = 'OccupationCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'OccupationCategory' AND v.code_value = 'Others'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Professional', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'OccupationCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'OccupationCategory' AND v.code_value = 'Professional'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Salaried / Service', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'OccupationCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'OccupationCategory' AND v.code_value = 'Salaried / Service'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Student / Non-Earning', NULL, 5, NULL, true, false FROM m_code WHERE code_name = 'OccupationCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'OccupationCategory' AND v.code_value = 'Student / Non-Earning'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Money Transfer', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'PaymentType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PaymentType' AND v.code_value = 'Money Transfer'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Half Yearly', 'Half Yearly', 3, NULL, true, false FROM m_code WHERE code_name = 'PeriodFrequency' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PeriodFrequency' AND v.code_value = 'Half Yearly'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Monthly', 'Monthly', 1, NULL, true, false FROM m_code WHERE code_name = 'PeriodFrequency' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PeriodFrequency' AND v.code_value = 'Monthly'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Quarterly', 'Quarterly', 2, NULL, true, false FROM m_code WHERE code_name = 'PeriodFrequency' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PeriodFrequency' AND v.code_value = 'Quarterly'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Yearly', 'Yearly', 4, NULL, true, false FROM m_code WHERE code_name = 'PeriodFrequency' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PeriodFrequency' AND v.code_value = 'Yearly'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'BUSINESS', 'Business Owner', 2, NULL, true, false FROM m_code WHERE code_name = 'PROFESSION' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PROFESSION' AND v.code_value = 'BUSINESS'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'RETIRED', 'Retired Person', 5, NULL, true, false FROM m_code WHERE code_name = 'PROFESSION' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PROFESSION' AND v.code_value = 'RETIRED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SALARIED', 'Salaried Employee', 1, NULL, true, false FROM m_code WHERE code_name = 'PROFESSION' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PROFESSION' AND v.code_value = 'SALARIED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SELF_EMPLOYED', 'Self Employed Professional', 3, NULL, true, false FROM m_code WHERE code_name = 'PROFESSION' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PROFESSION' AND v.code_value = 'SELF_EMPLOYED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'STUDENT', 'Student', 4, NULL, true, false FROM m_code WHERE code_name = 'PROFESSION' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PROFESSION' AND v.code_value = 'STUDENT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Acid Attack Victim', 'Acid Attack Victim', 20, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Acid Attack Victim'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Autism Spectrum Disorder', 'Autism Spectrum Disorder', 9, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Autism Spectrum Disorder'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Blindness', 'Blindness', 1, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Blindness'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Cerebral Palsy', 'Cerebral Palsy', 10, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Cerebral Palsy'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Chronic Neurological Conditions', 'Chronic Neurological Conditions', 12, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Chronic Neurological Conditions'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Dwarfism', 'Dwarfism', 6, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Dwarfism'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Hearing Impairment (Deaf and Hard of Hearing)', 'Hearing Impairment (Deaf and Hard of Hearing)', 4, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Hearing Impairment (Deaf and Hard of Hearing)'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Hemophilia', 'Hemophilia', 17, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Hemophilia'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Intellectual Disability', 'Intellectual Disability', 7, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Intellectual Disability'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Leprosy Cured Persons', 'Leprosy Cured Persons', 3, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Leprosy Cured Persons'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Locomotor Disability', 'Locomotor Disability', 5, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Locomotor Disability'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Low Vision', 'Low Vision', 2, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Low Vision'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Mental Illness', 'Mental Illness', 8, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Mental Illness'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Multiple Disabilities', 'Multiple Disabilities', 19, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Multiple Disabilities'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Multiple Sclerosis', 'Multiple Sclerosis', 14, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Multiple Sclerosis'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Muscular Dystrophy', 'Muscular Dystrophy', 11, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Muscular Dystrophy'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Parkinson''s Disease', 'Parkinson''s Disease', 21, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Parkinson''s Disease'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sickle Cell Disease', 'Sickle Cell Disease', 18, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Sickle Cell Disease'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Specific Learning Disabilities', 'Specific Learning Disabilities', 13, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Specific Learning Disabilities'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Speech and Language Disability', 'Speech and Language Disability', 15, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Speech and Language Disability'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Thalassemia', 'Thalassemia', 16, NULL, true, false FROM m_code WHERE code_name = 'PwdCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'PwdCategory' AND v.code_value = 'Thalassemia'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DPD_RESET', 'DPD Reset After Payment', 1, NULL, true, false FROM m_code WHERE code_name = 'ReAgeReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ReAgeReasons' AND v.code_value = 'DPD_RESET'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'RESTRUCTURE_APPROVED', 'Restructure Approved', 2, NULL, true, false FROM m_code WHERE code_name = 'ReAgeReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ReAgeReasons' AND v.code_value = 'RESTRUCTURE_APPROVED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'TECHNICAL_ADJUSTMENT', 'Technical Adjustment', 3, NULL, true, false FROM m_code WHERE code_name = 'ReAgeReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ReAgeReasons' AND v.code_value = 'TECHNICAL_ADJUSTMENT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'EMI_REDUCTION', 'EMI Reduction', 2, NULL, true, false FROM m_code WHERE code_name = 'ReAmortizationReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ReAmortizationReasons' AND v.code_value = 'EMI_REDUCTION'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'PART_PREPAYMENT', 'After Part Prepayment', 4, NULL, true, false FROM m_code WHERE code_name = 'ReAmortizationReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ReAmortizationReasons' AND v.code_value = 'PART_PREPAYMENT'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'RATE_REVISION', 'Interest Rate Revision', 3, NULL, true, false FROM m_code WHERE code_name = 'ReAmortizationReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ReAmortizationReasons' AND v.code_value = 'RATE_REVISION'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'TENURE_EXTENSION', 'Loan Tenure Extension', 1, NULL, true, false FROM m_code WHERE code_name = 'ReAmortizationReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'ReAmortizationReasons' AND v.code_value = 'TENURE_EXTENSION'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Rd Account', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'RecurringDepositProductAccountType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'RecurringDepositProductAccountType' AND v.code_value = 'Rd Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Individual', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'RecurringDepositProductCustomerSegment' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'RecurringDepositProductCustomerSegment' AND v.code_value = 'Individual'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Non-Individual', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'RecurringDepositProductCustomerSegment' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'RecurringDepositProductCustomerSegment' AND v.code_value = 'Non-Individual'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'CARETAKER', NULL, 6, NULL, true, false FROM m_code WHERE code_name = 'RELATIONSHIP' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'RELATIONSHIP' AND v.code_value = 'CARETAKER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DAUGHTER', 'Daughter', 5, NULL, true, false FROM m_code WHERE code_name = 'RELATIONSHIP' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'RELATIONSHIP' AND v.code_value = 'DAUGHTER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FATHER', 'Father', 1, NULL, true, false FROM m_code WHERE code_name = 'RELATIONSHIP' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'RELATIONSHIP' AND v.code_value = 'FATHER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'MOTHER', 'Mother', 2, NULL, true, false FROM m_code WHERE code_name = 'RELATIONSHIP' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'RELATIONSHIP' AND v.code_value = 'MOTHER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SON', 'Son', 4, NULL, true, false FROM m_code WHERE code_name = 'RELATIONSHIP' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'RELATIONSHIP' AND v.code_value = 'SON'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SPOUSE', 'Spouse', 3, NULL, true, false FROM m_code WHERE code_name = 'RELATIONSHIP' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'RELATIONSHIP' AND v.code_value = 'SPOUSE'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Buddhist', NULL, 6, NULL, true, false FROM m_code WHERE code_name = 'Religion' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Religion' AND v.code_value = 'Buddhist'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Christian', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'Religion' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Religion' AND v.code_value = 'Christian'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Hindu', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'Religion' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Religion' AND v.code_value = 'Hindu'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Jain', NULL, 5, NULL, true, false FROM m_code WHERE code_name = 'Religion' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Religion' AND v.code_value = 'Jain'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Muslim', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'Religion' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Religion' AND v.code_value = 'Muslim'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Others', NULL, 7, NULL, true, false FROM m_code WHERE code_name = 'Religion' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Religion' AND v.code_value = 'Others'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sikh', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'Religion' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Religion' AND v.code_value = 'Sikh'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Dr.', NULL, 5, NULL, true, false FROM m_code WHERE code_name = 'Salutation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Salutation' AND v.code_value = 'Dr.'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Master', NULL, 8, NULL, true, false FROM m_code WHERE code_name = 'Salutation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Salutation' AND v.code_value = 'Master'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Miss', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'Salutation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Salutation' AND v.code_value = 'Miss'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Mr.', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'Salutation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Salutation' AND v.code_value = 'Mr.'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Mrs.', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'Salutation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Salutation' AND v.code_value = 'Mrs.'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Ms.', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'Salutation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Salutation' AND v.code_value = 'Ms.'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Shri', NULL, 6, NULL, true, false FROM m_code WHERE code_name = 'Salutation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Salutation' AND v.code_value = 'Shri'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Smt.', NULL, 7, NULL, true, false FROM m_code WHERE code_name = 'Salutation' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'Salutation' AND v.code_value = 'Smt.'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'COURT_ORDER', 'Court Order Freeze', 2, NULL, true, false FROM m_code WHERE code_name = 'SavingsAccountBlockReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SavingsAccountBlockReasons' AND v.code_value = 'COURT_ORDER'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'KYC_PENDING', 'KYC Pending', 1, NULL, true, false FROM m_code WHERE code_name = 'SavingsAccountBlockReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SavingsAccountBlockReasons' AND v.code_value = 'KYC_PENDING'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Savings Account Minor', 'Savings Account Minor', 1, NULL, true, false FROM m_code WHERE code_name = 'SavingsProductAccountType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SavingsProductAccountType' AND v.code_value = 'Savings Account Minor'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Savings HUF', 'Savings HUF', 3, NULL, true, false FROM m_code WHERE code_name = 'SavingsProductAccountType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SavingsProductAccountType' AND v.code_value = 'Savings HUF'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Small Saving Account', 'Small Saving Account', 2, NULL, true, false FROM m_code WHERE code_name = 'SavingsProductAccountType' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SavingsProductAccountType' AND v.code_value = 'Small Saving Account'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Individual', 'Individual', 1, NULL, true, false FROM m_code WHERE code_name = 'SavingsProductCustomerSegment' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SavingsProductCustomerSegment' AND v.code_value = 'Individual'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Non Individual', 'Non Individual', 3, NULL, true, false FROM m_code WHERE code_name = 'SavingsProductCustomerSegment' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SavingsProductCustomerSegment' AND v.code_value = 'Non Individual'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'ACCOUNT_REVIEW', 'Account Under Review', 1, NULL, true, false FROM m_code WHERE code_name = 'SavingsTransactionFreezeReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SavingsTransactionFreezeReasons' AND v.code_value = 'ACCOUNT_REVIEW'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'General', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'SocialCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SocialCategory' AND v.code_value = 'General'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'OBC', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'SocialCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SocialCategory' AND v.code_value = 'OBC'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'SC', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'SocialCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SocialCategory' AND v.code_value = 'SC'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'ST', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'SocialCategory' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SocialCategory' AND v.code_value = 'ST'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Andaman and Nicobar Islands', 'Union Territory', 29, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Andaman and Nicobar Islands'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Andhra Pradesh', 'Indian State', 1, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Andhra Pradesh'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Arunachal Pradesh', 'Indian State', 2, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Arunachal Pradesh'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Assam', 'Indian State', 3, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Assam'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Bihar', 'Indian State', 4, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Bihar'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Chandigarh', 'Union Territory', 30, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Chandigarh'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Chhattisgarh', 'Indian State', 5, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Chhattisgarh'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Dadra and Nagar Haveli and Daman and Diu', 'Union Territory', 31, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Dadra and Nagar Haveli and Daman and Diu'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Delhi', 'Union Territory', 3, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Delhi'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Goa', 'Indian State', 6, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Goa'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gujarat', 'Indian State', 7, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Gujarat'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Haryana', 'Indian State', 8, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Haryana'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Himachal Pradesh', 'Indian State', 9, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Himachal Pradesh'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Jammu and Kashmir', 'Union Territory', 33, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Jammu and Kashmir'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Jharkhand', 'Indian State', 10, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Jharkhand'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Karnataka', 'Indian State', 11, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Karnataka'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Kerala', 'Indian State', 12, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Kerala'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Ladakh', 'Union Territory', 34, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Ladakh'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Lakshadweep', 'Union Territory', 35, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Lakshadweep'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Madhya Pradesh', 'Indian State', 2, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Madhya Pradesh'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Maharashtra', 'Indian State', 1, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Maharashtra'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Manipur', 'Indian State', 15, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Manipur'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Meghalaya', 'Indian State', 16, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Meghalaya'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Mizoram', 'Indian State', 17, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Mizoram'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Nagaland', 'Indian State', 18, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Nagaland'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Odisha', 'Indian State', 19, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Odisha'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Puducherry', 'Union Territory', 36, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Puducherry'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Punjab', 'Indian State', 20, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Punjab'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Rajasthan', 'Indian State', 21, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Rajasthan'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sikkim', 'Indian State', 22, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Sikkim'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Tamil Nadu', 'Indian State', 23, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Tamil Nadu'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Telangana', 'Indian State', 24, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Telangana'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Tripura', 'Indian State', 25, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Tripura'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Uttar Pradesh', 'Indian State', 26, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Uttar Pradesh'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Uttarakhand', 'Indian State', 27, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'Uttarakhand'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'West Bengal', 'Indian State', 28, NULL, true, false FROM m_code WHERE code_name = 'STATE' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'STATE' AND v.code_value = 'West Bengal'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Baiga', NULL, 43, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Baiga'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Balmiki', NULL, 31, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Balmiki'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Banjara', NULL, 20, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Banjara'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Bharia', NULL, 44, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Bharia'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Bhil', NULL, 41, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Bhil'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Brahmin', NULL, 1, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Brahmin'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Chamar / Jatav', NULL, 30, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Chamar / Jatav'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Dhobi', NULL, 32, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Dhobi'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Gond', NULL, 40, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Gond'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Jat', NULL, 5, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Jat'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Kayastha', NULL, 4, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Kayastha'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Kewat / Dhimar', NULL, 14, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Kewat / Dhimar'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Kori', NULL, 35, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Kori'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Korku', NULL, 42, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Korku'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Kshatriya / Rajput', NULL, 2, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Kshatriya / Rajput'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Kumhar', NULL, 15, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Kumhar'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Kurmi', NULL, 11, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Kurmi'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Kushwaha / Patel', NULL, 16, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Kushwaha / Patel'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Lohar', NULL, 18, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Lohar'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Mali', NULL, 17, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Mali'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Meghwal', NULL, 34, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Meghwal'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Nai / Napit', NULL, 13, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Nai / Napit'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other General', NULL, 7, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Other General'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other OBC', NULL, 21, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Other OBC'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other SC', NULL, 36, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Other SC'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Other ST', NULL, 46, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Other ST'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Pasi', NULL, 33, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Pasi'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Prajapati', NULL, 19, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Prajapati'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sahariya', NULL, 45, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Sahariya'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Sindhi', NULL, 6, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Sindhi'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Teli', NULL, 12, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Teli'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Vaishya / Baniya', NULL, 3, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Vaishya / Baniya'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'Yadav', NULL, 10, NULL, true, false FROM m_code WHERE code_name = 'SubCaste' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'SubCaste' AND v.code_value = 'Yadav'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'DECEASED', 'Customer Deceased', 2, NULL, true, false FROM m_code WHERE code_name = 'WriteOffReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'WriteOffReasons' AND v.code_value = 'DECEASED'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'FRAUD', 'Fraud Account', 3, NULL, true, false FROM m_code WHERE code_name = 'WriteOffReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'WriteOffReasons' AND v.code_value = 'FRAUD'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NPA', 'Non Performing Asset', 1, NULL, true, false FROM m_code WHERE code_name = 'WriteOffReasons' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'WriteOffReasons' AND v.code_value = 'NPA'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'NO', 'No Option', 2, NULL, true, false FROM m_code WHERE code_name = 'YesNo' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'YesNo' AND v.code_value = 'NO'); +INSERT INTO m_code_value (code_id, code_value, code_description, order_position, code_score, is_active, is_mandatory) SELECT id, 'YES', 'Yes Option', 1, NULL, true, false FROM m_code WHERE code_name = 'YesNo' AND NOT EXISTS (SELECT 1 FROM m_code_value v JOIN m_code c ON c.id = v.code_id WHERE c.code_name = 'YesNo' AND v.code_value = 'YES'); + + + + + \ No newline at end of file diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0506_catchup_context_default_client_kyc_migrations.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0506_catchup_context_default_client_kyc_migrations.xml new file mode 100644 index 000000000..5c3190144 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0506_catchup_context_default_client_kyc_migrations.xml @@ -0,0 +1,534 @@ + + + + + + + + + + SELECT COUNT(*) FROM m_permission WHERE code = 'READ_OPENPROJECT' + + + + + + + + + + + + SELECT COUNT(*) FROM m_permission WHERE code = 'CREATE_OPENPROJECT' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UPDATE m_client_kyc + SET kyc_status = 300, verified_on = CURRENT_DATE + WHERE kyc_type = 1 AND pan_verified = true AND aadhaar_verified = true + AND kyc_status != 300 AND kyc_status != 400; + + UPDATE m_client_kyc + SET kyc_status = 300, verified_on = CURRENT_DATE + WHERE kyc_type = 2 AND pan_verified = true AND gstin_verified = true + AND kyc_status != 300 AND kyc_status != 400; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM m_permission WHERE code = 'READ_CLIENTNOMINEE' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM m_permission WHERE code = 'READ_FAMILYMEMBERDOCUMENT' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UPDATE m_address SET client_id = ca.client_id + FROM m_client_address ca + WHERE m_address.id = ca.address_id AND m_address.client_id IS NULL; + + + + + + + + UPDATE m_field_configuration SET is_enabled = true WHERE field = 'townVillage' AND entity = 'ADDRESS'; + UPDATE m_field_configuration SET is_enabled = true WHERE field = 'countyDistrict' AND entity = 'ADDRESS'; + + + + + SELECT COUNT(*) FROM m_field_configuration WHERE entity='ADDRESS' AND field='street' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UPDATE m_address SET address_type_id = ca.address_type_id + FROM m_client_address ca + WHERE m_address.id = ca.address_id AND m_address.address_type_id IS NULL; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0507_simplify_teller_payment_types.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0507_simplify_teller_payment_types.xml new file mode 100644 index 000000000..60fc0d3a4 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0507_simplify_teller_payment_types.xml @@ -0,0 +1,72 @@ + + + + + + + + SELECT COUNT(*) FROM m_payment_type WHERE is_cash_payment = true + + + + + + + + + + + + + + SELECT COUNT(*) FROM m_payment_type WHERE value = 'Money Transfer' + + + + + value = 'Money Transfer' + + + + + + UPDATE m_payment_type SET is_system_defined = true + WHERE code_name IN ('SHARE_REDEMPTION_TRANSFER', 'DIVIDEND_CLAIM_SETTLEMENT') AND is_system_defined = false; + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0508_retire_share_redemption_transfer_payment_type.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0508_retire_share_redemption_transfer_payment_type.xml new file mode 100644 index 000000000..91261848b --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0508_retire_share_redemption_transfer_payment_type.xml @@ -0,0 +1,60 @@ + + + + + + + + SELECT COUNT(*) FROM m_payment_type WHERE code_name = 'SHARE_REDEMPTION_TRANSFER' + + + UPDATE m_payment_detail SET payment_type_id = (SELECT id FROM m_payment_type WHERE code_name = 'TRANSFER' OR value = 'Transfer' LIMIT 1) + WHERE payment_type_id = (SELECT id FROM m_payment_type WHERE code_name = 'SHARE_REDEMPTION_TRANSFER'); + + UPDATE acc_product_mapping SET payment_type = (SELECT id FROM m_payment_type WHERE code_name = 'TRANSFER' OR value = 'Transfer' LIMIT 1) + WHERE payment_type = (SELECT id FROM m_payment_type WHERE code_name = 'SHARE_REDEMPTION_TRANSFER'); + + UPDATE m_charge SET payment_type_id = (SELECT id FROM m_payment_type WHERE code_name = 'TRANSFER' OR value = 'Transfer' LIMIT 1) + WHERE payment_type_id = (SELECT id FROM m_payment_type WHERE code_name = 'SHARE_REDEMPTION_TRANSFER'); + + UPDATE m_clerk_share_withdrawal_request SET settlement_payment_type_id = (SELECT id FROM m_payment_type WHERE code_name = 'TRANSFER' OR value = 'Transfer' LIMIT 1) + WHERE settlement_payment_type_id = (SELECT id FROM m_payment_type WHERE code_name = 'SHARE_REDEMPTION_TRANSFER') + OR (settlement_payment_type_id IS NULL AND status = 'APPROVED'); + + DELETE FROM m_payment_type WHERE code_name = 'SHARE_REDEMPTION_TRANSFER'; + + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0509_retire_all_system_defined_payment_types.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0509_retire_all_system_defined_payment_types.xml new file mode 100644 index 000000000..6586f5e9d --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0509_retire_all_system_defined_payment_types.xml @@ -0,0 +1,69 @@ + + + + + + + + + SELECT COUNT(*) FROM m_payment_type WHERE is_system_defined = true + + + + UPDATE m_payment_detail SET payment_type_id = (SELECT id FROM m_payment_type WHERE value = 'Transfer' LIMIT 1) + WHERE payment_type_id IN (SELECT id FROM m_payment_type WHERE is_system_defined = true); + + UPDATE acc_product_mapping SET payment_type = (SELECT id FROM m_payment_type WHERE value = 'Transfer' LIMIT 1) + WHERE payment_type IN (SELECT id FROM m_payment_type WHERE is_system_defined = true); + + UPDATE m_charge SET payment_type_id = (SELECT id FROM m_payment_type WHERE value = 'Transfer' LIMIT 1) + WHERE payment_type_id IN (SELECT id FROM m_payment_type WHERE is_system_defined = true); + + UPDATE m_clerk_share_withdrawal_request SET settlement_payment_type_id = (SELECT id FROM m_payment_type WHERE value = 'Transfer' LIMIT 1) + WHERE settlement_payment_type_id IN (SELECT id FROM m_payment_type WHERE is_system_defined = true); + + DELETE FROM m_payment_type WHERE is_system_defined = true; + + + + diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/data/FacilityChargeMappingData.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/data/FacilityChargeMappingData.java new file mode 100644 index 000000000..b21481595 --- /dev/null +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/data/FacilityChargeMappingData.java @@ -0,0 +1,83 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.data; + +import java.math.BigDecimal; +import java.util.List; +import lombok.Getter; +import lombok.Setter; + +/** + * One row of {@code m_facility_charge_mapping}: which {@link org.apache.fineract.portfolio.charge.domain.Charge} + * is applied when a named account facility (ATM_FACILITY, UPI_FACILITY, ...) is enabled. {@link #chargeOptions} + * is populated only on the template response, for the admin screen's "change the mapped charge" dropdown. + */ +@Getter +@Setter +public class FacilityChargeMappingData { + + private Long id; + private String facilityType; + private Long chargeId; + private String chargeName; + private BigDecimal defaultAmount; + private Integer chargeTimeType; + private Integer chargeAppliesTo; + private Boolean isActive; + + /** + * False when the mapped charge has since been deleted or deactivated (and true whenever there is simply no + * charge mapped at all). {@link #chargeName} still shows whatever name was cached at mapping time either + * way, so the admin screen needs this flag to tell "correctly mapped" apart from "was mapped, now broken". + */ + private Boolean chargeAvailable; + + private List chargeOptions; + + public FacilityChargeMappingData() {} + + public FacilityChargeMappingData(final Long id, final String facilityType, final Long chargeId, final String chargeName, + final BigDecimal defaultAmount, final Integer chargeTimeType, final Integer chargeAppliesTo, final Boolean isActive, + final Boolean chargeAvailable) { + this.id = id; + this.facilityType = facilityType; + this.chargeId = chargeId; + this.chargeName = chargeName; + this.defaultAmount = defaultAmount; + this.chargeTimeType = chargeTimeType; + this.chargeAppliesTo = chargeAppliesTo; + this.isActive = isActive; + this.chargeAvailable = chargeAvailable; + } + + @Getter + @Setter + public static class FacilityChargeOptionData { + + private final Long id; + private final String name; + private final BigDecimal amount; + + public FacilityChargeOptionData(final Long id, final String name, final BigDecimal amount) { + this.id = id; + this.name = name; + this.amount = amount; + } + } +} diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/exception/FacilityChargeMappingNotFoundException.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/exception/FacilityChargeMappingNotFoundException.java new file mode 100644 index 000000000..01cb3eeb2 --- /dev/null +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/exception/FacilityChargeMappingNotFoundException.java @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.exception; + +import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + +public class FacilityChargeMappingNotFoundException extends AbstractPlatformResourceNotFoundException { + + public FacilityChargeMappingNotFoundException(final Long id) { + super("error.msg.facilitychargemapping.id.invalid", "Facility charge mapping with identifier " + id + " does not exist", id); + } +} diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeAutoApplyService.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeAutoApplyService.java index d7bbf84bc..892629e2a 100644 --- a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeAutoApplyService.java +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeAutoApplyService.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.portfolio.charge.domain.Charge; @@ -117,18 +118,13 @@ public class FacilityChargeAutoApplyService { public List applyChargesForFacilities(final SavingsAccount account, final java.util.Set facilityTypes) { final List chargesToApply = new ArrayList<>(); for (final String facilityType : facilityTypes) { - mappingRepository.findByFacilityType(facilityType).ifPresent(mapping -> { - final Charge charge = mapping.getCharge(); - if (charge == null) { - return; - } - final MonthDay feeOnMonthDay = resolveFeeOnMonthDay(charge); - final SavingsAccountCharge accountCharge = SavingsAccountCharge.createNewWithoutSavingsAccount(charge, charge.getAmount(), - null, null, resolveDueDate(charge), true, feeOnMonthDay, charge.getFeeInterval()); - accountCharge.update(account); - account.charges().add(accountCharge); - chargesToApply.add(accountCharge); - }); + final Charge charge = requireMappedCharge(facilityType); + final MonthDay feeOnMonthDay = resolveFeeOnMonthDay(charge); + final SavingsAccountCharge accountCharge = SavingsAccountCharge.createNewWithoutSavingsAccount(charge, charge.getAmount(), + null, null, resolveDueDate(charge), true, feeOnMonthDay, charge.getFeeInterval()); + accountCharge.update(account); + account.charges().add(accountCharge); + chargesToApply.add(accountCharge); } if (!chargesToApply.isEmpty()) { savingsAccountChargeRepository.saveAll(chargesToApply); @@ -219,25 +215,49 @@ public class FacilityChargeAutoApplyService { && c.getCharge().getName().equals(getChargeName(facilityType))); if (alreadyApplied) return; - mappingRepository.findByFacilityType(facilityType).ifPresent(mapping -> { - final Charge charge = mapping.getCharge(); - if (charge == null) return; + final Charge charge = requireMappedCharge(facilityType); - final MonthDay feeOnMonthDay = resolveFeeOnMonthDay(charge); - final SavingsAccountCharge accountCharge = SavingsAccountCharge.createNewWithoutSavingsAccount( - charge, - charge.getAmount(), - null, // chargeTime derived from Charge definition - null, // chargeCalculation derived from Charge definition - resolveDueDate(charge), - true, - feeOnMonthDay, - charge.getFeeInterval()); + final MonthDay feeOnMonthDay = resolveFeeOnMonthDay(charge); + final SavingsAccountCharge accountCharge = SavingsAccountCharge.createNewWithoutSavingsAccount( + charge, + charge.getAmount(), + null, // chargeTime derived from Charge definition + null, // chargeCalculation derived from Charge definition + resolveDueDate(charge), + true, + feeOnMonthDay, + charge.getFeeInterval()); - accountCharge.update(account); - account.charges().add(accountCharge); - collector.add(accountCharge); - }); + accountCharge.update(account); + account.charges().add(accountCharge); + collector.add(accountCharge); + } + + /** + * Looks up the charge mapped to {@code facilityType}, throwing rather than silently letting the facility be + * enabled with no charge (or a charge that no longer exists) if the mapping is missing, has no charge + * configured, or its charge has since been deleted/deactivated. Configure it via Products {@literal >} + * Facility Charge Mappings first. + */ + private Charge requireMappedCharge(final String facilityType) { + final FacilityChargeMapping mapping = mappingRepository.findByFacilityType(facilityType).orElse(null); + // An inactive mapping is treated the same as an unmapped one: the Facility Charge Mappings screen's + // "Active" toggle is how an admin marks a mapping as genuinely configured, so a charge sitting on an + // inactive row must not silently apply. + if (mapping == null || mapping.getCharge() == null || !Boolean.TRUE.equals(mapping.getIsActive())) { + throw new GeneralPlatformDomainRuleException("error.msg.facility.charge.not.mapped", + "A charge has not been mapped for the '" + facilityType + + "' facility. Configure it under Products > Facility Charge Mappings before enabling it.", + facilityType); + } + final Charge charge = mapping.getCharge(); + if (charge.isDeleted() || !charge.isActive()) { + throw new GeneralPlatformDomainRuleException("error.msg.facility.charge.deleted", + "The charge mapped to the '" + facilityType + + "' facility has been deleted or deactivated. Update the mapping under Products > Facility Charge Mappings before enabling it.", + facilityType); + } + return charge; } private MonthDay resolveFeeOnMonthDay(final Charge charge) { diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingReadPlatformService.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingReadPlatformService.java new file mode 100644 index 000000000..d7e2794d2 --- /dev/null +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingReadPlatformService.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.service; + +import java.util.List; +import org.apache.fineract.portfolio.savings.data.FacilityChargeMappingData; + +public interface FacilityChargeMappingReadPlatformService { + + List retrieveAll(); + + FacilityChargeMappingData retrieveOne(Long id); + + /** All active charges, for the admin screen's "change the mapped charge" dropdown. */ + FacilityChargeMappingData retrieveTemplate(); +} diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingReadPlatformServiceImpl.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingReadPlatformServiceImpl.java new file mode 100644 index 000000000..5f868c671 --- /dev/null +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingReadPlatformServiceImpl.java @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.service; + +import java.util.Comparator; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.apache.fineract.portfolio.charge.domain.Charge; +import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; +import org.apache.fineract.portfolio.savings.data.FacilityChargeMappingData; +import org.apache.fineract.portfolio.savings.data.FacilityChargeMappingData.FacilityChargeOptionData; +import org.apache.fineract.portfolio.savings.domain.FacilityChargeMapping; +import org.apache.fineract.portfolio.savings.domain.FacilityChargeMappingRepository; +import org.apache.fineract.portfolio.savings.exception.FacilityChargeMappingNotFoundException; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class FacilityChargeMappingReadPlatformServiceImpl implements FacilityChargeMappingReadPlatformService { + + private final FacilityChargeMappingRepository facilityChargeMappingRepository; + private final ChargeReadPlatformService chargeReadPlatformService; + + @Override + public List retrieveAll() { + return facilityChargeMappingRepository.findAll().stream().sorted(Comparator.comparing(FacilityChargeMapping::getFacilityType)) + .map(this::toData).toList(); + } + + @Override + public FacilityChargeMappingData retrieveOne(final Long id) { + final FacilityChargeMapping mapping = facilityChargeMappingRepository.findById(id) + .orElseThrow(() -> new FacilityChargeMappingNotFoundException(id)); + return toData(mapping); + } + + @Override + public FacilityChargeMappingData retrieveTemplate() { + final FacilityChargeMappingData template = new FacilityChargeMappingData(); + template.setChargeOptions(chargeReadPlatformService.retrieveAllCharges().stream() + .map(charge -> new FacilityChargeOptionData(charge.getId(), charge.getName(), charge.getAmount())).toList()); + return template; + } + + private FacilityChargeMappingData toData(final FacilityChargeMapping mapping) { + final Charge charge = mapping.getCharge(); + final boolean chargeAvailable = charge == null || (!charge.isDeleted() && charge.isActive()); + // FacilityChargeAutoApplyService always charges charge.getAmount() (the charge's own, live amount) -- + // mapping.getDefaultAmount() is a separate, unrelated stored column that nothing in the actual charging + // path reads, so showing it here would silently drift from what an account is really charged the moment + // someone edits the charge itself. Show the charge's real amount instead; edits to it happen on the + // Charge (Products > Charges), not here. + // When no charge is mapped, mapping.getChargeName()/getDefaultAmount() are stale leftovers from the + // pre-seed migration -- report null so the screen shows the facility as genuinely unmapped, not as + // if a charge (with a name and amount) were already chosen. + final String chargeName = charge != null ? charge.getName() : null; + final java.math.BigDecimal amount = charge != null ? charge.getAmount() : null; + return new FacilityChargeMappingData(mapping.getId(), mapping.getFacilityType(), charge == null ? null : charge.getId(), + chargeName, amount, mapping.getChargeTimeType(), mapping.getChargeAppliesTo(), mapping.getIsActive(), + chargeAvailable); + } +} diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingWritePlatformService.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingWritePlatformService.java new file mode 100644 index 000000000..1a93d8e80 --- /dev/null +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingWritePlatformService.java @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.service; + +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; + +public interface FacilityChargeMappingWritePlatformService { + + CommandProcessingResult updateMapping(Long id, JsonCommand command); +} diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingWritePlatformServiceImpl.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingWritePlatformServiceImpl.java new file mode 100644 index 000000000..66471cef8 --- /dev/null +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeMappingWritePlatformServiceImpl.java @@ -0,0 +1,102 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.service; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import org.apache.fineract.infrastructure.core.api.JsonCommand; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; +import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; +import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException; +import org.apache.fineract.portfolio.charge.domain.Charge; +import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper; +import org.apache.fineract.portfolio.savings.domain.FacilityChargeMapping; +import org.apache.fineract.portfolio.savings.domain.FacilityChargeMappingRepository; +import org.apache.fineract.portfolio.savings.exception.FacilityChargeMappingNotFoundException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class FacilityChargeMappingWritePlatformServiceImpl implements FacilityChargeMappingWritePlatformService { + + private static final String CHARGE_ID_PARAM = "chargeId"; + private static final String IS_ACTIVE_PARAM = "isActive"; + + private final FacilityChargeMappingRepository facilityChargeMappingRepository; + private final ChargeRepositoryWrapper chargeRepositoryWrapper; + + @Transactional + @Override + public CommandProcessingResult updateMapping(final Long id, final JsonCommand command) { + final FacilityChargeMapping mapping = facilityChargeMappingRepository.findById(id) + .orElseThrow(() -> new FacilityChargeMappingNotFoundException(id)); + + final Map changes = new HashMap<>(); + + final Long existingChargeId = mapping.getCharge() == null ? null : mapping.getCharge().getId(); + if (command.isChangeInLongParameterNamed(CHARGE_ID_PARAM, existingChargeId)) { + final Long newChargeId = command.longValueOfParameterNamed(CHARGE_ID_PARAM); + final Charge charge = chargeRepositoryWrapper.findOneWithNotFoundDetection(newChargeId); + + // Each facility's charge must be its own: FacilityChargeAutoApplyService#applyIfEnabled dedups a + // newly-enabled facility's charge by matching an existing SavingsAccountCharge's charge NAME, so if + // two facilities shared the same charge, enabling the second one on an account that already has the + // first would be silently skipped as "already applied" -- under-charging the account by one facility + // worth of fee. Reject the mapping change here instead of letting that surface downstream. + final Optional conflict = facilityChargeMappingRepository.findAllByIsActiveTrue().stream() + .filter(other -> !other.getId().equals(mapping.getId())) // + .filter(other -> other.getCharge() != null && newChargeId.equals(other.getCharge().getId())) // + .findFirst(); + if (conflict.isPresent()) { + throw new GeneralPlatformDomainRuleException("error.msg.facility.charge.already.mapped", + "This charge is already mapped to the '" + conflict.get().getFacilityType() + + "' facility. Each charge can only be mapped to one facility, to avoid a shared charge being" + + " under-applied when both facilities are enabled on the same account.", + conflict.get().getFacilityType()); + } + + mapping.setCharge(charge); + mapping.setChargeName(charge.getName()); + // Keep the stored column in step with the charge actually being applied, even though nothing + // currently reads it directly (the read side reports charge.getAmount() live) -- avoids a future + // reader finding a stale value here. + mapping.setDefaultAmount(charge.getAmount()); + changes.put(CHARGE_ID_PARAM, newChargeId); + } + + if (command.isChangeInBooleanParameterNamed(IS_ACTIVE_PARAM, mapping.getIsActive())) { + final Boolean newIsActive = command.booleanObjectValueOfParameterNamed(IS_ACTIVE_PARAM); + mapping.setIsActive(newIsActive); + changes.put(IS_ACTIVE_PARAM, newIsActive); + } + + if (!changes.isEmpty()) { + facilityChargeMappingRepository.saveAndFlush(mapping); + } + + return new CommandProcessingResultBuilder() // + .withCommandId(command.commandId()) // + .withEntityId(id) // + .with(changes) // + .build(); + } +} diff --git a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeSeederService.java b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeSeederService.java index 92c8c30e6..6eed63afb 100644 --- a/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeSeederService.java +++ b/fineract-savings/src/main/java/org/apache/fineract/portfolio/savings/service/FacilityChargeSeederService.java @@ -29,11 +29,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; /** - * Seeds default facility charges on service startup via JDBC. - * For each facility type (ATM, UPI, NEFT etc.), ensures a charge exists in m_charge - * and a mapping exists in m_facility_charge_mapping. - * Bank staff can change amounts from the Charges admin screen later. - * Seeder only creates records that are missing — safe to run repeatedly. + * Seeds default facility charges on service startup via JDBC, one per facility type (ATM, UPI, + * NEFT etc.), so the Facility Charge Mappings admin screen has ready-made charges to choose from. + * Deliberately does NOT link a charge to its facility's m_facility_charge_mapping row or activate + * it — that mapping must be an explicit admin choice made through that screen (an unmapped facility + * is blocked from being enabled on an account by FacilityChargeAutoApplyService). Seeder only + * creates charges that are missing — safe to run repeatedly. */ @Service @RequiredArgsConstructor @@ -82,23 +83,13 @@ public class FacilityChargeSeederService { final int chargeTimeType = (int) def[2]; final int chargeAppliesTo = (int) def[3]; - // 1. Check if mapping row exists and already has a charge linked - List existingChargeId = jdbcTemplate.queryForList( - "SELECT charge_id FROM m_facility_charge_mapping WHERE facility_type = ? AND charge_id IS NOT NULL", - Long.class, facilityType); - - if (!existingChargeId.isEmpty()) { - continue; // Already seeded - } - - // 2. Check if charge with this name already exists in m_charge + // 1. Ensure a default charge exists in m_charge for this facility (creates it if missing) — + // purely so it's available as a ready-made option in the mapping screen's charge dropdown. List chargeIds = jdbcTemplate.queryForList( "SELECT id FROM m_charge WHERE name = ? AND is_deleted = false LIMIT 1", Long.class, chargeName); - Long chargeId; if (chargeIds.isEmpty()) { - // 3. Insert charge into m_charge jdbcTemplate.update( "INSERT INTO m_charge (name, currency_code, amount, charge_applies_to_enum, " + "charge_time_enum, charge_calculation_enum, is_penalty, is_active, is_deleted, " @@ -106,29 +97,24 @@ public class FacilityChargeSeederService { + "VALUES (?, 'INR', ?, ?, ?, true, false, true, false, false, false, ?)", chargeName, amount, chargeAppliesTo, chargeTimeType, incomeGlAccountId); - chargeId = jdbcTemplate.queryForObject( - "SELECT id FROM m_charge WHERE name = ? AND is_deleted = false ORDER BY id DESC LIMIT 1", - Long.class, chargeName); - - log.info("FacilityChargeSeeder: inserted charge '{}' id={}", chargeName, chargeId); - } else { - chargeId = chargeIds.get(0); + log.info("FacilityChargeSeeder: inserted charge '{}'", chargeName); } - // 4. Update or insert mapping row - int updated = jdbcTemplate.update( - "UPDATE m_facility_charge_mapping SET charge_id = ? WHERE facility_type = ?", - chargeId, facilityType); + // 2. Ensure the facility_charge_mapping row itself exists so the admin screen lists every + // facility type, but leave it unmapped/inactive — an admin must explicitly pick a charge + // for it via the Facility Charge Mappings screen before it can be enabled on an account. + List existingMapping = jdbcTemplate.queryForList( + "SELECT id FROM m_facility_charge_mapping WHERE facility_type = ?", Long.class, facilityType); - if (updated == 0) { + if (existingMapping.isEmpty()) { jdbcTemplate.update( "INSERT INTO m_facility_charge_mapping " + "(facility_type, charge_id, charge_name, default_amount, charge_time_type, charge_applies_to, is_active) " - + "VALUES (?, ?, ?, ?, ?, ?, 1)", - facilityType, chargeId, chargeName, amount, chargeTimeType, chargeAppliesTo); - } + + "VALUES (?, NULL, ?, ?, ?, ?, false)", + facilityType, chargeName, amount, chargeTimeType, chargeAppliesTo); - log.info("FacilityChargeSeeder: mapped facility '{}' → charge id={}", facilityType, chargeId); + log.info("FacilityChargeSeeder: added unmapped facility row '{}'", facilityType); + } } log.info("FacilityChargeSeeder: seeding complete.");