Merge pull request #1079 from vorburger/SpringBootAndMariaDB4j

MIFOSX-1552 Spring Boot + MariaDB4j
This commit is contained in:
Vishwas Babu A J
2014-09-24 21:06:48 -07:00
247 changed files with 1827 additions and 967 deletions
@@ -23,6 +23,11 @@ import com.jayway.restassured.path.json.JsonPath;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
/**
* Util for RestAssured tests.
* This class here in src/integrationTest is copy/pasted to src/test; please keep them in sync.
*/
@SuppressWarnings("unchecked")
public class Utils {
@@ -33,7 +38,7 @@ public class Utils {
public static void initializeRESTAssured() {
RestAssured.baseURI = "https://localhost";
RestAssured.port = 8443;
RestAssured.keystore("../keystore.jks", "openmf");
RestAssured.keystore("src/main/resources/keystore.jks", "openmf");
}
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
@@ -0,0 +1,43 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform;
import org.mifosplatform.infrastructure.core.boot.AbstractApplicationConfiguration;
import org.mifosplatform.infrastructure.core.boot.ApplicationExitUtil;
import org.mifosplatform.infrastructure.core.boot.EmbeddedTomcatWithSSLConfiguration;
import org.mifosplatform.infrastructure.core.boot.db.DataSourceConfiguration;
import org.mifosplatform.infrastructure.core.boot.db.DataSourceProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;
/**
* Mifos main() application which launches Mifos X in an embedded Tomcat HTTP
* (using Spring Boot).
*
* The DataSource used is a to a "normal" external database (not use MariaDB4j).
* This DataSource can be configured with parameters, see {@link DataSourceProperties}.
*
* You can easily launch this via Debug as Java Application in your IDE -
* without needing command line Gradle stuff, no need to build and deploy a WAR,
* remote attachment etc.
*
* It's the old/classic Mifos (non-X) Workspace 2.0 reborn for Mifos X! ;-)
*
* @see DataSourceProperties about how to configure the DataSource used
* @see ServerWithMariaDB4jApplication for an alternative with an embedded DB
*/
public class ServerApplication {
@Import({ DataSourceConfiguration.class, EmbeddedTomcatWithSSLConfiguration.class })
private static class Configuration extends AbstractApplicationConfiguration { }
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext ctx = SpringApplication.run(Configuration.class, args);
ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx);
}
}
@@ -0,0 +1,39 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform;
import org.mifosplatform.infrastructure.core.boot.AbstractApplicationConfiguration;
import org.mifosplatform.infrastructure.core.boot.ApplicationExitUtil;
import org.mifosplatform.infrastructure.core.boot.EmbeddedTomcatWithSSLConfiguration;
import org.mifosplatform.infrastructure.core.boot.db.MariaDB4jDataSourceConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;
/**
* Mifos main() application which launches Mifos X in an embedded Tomcat HTTP
* server (using Spring Boot), as well as an embedded database (using
* MariaDB4j).
*
* You can easily launch this via Debug as Java Application in your IDE -
* without needing command line Gradle stuff, no need to build and deploy a WAR,
* remote attachment etc.
*
* It's the old/classic Mifos (non-X) Workspace 2.0 reborn for Mifos X! ;-)
*
* @see ServerApplication for the same without the embedded MariaDB4j database
*/
public class ServerWithMariaDB4jApplication {
@Import({ MariaDB4jDataSourceConfiguration.class, EmbeddedTomcatWithSSLConfiguration.class })
public static class Configuration extends AbstractApplicationConfiguration { }
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext ctx = SpringApplication.run(Configuration.class, args);
ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx);
}
}
@@ -0,0 +1,37 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
/**
* Base Spring Configuration with what's common to all Configuration subclasses.
*
* Notably the EnableAutoConfiguration excludes relevant for (and often adjusted
* when upgrading versions of) Spring Boot, the "old" (pre. Spring Boot &
* MariaDB4j) Mifos X appContext.xml which all configurations need, and the
* web.xml successor WebXmlConfiguration.
*
* Should NOT include Configuration related to embedded Tomcat, data sources,
* and MariaDB4j (because those differ in the subclasses).
*/
@Configuration
@Import({ WebXmlConfiguration.class })
@ImportResource({ "classpath*:META-INF/spring/appContext.xml" })
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
FlywayAutoConfiguration.class })
public abstract class AbstractApplicationConfiguration {
}
@@ -0,0 +1,33 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.springframework.context.ConfigurableApplicationContext;
public abstract class ApplicationExitUtil {
private ApplicationExitUtil() {}
public static void waitForKeyPressToCleanlyExit(ConfigurableApplicationContext ctx) throws IOException {
// NOTE: In Eclipse, the Shutdown Hooks are not invoked on exit (red
// button).. In the case of MariaDB4j that's a problem because then the
// mysqld won't be stopped, so:
// (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=38016)
System.out.println("\nHit Enter to quit...");
// NOTE: In Eclipse, System.console() is not available.. so:
// (@see https://bugs.eclipse.org/bugs/show_bug.cgi?id=122429)
BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
d.readLine();
ctx.stop();
ctx.close();
}
}
@@ -0,0 +1,104 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import org.apache.catalina.connector.Connector;
import org.apache.commons.io.FileUtils;
import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
@Configuration
public class EmbeddedTomcatWithSSLConfiguration {
// http://docs.spring.io/spring-boot/docs/1.1.5.RELEASE/reference/htmlsingle/#howto-enable-multiple-connectors-in-tomcat
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
tomcat.setContextPath(getContextPath());
tomcat.addAdditionalTomcatConnectors(createSslConnector());
return tomcat;
}
private String getContextPath() {
return "/mifosng-provider";
}
protected Connector createSslConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
try {
File keystore = getFile(getKeystore());
File truststore = keystore;
connector.setScheme("https");
connector.setSecure(true);
connector.setPort(getHTTPSPort());
protocol.setSSLEnabled(true);
protocol.setKeystoreFile(keystore.getAbsolutePath());
protocol.setKeystorePass(getKeystorePass());
protocol.setTruststoreFile(truststore.getAbsolutePath());
protocol.setTruststorePass(getKeystorePass());
// ? protocol.setKeyAlias("apitester");
return connector;
} catch (IOException ex) {
throw new IllegalStateException("can't access keystore: [" + "keystore" + "] or truststore: [" + "keystore" + "]", ex);
}
}
protected int getHTTPSPort() {
// TODO This shouldn't be hard-coded here, but configurable
return 8443;
}
protected String getKeystorePass() {
return "openmf";
}
protected Resource getKeystore() {
return new ClassPathResource("/keystore.jks");
}
public File getFile(Resource resource) throws IOException {
try {
return resource.getFile();
} catch (IOException e) {
// Uops.. OK, try again (below)
}
try {
URL url = resource.getURL();
// If this creates filenames that are too long on Win,
// then could just use resource.getFilename(),
// even though not unique, real risk prob. min.bon
String tempDir = System.getProperty("java.io.tmpdir");
tempDir = tempDir + "/" + getClass().getSimpleName() + "/";
String path = url.getPath();
String uniqName = path.replace("file:/", "").replace('!', '_');
String tempFullPath = tempDir + uniqName;
// instead of File.createTempFile(prefix?, suffix?);
File targetFile = new File(tempFullPath);
long len = resource.contentLength();
if (!targetFile.exists() || targetFile.length() != len) { // Only copy new files
FileUtils.copyURLToFile(url, targetFile);
}
return targetFile;
} catch (IOException e) {
// Uops.. erm, give up:
throw new IOException("Cannot obtain a File for Resource: "
+ resource.toString(), e);
}
}
}
@@ -0,0 +1,40 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ImportResource;
/**
* Required to still have a working legacy "classic" WAR.
*
* Configuration just adds the JNDI-based DataSource lookup to its
* AbstractApplicationConfiguration.
*
* This (intentionally) only configures the original (pre-Spring Boot &
* MariaDB4j) Mifos X Spring Beans, and does NOT include the embedded Tomcat
* (incl. TomcatSSLConfiguration) nor the MariaDB4jSetupService or
* MariaDB4jDataSourceConfiguration, and not even the DataSourceConfiguration
* (as it uses "classic" JNDI) - we want the WAR to "work like before".
*
* @see <a
* href="http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-convert-an-existing-application-to-spring-boot">#howto-convert-an-existing-application-to-spring-boot</a>
*/
public class WarWebApplicationInitializer extends SpringBootServletInitializer {
@ImportResource({ "classpath*:META-INF/spring/jndi.xml" })
private static class Configuration extends AbstractApplicationConfiguration {
}
@Override
protected SpringApplicationBuilder configure(
SpringApplicationBuilder application) {
// let's share Spring Boot Love, so no showBanner(false)
return application.sources(Configuration.class);
}
}
@@ -0,0 +1,50 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot;
import javax.servlet.Filter;
import javax.servlet.Servlet;
import org.mifosplatform.infrastructure.core.filters.ResponseCorsFilter;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.DelegatingFilterProxy;
import com.sun.jersey.spi.spring.container.servlet.SpringServlet;
/**
* This Configuration replaces what formerly was in web.xml.
*
* @see <a
* href="http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-convert-an-existing-application-to-spring-boot">#howto-convert-an-existing-application-to-spring-boot</a>
*/
@Configuration
public class WebXmlConfiguration {
@Bean
public Filter springSecurityFilterChain() {
return new DelegatingFilterProxy();
}
@Bean
public ServletRegistrationBean jersey() {
Servlet jerseyServlet = new SpringServlet();
ServletRegistrationBean jerseyServletRegistration = new ServletRegistrationBean();
jerseyServletRegistration.setServlet(jerseyServlet);
jerseyServletRegistration.addUrlMappings("/api/v1/*");
jerseyServletRegistration.setName("jersey-servlet");
jerseyServletRegistration.setLoadOnStartup(1);
jerseyServletRegistration.addInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
jerseyServletRegistration.addInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters",
ResponseCorsFilter.class.getName());
// debugging for development:
// jerseyServletRegistration.addInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters",
// LoggingFilter.class.getName());
return jerseyServletRegistration;
}
}
@@ -0,0 +1,41 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot.db;
import javax.sql.DataSource;
import org.apache.tomcat.jdbc.pool.PoolConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Configuration for a DataSource.
* @see DataSourceProperties about how to configure this DS
*/
@Configuration
public class DataSourceConfiguration {
private static final Logger logger = LoggerFactory.getLogger(DataSourceConfiguration.class);
@Bean
public DataSourceProperties dataSourceProperties() {
return new DataSourceProperties();
}
@Bean
public DataSource tenantDataSourceJndi() {
PoolConfiguration p = getProperties();
org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(p);
logger.info("Created new DataSource; url=" + p.getUrl());
return ds;
}
protected DataSourceProperties getProperties() {
return dataSourceProperties();
}
}
@@ -0,0 +1,146 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot.db;
import javax.validation.constraints.NotNull;
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
/**
* Configurable DataSource. Properties have sensible defaults, but end-users can
* override those via the Spring Values listed below; i.e. via -D Java System
* properties, or main() command line arguments, OS environment variables, from
* JNDI, or application.properties (thanks Spring Boot). For example:
* -Dmifos.datasource.port=3307.
*/
// NOT a @Component - we do not want this to picked up by component scan, only explicitly declared in DataSourceConfiguration (if that's active)
public class DataSourceProperties extends PoolProperties {
public final static String PORT = "mifos.datasource.port";
public final static String HOST = "mifos.datasource.host";
public final static String DB = "mifos.datasource.db";
public final static String UID = "mifos.datasource.username";
public final static String PWD = "mifos.datasource.password";
public final static String PROTOCOL = "mifos.datasource.protocol";
public final static String SUBPROTOCOL = "mifos.datasource.subprotocol";
@Value("${" + PORT + ":3306}")
private volatile @NotNull int port;
@Value("${" + HOST + ":localhost}")
private volatile @NotNull String hostname;
@Value("${" + DB + ":mifosplatform-tenants}")
private volatile @NotNull String dbName;
@Value("${" + UID + ":root}")
private volatile @NotNull String username;
@Value("${" + PWD + ":mysql}")
private volatile @NotNull String password;
@Value("${" + PROTOCOL + ":jdbc}")
private volatile @NotNull String jdbcProtocol;
@Value("${" + SUBPROTOCOL + ":mysql}")
private volatile @NotNull String jdbcSubprotocol;
public DataSourceProperties() {
super();
// default to save us from re-specifying this; note that it can still be
// overridden
setDriverClassName(com.mysql.jdbc.Driver.class.getName());
setMifosDefaults();
}
/**
* as per (some of..) INSTALL.md and
* org.mifosplatform.infrastructure.core.service
* .TomcatJdbcDataSourcePerTenantService
* .createNewDataSourceFor(MifosPlatformTenant)
*/
protected void setMifosDefaults() {
setInitialSize(3);
// setMaxIdle(6); -- strange, why?
// setMinIdle(3); -- JavaDoc says default is initialSize.. so shouldn't
// be needed
if (getValidationQuery() == null) setValidationQuery("SELECT 1");
setTestOnBorrow(true);
setTestOnReturn(true);
setTestWhileIdle(true);
setTimeBetweenEvictionRunsMillis(30000);
setTimeBetweenEvictionRunsMillis(60000);
setLogAbandoned(true);
setSuspectTimeout(60);
setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport");
}
@Override
public void setUrl(@SuppressWarnings("unused") String url) {
throw new UnsupportedOperationException("Use setHost/Port/DB() instead of setURL()");
}
@Override
public String getUrl() {
String url = super.getUrl();
if (StringUtils.hasText(url)) {
throw new IllegalStateException();
}
return jdbcProtocol + ":" + jdbcSubprotocol + "://" + getHost() + ":" + getPort() + "/" + getDBName();
}
public String getHost() {
return hostname;
}
public int getPort() {
return port;
}
public String getDBName() {
return dbName;
}
public void setPort(int port) {
this.port = port;
}
public void setHost(String hostname) {
this.hostname = hostname;
}
public void setDBName(String dbName) {
this.dbName = dbName;
}
@Override
public String getUsername() {
return this.username;
}
@Override
public void setUsername(String username) {
this.username = username;
}
@Override
public String getPassword() {
return this.password;
}
@Override
public void setPassword(String password) {
this.password = password;
}
}
@@ -0,0 +1,49 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot.db;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
@Configuration
public class MariaDB4jDataSourceConfiguration extends DataSourceConfiguration {
@Bean
public MariaDB4jSetupService mariaDB4jSetUp() {
return new MariaDB4jSetupService(mariaDB4j().getDB());
}
@Bean
public MariaDB4jSpringService mariaDB4j() {
MariaDB4jSpringService mariaDB4jSpringService = new MariaDB4jSpringService();
mariaDB4jSpringService.setDefaultBaseDir("build/db/bin");
mariaDB4jSpringService.setDefaultDataDir("build/db/data");
return mariaDB4jSpringService;
}
@Override
// NOT @Bean @Override dataSourceProperties() - doesn't work :(
protected DataSourceProperties getProperties() {
DataSourceProperties p = super.getProperties();
String dbName = mariaDB4jSetUp().getTenantDBName();
// Do not use p.setUrl(mariaDB4j().getConfiguration().getURL(dbName));
// Because TenantDataSourcePortFixService needs separate
// host/port/db/uid/pwd:
// (DataSourceProperties getUrl() creates the correct JDBC URL from it)
// This intentionally overrides any mifos.datasource.* settings, because
// in this configuration, logically the mariaDB4j settings take
// precedence:
p.setHost("localhost");
p.setPort(mariaDB4j().getConfiguration().getPort());
p.setDBName(dbName);
// TODO p.setUsername(mariaDB4j().getConfiguration().getUsername());
// TODO p.setPassword(mariaDB4j().getConfiguration().getPassword());
return p;
}
}
@@ -0,0 +1,41 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot.db;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.springframework.beans.factory.annotation.Autowired;
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DB;
public class MariaDB4jSetupService {
private DB db;
@Autowired
public MariaDB4jSetupService(DB db) {
this.db = db;
}
@PostConstruct
protected void setUpMifosDBs() throws ManagedProcessException {
db.createDB(getTenantDBName());
db.createDB("mifostenant-default");
// Note that we don't need to initialize the DBs, because
// the TenantDatabaseUpgradeService will do this in just a moment.
}
public String getTenantDBName() {
return "mifosplatform-tenants";
}
@PreDestroy
protected void stop() throws ManagedProcessException {
db = null;
}
}
@@ -0,0 +1,83 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.mifosplatform.infrastructure.core.boot.db;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
/**
* Service which "fixes up" the schemaServerPort in the tenants table of the
* mifosplatform-tenants schema. It sets it to the actual current port of
* MariaDB4j, instead of the default 3306 which is hard-coded in the initial
* set-up SQL script (V1__mifos-platform-shared-tenants.sql).
*
* This service is called by the TenantDatabaseUpgradeService
* "just at the right time" during start-up, that is AFTER the initialization of
* the mifosplatform-tenants but BEFORE Flyway runs on all tenant schemas.
*
* It's difficult to achieve the same goal elsewhere, because we cannot do this
* e.g. in MariaDB4jSetupService, as that's too early
* (TenantDatabaseUpgradeService has not yet run), nor e.g. in
* TomcatJdbcDataSourcePerTenantService because in there we do not have access
* to and should not depend on MariaDB4j configuration.
*/
@Service
public class TenantDataSourcePortFixService {
private static final Logger logger = LoggerFactory.getLogger(TenantDataSourcePortFixService.class);
/**
* While what this class does is convenient in 96% you may would like to
* completely disable it if you've hand tuned your tenants table for an
* advanced configuration and use e.g. different databases maybe on
* different hosts for different tenants.
*/
public final static String ENABLED = "mifos.tenantdb.fixup";
@Value("${" + ENABLED + ":true}")
private boolean enabled;
// required=false is important here, because in
// WebApplicationInitializerConfiguration for classic WAR there
// is (intentionally) no MariaDB4j nor a DataSourceProperties
// bean (because in the WAR we're using a DS from JNDI)
private @Autowired(required = false) DataSourceProperties dsp;
private JdbcTemplate jdbcTemplate;
@Autowired
public TenantDataSourcePortFixService(@Qualifier("tenantDataSourceJndi") final DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
public void fixUpTenantsSchemaServerPort() {
if (!enabled) {
logger.info("No schema_server_port UPDATE made to tenants table of the mifosplatform-tenants schema, because " + ENABLED + " = false");
return;
}
if (dsp == null) {
// we don't have any generic mechanism to know the DB port, given just a tenant DataSource
logger.debug("No schema_server_port UPDATE made to tenants table of the mifosplatform-tenants schema (because neither MariaDB4j nor our own Spring Boot DataSourceConfiguration is used in a traditional WAR)");
return;
}
int r = jdbcTemplate
.update("UPDATE tenants SET schema_server = ?, schema_server_port = ?, schema_username = ?, schema_password = ?",
dsp.getHost(), dsp.getPort(), dsp.getUsername(), dsp.getPassword());
if ( r == 0 )
logger.warn("UPDATE tenants SET ... did not update ANY rows - something is probably wrong");
else
logger.info("Upated "
+ r
+ " rows in the tenants table of the mifosplatform-tenants schema to the real current host: "
+ dsp.getHost() + ", port: " + dsp.getPort());
}
}
@@ -12,18 +12,22 @@ import java.util.Enumeration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.stereotype.Service;
import com.mysql.jdbc.AbandonedConnectionCleanupThread;
@Service
public class AbandonedConnectionCleanupShutdownListener implements ApplicationListener<ContextStoppedEvent> {
public class AbandonedConnectionCleanupShutdownListener implements ApplicationListener<ContextClosedEvent> {
private final static Logger logger = LoggerFactory.getLogger(AbandonedConnectionCleanupShutdownListener.class);
/**
* @see JobRegisterServiceImpl#onApplicationEvent(ContextClosedEvent) doc
* re. why we use ContextClosedEvent instead of ContextStoppedEvent
*/
@Override
public void onApplicationEvent(@SuppressWarnings("unused") ContextStoppedEvent event) {
public void onApplicationEvent(@SuppressWarnings("unused") ContextClosedEvent event) {
shutDowncleanUpThreadAndDeregisterJDBCDriver();
}
@@ -8,13 +8,17 @@ package org.mifosplatform.infrastructure.core.service;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import org.mifosplatform.infrastructure.core.boot.db.TenantDataSourcePortFixService;
import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant;
import org.mifosplatform.infrastructure.security.service.TenantDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.googlecode.flyway.core.Flyway;
import com.googlecode.flyway.core.api.FlywayException;
/**
* A service that picks up on tenants that are configured to auto-update their
@@ -24,23 +28,52 @@ import com.googlecode.flyway.core.Flyway;
public class TenantDatabaseUpgradeService {
private final TenantDetailsService tenantDetailsService;
protected final DataSource tenantDataSource;
protected final TenantDataSourcePortFixService tenantDataSourcePortFixService;
@Autowired
public TenantDatabaseUpgradeService(final TenantDetailsService detailsService) {
public TenantDatabaseUpgradeService(
final TenantDetailsService detailsService,
@Qualifier("tenantDataSourceJndi") final DataSource dataSource,
TenantDataSourcePortFixService tenantDataSourcePortFixService)
{
this.tenantDetailsService = detailsService;
this.tenantDataSource = dataSource;
this.tenantDataSourcePortFixService = tenantDataSourcePortFixService;
}
@PostConstruct
public void upgradeAllTenants() {
upgradeTenantDB();
final List<MifosPlatformTenant> tenants = this.tenantDetailsService.findAllTenants();
for (final MifosPlatformTenant tenant : tenants) {
if (tenant.isAutoUpdateEnabled()) {
final Flyway flyway = new Flyway();
flyway.setDataSource(tenant.databaseURL(), tenant.getSchemaUsername(), tenant.getSchemaPassword());
flyway.setLocations("sql");
flyway.setLocations("sql/migrations/core_db");
flyway.setOutOfOrder(true);
flyway.migrate();
try {
flyway.migrate();
} catch (FlywayException e) {
String betterMessage = e.getMessage()
+ "; for Tenant DB URL: " + tenant.databaseURL()
+ ", username: " + tenant.getSchemaUsername();
throw new FlywayException(betterMessage, e.getCause());
}
}
}
}
/**
* Initializes, and if required upgrades (using Flyway) the Tenant DB itself.
*/
private void upgradeTenantDB() {
final Flyway flyway = new Flyway();
flyway.setDataSource(tenantDataSource);
flyway.setLocations("sql/migrations/list_db");
flyway.setOutOfOrder(true);
flyway.migrate();
tenantDataSourcePortFixService.fixUpTenantsSchemaServerPort();
}
}
@@ -64,6 +64,8 @@ public class TomcatJdbcDataSourcePerTenantService implements RoutingDataSourceSe
// see
// http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency
// see also org.mifosplatform.DataSourceProperties.setMifosDefaults()
final String jdbcUrl = tenant.databaseURL();
final PoolConfiguration poolConfiguration = new PoolProperties();
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
@@ -48,7 +48,7 @@ import org.springframework.stereotype.Service;
* {@link CronTriggerFactoryBean}
*/
@Service
public class JobRegisterServiceImpl implements JobRegisterService, ApplicationListener<ContextStoppedEvent> {
public class JobRegisterServiceImpl implements JobRegisterService, ApplicationListener<ContextClosedEvent> {
private final static Logger logger = LoggerFactory.getLogger(JobRegisterServiceImpl.class);
@@ -230,8 +230,14 @@ public class JobRegisterServiceImpl implements JobRegisterService, ApplicationLi
return !this.schedularWritePlatformService.retriveSchedulerDetail().isSuspended();
}
/**
* Need to use ContextClosedEvent instead of ContextStoppedEvent because in
* case Spring Boot fails to start-up (e.g. because Tomcat port is already
* in use) then org.springframework.boot.SpringApplication.run(String...)
* does a context.close(); and not a context.stop();
*/
@Override
public void onApplicationEvent(@SuppressWarnings("unused") ContextStoppedEvent event) {
public void onApplicationEvent(@SuppressWarnings("unused") ContextClosedEvent event) {
this.stopAllSchedulers();
}
@@ -28,14 +28,12 @@ public class PlatformRequestLog {
@SuppressWarnings("unused")
private final String url;
@SuppressWarnings("unused")
private final Map<String, String> parameters;
private final Map<String, String[]> parameters;
public static PlatformRequestLog from(final StopWatch task, final HttpServletRequest request) throws IOException {
final String requestUrl = request.getRequestURL().toString();
@SuppressWarnings("unchecked")
final Map<String, String> parameters = new HashMap<>(request.getParameterMap());
final Map<String, String[]> parameters = new HashMap<>(request.getParameterMap());
parameters.remove("password");
parameters.remove("_");
@@ -43,7 +41,7 @@ public class PlatformRequestLog {
}
private PlatformRequestLog(final long startTime, final long time, final String method, final String requestUrl,
final Map<String, String> parameters) {
final Map<String, String[]> parameters) {
this.startTime = startTime;
this.totalTime = time;
this.method = method;
@@ -45,6 +45,13 @@
org.mifosplatform.batch">
<context:exclude-filter expression="org.springframework.stereotype.Controller"
type="annotation" />
<!-- We do NOT want all @Configuration "beans" to be auto-detected by ComponentScan,
but we want to use / import them explicitly in Tests & Spring Boot applications,
or other import in other @Configuration, so that we could have mutually exclusive ones.
-->
<context:exclude-filter expression="org.springframework.context.annotation.Configuration"
type="annotation" />
</context:component-scan>
<bean id="auditorAware"
@@ -63,9 +70,8 @@
<import resource="infrastructure.xml" />
<!-- do NOT <import resource="jndi.xml" /> here;
because we want the TestDataSourceConfiguration to not have that;
we'll manually list jndi.xml in web.xml
<!-- do NOT <import resource="jndi.xml" /> here anymore;
we'll manually import jndi.xml where we still need it (MifosServletWebApplicationInitializerConfiguration)
-->
<import resource="securityContext.xml" />
Binary file not shown.
@@ -0,0 +1 @@
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('GroupSavingSummary', 'Table', NULL, NULL, 'select ifnull(cur.display_symbol, sa.currency_code) as currency,\ncount(sa.id) as totalSavingAccounts, ifnull(sum(sa.account_balance_derived),0) as totalSavings\nfrom m_group topgroup\njoin m_office o on o.id = topgroup.office_id and o.hierarchy like concat(\'${currentUserHierarchy}\', \'%\')\njoin m_group g on g.hierarchy like concat(topgroup.hierarchy, \'%\')\njoin m_savings_account sa on sa.group_id = g.id\nleft join m_currency cur on cur.code = sa.currency_code\nwhere topgroup.id = ${groupId}\nand sa.activatedon_date is not null\ngroup by sa.currency_code', 'Utility query for getting group or center saving summary details for a group_id', 1, 0);
@@ -0,0 +1,2 @@
ALTER TABLE `m_savings_account_transfer`
ADD COLUMN `currency_multiplesof` SMALLINT(5) NULL DEFAULT NULL AFTER `currency_digits`;
@@ -0,0 +1,30 @@
CREATE TABLE `m_meeting` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`calendar_instance_id` BIGINT(20) NOT NULL,
`meeting_date` DATE NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `unique_calendar_instance_id_meeting_date` (`calendar_instance_id`, `meeting_date`),
CONSTRAINT `FK_m_calendar_instance_m_meeting` FOREIGN KEY (`calendar_instance_id`) REFERENCES `m_calendar_instance` (`id`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB;
CREATE TABLE `m_client_attendance` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`client_id` BIGINT(20) NOT NULL DEFAULT '0',
`meeting_id` BIGINT(20) NOT NULL,
`attendance_type_enum` SMALLINT(5) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `unique_client_meeting_attendance` (`client_id`, `meeting_id`),
INDEX `FK_m_meeting_m_client_attendance` (`meeting_id`),
CONSTRAINT `FK_m_client_m_client_attendance` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
CONSTRAINT `FK_m_meeting_m_client_attendance` FOREIGN KEY (`meeting_id`) REFERENCES `m_meeting` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'CREATE_MEETING', 'MEETING', 'CREATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'UPDATE_MEETING', 'MEETING', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'DELETE_MEETING', 'MEETING', 'DELETE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'SAVEORUPDATEATTENDANCE_MEETING', 'MEETING', 'SAVEORUPDATEATTENDANCE', 0);
@@ -0,0 +1,14 @@
ALTER TABLE `job`
ADD COLUMN `is_misfired` TINYINT(1) NOT NULL DEFAULT '0' AFTER `scheduler_group`;
CREATE TABLE `scheduler_detail` (
`id` SMALLINT(2) NOT NULL AUTO_INCREMENT,
`is_suspended` TINYINT(1) NOT NULL DEFAULT '0',
`execute_misfired_jobs` TINYINT(1) NOT NULL DEFAULT '1',
`reset_scheduler_on_bootup` TINYINT(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
INSERT INTO `scheduler_detail` (`is_suspended`, `execute_misfired_jobs`, `reset_scheduler_on_bootup`) VALUES (FALSE,TRUE,TRUE);
@@ -0,0 +1,11 @@
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio_group', 'TRANSFERCLIENTS_GROUP', 'GROUP', 'TRANSFERCLIENTS', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio_group', 'TRANSFERCLIENTS_GROUP_CHECKER', 'GROUP', 'TRANSFERCLIENTS', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'TRANSFER_CLIENT', 'CLIENT', 'TRANSFER', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'TRANSFER_CLIENT_CHECKER', 'CLIENT', 'TRANSFER', 0);
@@ -0,0 +1,15 @@
ALTER TABLE `m_loan_transaction`
ADD COLUMN `office_id` BIGINT(20) NULL DEFAULT NULL AFTER `loan_id`;
/**update client loans**/
UPDATE m_loan_transaction lt set lt.office_id = (SELECT c.office_id AS officeId FROM m_loan l JOIN m_client c on l.client_id=c.id where l.id=lt.loan_id) where lt.loan_id in (Select l.id from m_loan l where l.client_id is not null);
/**update group loans**/
UPDATE m_loan_transaction lt set lt.office_id = (SELECT g.office_id AS officeId FROM m_loan l JOIN m_group g on l.group_id=g.id where l.id=lt.loan_id) where lt.loan_id in (Select l.id from m_loan l where l.group_id is not null);
/**Add foreign key constraints**/
ALTER TABLE `m_loan_transaction`
CHANGE COLUMN `office_id` `office_id` BIGINT(20) NOT NULL AFTER `loan_id`;
ALTER TABLE `m_loan_transaction`
ADD CONSTRAINT `FK_m_loan_transaction_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`);
@@ -0,0 +1,30 @@
DELETE FROM `m_permission` WHERE `code`="TRANSFER_CLIENT";
DELETE FROM `m_permission` WHERE `code`="TRANSFER_CLIENT_CHECKER";
/**Permissions for proposing a transfer**/
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'PROPOSETRANSFER_CLIENT', 'CLIENT', 'PROPOSETRANSFER', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'PROPOSETRANSFER_CLIENT_CHECKER', 'CLIENT', 'PROPOSETRANSFER', 0);
/**Permissions for accepting a transfer**/
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'ACCEPTTRANSFER_CLIENT', 'CLIENT', 'ACCEPTTRANSFER', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'ACCEPTTRANSFER_CLIENT_CHECKER', 'CLIENT', 'ACCEPTTRANSFER', 0);
/**Permissions for rejecting a transfer**/
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'REJECTTRANSFER_CLIENT', 'CLIENT', 'REJECTTRANSFER', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'REJECTTRANSFER_CLIENT_CHECKER', 'CLIENT', 'REJECTTRANSFER', 0);
/**Permissions for withdrawing a transfer proposal**/
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'WITHDRAWTRANSFER_CLIENT', 'CLIENT', 'WITHDRAWTRANSFER', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'WITHDRAWTRANSFER_CLIENT_CHECKER', 'CLIENT', 'WITHDRAWTRANSFER', 0);
@@ -0,0 +1,11 @@
CREATE TABLE `x_table_cloumn_code_mappings` (
`column_alias_name` VARCHAR(50) NOT NULL,
`code_id` INT(10) NOT NULL,
PRIMARY KEY (`column_alias_name`),
INDEX `FK_x_code_id` (`code_id`),
CONSTRAINT `FK_x_code_id` FOREIGN KEY (`code_id`) REFERENCES `m_code` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
INSERT INTO `c_configuration` (`name`, `enabled`) VALUES ('constraint_approach_for_datatables', 1);
@@ -0,0 +1,9 @@
/***Store destination office Id while client is pending transfers and effective joining date in a particular branch**/
ALTER TABLE `m_client`
ADD COLUMN `office_joining_date` DATE NULL AFTER `activation_date`,
ADD COLUMN `transfer_to_office_id` BIGINT(20) NULL AFTER `office_id`,
ADD CONSTRAINT `FK_m_client_m_office` FOREIGN KEY (`transfer_to_office_id`) REFERENCES `m_office` (`id`);
/**For current Clients, set the office joining date to activation date**/
update m_client set office_joining_date=activation_date;
@@ -0,0 +1,5 @@
ALTER TABLE `m_savings_product`
ADD COLUMN `withdrawal_fee_for_transfer` TINYINT NULL DEFAULT '1' AFTER `withdrawal_fee_type_enum`;
ALTER TABLE `m_savings_account`
ADD COLUMN `withdrawal_fee_for_transfer` TINYINT NULL DEFAULT '1' AFTER `withdrawal_fee_type_enum`;
@@ -0,0 +1,12 @@
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES
('transaction_savings', 'POSTINTEREST_SAVINGSACCOUNT', 'SAVINGSACCOUNT', 'POSTINTEREST', '1'),
('transaction_savings', 'POSTINTEREST_SAVINGSACCOUNT_CHECKER', 'SAVINGSACCOUNT', 'POSTINTEREST', '0');
ALTER TABLE `m_savings_product`
ADD COLUMN `interest_posting_period_enum` SMALLINT(5) NOT NULL DEFAULT 4 AFTER `interest_compounding_period_enum`;
ALTER TABLE `m_savings_account`
ADD COLUMN `interest_posting_period_enum` SMALLINT(5) NOT NULL DEFAULT 4 AFTER `interest_compounding_period_enum`;
@@ -0,0 +1,8 @@
INSERT INTO `m_code` (`code_name`, `is_system_defined`) VALUES ('GroupClosureReason', 1);
ALTER TABLE `m_group` ADD COLUMN `closure_reason_cv_id` INT(11) NULL DEFAULT NULL,
ADD COLUMN `closedon_date` DATE NULL DEFAULT NULL,
ADD CONSTRAINT `FK_m_group_m_code` FOREIGN KEY (`closure_reason_cv_id`) REFERENCES `m_code_value` (`id`);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`) VALUES ('portfolio', 'CLOSE_GROUP', 'GROUP', 'CLOSE');
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`) VALUES ('portfolio', 'CLOSE_CENTER', 'CENTER', 'CLOSE');
@@ -0,0 +1,4 @@
INSERT INTO `acc_product_mapping` (`gl_account_id`,`product_id`,`product_type`,`payment_type`,`charge_id`,`financial_account_type`)
select mapping.gl_account_id,mapping.product_id,mapping.product_type,mapping.payment_type,mapping.charge_id, 10
from acc_product_mapping mapping
where mapping.financial_account_type = 1 and mapping.product_type=1;
@@ -0,0 +1 @@
update c_configuration set enabled=0 where name="constraint_approach_for_datatables";
@@ -0,0 +1,113 @@
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES
('xbrlmapping', 'UPDATE_XBRLMAPPING', 'XBRLMAPPING', 'UPDATE', 0);
DROP TABLE IF EXISTS `mix_taxonomy`;
CREATE TABLE `mix_taxonomy` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`namespace_id` int(11) DEFAULT NULL,
`dimension` varchar(100) DEFAULT NULL,
`type` int(11) DEFAULT NULL,
`description` varchar(1000) DEFAULT NULL,
`need_mapping` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
LOCK TABLES `mix_taxonomy` WRITE;
INSERT INTO `mix_taxonomy` (`id`, `name`, `namespace_id`, `dimension`, `type`, `description`, `need_mapping`)
VALUES
(1,'AdministrativeExpense',1,NULL,3,NULL,1),
(2,'Assets',3,NULL,1,'All outstanding principals due for all outstanding client loans. This includes current, delinquent, and renegotiated loans, but not loans that have been written off. It does not include interest receivable.',1),
(3,'Assets',3,'MaturityDimension:LessThanOneYearMember',1,'Segmentation based on the life of an asset or liability.',1),
(4,'Assets',3,'MaturityDimension:MoreThanOneYearMember',1,'Segmentation based on the life of an asset or liability.',1),
(5,'CashAndCashEquivalents',1,NULL,1,NULL,1),
(6,'Deposits',3,NULL,1,'The total value of funds placed in an account with an MFI that are payable to a depositor. This item includes any current, checking, or savings accounts that are payable on demand. It also includes time deposits which have a fixed maturity date and compulsory deposits.',1),
(7,'Deposits',3,'DepositProductsDimension:CompulsoryMember',1,'The value of deposits that an MFI\'s clients are required to maintain as a condition of an existing or future loan.',NULL),
(8,'Deposits',3,'DepositProductsDimension:VoluntaryMember',1,'The value of deposits that an MFI\'s clients are not required to maintain as a condition of an existing or future loan.',NULL),
(9,'Deposits',3,'LocationDimension:RuralMember',1,'Located in rural areas. Segmentation based on location.',NULL),
(10,'Deposits',3,'LocationDimension:UrbanMember',1,'Located in urban areas. Segmentation based on location.',NULL),
(11,'Deposits',3,'MaturityDimension:LessThanOneYearMember',1,'Segmentation based on the life of an asset or liability.',NULL),
(12,'Deposits',3,'MaturityDimension:MoreThanOneYearMember',1,'Segmentation based on the life of an asset or liability.',NULL),
(13,'EmployeeBenefitsExpense',1,NULL,3,NULL,NULL),
(14,'Equity',1,NULL,1,NULL,NULL),
(15,'Expense',1,NULL,3,NULL,NULL),
(16,'FinancialExpense',3,NULL,3,'All costs All costs incurred in raising funds from third parties, fee expenses from non-financial services, net gains (losses) due to changes in fair value of financial liabilities, impairment losses net of reversals of financial assets other than loan portfolio and net gains (losses) from restatement of financial statements in terms of the measuring unit current at the end of the reporting period.',NULL),
(17,'FinancialRevenueOnLoans',3,NULL,2,'Interest and non-interest income generated by the provision of credit services to the clients. Fees and commissions for late payment are also included.',NULL),
(18,'ImpairmentLossAllowanceGrossLoanPortfolio',3,NULL,2,'An allowance for the risk of losses in the gross loan portfolio due to default .',NULL),
(19,'Liabilities',1,NULL,1,NULL,NULL),
(20,'Liabilities',3,'MaturityDimension:LessThanOneYearMember',1,'Segmentation based on the life of an asset or liability.',NULL),
(21,'Liabilities',3,'MaturityDimension:MoreThanOneYearMember',1,'Segmentation based on the life of an asset or liability.',NULL),
(22,'LoanPortfolioGross',3,NULL,2,'All outstanding principals due for all outstanding client loans. This includes current, delinquent, and renegotiated loans, but not loans that have been written off. It does not include interest receivable.',NULL),
(23,'LoanPortfolioGross',3,'CreditProductsDimension:MicroenterpriseMember',2,'Loans that finance the production or trade of goods and services for an individual\'s microenterprise, whether or not the microenterprise is legally registered. Segmentation based on loan product.',NULL),
(24,'LoanPortfolioGross',3,'DelinquencyDimension:OneMonthOrMoreMember',2,'Segmentation based on the principal balance of all loans outstanding that have one or more installments of principal past due or renegotiated. Segmentation based on the principal balance of all loans outstanding that have one or more installments of principal past due or renegotiated.',NULL),
(25,'LoanPortfolioGross',3,'DelinquencyDimension:ThreeMonthsOrMoreMember',2,'Segmentation based on the principal balance of all loans outstanding that have one or more installments of principal past due or renegotiated.? Segmentation based on the principal balance of all loans outstanding that have one or more installments of principal past due or renegotiated.',NULL),
(26,'LoanPortfolioGross',3,'LocationDimension:RuralMember',2,'Located in rural areas. Segmentation based on geographic location.',NULL),
(27,'LoanPortfolioGross',3,'LocationDimension:UrbanMember',2,'Located in urbal areas. Segmentation based on geographic location.',NULL),
(28,'LoanPortfolioGross',3,'MaturityDimension:LessThanOneYearMember',2,'Segmentation based on the life of an asset or liability.',NULL),
(29,'LoanPortfolioGross',3,'MaturityDimension:MoreThanOneYearMember',2,'Segmentation based on the life of an asset or liability.',NULL),
(30,'NetLoanLoss',3,'',3,'Referred to the value of delinquency loans written off net of any principal recovery.',NULL),
(31,'NetLoanLossProvisionExpense',3,NULL,3,'Represent the net value of loan portfolio impairment loss considering any reversal on impairment loss and any recovery on loans written off recognized as a income during the accounting period.',NULL),
(32,'NetOperatingIncome',3,NULL,2,'Total operating revenue less all expenses related to the MFI\'s core financial service operation including total financial expense, impairment loss and operating expense. Donations are excluded.',NULL),
(33,'NetOperatingIncomeNetOfTaxExpense',3,NULL,3,'Net operating income reported incorporating the effect of taxes. Taxes include all domestic and foreign taxes which are based on taxable profits, other taxes related to personnel, financial transactions or value-added taxes are not considered in calculation of this value.',NULL),
(34,'NumberOfActiveBorrowers',3,NULL,0,'The number of individuals who currently have an outstanding loan balance with the MFI or are primarily responsible for repaying any portion of the gross loan portfolio. Individuals who have multiple loans with an MFI should be counted as a single borrower.',NULL),
(35,'NumberOfActiveBorrowers',3,'GenderDimension:FemaleMember',0,'The number of individuals who currently have an outstanding loan balance with the MFI or are primarily responsible for repaying any portion of the gross loan portfolio. Individuals who have multiple loans with an MFI should be counted as a single borrower.',NULL),
(36,'NumberOfBoardMembers',3,'GenderDimension:FemaleMember',0,'The number of members that comprise the board of directors at the end of the reporting period who are female.',NULL),
(37,'NumberOfDepositAccounts',3,NULL,0,'The number of individuals who currently have funds on deposit with the MFI on a voluntary basis; i.e., they are not required to maintain the deposit account to access a loan. This number applies only to deposits held by an MFI, not to those deposits held in other institutions by the MFI\'s clients. The number should be based on the number of individuals rather than the number of groups. A single deposit account may represent multiple depositors.',NULL),
(38,'NumberOfDepositors',3,'',0,'The number of deposit accounts, both voluntary and compulsory, opened at the MFI whose balances the institution is liable to repay. The number should be based on the number of individual accounts rather than on the number of groups.',NULL),
(39,'NumberOfEmployees',3,NULL,0,'The number of individuals who are actively employed by an entity. This number includes contract employees or advisors who dedicate a substantial portion of their time to the entity, even if they are not on the entity\'s employees roster.',NULL),
(40,'NumberOfEmployees',3,'GenderDimension:FemaleMember',0,'The number of individuals who are actively employed by an entity. This number includes contract employees or advisors who dedicate a substantial portion of their time to the entity, even if they are not on the entity\'s employees roster.',NULL),
(41,'NumberOfLoanOfficers',3,NULL,0,'The number of employees whose main activity is to manage a portion of the gross loan portfolio. A loan officer is a staff member of record who is directly responsible for arranging and monitoring client loans.',NULL),
(42,'NumberOfLoanOfficers',3,'GenderDimension:FemaleMember',0,'The number of employees whose main activity is to manage a portion of the gross loan portfolio. A loan officer is a staff member of record who is directly responsible for arranging and monitoring client loans.',NULL),
(43,'NumberOfManagers',3,'GenderDimension:FemaleMember',0,'The number of members that comprise the management of the institution who are female.',NULL),
(44,'NumberOfOffices',3,NULL,0,'The number of staffed points of service and administrative sites used to deliver or support the delivery of financial services to microfinance clients.',NULL),
(45,'NumberOfOutstandingLoans',3,NULL,0,'The number of loans in the gross loan portfolio. For MFIs using a group lending methodology, the number of loans should refer to the number of individuals receiving loans as part of a group or as part of a group loan.',NULL),
(46,'OperatingExpense',3,NULL,3,'Includes expenses not related to financial and credit loss impairment, such as personnel expenses, depreciation, amortization and administrative expenses.',NULL),
(47,'OperatingIncome',3,NULL,2,'Includes all financial income and other operating revenue which is generated from non-financial services. Operating income also includes net gains (losses) from holding financial assets (changes on their values during the period and foreign exchange differences). Donations or any revenue not related with an MFI\'s core business of making loans and providing financial services are not considered under this category.',NULL),
(48,'WriteOffsOnGrossLoanPortfolio',3,NULL,2,'The value of loans that have been recognized as uncollectible for accounting purposes. A write-off is an accounting procedure that removes the outstanding balance of the loan from the gross loan portfolio and impairment loss allowance. Thus, the write-off does not affect the net loan portfolio, total assets, or any equity account. If the impairment loss allowance is insufficient to cover the amount written off, the excess amount will result in an additional impairment loss on loans recognised in profit or loss of the period.',NULL);
UNLOCK TABLES;
DROP TABLE IF EXISTS `mix_taxonomy_mapping`;
CREATE TABLE `mix_taxonomy_mapping` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`identifier` varchar(50) NOT NULL DEFAULT '',
`config` varchar(200) DEFAULT NULL,
`last_update_date` datetime DEFAULT NULL,
`currency` varchar(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
LOCK TABLES `mix_taxonomy_mapping` WRITE;
INSERT INTO `mix_taxonomy_mapping` (`id`, `identifier`, `config`, `last_update_date`, `currency`) VALUES
(1,'default',NULL,NULL,'');
UNLOCK TABLES;
DROP TABLE IF EXISTS `mix_xbrl_namespace`;
CREATE TABLE `mix_xbrl_namespace` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`prefix` varchar(20) NOT NULL DEFAULT '',
`url` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UNQUE` (`prefix`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
LOCK TABLES `mix_xbrl_namespace` WRITE;
INSERT INTO `mix_xbrl_namespace` (`id`, `prefix`, `url`)
VALUES
(1,'ifrs','http://xbrl.iasb.org/taxonomy/2009-04-01/ifrs'),
(2,'iso4217','http://www.xbrl.org/2003/iso4217'),
(3,'mix','http://www.themix.org/int/fr/ifrs/basi/YYYY-MM-DD/mx-cor'),
(4,'xbrldi','http://xbrl.org/2006/xbrldi'),
(5,'xbrli','http://www.xbrl.org/2003/instance'),
(6,'link','http://www.xbrl.org/2003/linkbase'),
(7,'dc-all','http://www.themix.org/int/fr/ifrs/basi/2010-08-31/dc-all');
UNLOCK TABLES;
@@ -0,0 +1,15 @@
ALTER TABLE `m_savings_account_transaction`
ADD COLUMN `office_id` BIGINT(20) NULL DEFAULT NULL AFTER `savings_account_id`;
/**update client savings**/
UPDATE m_savings_account_transaction st set st.office_id = (SELECT c.office_id AS officeId FROM m_savings_account sa JOIN m_client c on sa.client_id=c.id where sa.id=st.savings_account_id) where st.savings_account_id in (Select sa.id from m_savings_account sa where sa.client_id is not null);
/**update group savings**/
UPDATE m_savings_account_transaction st set st.office_id = (SELECT g.office_id AS officeId FROM m_savings_account sa JOIN m_group g on sa.group_id=g.id where sa.id=st.savings_account_id) where st.savings_account_id in (Select sa.id from m_savings_account sa where sa.group_id is not null);
/**Add foreign key constraints**/
ALTER TABLE `m_savings_account_transaction`
CHANGE COLUMN `office_id` `office_id` BIGINT(20) NOT NULL AFTER `savings_account_id`;
ALTER TABLE `m_savings_account_transaction`
ADD CONSTRAINT `FK_m_savings_account_transaction_m_office` FOREIGN KEY (`office_id`) REFERENCES `m_office` (`id`);
@@ -0,0 +1,4 @@
INSERT INTO `acc_product_mapping` (`gl_account_id`,`product_id`,`product_type`,`payment_type`,`charge_id`,`financial_account_type`)
select mapping.gl_account_id,mapping.product_id,mapping.product_type,mapping.payment_type,mapping.charge_id, 10
from acc_product_mapping mapping
where mapping.financial_account_type = 1 and mapping.product_type=2;
@@ -0,0 +1,19 @@
DROP TABLE IF EXISTS `c_cache`;
CREATE TABLE `c_cache` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`cache_type_enum` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `c_cache`
(`id`,`cache_type_enum`)
VALUES
(1, 1);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('configuration', 'READ_CACHE', 'CACHE', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('configuration', 'UPDATE_CACHE', 'CACHE', 'UPDATE', 0);
@@ -0,0 +1,29 @@
/**Add currency code**/
ALTER TABLE `acc_gl_journal_entry`
ADD COLUMN `currency_code` VARCHAR(3) NULL DEFAULT NULL AFTER `reversal_id`;
/**Update currency codes for loans**/
UPDATE acc_gl_journal_entry journal_entry SET currency_code = (
SELECT m_loan.currency_code
FROM m_loan, m_loan_transaction
WHERE m_loan.id = m_loan_transaction.loan_id AND m_loan_transaction.id=journal_entry.transaction_id)
WHERE journal_entry.entity_type_enum=1;
/**Update currency codes for savings**/
UPDATE acc_gl_journal_entry journal_entry SET currency_code = (
SELECT m_savings_account.currency_code
FROM m_savings_account, m_savings_account_transaction
WHERE m_savings_account.id = m_savings_account_transaction.savings_account_id AND m_savings_account_transaction.id=journal_entry.transaction_id)
WHERE journal_entry.entity_type_enum=2;
/**Update currency codes for manual journal entries***/
update acc_gl_journal_entry set currency_code = (select code from m_organisation_currency limit 1)
where acc_gl_journal_entry.currency_code is NULL;
/**Make currency code not null**/
ALTER TABLE `acc_gl_journal_entry`
ALTER `currency_code` DROP DEFAULT;
ALTER TABLE `acc_gl_journal_entry`
CHANGE COLUMN `currency_code` `currency_code` VARCHAR(3) NOT NULL AFTER `reversal_id`;
@@ -0,0 +1,26 @@
CREATE TABLE `m_portfolio_account_associations` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`loan_account_id` BIGINT NULL DEFAULT NULL,
`savings_account_id` BIGINT NULL DEFAULT NULL,
`linked_loan_account_id` BIGINT NULL DEFAULT NULL,
`linked_savings_account_id` BIGINT NULL DEFAULT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `account_association_loan_fk` FOREIGN KEY (`loan_account_id`) REFERENCES `m_loan` (`id`),
CONSTRAINT `account_association_savings_fk` FOREIGN KEY (`savings_account_id`) REFERENCES `m_savings_account` (`id`),
CONSTRAINT `linked_loan_fk` FOREIGN KEY (`linked_loan_account_id`) REFERENCES `m_loan` (`id`),
CONSTRAINT `linked_savings_fk` FOREIGN KEY (`linked_savings_account_id`) REFERENCES `m_savings_account` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
ALTER TABLE `m_charge`
ADD COLUMN `charge_payment_mode_enum` SMALLINT(5) NOT NULL DEFAULT '0' AFTER `charge_calculation_enum`;
ALTER TABLE `m_loan_charge`
ADD COLUMN `charge_payment_mode_enum` SMALLINT(5) NOT NULL DEFAULT '0' AFTER `charge_calculation_enum`;
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('transaction_loan', 'PAY_LOANCHARGE', 'LOANCHARGE', 'PAY', 0);
INSERT INTO `job` (`name`, `display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `job_key`, `initializing_errorlog`, `is_active`, `currently_running`, `updates_allowed`, `scheduler_group`, `is_misfired`) VALUES ('Transfer Fee For Loans From Savings', 'Transfer Fee For Loans From Savings', '0 1 0 1/1 * ? *', now(), 5, NULL, NULL, NULL, NULL, NULL, 1, 0, 1, 0, 0);
@@ -0,0 +1,3 @@
ALTER TABLE `m_savings_account`
ADD COLUMN `total_fees_charge_derived` DECIMAL(19,6) NULL DEFAULT NULL AFTER `total_withdrawal_fees_derived`,
ADD COLUMN `total_penalty_charge_derived` DECIMAL(19,6) NULL DEFAULT NULL AFTER `total_fees_charge_derived`;
@@ -0,0 +1 @@
delete from acc_product_mapping where financial_account_type=10 and payment_type is not null;
@@ -0,0 +1,6 @@
/**Permissions for proposing and accepting a transfer**/
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'PROPOSEANDACCEPTTRANSFER_CLIENT', 'CLIENT', 'PROPOSEANDACCEPTTRANSFER', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('portfolio', 'PROPOSEANDACCEPTTRANSFER_CLIENT_CHECKER', 'CLIENT', 'PROPOSEANDACCEPTTRANSFER', 0);
@@ -0,0 +1,8 @@
/***Delete previously set defaults**/
delete from acc_product_mapping where financial_account_type=10 and product_type=2;
/***Set the proper defaults**/
INSERT INTO `acc_product_mapping` (`gl_account_id`,`product_id`,`product_type`,`payment_type`,`charge_id`,`financial_account_type`)
select mapping.gl_account_id,mapping.product_id,mapping.product_type,mapping.payment_type,mapping.charge_id, 10
from acc_product_mapping mapping
where mapping.financial_account_type = 2 and mapping.product_type=2;
@@ -0,0 +1 @@
INSERT INTO `job` (`name`, `display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `job_key`, `initializing_errorlog`, `is_active`, `currently_running`, `updates_allowed`, `scheduler_group`, `is_misfired`) VALUES ('Pay Due Savings Charges', 'Pay Due Savings Charges', '0 0 12 * * ?', '2013-09-23 00:00:00', 5, NULL, NULL, NULL, 'Pay Due Savings ChargesJobDetail1 _ DEFAULT', NULL, 1, 0, 1, 0, 0);
@@ -0,0 +1,5 @@
/***Set defaults for income from Penalties for existing Saving Products**/
INSERT INTO `acc_product_mapping` (`gl_account_id`,`product_id`,`product_type`,`payment_type`,`charge_id`,`financial_account_type`)
select mapping.gl_account_id,mapping.product_id,mapping.product_type,mapping.payment_type,mapping.charge_id, 5
from acc_product_mapping mapping
where mapping.financial_account_type = 4 and mapping.product_type=2;
@@ -0,0 +1,253 @@
ALTER TABLE `m_savings_account_charge`
CHANGE COLUMN `due_for_collection_as_of_date` `charge_due_date` DATE NULL DEFAULT NULL AFTER `charge_time_enum`;
ALTER TABLE `m_savings_account_charge`
ADD COLUMN `fee_on_month` SMALLINT(5) NULL DEFAULT NULL AFTER `charge_due_date`,
ADD COLUMN `fee_on_day` SMALLINT(5) NULL DEFAULT NULL AFTER `fee_on_month`,
ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `waived`;
delimiter //
CREATE PROCEDURE migrate_withdrwal_fees()
begin
declare no_more_rows boolean default false;
declare v_currency_code VARCHAR(3);
declare v_withdrawal_fee_type_enum SMALLINT(5);
declare v_withdrawal_fee_amount_charge_def DECIMAL(19,6);
declare v_account_id BIGINT(20);
declare v_withdrawal_fee_amount DECIMAL(19,6);
declare t_calculation_percentage DECIMAL(19,6);
declare t_calculation_on_amount DECIMAL(19,6);
declare t_withdrawal_fee_name VARCHAR(100);
declare t_charge_id BIGINT(20);
declare t_savings_charge_id BIGINT(20);
-- savings transaction variables
declare v_savings_transaction_id BIGINT(20);
declare v_transaction_amount DECIMAL(19,6);
declare cursor1 cursor for
select sa.currency_code, sa.withdrawal_fee_type_enum, sa.withdrawal_fee_amount
from m_savings_account sa where sa.withdrawal_fee_amount is not null and sa.withdrawal_fee_amount > 0 group by sa.currency_code, sa.withdrawal_fee_type_enum;
declare cursor2 cursor for
select sa.id, sa.withdrawal_fee_amount from m_savings_account sa where sa.currency_code=v_currency_code and sa.withdrawal_fee_type_enum=v_withdrawal_fee_type_enum and sa.withdrawal_fee_amount is not null and sa.withdrawal_fee_amount > 0;
declare cursor3 cursor for
select sat.id, sat.amount from m_savings_account_transaction sat
where sat.savings_account_id=v_account_id and sat.transaction_type_enum=4;
declare continue handler for not found
set no_more_rows := true;
open cursor1;
LOOP1: loop
fetch cursor1 into v_currency_code, v_withdrawal_fee_type_enum, v_withdrawal_fee_amount_charge_def;
if no_more_rows then
close cursor1;
leave LOOP1;
end if;
-- set withdrawal fee name
if(v_withdrawal_fee_type_enum = 1) then
set t_withdrawal_fee_name = CONCAT('Withdrawal fee-Flat-',v_currency_code);
else
set t_withdrawal_fee_name = CONCAT('Withdrawal fee-Percentage-',v_currency_code);
end if;
-- get charge id if already exists
set t_charge_id = (select id from m_charge where name = t_withdrawal_fee_name);
if t_charge_id is null then
-- add withdrawal fee to charges
INSERT INTO `m_charge` (`name`, `currency_code`, `charge_applies_to_enum`, `charge_time_enum`, `charge_calculation_enum`, `charge_payment_mode_enum`, `amount`, `is_penalty`, `is_active`, `is_deleted`) VALUES (t_withdrawal_fee_name , v_currency_code, 2, 5, v_withdrawal_fee_type_enum, 0, v_withdrawal_fee_amount_charge_def, 0, 1, 0);
-- get inserted charge id
set t_charge_id = last_insert_id();
end if;
open cursor2;
LOOP2: loop
fetch cursor2 into v_account_id, v_withdrawal_fee_amount;
if no_more_rows then
set no_more_rows := false;
close cursor2;
leave LOOP2;
end if;
if (v_withdrawal_fee_type_enum=1) then
set t_calculation_percentage = NULL;
set t_calculation_on_amount = NULL;
else
set t_calculation_percentage = v_withdrawal_fee_amount;
set v_withdrawal_fee_amount = 0;
set t_calculation_on_amount = 0;
end if;
if not exists (select id from m_savings_account_charge sac where
sac.savings_account_id=v_account_id and sac.charge_id=t_charge_id and sac.charge_time_enum=5) then
-- attach withdrawal charge to savings
INSERT INTO `m_savings_account_charge` (`savings_account_id`, `charge_id`, `is_penalty`, `charge_time_enum`, `charge_due_date`, `fee_on_month`, `fee_on_day`, `charge_calculation_enum`, `calculation_percentage`, `calculation_on_amount`, `amount`, `amount_paid_derived`, `amount_waived_derived`, `amount_writtenoff_derived`, `amount_outstanding_derived`, `is_paid_derived`, `waived`, `is_active`) VALUES (v_account_id, t_charge_id, 0, 5, NULL, NULL, NULL, v_withdrawal_fee_type_enum, t_calculation_percentage, t_calculation_on_amount, v_withdrawal_fee_amount, NULL, NULL, NULL, 0.000000, 0, 0, 1);
-- set savings account charge id
set t_savings_charge_id = last_insert_id();
else
set t_savings_charge_id = (select id from m_savings_account_charge sac where sac.savings_account_id=v_account_id and sac.charge_id=t_charge_id and sac.charge_time_enum=5);
end if;
open cursor3;
LOOP3: loop
fetch cursor3 into v_savings_transaction_id, v_transaction_amount;
if no_more_rows then
set no_more_rows := false;
close cursor3;
leave LOOP3;
end if;
if not exists (select id from m_savings_account_charge_paid_by sacp where
sacp.savings_account_transaction_id=v_savings_transaction_id and sacp.savings_account_charge_id=t_savings_charge_id) then
-- insert a record into savings account charge paid by
INSERT INTO `m_savings_account_charge_paid_by` (`savings_account_transaction_id`, `savings_account_charge_id`, `amount`) VALUES(v_savings_transaction_id, t_savings_charge_id, v_transaction_amount);
end if;
end loop LOOP3;
end loop LOOP2;
end loop LOOP1;
end //
CREATE PROCEDURE migrate_annual_fees()
begin
declare no_more_rows boolean default false;
declare v_currency_code VARCHAR(3);
declare v_annual_fee_amount_charge_def DECIMAL(19,6);
declare v_account_id BIGINT(20);
declare v_annual_fee_amount DECIMAL(19,6);
declare v_annual_fee_on_month SMALLINT(5);
declare v_annual_fee_on_day SMALLINT(5);
declare v_annual_fee_next_due_date DATE;
declare t_annual_fee_name VARCHAR(100);
declare t_charge_id BIGINT(20);
declare t_savings_charge_id BIGINT(20);
-- savings transaction variables
declare v_savings_transaction_id BIGINT(20);
declare v_transaction_amount DECIMAL(19,6);
declare cursor1 cursor for
select sa.currency_code, sa.annual_fee_amount
from m_savings_account sa where sa.annual_fee_amount is not null and sa.annual_fee_on_month is not null and sa.annual_fee_on_day is not null group by sa.currency_code;
declare cursor2 cursor for
select sa.id, sa.annual_fee_amount, sa.annual_fee_on_month, sa.annual_fee_on_day, sa.annual_fee_next_due_date from m_savings_account sa where sa.currency_code=v_currency_code and sa.annual_fee_amount is not null and sa.annual_fee_on_month is not null and sa.annual_fee_on_day is not null;
declare cursor3 cursor for
select sat.id, sat.amount from m_savings_account_transaction sat
where sat.savings_account_id=v_account_id and sat.transaction_type_enum=5;
declare continue handler for not found
set no_more_rows := true;
open cursor1;
LOOP1: loop
fetch cursor1 into v_currency_code, v_annual_fee_amount_charge_def;
if no_more_rows then
close cursor1;
leave LOOP1;
end if;
-- set annual fee name
set t_annual_fee_name = CONCAT('Annual fee - ',v_currency_code);
-- get charge id if already exists
set t_charge_id = (select id from m_charge where name = t_annual_fee_name);
if t_charge_id is null then
-- add annual fee to charges
INSERT INTO `m_charge` (`name`, `currency_code`, `charge_applies_to_enum`, `charge_time_enum`, `charge_calculation_enum`, `charge_payment_mode_enum`, `amount`, `is_penalty`, `is_active`, `is_deleted`) VALUES (t_annual_fee_name, v_currency_code, 2, 6, 1, 0, v_annual_fee_amount_charge_def, 0, 1, 0);
-- get inserted charge id
set t_charge_id = last_insert_id();
end if;
open cursor2;
LOOP2: loop
fetch cursor2 into v_account_id, v_annual_fee_amount, v_annual_fee_on_month, v_annual_fee_on_day, v_annual_fee_next_due_date;
if no_more_rows then
set no_more_rows := false;
close cursor2;
leave LOOP2;
end if;
if not exists (select id from m_savings_account_charge sac where
sac.savings_account_id=v_account_id and sac.charge_id=t_charge_id and sac.charge_time_enum=6) then
-- attach annual charge to savings
INSERT INTO `m_savings_account_charge` (`savings_account_id`, `charge_id`, `is_penalty`, `charge_time_enum`, `charge_due_date`, `fee_on_month`, `fee_on_day`, `charge_calculation_enum`, `calculation_percentage`, `calculation_on_amount`, `amount`, `amount_paid_derived`, `amount_waived_derived`, `amount_writtenoff_derived`, `amount_outstanding_derived`, `is_paid_derived`, `waived`, `is_active`) VALUES (v_account_id, t_charge_id, 0, 6, v_annual_fee_next_due_date, v_annual_fee_on_month, v_annual_fee_on_day, 1, NULL, NULL, v_annual_fee_amount, NULL, NULL, NULL, v_annual_fee_amount, 0, 0, 1);
-- set savings account charge id
set t_savings_charge_id = last_insert_id();
else
set t_savings_charge_id = (select id from m_savings_account_charge sac where sac.savings_account_id=v_account_id and sac.charge_id=t_charge_id and sac.charge_time_enum=6);
end if;
open cursor3;
LOOP3: loop
fetch cursor3 into v_savings_transaction_id, v_transaction_amount;
if no_more_rows then
set no_more_rows := false;
close cursor3;
leave LOOP3;
end if;
if not exists (select id from m_savings_account_charge_paid_by sacp where
sacp.savings_account_transaction_id=v_savings_transaction_id and sacp.savings_account_charge_id=t_savings_charge_id) then
-- insert a record into savings account charge paid by
INSERT INTO `m_savings_account_charge_paid_by` (`savings_account_transaction_id`, `savings_account_charge_id`, `amount`) VALUES(v_savings_transaction_id, t_savings_charge_id, v_transaction_amount);
end if;
end loop LOOP3;
end loop LOOP2;
end loop LOOP1;
end //
delimiter ;
call migrate_withdrwal_fees();
call migrate_annual_fees();
drop procedure if exists migrate_annual_fees;
drop procedure if exists migrate_withdrwal_fees;
ALTER TABLE `m_savings_account`
DROP COLUMN `annual_fee_amount`,
DROP COLUMN `annual_fee_on_month`,
DROP COLUMN `annual_fee_on_day`,
DROP COLUMN `annual_fee_next_due_date`,
DROP COLUMN `withdrawal_fee_amount`,
DROP COLUMN `withdrawal_fee_type_enum`;
ALTER TABLE `m_savings_product`
DROP COLUMN `annual_fee_amount`,
DROP COLUMN `annual_fee_on_month`,
DROP COLUMN `annual_fee_on_day`;
@@ -0,0 +1,16 @@
/***Set defaults for income from Penalties for existing Saving Products**/
ALTER TABLE `m_loan_transaction`
ADD COLUMN `overpayment_portion_derived` DECIMAL(19,6) NULL DEFAULT NULL AFTER `penalty_charges_portion_derived`;
/**Add dummy liability account if organization already has a loan product with accounting enabled**/
INSERT INTO `acc_gl_account` (`name`, `hierarchy`, `gl_code`,`account_usage`, `classification_enum`,`description`)
select 'Loan Overpayments (Temp)', '.', '22000-Temp', 1, 2,'Temporary account to track Loan overpayments Liabilities'
FROM m_product_loan WHERE accounting_type != 1
limit 1;
/**Map a liability account for every loan which has accounting enabled**/
INSERT INTO `acc_product_mapping` (`gl_account_id`,`product_id`,`product_type`,`financial_account_type`)
select (select max(id) from acc_gl_account where classification_enum=2 and account_usage=1 LIMIT 1), mapping.product_id, mapping.product_type, 11
from acc_product_mapping mapping
where mapping.financial_account_type = 2 and mapping.product_type=1;
@@ -0,0 +1,64 @@
CREATE TABLE `m_savings_account_charge` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`savings_account_id` BIGINT(20) NOT NULL,
`charge_id` BIGINT(20) NOT NULL,
`is_penalty` TINYINT(1) NOT NULL DEFAULT '0',
`charge_time_enum` SMALLINT(5) NOT NULL,
`due_for_collection_as_of_date` DATE NULL DEFAULT NULL,
`charge_calculation_enum` SMALLINT(5) NOT NULL,
`calculation_percentage` DECIMAL(19,6) NULL DEFAULT NULL,
`calculation_on_amount` DECIMAL(19,6) NULL DEFAULT NULL,
`amount` DECIMAL(19,6) NOT NULL,
`amount_paid_derived` DECIMAL(19,6) NULL DEFAULT NULL,
`amount_waived_derived` DECIMAL(19,6) NULL DEFAULT NULL,
`amount_writtenoff_derived` DECIMAL(19,6) NULL DEFAULT NULL,
`amount_outstanding_derived` DECIMAL(19,6) NOT NULL DEFAULT '0.000000',
`is_paid_derived` TINYINT(1) NOT NULL DEFAULT '0',
`waived` TINYINT(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
INDEX `charge_id` (`charge_id`),
INDEX `m_savings_account_charge_ibfk_2` (`savings_account_id`),
CONSTRAINT `m_savings_account_charge_ibfk_1` FOREIGN KEY (`charge_id`) REFERENCES `m_charge` (`id`),
CONSTRAINT `m_savings_account_charge_ibfk_2` FOREIGN KEY (`savings_account_id`) REFERENCES `m_savings_account` (`id`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `m_savings_product_charge` (
`savings_product_id` BIGINT(20) NOT NULL,
`charge_id` BIGINT(20) NOT NULL,
PRIMARY KEY (`savings_product_id`, `charge_id`),
INDEX `charge_id` (`charge_id`),
CONSTRAINT `m_savings_product_charge_ibfk_1` FOREIGN KEY (`charge_id`) REFERENCES `m_charge` (`id`),
CONSTRAINT `m_savings_product_charge_ibfk_2` FOREIGN KEY (`savings_product_id`) REFERENCES `m_savings_product` (`id`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'CREATE_SAVINGSACCOUNTCHARGE', 'SAVINGSACCOUNTCHARGE', 'CREATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'CREATE_SAVINGSACCOUNTCHARGE_CHECKER', 'SAVINGSACCOUNTCHARGE', 'CREATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'UPDATE_SAVINGSACCOUNTCHARGE', 'SAVINGSACCOUNTCHARGE', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'UPDATE_SAVINGSACCOUNTCHARGE_CHECKER', 'SAVINGSACCOUNTCHARGE', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'DELETE_SAVINGSACCOUNTCHARGE', 'SAVINGSACCOUNTCHARGE', 'DELETE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'DELETE_SAVINGSACCOUNTCHARGE_CHECKER', 'SAVINGSACCOUNTCHARGE', 'DELETE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'WAIVE_SAVINGSACCOUNTCHARGE', 'SAVINGSACCOUNTCHARGE', 'WAIVE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'WAIVE_SAVINGSACCOUNTCHARGE_CHECKER', 'SAVINGSACCOUNTCHARGE', 'WAIVE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'PAY_SAVINGSACCOUNTCHARGE', 'SAVINGSACCOUNTCHARGE', 'PAY', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ( 'portfolio', 'PAY_SAVINGSACCOUNTCHARGE_CHECKER', 'SAVINGSACCOUNTCHARGE', 'PAY', 0);
CREATE TABLE `m_savings_account_charge_paid_by` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`savings_account_transaction_id` BIGINT(20) NOT NULL,
`savings_account_charge_id` BIGINT(20) NOT NULL,
`amount` DECIMAL(19,6) NOT NULL,
PRIMARY KEY (`id`),
INDEX `FK__m_savings_account_transaction` (`savings_account_transaction_id`),
INDEX `FK__m_savings_account_charge` (`savings_account_charge_id`),
CONSTRAINT `FK__m_savings_account_charge` FOREIGN KEY (`savings_account_charge_id`) REFERENCES `m_savings_account_charge` (`id`),
CONSTRAINT `FK__m_savings_account_transaction` FOREIGN KEY (`savings_account_transaction_id`) REFERENCES `m_savings_account_transaction` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
@@ -0,0 +1,34 @@
DROP TABLE IF EXISTS `m_template`;
CREATE TABLE `m_template` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`text` longtext COLLATE utf8_unicode_ci NOT NULL,
`entity` int(11) DEFAULT NULL,
`type` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unq_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `m_templatemappers`;
CREATE TABLE `m_templatemappers` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`mapperkey` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`mapperorder` int(11) DEFAULT NULL,
`mappervalue` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `m_template_m_templatemappers`;
CREATE TABLE `m_template_m_templatemappers` (
`m_template_id` bigint(20) NOT NULL,
`mappers_id` bigint(20) NOT NULL,
UNIQUE KEY `mappers_id` (`mappers_id`),
KEY (`mappers_id`),
KEY (`m_template_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('organistion', 'DELETE_TEMPLATE', 'TEMPLATE', 'DELETE', 0),
('organistion', 'CREATE_TEMPLATE', 'TEMPLATE', 'CREATE', 0),
('organistion', 'UPDATE_TEMPLATE', 'TEMPLATE', 'UPDATE', 0),
('organistion', 'READ_TEMPLATE', 'TEMPLATE', 'READ', 0);
@@ -0,0 +1,24 @@
/*
New table for storing transaction details (for both loan and savings)
*/
CREATE TABLE `m_payment_detail` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`payment_type_enum` SMALLINT(5) NOT NULL,
`account_number` VARCHAR(100) NULL DEFAULT NULL,
`check_number` VARCHAR(100) NULL DEFAULT NULL,
`receipt_number` VARCHAR(100) NULL DEFAULT NULL,
`bank_number` VARCHAR(100) NULL DEFAULT NULL,
`routing_code` VARCHAR(100) NULL DEFAULT NULL,
PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
/*
Update loan transaction to add a link to transaction detail table
*/
ALTER TABLE `m_loan_transaction`
ADD COLUMN `payment_detail_id` BIGINT(20) NULL AFTER `loan_id`,
ADD CONSTRAINT `FK_m_loan_transaction_m_payment_detail` FOREIGN KEY (`payment_detail_id`) REFERENCES `m_payment_detail` (`id`);
@@ -0,0 +1,5 @@
ALTER TABLE `acc_gl_journal_entry`
ADD COLUMN `is_running_balance_caculated` TINYINT NOT NULL DEFAULT '0' AFTER `lastmodified_date`,
ADD COLUMN `office_running_balance` DECIMAL(19,6) NOT NULL DEFAULT '0.000000' AFTER `is_running_balance_caculated`;
INSERT INTO `job` (`name`, `display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `job_key`, `initializing_errorlog`, `is_active`, `currently_running`, `updates_allowed`, `scheduler_group`, `is_misfired`) VALUES ('Update Accounting Running Balances', 'Update Accounting Running Balances', '0 1 0 1/1 * ? *', now(), 5, NULL, NULL, NULL, NULL, NULL, 1, 0, 1, 0, 0);
@@ -0,0 +1,4 @@
ALTER TABLE `acc_gl_journal_entry`
ADD COLUMN `organization_running_balance` DECIMAL(19,6) NOT NULL DEFAULT '0.000000' AFTER `office_running_balance`;
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('accounting', 'UPDATERUNNINGBALANCE_JOURNALENTRY', 'JOURNALENTRY', 'UPDATERUNNINGBALANCE', 0);
@@ -0,0 +1,8 @@
ALTER TABLE `m_charge`
ADD COLUMN `fee_on_day` SMALLINT(5) NULL AFTER `amount`,
ADD COLUMN `fee_interval` SMALLINT(5) NULL AFTER `fee_on_day`,
ADD COLUMN `fee_on_month` SMALLINT(5) NULL AFTER `fee_interval`;
ALTER TABLE `m_savings_account_charge`
ADD COLUMN `fee_interval` SMALLINT(5) NULL DEFAULT NULL AFTER `fee_on_day`;
@@ -0,0 +1,2 @@
ALTER TABLE `m_charge`
CHANGE COLUMN `charge_payment_mode_enum` `charge_payment_mode_enum` SMALLINT(5) NULL DEFAULT NULL AFTER `charge_calculation_enum`;
@@ -0,0 +1,7 @@
ALTER TABLE `m_charge`
ADD COLUMN `min_cap` DECIMAL(19,6) NULL AFTER `is_deleted`,
ADD COLUMN `max_cap` DECIMAL(19,6) NULL AFTER `min_cap`;
ALTER TABLE `m_loan_charge`
ADD COLUMN `min_cap` DECIMAL(19,6) NULL AFTER `waived`,
ADD COLUMN `max_cap` DECIMAL(19,6) NULL AFTER `min_cap`;
@@ -0,0 +1,2 @@
ALTER TABLE `m_loan_charge`
ADD COLUMN `charge_amount_or_percentage` DECIMAL(19,6) NULL DEFAULT NULL AFTER `calculation_on_amount`;
@@ -0,0 +1,36 @@
DROP TABLE IF EXISTS `sms_messages_outbound`;
CREATE TABLE `sms_messages_outbound` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`group_id` bigint(20) DEFAULT NULL,
`client_id` bigint(20) DEFAULT NULL,
`staff_id` bigint(20) DEFAULT NULL,
`status_enum` int(5) NOT NULL DEFAULT '100',
`mobile_no` varchar(50) NOT NULL,
`message` varchar(1000) NOT NULL,
PRIMARY KEY (`id`),
KEY `FKGROUP000000001` (`group_id`),
KEY `FKCLIENT00000001` (`client_id`),
CONSTRAINT `FKGROUP000000001` FOREIGN KEY (`group_id`) REFERENCES `m_group` (`id`),
CONSTRAINT `FKCLIENT00000001` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`),
CONSTRAINT `FKSTAFF000000001` FOREIGN KEY (`staff_id`) REFERENCES `m_staff` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Permissions for CRUD on SMS outbound message tracking
DELETE FROM `m_permission` WHERE `entity_name`='SMS';
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('organisation', 'READ_SMS', 'SMS', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('organisation', 'CREATE_SMS', 'SMS', 'CREATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('organisation', 'CREATE_SMS_CHECKER', 'SMS', 'CREATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('organisation', 'UPDATE_SMS', 'SMS', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('organisation', 'UPDATE_SMS_CHECKER', 'SMS', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('organisation', 'DELETE_SMS', 'SMS', 'DELETE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
VALUES ('organisation', 'DELETE_SMS_CHECKER', 'SMS', 'DELETE', 0);
@@ -0,0 +1,8 @@
ALTER TABLE `m_client`
ADD COLUMN `mobile_no` VARCHAR(50) NULL DEFAULT NULL AFTER `display_name`,
ADD UNIQUE INDEX `mobile_no_UNIQUE` (`mobile_no` ASC);
ALTER TABLE `m_staff`
ADD COLUMN `mobile_no` VARCHAR(50) NULL DEFAULT NULL AFTER `display_name`,
ADD UNIQUE INDEX `mobile_no_UNIQUE` (`mobile_no` ASC);
@@ -0,0 +1,19 @@
CREATE TABLE `m_loan_installment_charge` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`loan_charge_id` BIGINT(20) NOT NULL,
`loan_schedule_id` BIGINT(20) NOT NULL,
`due_date` DATE NULL DEFAULT NULL,
`amount` DECIMAL(19,6) NOT NULL,
`amount_paid_derived` DECIMAL(19,6) NULL DEFAULT NULL,
`amount_waived_derived` DECIMAL(19,6) NULL DEFAULT NULL,
`amount_writtenoff_derived` DECIMAL(19,6) NULL DEFAULT NULL,
`amount_outstanding_derived` DECIMAL(19,6) NOT NULL DEFAULT '0.000000',
`is_paid_derived` TINYINT(1) NOT NULL DEFAULT '0',
`waived` TINYINT(1) NOT NULL DEFAULT '0',
`amount_through_charge_payment` DECIMAL(19,6) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `FK_loan_charge_id_charge_schedule` FOREIGN KEY (`loan_charge_id`) REFERENCES `m_loan_charge` (`id`),
CONSTRAINT `FK_loan_schedule_id_charge_schedule` FOREIGN KEY (`loan_schedule_id`) REFERENCES `m_loan_repayment_schedule` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
@@ -0,0 +1,9 @@
ALTER TABLE `m_client` ADD `submittedon_date` DATE NULL DEFAULT NULL ,
ADD `submittedon_userid` BIGINT( 20 ) NULL DEFAULT NULL ,
ADD `activatedon_userid` BIGINT( 20 ) NULL DEFAULT NULL ,
ADD `closedon_userid` BIGINT( 20 ) NULL DEFAULT NULL ;
ALTER TABLE `m_group` ADD `activatedon_userid` BIGINT( 20 ) NULL ,
ADD `submittedon_date` DATE NULL ,
ADD `submittedon_userid` BIGINT( 20 ) NULL ,
ADD `closedon_userid` BIGINT( 20 ) NULL ;
@@ -0,0 +1,26 @@
ALTER TABLE m_group
ADD UNIQUE INDEX `external_id_UNIQUE` (`external_id` ASC) ;
ALTER TABLE m_product_loan
ADD COLUMN `external_id` VARCHAR(100) NULL AFTER `loan_transaction_strategy_id` ,
ADD UNIQUE INDEX `external_id_UNIQUE` (`external_id` ASC) ;
ALTER TABLE m_staff
ADD COLUMN `external_id` VARCHAR(100) NULL AFTER `display_name` ,
ADD UNIQUE INDEX `external_id_UNIQUE` (`external_id` ASC) ;
/* status_id values for client and group
0 - Invalid
100 - Pending
300 - Active
600 - Closed( or Exited)
*/
ALTER TABLE m_client
ADD COLUMN `status_id` INT(5) NOT NULL DEFAULT 300 AFTER `is_deleted` ;
ALTER TABLE m_group
ADD COLUMN `status_id` INT(5) NOT NULL DEFAULT 300 AFTER `is_deleted` ;
@@ -0,0 +1,19 @@
CREATE TABLE `m_calendar_history` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`calendar_id` BIGINT(20) NOT NULL,
`title` VARCHAR(50) NOT NULL,
`description` VARCHAR(100) NULL DEFAULT NULL,
`location` VARCHAR(50) NULL DEFAULT NULL,
`start_date` DATE NOT NULL,
`end_date` DATE NULL DEFAULT NULL,
`duration` SMALLINT(6) NULL DEFAULT NULL,
`calendar_type_enum` SMALLINT(5) NOT NULL,
`repeating` TINYINT(1) NOT NULL DEFAULT '0',
`recurrence` VARCHAR(100) NULL DEFAULT NULL,
`remind_by_enum` SMALLINT(5) NULL DEFAULT NULL,
`first_reminder` SMALLINT(11) NULL DEFAULT NULL,
`second_reminder` SMALLINT(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `FK_m_calendar_m_calendar_history` (`calendar_id`),
CONSTRAINT `FK_m_calendar_m_calendar_history` FOREIGN KEY (`calendar_id`) REFERENCES `m_calendar` (`id`)
);
@@ -0,0 +1,16 @@
ALTER TABLE `m_holiday`
ADD COLUMN `status_enum` INT(5) NOT NULL DEFAULT '100' AFTER `repayments_rescheduled_to`;
ALTER TABLE `m_holiday`
DROP INDEX `holiday_name`,
ADD UNIQUE INDEX `holiday_name` (`name`, `from_date`);
UPDATE `m_holiday` set `status_enum`=300;
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'CREATE_HOLIDAY_CHECKER', 'HOLIDAY', 'CREATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'ACTIVATE_HOLIDAY', 'HOLIDAY', 'ACTIVATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'ACTIVATE_HOLIDAY_CHECKER', 'HOLIDAY', 'ACTIVATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'UPDATE_HOLIDAY', 'HOLIDAY', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'UPDATE_HOLIDAY_CHECKER', 'HOLIDAY', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'DELETE_HOLIDAY', 'HOLIDAY', 'DELETE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'DELETE_HOLIDAY_CHECKER', 'HOLIDAY', 'DELETE', 0);
@@ -0,0 +1,19 @@
CREATE TABLE `m_product_loan_variations_borrower_cycle` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`loan_product_id` BIGINT(20) NOT NULL DEFAULT '0',
`borrower_cycle_number` INT(3) NOT NULL DEFAULT '0',
`value_condition` INT(1) NOT NULL DEFAULT '0',
`param_type` INT(1) NOT NULL DEFAULT '0',
`default_value` DECIMAL(19,6) NOT NULL DEFAULT '0.000000',
`max_value` DECIMAL(19,6) NULL DEFAULT NULL,
`min_value` DECIMAL(19,6) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `borrower_cycle_loan_product_FK` (`loan_product_id`),
CONSTRAINT `borrower_cycle_loan_product_FK` FOREIGN KEY (`loan_product_id`) REFERENCES `m_product_loan` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
ALTER TABLE `m_product_loan`
ADD COLUMN `use_borrower_cycle` TINYINT(1) NOT NULL DEFAULT '0' AFTER `include_in_borrower_cycle`;
@@ -0,0 +1,9 @@
ALTER TABLE `acc_gl_journal_entry`
ADD COLUMN `loan_transaction_id` BIGINT(20) NULL AFTER `transaction_id`,
ADD COLUMN `savings_transaction_id` BIGINT(20) NULL AFTER `loan_transaction_id`,
ADD CONSTRAINT `FK_acc_gl_journal_entry_m_loan_transaction` FOREIGN KEY (`loan_transaction_id`) REFERENCES `m_loan_transaction` (`id`),
ADD CONSTRAINT `FK_acc_gl_journal_entry_m_savings_account_transaction` FOREIGN KEY (`savings_transaction_id`) REFERENCES `m_savings_account_transaction` (`id`);
UPDATE acc_gl_journal_entry je SET je.savings_transaction_id=je.transaction_id,je.transaction_id=Concat('S',je.transaction_id) WHERE je.entity_type_enum=2;
UPDATE acc_gl_journal_entry je SET je.loan_transaction_id=je.transaction_id,je.transaction_id=Concat('L',je.transaction_id) WHERE je.entity_type_enum=1;
@@ -0,0 +1,5 @@
UPDATE m_client mc SET mc.submittedon_date=mc.activation_date where mc.submittedon_date is NULL;
UPDATE m_client mc SET mc.submittedon_date=now() where mc.submittedon_date is NULL;
UPDATE m_group mg SET mg.submittedon_date=mg.activation_date where mg.submittedon_date is NULL;
UPDATE m_group mg SET mg.submittedon_date=now() where mg.submittedon_date is NULL;
@@ -0,0 +1 @@
update m_permission set grouping="organisation" where grouping = "organistion";
@@ -0,0 +1,12 @@
ALTER TABLE `c_configuration`
ADD COLUMN `value` INT NULL AFTER `name`;
INSERT INTO `c_configuration` (
`id` ,
`name` ,
`value` ,
`enabled`
)
VALUES (
NULL , 'penalty-wait-period', '2', '1'
);
@@ -0,0 +1 @@
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('transaction_loan', 'UNDOWRITEOFF_LOAN', 'LOAN', 'UNDOWRITEOFF', 0);
@@ -0,0 +1 @@
UPDATE stretchy_parameter SET `parameter_sql`='select p.id, p.`name`\r\nfrom m_product_loan p\r\nwhere (p.currency_code = \'${currencyId}\' or \'-1\'= \'${currencyId}\')\r\norder by 2' WHERE parameter_name='loanProductIdSelectAll';
@@ -0,0 +1 @@
ALTER TABLE `m_staff` ADD COLUMN `is_active` TINYINT(1) DEFAULT '0' AFTER `organisational_role_parent_staff_id`;
@@ -0,0 +1,18 @@
ALTER TABLE `m_product_loan`
ADD COLUMN `short_name` VARCHAR(4) NULL DEFAULT NULL AFTER `id`;
update m_product_loan set short_name=concat(LEFT(name,2), RIGHT(id,2)) where short_name is null;
ALTER TABLE `m_product_loan`
ALTER `short_name` DROP DEFAULT;
ALTER TABLE `m_product_loan`
CHANGE COLUMN `short_name` `short_name` VARCHAR(4) NOT NULL AFTER `id`;
ALTER TABLE `m_product_loan`
ADD UNIQUE INDEX `unq_short_name` (`short_name`);
ALTER TABLE `m_savings_product`
ADD COLUMN `short_name` VARCHAR(4) NULL DEFAULT NULL AFTER `name`;
update m_savings_product set short_name=concat(LEFT(name,2), RIGHT(id,2)) where short_name is null;
ALTER TABLE `m_savings_product`
ALTER `short_name` DROP DEFAULT;
ALTER TABLE `m_savings_product`
CHANGE COLUMN `short_name` `short_name` VARCHAR(4) NOT NULL AFTER `name`,
ADD UNIQUE INDEX `sp_unq_short_name` (`short_name`);
@@ -0,0 +1,3 @@
ALTER TABLE `m_staff`
CHANGE COLUMN `is_active` `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `organisational_role_parent_staff_id`;
UPDATE `m_staff` SET `is_active`=1;
@@ -0,0 +1,19 @@
/*
default client and group status is active 300. If you want to be able to have pending as the initial client stat
*/
INSERT INTO c_configuration (`name`, `enabled`) VALUES ('allow-pending-client-status', '0');
INSERT INTO c_configuration (`name`, `enabled`) VALUES ('allow-pending-group-status', '0');
INSERT INTO .`r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('status_id', '0', 'Invalid', 'Invalid');
INSERT INTO .`r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('status_id', '100', 'Pending', 'Pending');
INSERT INTO .`r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('status_id', '300', 'Active', 'Active');
INSERT INTO .`r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('status_id', '600', 'Closed', 'Closed');
INSERT INTO .`r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`)
VALUES ('loan_status_id', '0', 'Invalid', 'Invalid');
@@ -0,0 +1,3 @@
ALTER TABLE `acc_gl_journal_entry`
ADD COLUMN `payment_details_id` BIGINT(20) NULL AFTER `organization_running_balance`,
ADD CONSTRAINT `FK_acc_gl_journal_entry_m_payment_detail` FOREIGN KEY (`payment_details_id`) REFERENCES `m_payment_detail` (`id`);
@@ -0,0 +1,2 @@
ALTER TABLE `m_loan_charge`
ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `max_cap`;
@@ -0,0 +1,3 @@
INSERT INTO `ref_loan_transaction_processing_strategy` ( `code`, `name`)
VALUES
( 'early-repayment-strategy', 'Early Repayment Strategy');
@@ -0,0 +1 @@
insert into `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'READ_SAVINGSACCOUNTCHARGE', 'SAVINGSACCOUNTCHARGE', 'READ', 0);
@@ -0,0 +1 @@
insert into `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('accounting', 'CREATE_JOURNALENTRY_CHECKER', 'JOURNALENTRY', 'CREATE', 0);
@@ -0,0 +1,4 @@
RENAME TABLE `x_table_cloumn_code_mappings` TO `x_table_column_code_mappings`;
ALTER TABLE `acc_gl_journal_entry`
CHANGE COLUMN `is_running_balance_caculated` `is_running_balance_calculated` TINYINT(4) NOT NULL DEFAULT '0' AFTER `lastmodified_date`;
@@ -0,0 +1,17 @@
INSERT INTO `c_configuration` (`id`, `name`, `value`, `enabled`) VALUES (NULL, 'force-password-reset-days', '0', '0');
ALTER TABLE `m_appuser` ADD `last_time_password_updated` DATE NOT NULL ,
ADD INDEX ( `last_time_password_updated` ) ;
UPDATE `m_appuser` SET `last_time_password_updated` = NOW() WHERE `m_appuser`.`last_time_password_updated` ='0000-00-00';
CREATE TABLE IF NOT EXISTS `m_appuser_previous_password` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`password` varchar(255) NOT NULL,
`removal_date` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
ALTER TABLE m_appuser_previous_password
ADD FOREIGN KEY (user_id) REFERENCES m_appuser(id);
@@ -0,0 +1,38 @@
ALTER TABLE `m_product_loan`
ADD COLUMN `multi_disburse_loan` TINYINT(1) NOT NULL DEFAULT '0' AFTER `close_date`,
ADD COLUMN `max_tranche_count` INT(2) NULL DEFAULT NULL AFTER `multi_disburse_loan`,
ADD COLUMN `outstanding_loan_balance` DECIMAL(19,6) NULL DEFAULT NULL AFTER `max_tranche_count`;
CREATE TABLE `m_loan_disbursement_detail` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`loan_id` BIGINT(20) NOT NULL,
`expected_disburse_date` DATETIME NOT NULL,
`disbursedon_date` DATETIME NULL,
`principal` DECIMAL(19,6) NOT NULL,
`approved_principal` DECIMAL(19,6) NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `FK_loan_disbursement_detail_loan_id` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
ALTER TABLE `m_loan`
ADD COLUMN `fixed_emi_amount` DECIMAL(19,6) NULL AFTER `loan_product_counter`,
ADD COLUMN `approved_principal` DECIMAL(19,6) NOT NULL AFTER `principal_amount`,
ADD COLUMN `max_outstanding_loan_balance` DECIMAL(19,6) NULL DEFAULT NULL AFTER `fixed_emi_amount`;
UPDATE m_loan ml SET ml.approved_principal = ml.principal_amount;
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'UPDATE_DISBURSEMENTDETAIL', 'DISBURSEMENTDETAIL', 'UPDATE', 0);
CREATE TABLE `m_loan_term_variations` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`loan_id` BIGINT(20) NOT NULL,
`term_type` SMALLINT(2) NOT NULL,
`applicable_from` DATE NOT NULL,
`term_value` DECIMAL(19,6) NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `FK_loan_id_m_loan_id` FOREIGN KEY (`loan_id`) REFERENCES `m_loan` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
@@ -0,0 +1,4 @@
ALTER TABLE `m_product_loan`
CHANGE COLUMN `multi_disburse_loan` `allow_multiple_disbursals` TINYINT(1) NOT NULL DEFAULT '0' AFTER `close_date`,
CHANGE COLUMN `max_tranche_count` `max_disbursals` INT(2) NULL DEFAULT NULL AFTER `allow_multiple_disbursals`,
CHANGE COLUMN `outstanding_loan_balance` `max_outstanding_loan_balance` DECIMAL(19,6) NULL DEFAULT NULL AFTER `max_disbursals`;
@@ -0,0 +1,14 @@
ALTER TABLE `m_savings_product`
ADD COLUMN `allow_overdraft` TINYINT(1) NOT NULL DEFAULT '0' AFTER `withdrawal_fee_for_transfer`,
ADD COLUMN `overdraft_limit` DECIMAL(19,6) NULL DEFAULT NULL AFTER `allow_overdraft`;
ALTER TABLE `m_savings_account`
ADD COLUMN `allow_overdraft` TINYINT(1) NOT NULL DEFAULT '0' AFTER `withdrawal_fee_for_transfer`,
ADD COLUMN `overdraft_limit` DECIMAL(19,6) NULL DEFAULT NULL AFTER `allow_overdraft`;
ALTER TABLE `m_savings_account_transaction`
ADD COLUMN `overdraft_amount_derived` DECIMAL(19,6) NULL DEFAULT NULL AFTER `amount`;
ALTER TABLE `m_client`
ADD COLUMN `default_savings_product` BIGINT(20) NULL DEFAULT NULL AFTER `closedon_userid`,
ADD CONSTRAINT `FK_m_client_m_savings_product` FOREIGN KEY (`default_savings_product`) REFERENCES `m_savings_product` (`id`);
@@ -0,0 +1,4 @@
ALTER TABLE `m_savings_account_transaction`
ADD COLUMN `created_date` DATETIME NOT NULL AFTER `cumulative_balance_derived`;
update m_savings_account_transaction sat set sat.created_date=sat.transaction_date;
@@ -0,0 +1,8 @@
ALTER TABLE m_group CHANGE COLUMN `status_id` `status_enum` INT(5) NOT NULL DEFAULT '300' ;
ALTER TABLE m_client CHANGE COLUMN `status_id` `status_enum` INT(5) NOT NULL DEFAULT '300' ;
update r_enum_value
set enum_name = 'status_enum'
where enum_name = 'status_id';
@@ -0,0 +1,30 @@
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Savings Transactions', 'Pentaho', NULL, 'Savings', NULL, NULL, 0, 1);
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Client Savings Summary', 'Pentaho', NULL, 'Savings', NULL, NULL, 0, 1);
INSERT INTO `stretchy_parameter` (`parameter_name`, `parameter_variable`, `parameter_label`, `parameter_displayType`, `parameter_FormatType`, `parameter_default`, `special`, `selectOne`, `selectAll`, `parameter_sql`, `parent_id`) VALUES ( 'selectAccount', 'accountNo', 'Enter Account No', 'text', 'string', 'n/a', NULL, NULL, NULL, NULL, NULL);
INSERT INTO `stretchy_parameter` (`parameter_name`, `parameter_variable`, `parameter_label`, `parameter_displayType`, `parameter_FormatType`, `parameter_default`, `special`, `selectOne`, `selectAll`, `parameter_sql`, `parent_id`) VALUES ('savingsProductIdSelectAll', 'savingsProductId', 'Product', 'select', 'number', '0', NULL, NULL, 'Y', 'select p.id, p.`name`\r\nfrom m_savings_product p\r\norder by 2', NULL);
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Savings Transactions'), (select id from stretchy_parameter where parameter_name='startDateSelect'), 'fromDate');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Savings Transactions'), (select id from stretchy_parameter where parameter_name='endDateSelect'), 'toDate');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Savings Transactions'), (select id from stretchy_parameter where parameter_name='selectAccount'), 'accountNo');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Savings Summary'), (select id from stretchy_parameter where parameter_name='startDateSelect'), 'fromDate');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Savings Summary'), (select id from stretchy_parameter where parameter_name='endDateSelect'), 'toDate');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Savings Summary'), (select id from stretchy_parameter where parameter_name='OfficeIdSelectOne'), 'selectOffice');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Savings Summary'), (select id from stretchy_parameter where parameter_name='savingsProductIdSelectAll'), 'selectProduct');
ALTER TABLE `r_enum_value`
ADD COLUMN `enum_type` TINYINT(1) NOT NULL AFTER `enum_value`;
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 1, 'deposit', 'deposit', 0);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 2, 'withdrawal', 'withdrawal', 1);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 3, 'Interest Posting', 'Interest Posting', 0);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 4, 'Withdrawal Fee', 'Withdrawal Fee', 1);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 5, 'Annual Fee', 'Annual Fee', 1);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 6, 'Waive Charge', 'Waive Charge', 0);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 7, 'Pay Charge', 'Pay Charge', 1);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 12, 'Initiate Transfer', 'Initiate Transfer', 0);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 13, 'Approve Transfer', 'Approve Transfer', 0);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 14, 'Withdraw Transfer', 'Withdraw Transfer', 0);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 15, 'Reject Transfer', 'Reject Transfer', 0);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 16, 'Written-Off', 'Written-Off', 0);
INSERT INTO `r_enum_value` (`enum_name`, `enum_id`, `enum_message_property`, `enum_value`, `enum_type`) VALUES ('savings_transaction_type_enum', 17, 'Overdraft Interest', 'Overdraft Interest', 0);
@@ -0,0 +1,5 @@
ALTER TABLE `m_client`
ADD COLUMN `default_savings_account` BIGINT(20) NULL DEFAULT NULL AFTER `default_savings_product`,
ADD CONSTRAINT `FK_m_client_m_savings_account` FOREIGN KEY (`default_savings_account`) REFERENCES `m_savings_account` (`id`);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'UPDATESAVINGSACCOUNT_CLIENT', 'CLIENT', 'UPDATESAVINGSACCOUNT', 0);
@@ -0,0 +1,5 @@
ALTER TABLE `m_product_loan`
ADD COLUMN `grace_on_arrears_ageing` SMALLINT(5) NULL DEFAULT NULL AFTER `max_outstanding_loan_balance`;
ALTER TABLE `m_loan`
ADD COLUMN `grace_on_arrears_ageing` SMALLINT(5) NULL DEFAULT NULL AFTER `max_outstanding_loan_balance`;
@@ -0,0 +1,9 @@
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('accounting', 'READ_ACCOUNTINGRULE', 'ACCOUNTINGRULE', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('accounting', 'READ_JOURNALENTRY', 'JOURNALENTRY', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('accounting', 'READ_GLACCOUNT', 'GLACCOUNT', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('accounting', 'READ_GLCLOSURE', 'GLCLOSURE', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('organisation', 'READ_HOLIDAY', 'HOLIDAY', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('jobs', 'READ_SCHEDULER', 'SCHEDULER', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'READ_PRODUCTMIX', 'PRODUCTMIX', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'READ_MEETING', 'MEETING', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('jobs', 'EXECUTEJOB_SCHEDULER', 'SCHEDULER', 'EXECUTEJOB', 0);
@@ -0,0 +1 @@
UPDATE `stretchy_report` SET `report_sql`='\r\nSELECT \r\nconcat(repeat("..", \r\n ((LENGTH(ounder.`hierarchy`) - LENGTH(REPLACE(ounder.`hierarchy`, \'.\', \'\')) - 1))), ounder.`name`) as "Office/Branch",\r\nifnull(cur.display_symbol, ml.currency_code) as Currency, \r\nmc.account_no as "Client Account No.",\r\n mc.display_name AS "Client Name",\r\n ml.account_no AS "Account Number",\r\n ml.principal_amount AS "Loan Amount",\r\n ml.principal_disbursed_derived AS "Original Principal",\r\n ml.interest_charged_derived AS "Original Interest",\r\n ml.principal_repaid_derived AS "Principal Paid",\r\n ml.interest_repaid_derived AS "Interest Paid",\r\n laa.principal_overdue_derived AS "Principal Overdue",\r\n laa.interest_overdue_derived AS "Interest Overdue",\r\nDATEDIFF(CURDATE(), laa.overdue_since_date_derived) as "Days in Arrears",\r\n\r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<7, \'<1\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<8, \' 1\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<15, \'2\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<22, \' 3\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<29, \' 4\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<36, \' 5\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<43, \' 6\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<50, \' 7\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<57, \' 8\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<64, \' 9\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<71, \'10\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<78, \'11\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<85, \'12\', \'12+\')))))))))))) )AS "Weeks In Arrears Band",\r\n\r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<31, \'0 - 30\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<61, \'30 - 60\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<91, \'60 - 90\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<181, \'90 - 180\', \r\n IF(DATEDIFF(CURDATE(), laa.overdue_since_date_derived)<361, \'180 - 360\', \r\n \'> 360\'))))) AS "Days in Arrears Band"\r\n\r\n FROM m_office mo \r\n JOIN m_office ounder ON ounder.hierarchy like concat(mo.hierarchy, \'%\')\r\n AND ounder.hierarchy like CONCAT(\'${currentUserHierarchy}\', \'%\')\r\n INNER JOIN m_client mc ON mc.office_id=ounder.id\r\n INNER JOIN m_loan ml ON ml.client_id = mc.id\r\n INNER JOIN r_enum_value rev ON rev.enum_id=ml.loan_status_id AND rev.enum_name = \'loan_status_id\'\r\n INNER JOIN m_loan_arrears_aging laa ON laa.loan_id=ml.id\r\n left join m_currency cur on cur.code = ml.currency_code\r\n WHERE ml.loan_status_id=300\r\n AND mo.id=${officeId}\r\nORDER BY ounder.hierarchy, ifnull(cur.display_symbol, ml.currency_code), ml.account_no\r\n' WHERE `report_name`='Aging Detail';
@@ -0,0 +1,718 @@
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report)VALUES ("Active Loans - Details(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Active Loans - Summary(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Active Loans by Disbursal Period(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Active Loans in last installment Summary(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report)VALUES ("Active Loans in last installment(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Active Loans Passed Final Maturity Summary(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Active Loans Passed Final Maturity(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Aging Detail(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Aging Summary (Arrears in Months)(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Aging Summary (Arrears in Weeks)(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Client Listing(Pentaho)", 'Pentaho', 'Client', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Client Loans Listing(Pentaho)", 'Pentaho', 'Client', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Expected Payments By Date - Basic(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Funds Disbursed Between Dates Summary by Office(Pentaho)", 'Pentaho', 'Fund', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Funds Disbursed Between Dates Summary(Pentaho)", 'Pentaho', 'Fund', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Loans Awaiting Disbursal Summary by Month(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Loans Awaiting Disbursal Summary(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Loans Awaiting Disbursal(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Loans Pending Approval(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Obligation Met Loans Details(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Obligation Met Loans Summary(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Portfolio at Risk by Branch(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Portfolio at Risk(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Rescheduled Loans(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("TxnRunningBalances(Pentaho)", 'Pentaho', 'Transaction', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report (report_name, report_type, report_category, report_sql, description, core_report, use_report) VALUES ("Written-Off Loans(Pentaho)", 'Pentaho', 'Loan', '(NULL)', '(NULL)', 1, 1);
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name) VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Details(Pentaho)'),(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),'branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name) VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Details(Pentaho)'),(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'loanOfficer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name) VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Details(Pentaho)'),(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'currencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name) VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Details(Pentaho)'),(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name) VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Details(Pentaho)'),(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name) VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Details(Pentaho)'),(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'loanOfficer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans - Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='parTypeSelect'),
'parType');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans by Disbursal Period(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans by Disbursal Period(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'loanOfficer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans by Disbursal Period(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans by Disbursal Period(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans by Disbursal Period(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans by Disbursal Period(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans by Disbursal Period(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='startDateSelect'),
'startDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans by Disbursal Period(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='endDateSelect'),
'endDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='parTypeSelect'),
'parType');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans in last installment(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='parTypeSelect'),
'parType');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Active Loans Passed Final Maturity(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Aging Detail(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Aging Summary (Arrears in Months)(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Aging Summary (Arrears in Months)(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Aging Summary (Arrears in Weeks)(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Aging Summary (Arrears in Weeks)(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Client Listing(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'selectOffice');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Client Loans Listing(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Client Loans Listing(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Client Loans Listing(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Client Loans Listing(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Client Loans Listing(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Client Loans Listing(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Expected Payments By Date - Basic(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Expected Payments By Date - Basic(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Expected Payments By Date - Basic(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='startDateSelect'),
'startDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Expected Payments By Date - Basic(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='endDateSelect'),
'endDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Funds Disbursed Between Dates Summary by Office(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Funds Disbursed Between Dates Summary by Office(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Funds Disbursed Between Dates Summary by Office(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Funds Disbursed Between Dates Summary by Office(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='startDateSelect'),
'startDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Funds Disbursed Between Dates Summary by Office(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='endDateSelect'),
'endDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Funds Disbursed Between Dates Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Funds Disbursed Between Dates Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Funds Disbursed Between Dates Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='startDateSelect'),
'startDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Funds Disbursed Between Dates Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='endDateSelect'),
'endDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary by Month(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary by Month(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary by Month(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary by Month(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary by Month(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary by Month(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Awaiting Disbursal(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Pending Approval(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Pending Approval(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Pending Approval(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Pending Approval(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Pending Approval(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Loans Pending Approval(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Details(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Details(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Details(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Details(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Details(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Details(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Details(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='startDateSelect'),
'startDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Details(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='endDateSelect'),
'endDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Details(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='obligDateTypeSelect'),
'obligDateType');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='startDateSelect'),
'Startdate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='endDateSelect'),
'Enddate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Obligation Met Loans Summary(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='obligDateTypeSelect'),
'obligDateType');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk by Branch(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk by Branch(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk by Branch(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk by Branch(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk by Branch(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk by Branch(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk by Branch(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='parTypeSelect'),
'parType');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'loanOfficer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='fundIdSelectAll'),
'fundId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanPurposeIdSelectAll'),
'loanPurposeId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Portfolio at Risk(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='parTypeSelect'),
'parType');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Rescheduled Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Rescheduled Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Rescheduled Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Rescheduled Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='startDateSelect'),
'startDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Rescheduled Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='endDateSelect'),
'endDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='TxnRunningBalances(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='TxnRunningBalances(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanOfficerIdSelectAll'),
'Loan Officer');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='TxnRunningBalances(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='startDateSelect'),
'startDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='TxnRunningBalances(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='endDateSelect'),
'endDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Written-Off Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='OfficeIdSelectOne'),
'Branch');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Written-Off Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='currencyIdSelectAll'),
'CurrencyId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Written-Off Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='loanProductIdSelectAll'),
'loanProductId');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Written-Off Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='startDateSelect'),
'startDate');
INSERT INTO stretchy_report_parameter (report_id, parameter_id, report_parameter_name)
VALUES ((select sr.id From stretchy_report sr where sr.report_name='Written-Off Loans(Pentaho)'),
(select sp.id from stretchy_parameter sp where sp.parameter_name='endDateSelect'),
'endDate');
@@ -0,0 +1,9 @@
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Client Saving Transactions', 'Pentaho', NULL, 'Savings', NULL, NULL, 0, 0);
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Saving Transactions'), (select id from stretchy_parameter where parameter_name='startDateSelect'), 'startDate');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Saving Transactions'), (select id from stretchy_parameter where parameter_name='endDateSelect'), 'endDate');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Saving Transactions'), (select id from stretchy_parameter where parameter_name='selectAccount'), 'accountNo');
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Client Loan Account Schedule', 'Pentaho', NULL, 'Loans', NULL, NULL, 0, 0);
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Loan Account Schedule'), (select id from stretchy_parameter where parameter_name='startDateSelect'), 'startDate');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Loan Account Schedule'), (select id from stretchy_parameter where parameter_name='endDateSelect'), 'endDate');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select id from stretchy_report where report_name = 'Client Loan Account Schedule'), (select id from stretchy_parameter where parameter_name='selectAccount'), 'accountNo');
@@ -0,0 +1,18 @@
ALTER TABLE `m_charge`
ADD COLUMN `fee_frequency` SMALLINT(5) NULL DEFAULT NULL AFTER `max_cap`;
CREATE TABLE `m_loan_overdue_installment_charge` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`loan_charge_id` BIGINT(20) NOT NULL,
`loan_schedule_id` BIGINT(20) NOT NULL,
`frequency_number` INT(10) NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `FK_m_loan_overdue_installment_charge_m_loan_charge` FOREIGN KEY (`loan_charge_id`) REFERENCES `m_loan_charge` (`id`),
CONSTRAINT `FK_m_loan_overdue_installment_charge_m_loan_repayment_schedule` FOREIGN KEY (`loan_schedule_id`) REFERENCES `m_loan_repayment_schedule` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
INSERT INTO `c_configuration` (`name`, `value`, `enabled`) VALUES ('grace-on-penalty-posting', 0, 1);
INSERT INTO m_loan_overdue_installment_charge (`loan_charge_id`, `loan_schedule_id`, `frequency_number`) SELECT mlc.id ,ls.id ,1 from m_loan_charge as mlc inner join m_charge mc on mc.id = mlc.charge_id inner join m_loan_repayment_schedule ls on ls.loan_id = mlc.loan_id and ls.duedate = mlc.due_for_collection_as_of_date where mc.charge_time_enum = 9 and mlc.is_active = 1;
@@ -0,0 +1,17 @@
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('GroupNamesByStaff', 'Table', '', '', 'Select gr.id as id, gr.display_name as name from m_group gr where gr.level_id=1 and gr.staff_id = ${staffId}', '', 0, 1);
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('ClientTrendsByDay', 'Table', '', 'Client', 'SELECT COUNT(cl.id) AS count, \n cl.activation_date AS days\nFROM m_office of \n LEFT JOIN m_client cl on of.id = cl.office_id\nWHERE of.hierarchy like concat((select ino.hierarchy from m_office ino where ino.id = ${officeId}),"%" ) \n AND (cl.activation_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 DAY) AND DATE(NOW()- INTERVAL 1 DAY))\nGROUP BY days', 'Retrieves the number of clients joined in last 12 days', 0, 1);
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('ClientTrendsByWeek', 'Table', '', 'Client', 'SELECT COUNT(cl.id) AS count, \n WEEK(cl.activation_date) AS Weeks\nFROM m_office of \n LEFT JOIN m_client cl on of.id = cl.office_id\nWHERE of.hierarchy like concat((select ino.hierarchy from m_office ino where ino.id = ${officeId}),"%" ) \n AND (cl.activation_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 WEEK) AND DATE(NOW()))\nGROUP BY Weeks', '', 0, 1);
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('ClientTrendsByMonth', 'Table', '', 'Client', 'SELECT COUNT(cl.id) AS count, \n MONTHNAME(cl.activation_date) AS Months\nFROM m_office of \n LEFT JOIN m_client cl on of.id = cl.office_id\nWHERE of.hierarchy like concat((select ino.hierarchy from m_office ino where ino.id = ${officeId}),"%" ) \n AND (cl.activation_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 MONTH) AND DATE(NOW()))\nGROUP BY Months', '', 0, 1);
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('LoanTrendsByDay', 'Table', '', 'Loan', 'SELECT COUNT(ln.id) AS lcount, \n ln.disbursedon_date AS days\nFROM m_office of \n LEFT JOIN m_client cl on of.id = cl.office_id\n LEFT JOIN m_loan ln on cl.id = ln.client_id\nWHERE of.hierarchy like concat((select ino.hierarchy from m_office ino where ino.id = ${officeId}),"%" ) \n AND (ln.disbursedon_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 DAY) AND DATE(NOW()- INTERVAL 1 DAY))\nGROUP BY days', 'Retrieves Number of loans disbursed for last 12 days', 0, 1);
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('LoanTrendsByWeek', 'Table', '', 'Loan', 'SELECT COUNT(ln.id) AS lcount, \n WEEK(ln.disbursedon_date) AS Weeks\nFROM m_office of \n LEFT JOIN m_client cl on of.id = cl.office_id\n LEFT JOIN m_loan ln on cl.id = ln.client_id\nWHERE of.hierarchy like concat((select ino.hierarchy from m_office ino where ino.id = ${officeId}),"%" ) \n AND (ln.disbursedon_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 WEEK) AND DATE(NOW()))\nGROUP BY Weeks', '', 0, 1);
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('LoanTrendsByMonth', 'Table', '', 'Loan', 'SELECT COUNT(ln.id) AS lcount, \n MONTHNAME(ln.disbursedon_date) AS Months\nFROM m_office of \n LEFT JOIN m_client cl on of.id = cl.office_id\n LEFT JOIN m_loan ln on cl.id = ln.client_id\nWHERE of.hierarchy like concat((select ino.hierarchy from m_office ino where ino.id = ${officeId}),"%" ) \n AND (ln.disbursedon_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 12 MONTH) AND DATE(NOW()))\nGROUP BY Months', '', 0, 1);
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Demand_Vs_Collection', 'Table', '', 'Loan', 'select amount.AmountDue-amount.AmountPaid as AmountDue, amount.AmountPaid as AmountPaid from\n(SELECT \n(IFNULL(SUM(ls.principal_amount),0) - IFNULL(SUM(ls.principal_writtenoff_derived),0)\n + IFNULL(SUM(ls.interest_amount),0) - IFNULL(SUM(ls.interest_writtenoff_derived),0) \n - IFNULL(SUM(ls.interest_waived_derived),0)\n + IFNULL(SUM(ls.fee_charges_amount),0) - IFNULL(SUM(ls.fee_charges_writtenoff_derived),0) \n - IFNULL(SUM(ls.fee_charges_waived_derived),0)\n + IFNULL(SUM(ls.penalty_charges_amount),0) - IFNULL(SUM(ls.penalty_charges_writtenoff_derived),0) \n - IFNULL(SUM(ls.penalty_charges_waived_derived),0)\n) AS AmountDue, \n\n(IFNULL(SUM(ls.principal_completed_derived),0) - IFNULL(SUM(ls.principal_writtenoff_derived),0) + IFNULL(SUM(ls.interest_completed_derived),0) - IFNULL(SUM(ls.interest_writtenoff_derived),0) \n - IFNULL(SUM(ls.interest_waived_derived),0)\n + IFNULL(SUM(ls.fee_charges_completed_derived),0) - IFNULL(SUM(ls.fee_charges_writtenoff_derived),0) \n - IFNULL(SUM(ls.fee_charges_waived_derived),0)\n + IFNULL(SUM(ls.penalty_charges_completed_derived),0) - IFNULL(SUM(ls.penalty_charges_writtenoff_derived),0) \n - IFNULL(SUM(ls.penalty_charges_waived_derived),0)\n) AS AmountPaid\nFROM m_office of\nLEFT JOIN m_client cl ON of.id = cl.office_id\nLEFT JOIN m_loan ln ON cl.id = ln.client_id\nLEFT JOIN m_loan_repayment_schedule ls ON ln.id = ls.loan_id\nWHERE ls.duedate = DATE(NOW()) AND \n (of.hierarchy LIKE CONCAT((\nSELECT ino.hierarchy\nFROM m_office ino\nWHERE ino.id = ${officeId}),"%"))) as amount', 'Demand Vs Collection', 0, 1);
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_category`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Disbursal_Vs_Awaitingdisbursal', 'Table', '', 'Loan', 'select awaitinddisbursal.amount-disbursedAmount.amount as amountToBeDisburse, disbursedAmount.amount as disbursedAmount from \n(\nSELECT COUNT(ln.id) AS noOfLoans, \n IFNULL(SUM(ln.principal_amount),0) AS amount\nFROM \nm_office of\nLEFT JOIN m_client cl ON cl.office_id = of.id\nLEFT JOIN m_loan ln ON cl.id = ln.client_id\nWHERE \nln.expected_disbursedon_date = DATE(NOW()) AND \n(ln.loan_status_id=200 OR ln.loan_status_id=300) AND\n of.hierarchy like concat((select ino.hierarchy from m_office ino where ino.id = ${officeId}),"%" )\n) awaitinddisbursal,\n(\nSELECT COUNT(ltrxn.id) as count, \n IFNULL(SUM(ltrxn.amount),0) as amount \nFROM \nm_office of\nLEFT JOIN m_client cl ON cl.office_id = of.id\nLEFT JOIN m_loan ln ON cl.id = ln.client_id\nLEFT JOIN m_loan_transaction ltrxn ON ln.id = ltrxn.loan_id\nWHERE \nltrxn.transaction_date = DATE(NOW()) AND \nltrxn.transaction_type_enum=1 AND\n of.hierarchy like concat((select ino.hierarchy from m_office ino where ino.id = ${officeId}),"%" ) \n) disbursedAmount', 'Disbursal_Vs_Awaitingdisbursal', 0, 1);
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select sr.id from stretchy_report sr where sr.report_name = 'ClientTrendsByDay'), (select sp.id from stretchy_parameter sp where sp.parameter_name = 'OfficeIdSelectOne'), '');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select sr.id from stretchy_report sr where sr.report_name = 'ClientTrendsByWeek'), (select sp.id from stretchy_parameter sp where sp.parameter_name = 'OfficeIdSelectOne'), '');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select sr.id from stretchy_report sr where sr.report_name = 'ClientTrendsByMonth'), (select sp.id from stretchy_parameter sp where sp.parameter_name = 'OfficeIdSelectOne'), '');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select sr.id from stretchy_report sr where sr.report_name = 'LoanTrendsByDay'), (select sp.id from stretchy_parameter sp where sp.parameter_name = 'OfficeIdSelectOne'), '');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select sr.id from stretchy_report sr where sr.report_name = 'LoanTrendsByWeek'), (select sp.id from stretchy_parameter sp where sp.parameter_name = 'OfficeIdSelectOne'), '');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select sr.id from stretchy_report sr where sr.report_name = 'LoanTrendsByMonth'), (select sp.id from stretchy_parameter sp where sp.parameter_name = 'OfficeIdSelectOne'), '');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select sr.id from stretchy_report sr where sr.report_name = 'Demand_Vs_Collection'), (select sp.id from stretchy_parameter sp where sp.parameter_name = 'OfficeIdSelectOne'), '');
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`) VALUES ((select sr.id from stretchy_report sr where sr.report_name = 'Disbursal_Vs_Awaitingdisbursal'), (select sp.id from stretchy_parameter sp where sp.parameter_name = 'OfficeIdSelectOne'), '');
@@ -0,0 +1,2 @@
ALTER TABLE `m_portfolio_command_source`
ADD COLUMN `transaction_id` VARCHAR(100) NULL DEFAULT NULL AFTER `product_id`;
@@ -0,0 +1,7 @@
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'READ_CENTER', 'CENTER', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'CREATE_CENTER', 'CENTER', 'CREATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'CREATE_CENTER_CHECKER', 'CENTER', 'CREATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'UPDATE_CENTER', 'CENTER', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'UPDATE_CENTER_CHECKER', 'CENTER', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'DELETE_CENTER', 'CENTER', 'DELETE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'DELETE_CENTER_CHECKER', 'CENTER', 'DELETE', 0);
@@ -0,0 +1 @@
ALTER TABLE `m_product_loan` CHANGE `principal_amount` `principal_amount` DECIMAL( 19, 6 ) NULL ;
@@ -0,0 +1,125 @@
CREATE TABLE `m_account_transfer_details` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`from_office_id` BIGINT(20) NOT NULL,
`to_office_id` BIGINT(20) NOT NULL,
`from_client_id` BIGINT(20) NULL DEFAULT NULL,
`to_client_id` BIGINT(20) NULL DEFAULT NULL,
`from_savings_account_id` BIGINT(20) NULL DEFAULT NULL,
`to_savings_account_id` BIGINT(20) NULL DEFAULT NULL,
`from_loan_account_id` BIGINT(20) NULL DEFAULT NULL,
`to_loan_account_id` BIGINT(20) NULL DEFAULT NULL,
`transfer_type` SMALLINT(2) NULL DEFAULT NULL,
`from_savings_transaction_id` BIGINT(20) NULL DEFAULT NULL,
`from_loan_transaction_id` BIGINT(20) NULL DEFAULT NULL,
`to_savings_transaction_id` BIGINT(20) NULL DEFAULT NULL,
`to_loan_transaction_id` BIGINT(20) NULL DEFAULT NULL,
`is_reversed` TINYINT(1) NOT NULL,
`transaction_date` DATE NOT NULL,
`currency_code` VARCHAR(3) NOT NULL,
`currency_digits` SMALLINT(5) NOT NULL,
`currency_multiplesof` SMALLINT(5) NULL DEFAULT NULL,
`amount` DECIMAL(19,6) NOT NULL,
`description` VARCHAR(200) NOT NULL,
PRIMARY KEY (`id`),
INDEX `FK_m_account_transfer_details_from_office` (`from_office_id`),
INDEX `FK_m_account_transfer_details_to_office` (`to_office_id`),
INDEX `FK_m_account_transfer_details_from_client` (`from_client_id`),
INDEX `FK_m_account_transfer_details_to_client` (`to_client_id`),
INDEX `FK_m_account_transfer_details_from_savings_account` (`from_savings_account_id`),
INDEX `FK_m_account_transfer_details_to_savings_account` (`to_savings_account_id`),
INDEX `FK_m_account_transfer_details_from_loan_account` (`from_loan_account_id`),
INDEX `FK_m_account_transfer_details_to_loan_account` (`to_loan_account_id`),
CONSTRAINT `FK_m_account_transfer_details_from_client` FOREIGN KEY (`from_client_id`) REFERENCES `m_client` (`id`),
CONSTRAINT `FK_m_account_transfer_details_from_loan_account` FOREIGN KEY (`from_loan_account_id`) REFERENCES `m_loan` (`id`),
CONSTRAINT `FK_m_account_transfer_details_from_office` FOREIGN KEY (`from_office_id`) REFERENCES `m_office` (`id`),
CONSTRAINT `FK_m_account_transfer_details_from_savings_account` FOREIGN KEY (`from_savings_account_id`) REFERENCES `m_savings_account` (`id`),
CONSTRAINT `FK_m_account_transfer_details_to_client` FOREIGN KEY (`to_client_id`) REFERENCES `m_client` (`id`),
CONSTRAINT `FK_m_account_transfer_details_to_loan_account` FOREIGN KEY (`to_loan_account_id`) REFERENCES `m_loan` (`id`),
CONSTRAINT `FK_m_account_transfer_details_to_office` FOREIGN KEY (`to_office_id`) REFERENCES `m_office` (`id`),
CONSTRAINT `FK_m_account_transfer_details_to_savings_account` FOREIGN KEY (`to_savings_account_id`) REFERENCES `m_savings_account` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
CREATE TABLE `m_account_transfer_standing_instructions` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(250) NOT NULL,
`account_transfer_details_id` BIGINT(20) NOT NULL,
`priority` TINYINT(2) NOT NULL,
`status` TINYINT(2) NOT NULL,
`instruction_type` TINYINT(2) NOT NULL,
`amount` DECIMAL(19,6) NULL DEFAULT NULL,
`valid_from` DATE NOT NULL,
`valid_till` DATE NULL DEFAULT NULL,
`recurrence_type` TINYINT(1) NOT NULL,
`recurrence_frequency` SMALLINT(5) NULL DEFAULT NULL,
`recurrence_interval` SMALLINT(5) NULL DEFAULT NULL,
`recurrence_on_day` SMALLINT(2) NULL DEFAULT NULL,
`recurrence_on_month` SMALLINT(2) NULL DEFAULT NULL,
`last_run_date` DATE NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `name` (`name`),
INDEX `FK_m_standing_instructions_account_transfer_details` (`account_transfer_details_id`),
CONSTRAINT `FK_m_standing_instructions_account_transfer_details` FOREIGN KEY (`account_transfer_details_id`) REFERENCES `m_account_transfer_details` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
CREATE TABLE `m_account_transfer_transaction` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`account_transfer_details_id` BIGINT(20) NOT NULL,
`from_savings_transaction_id` BIGINT(20) NULL DEFAULT NULL,
`from_loan_transaction_id` BIGINT(20) NULL DEFAULT NULL,
`to_savings_transaction_id` BIGINT(20) NULL DEFAULT NULL,
`to_loan_transaction_id` BIGINT(20) NULL DEFAULT NULL,
`is_reversed` TINYINT(1) NOT NULL,
`transaction_date` DATE NOT NULL,
`currency_code` VARCHAR(3) NOT NULL,
`currency_digits` SMALLINT(5) NOT NULL,
`currency_multiplesof` SMALLINT(5) NULL DEFAULT NULL,
`amount` DECIMAL(19,6) NOT NULL,
`description` VARCHAR(200) NOT NULL,
PRIMARY KEY (`id`),
INDEX `FK_m_account_transfer_transaction_from_m_savings_transaction` (`from_savings_transaction_id`),
INDEX `FK_m_account_transfer_transaction_to_m_savings_transaction` (`to_savings_transaction_id`),
INDEX `FK_m_account_transfer_transaction_to_m_loan_transaction` (`to_loan_transaction_id`),
INDEX `FK_m_account_transfer_transaction_from_m_loan_transaction` (`from_loan_transaction_id`),
INDEX `FK_m_account_transfer_transaction_account_detail` (`account_transfer_details_id`),
CONSTRAINT `FK_m_account_transfer_transaction_account_detail` FOREIGN KEY (`account_transfer_details_id`) REFERENCES `m_account_transfer_details` (`id`),
CONSTRAINT `FK_m_account_transfer_transaction_from_m_loan_transaction` FOREIGN KEY (`from_loan_transaction_id`) REFERENCES `m_loan_transaction` (`id`),
CONSTRAINT `FK_m_account_transfer_transaction_from_m_savings_transaction` FOREIGN KEY (`from_savings_transaction_id`) REFERENCES `m_savings_account_transaction` (`id`),
CONSTRAINT `FK_m_account_transfer_transaction_to_m_loan_transaction` FOREIGN KEY (`to_loan_transaction_id`) REFERENCES `m_loan_transaction` (`id`),
CONSTRAINT `FK_m_account_transfer_transaction_to_m_savings_transaction` FOREIGN KEY (`to_savings_transaction_id`) REFERENCES `m_savings_account_transaction` (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
INSERT INTO `m_account_transfer_details` (`from_office_id`, `to_office_id`, `from_client_id`, `to_client_id`, `from_savings_account_id`, `to_savings_account_id`, `from_loan_account_id`, `to_loan_account_id`, `from_savings_transaction_id`, `from_loan_transaction_id`, `to_savings_transaction_id`, `to_loan_transaction_id`, `is_reversed`, `transaction_date`, `currency_code`, `currency_digits`, `currency_multiplesof`, `amount`, `description`) select at.from_office_id,at.to_office_id,at.from_client_id,at.to_client_id,at.from_savings_account_id,at.to_savings_account_id,at.from_loan_account_id,at.to_loan_account_id,at.from_savings_transaction_id,at.from_loan_transaction_id,at.to_savings_transaction_id,at.to_loan_transaction_id,at.is_reversed,at.transaction_date,at.currency_code,at.currency_digits,at.currency_multiplesof,at.amount,at.description from m_savings_account_transfer at;
INSERT INTO `m_account_transfer_transaction` (`account_transfer_details_id`, `from_savings_transaction_id`, `from_loan_transaction_id`, `to_savings_transaction_id`, `to_loan_transaction_id`, `is_reversed`, `transaction_date`, `currency_code`, `currency_digits`, `currency_multiplesof`, `amount`, `description`) select ad.id,ad.from_savings_transaction_id,ad.from_loan_transaction_id,ad.to_savings_transaction_id,ad.to_loan_transaction_id,ad.is_reversed,ad.transaction_date,ad.currency_code,ad.currency_digits,ad.currency_multiplesof,ad.amount,ad.description from m_account_transfer_details ad;
ALTER TABLE `m_account_transfer_details`
DROP COLUMN `from_savings_transaction_id`,
DROP COLUMN `from_loan_transaction_id`,
DROP COLUMN `to_savings_transaction_id`,
DROP COLUMN `to_loan_transaction_id`,
DROP COLUMN `is_reversed`,
DROP COLUMN `transaction_date`,
DROP COLUMN `currency_code`,
DROP COLUMN `currency_digits`,
DROP COLUMN `currency_multiplesof`,
DROP COLUMN `amount`,
DROP COLUMN `description`;
DROP TABLE `m_savings_account_transfer`;
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('account_transfer', 'READ_STANDINGINSTRUCTION ', 'STANDINGINSTRUCTION ', 'READ', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('account_transfer', 'CREATE_STANDINGINSTRUCTION ', 'STANDINGINSTRUCTION ', 'CREATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('account_transfer', 'UPDATE_STANDINGINSTRUCTION ', 'STANDINGINSTRUCTION ', 'UPDATE', 0);
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('account_transfer', 'DELETE_STANDINGINSTRUCTION ', 'STANDINGINSTRUCTION ', 'DELETE', 0);
INSERT INTO `job` (`name`, `display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `job_key`, `initializing_errorlog`, `is_active`, `currently_running`, `updates_allowed`, `scheduler_group`, `is_misfired`) VALUES ('Execute Standing Instruction', 'Execute Standing Instruction', '0 0 0 1/1 * ? *', now(), 5, NULL, NULL, NULL, NULL, NULL, 1, 0, 1, 0, 0);

Some files were not shown because too many files have changed in this diff Show More