Resolving compilation issues with Email Campaigns Feature and resolving 322.2 migration script issue
This commit is contained in:
+2
-1
@@ -3039,7 +3039,8 @@ public class CommandWrapperBuilder {
|
||||
this.entityId = adHocId;
|
||||
this.href = "/adhocquery/" + adHocId;
|
||||
this.json = "{}";
|
||||
|
||||
return this ;
|
||||
}
|
||||
public CommandWrapperBuilder createEmail() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "EMAIL";
|
||||
|
||||
+27
-43
@@ -29,9 +29,7 @@ import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSer
|
||||
import org.apache.fineract.infrastructure.core.service.Page;
|
||||
import org.apache.fineract.infrastructure.core.service.SearchParameters;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.data.EmailConfigurationData;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.data.EmailData;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.service.EmailConfigurationReadPlatformService;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.service.EmailReadPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -41,9 +39,9 @@ import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Path("/email")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@@ -58,71 +56,61 @@ public class EmailApiResource {
|
||||
private final DefaultToApiJsonSerializer<EmailData> toApiJsonSerializer;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private final EmailConfigurationReadPlatformService emailConfigurationReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public EmailApiResource(final PlatformSecurityContext context, final EmailReadPlatformService readPlatformService,
|
||||
final DefaultToApiJsonSerializer<EmailData> toApiJsonSerializer, final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
|
||||
EmailConfigurationReadPlatformService emailConfigurationReadPlatformService) {
|
||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||
this.context = context;
|
||||
this.readPlatformService = readPlatformService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
this.emailConfigurationReadPlatformService = emailConfigurationReadPlatformService;
|
||||
}
|
||||
|
||||
@GET
|
||||
public String retrieveAllEmails(@Context final UriInfo uriInfo) {
|
||||
|
||||
public String retrieveAllEmails(@Context final UriInfo uriInfo) {
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final Collection<EmailData> emailMessages = this.readPlatformService.retrieveAll();
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, emailMessages);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("pendingEmail")
|
||||
public String retrievePendingEmail(@QueryParam("sqlSearch") final String sqlSearch,
|
||||
@QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit,
|
||||
@QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, @Context final UriInfo uriInfo) {
|
||||
public String retrievePendingEmail(@QueryParam("sqlSearch") final String sqlSearch, @QueryParam("offset") final Integer offset,
|
||||
@QueryParam("limit") final Integer limit, @QueryParam("orderBy") final String orderBy,
|
||||
@QueryParam("sortOrder") final String sortOrder, @Context final UriInfo uriInfo) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final SearchParameters searchParameters = SearchParameters.forEmailCampaign(sqlSearch, offset, limit, orderBy, sortOrder);
|
||||
Page<EmailData> emailMessages = this.readPlatformService.retrieveAllPending(searchParameters);
|
||||
|
||||
final SearchParameters searchParameters = SearchParameters.forEmailCampaign(sqlSearch, offset, limit, orderBy, sortOrder);
|
||||
Collection<EmailData> emailMessages = this.readPlatformService.retrieveAllPending(searchParameters);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, emailMessages);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("sentEmail")
|
||||
public String retrieveSentEmail(@QueryParam("sqlSearch") final String sqlSearch,
|
||||
@QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit,
|
||||
@QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, @Context final UriInfo uriInfo) {
|
||||
public String retrieveSentEmail(@QueryParam("sqlSearch") final String sqlSearch, @QueryParam("offset") final Integer offset,
|
||||
@QueryParam("limit") final Integer limit, @QueryParam("orderBy") final String orderBy,
|
||||
@QueryParam("sortOrder") final String sortOrder, @Context final UriInfo uriInfo) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final SearchParameters searchParameters = SearchParameters.forEmailCampaign(sqlSearch, offset, limit, orderBy, sortOrder);
|
||||
Page<EmailData> emailMessages = this.readPlatformService.retrieveAllSent(searchParameters);
|
||||
final SearchParameters searchParameters = SearchParameters.forEmailCampaign(sqlSearch, offset, limit, orderBy, sortOrder);
|
||||
Collection<EmailData> emailMessages = this.readPlatformService.retrieveAllSent(searchParameters);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, emailMessages);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("messageByStatus")
|
||||
public String retrieveAllEmailByStatus(@QueryParam("sqlSearch") final String sqlSearch,
|
||||
@QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit,
|
||||
@QueryParam("status") final Long status,
|
||||
@QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder,
|
||||
@QueryParam("fromDate") final DateParam fromDateParam, @QueryParam("toDate") final DateParam toDateParam,
|
||||
@QueryParam("locale") final String locale, @QueryParam("dateFormat") final String dateFormat,@Context final UriInfo uriInfo) {
|
||||
public String retrieveAllEmailByStatus(@QueryParam("sqlSearch") final String sqlSearch, @QueryParam("offset") final Integer offset,
|
||||
@QueryParam("limit") final Integer limit, @QueryParam("status") final Integer status,
|
||||
@QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder,
|
||||
@QueryParam("fromDate") final DateParam fromDateParam, @QueryParam("toDate") final DateParam toDateParam,
|
||||
@QueryParam("locale") final String locale, @QueryParam("dateFormat") final String dateFormat, @Context final UriInfo uriInfo) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
Date fromDate = null;
|
||||
@@ -133,30 +121,26 @@ public class EmailApiResource {
|
||||
if (toDateParam != null) {
|
||||
toDate = toDateParam.getDate("toDate", dateFormat, locale);
|
||||
}
|
||||
|
||||
final SearchParameters searchParameters = SearchParameters.forEmailCampaign(sqlSearch, offset, limit, status, fromDate,toDate, orderBy, sortOrder);
|
||||
Page<EmailData> emailMessages = this.readPlatformService.retrieveEmailByStatus(searchParameters);
|
||||
|
||||
Page<EmailData> emailMessages = this.readPlatformService.retrieveEmailByStatus(limit, status, fromDate, toDate);
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, emailMessages);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("failedEmail")
|
||||
public String retrieveFailedEmail(@QueryParam("sqlSearch") final String sqlSearch,
|
||||
@QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit,
|
||||
@QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, @Context final UriInfo uriInfo) {
|
||||
public String retrieveFailedEmail(@QueryParam("sqlSearch") final String sqlSearch, @QueryParam("offset") final Integer offset,
|
||||
@QueryParam("limit") final Integer limit, @QueryParam("orderBy") final String orderBy,
|
||||
@QueryParam("sortOrder") final String sortOrder, @Context final UriInfo uriInfo) {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final SearchParameters searchParameters = SearchParameters.forEmailCampaign(sqlSearch, offset, limit, orderBy, sortOrder);
|
||||
Page<EmailData> emailMessages = this.readPlatformService.retrieveAllFailed(searchParameters);
|
||||
final SearchParameters searchParameters = SearchParameters.forEmailCampaign(sqlSearch, offset, limit, orderBy, sortOrder);
|
||||
Collection<EmailData> emailMessages = this.readPlatformService.retrieveAllFailed(searchParameters);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, emailMessages);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
public String create(final String apiRequestBodyAsJson) {
|
||||
|
||||
|
||||
+285
-259
@@ -45,9 +45,6 @@ import org.apache.fineract.infrastructure.dataqueries.exception.ReportNotFoundEx
|
||||
import org.apache.fineract.infrastructure.dataqueries.service.GenericDataService;
|
||||
import org.apache.fineract.infrastructure.dataqueries.service.ReadReportingService;
|
||||
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.FileSystemContentRepository;
|
||||
import org.apache.fineract.infrastructure.reportmailingjob.data.ReportMailingJobEmailData;
|
||||
import org.apache.fineract.infrastructure.reportmailingjob.domain.ReportMailingJob;
|
||||
import org.apache.fineract.infrastructure.reportmailingjob.domain.ReportMailingJobEmailAttachmentFileFormat;
|
||||
import org.apache.fineract.infrastructure.reportmailingjob.helper.IPv4Helper;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.data.EmailMessageWithAttachmentData;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.domain.*;
|
||||
@@ -57,22 +54,17 @@ import org.apache.fineract.infrastructure.campaigns.email.exception.EmailCampaig
|
||||
import org.apache.fineract.infrastructure.jobs.annotation.CronTarget;
|
||||
import org.apache.fineract.infrastructure.jobs.exception.JobExecutionException;
|
||||
import org.apache.fineract.infrastructure.jobs.service.JobName;
|
||||
import org.apache.fineract.infrastructure.jobs.service.SchedularWritePlatformService;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.data.PreviewCampaignMessage;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.data.EmailCampaignData;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.data.EmailCampaignValidator;
|
||||
import org.apache.fineract.organisation.staff.domain.Staff;
|
||||
import org.apache.fineract.portfolio.calendar.service.CalendarUtils;
|
||||
import org.apache.fineract.portfolio.client.domain.Client;
|
||||
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
|
||||
import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
|
||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepository;
|
||||
import org.apache.fineract.template.domain.TemplateRepository;
|
||||
import org.apache.fineract.template.service.TemplateMergeService;
|
||||
import org.apache.fineract.useradministration.domain.AppUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -89,7 +81,6 @@ import java.util.*;
|
||||
@Service
|
||||
public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampaignWritePlatformService {
|
||||
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(EmailCampaignWritePlatformCommandHandlerImpl.class);
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
@@ -98,43 +89,33 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
private final EmailCampaignValidator emailCampaignValidator;
|
||||
private final EmailCampaignReadPlatformService emailCampaignReadPlatformService;
|
||||
private final ReportRepository reportRepository;
|
||||
private final TemplateRepository templateRepository;
|
||||
private final TemplateMergeService templateMergeService;
|
||||
private final EmailMessageRepository emailMessageRepository;
|
||||
private final ClientRepositoryWrapper clientRepositoryWrapper;
|
||||
private final SchedularWritePlatformService schedularWritePlatformService;
|
||||
private final ReadReportingService readReportingService;
|
||||
private final GenericDataService genericDataService;
|
||||
private final FromJsonHelper fromJsonHelper;
|
||||
private final ReportParameterUsageRepository reportParameterUsageRepository;
|
||||
private final LoanRepository loanRepository;
|
||||
private final SavingsAccountRepository savingsAccountRepository;
|
||||
private final EmailMessageJobEmailService emailMessageJobEmailService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
public EmailCampaignWritePlatformCommandHandlerImpl(final PlatformSecurityContext context, final EmailCampaignRepository emailCampaignRepository,
|
||||
final EmailCampaignValidator emailCampaignValidator,final EmailCampaignReadPlatformService emailCampaignReadPlatformService,final ReportParameterUsageRepository reportParameterUsageRepository,
|
||||
final ReportRepository reportRepository,final TemplateRepository templateRepository, final TemplateMergeService templateMergeService,
|
||||
final EmailMessageRepository emailMessageRepository,final ClientRepositoryWrapper clientRepositoryWrapper,final SchedularWritePlatformService schedularWritePlatformService,
|
||||
final ReadReportingService readReportingService, final GenericDataService genericDataService,final FromJsonHelper fromJsonHelper,
|
||||
final LoanRepository loanRepository,final SavingsAccountRepository savingsAccountRepository,final EmailMessageJobEmailService emailMessageJobEmailService) {
|
||||
public EmailCampaignWritePlatformCommandHandlerImpl(final PlatformSecurityContext context,
|
||||
final EmailCampaignRepository emailCampaignRepository, final EmailCampaignValidator emailCampaignValidator,
|
||||
final EmailCampaignReadPlatformService emailCampaignReadPlatformService, final ReportRepository reportRepository,
|
||||
final EmailMessageRepository emailMessageRepository, final ClientRepositoryWrapper clientRepositoryWrapper,
|
||||
final ReadReportingService readReportingService, final GenericDataService genericDataService,
|
||||
final FromJsonHelper fromJsonHelper, final LoanRepository loanRepository,
|
||||
final SavingsAccountRepository savingsAccountRepository, final EmailMessageJobEmailService emailMessageJobEmailService) {
|
||||
this.context = context;
|
||||
this.emailCampaignRepository = emailCampaignRepository;
|
||||
this.emailCampaignValidator = emailCampaignValidator;
|
||||
this.emailCampaignReadPlatformService = emailCampaignReadPlatformService;
|
||||
this.reportRepository = reportRepository;
|
||||
this.templateRepository = templateRepository;
|
||||
this.templateMergeService = templateMergeService;
|
||||
this.emailMessageRepository = emailMessageRepository;
|
||||
this.clientRepositoryWrapper = clientRepositoryWrapper;
|
||||
this.schedularWritePlatformService = schedularWritePlatformService;
|
||||
this.readReportingService = readReportingService;
|
||||
this.genericDataService = genericDataService;
|
||||
this.fromJsonHelper = fromJsonHelper;
|
||||
this.reportParameterUsageRepository = reportParameterUsageRepository;
|
||||
this.loanRepository = loanRepository;
|
||||
this.savingsAccountRepository = savingsAccountRepository;
|
||||
this.emailMessageJobEmailService = emailMessageJobEmailService;
|
||||
@@ -150,29 +131,24 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
|
||||
final Long businessRuleId = command.longValueOfParameterNamed(EmailCampaignValidator.businessRuleId);
|
||||
|
||||
final Report businessRule = this.reportRepository.findOne(businessRuleId);
|
||||
if(businessRule == null){
|
||||
throw new ReportNotFoundException(businessRuleId);
|
||||
}
|
||||
final Report businessRule = this.reportRepository.findOne(businessRuleId);
|
||||
if (businessRule == null) { throw new ReportNotFoundException(businessRuleId); }
|
||||
|
||||
final Long reportId = command.longValueOfParameterNamed(EmailCampaignValidator.stretchyReportId);
|
||||
|
||||
final Report report = this.reportRepository.findOne(reportId);
|
||||
if(report == null){
|
||||
throw new ReportNotFoundException(reportId);
|
||||
}
|
||||
//find all report parameters and store them as json string
|
||||
final Report report = this.reportRepository.findOne(reportId);
|
||||
if (report == null) { throw new ReportNotFoundException(reportId); }
|
||||
// find all report parameters and store them as json string
|
||||
final Set<ReportParameterUsage> reportParameterUsages = report.getReportParameterUsages();
|
||||
final Map<String,String> stretchyReportParams = new HashMap<>();
|
||||
final Map<String, String> stretchyReportParams = new HashMap<>();
|
||||
|
||||
if(reportParameterUsages !=null && !reportParameterUsages.isEmpty()){
|
||||
for(final ReportParameterUsage reportParameterUsage : reportParameterUsages){
|
||||
stretchyReportParams.put(reportParameterUsage.getReportParameterName(),"");
|
||||
if (reportParameterUsages != null && !reportParameterUsages.isEmpty()) {
|
||||
for (final ReportParameterUsage reportParameterUsage : reportParameterUsages) {
|
||||
stretchyReportParams.put(reportParameterUsage.getReportParameterName(), "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EmailCampaign emailCampaign = EmailCampaign.instance(currentUser,businessRule,report,command);
|
||||
EmailCampaign emailCampaign = EmailCampaign.instance(currentUser, businessRule, report, command);
|
||||
emailCampaign.setStretchyReportParamMap(new Gson().toJson(stretchyReportParams));
|
||||
|
||||
this.emailCampaignRepository.save(emailCampaign);
|
||||
@@ -182,28 +158,28 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
.withEntityId(emailCampaign.getId()) //
|
||||
.build();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult update(final Long resourceId, final JsonCommand command) {
|
||||
try{
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
|
||||
try {
|
||||
this.context.authenticatedUser();
|
||||
this.emailCampaignValidator.validateForUpdate(command.json());
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(resourceId);
|
||||
|
||||
if(emailCampaign == null){ throw new EmailCampaignNotFound(resourceId);}
|
||||
if(emailCampaign.isActive()){ throw new EmailCampaignMustBeClosedToEditException(emailCampaign.getId());}
|
||||
if (emailCampaign == null) { throw new EmailCampaignNotFound(resourceId); }
|
||||
if (emailCampaign.isActive()) { throw new EmailCampaignMustBeClosedToEditException(emailCampaign.getId()); }
|
||||
final Map<String, Object> changes = emailCampaign.update(command);
|
||||
|
||||
if(changes.containsKey(EmailCampaignValidator.businessRuleId)){
|
||||
if (changes.containsKey(EmailCampaignValidator.businessRuleId)) {
|
||||
final Long newValue = command.longValueOfParameterNamed(EmailCampaignValidator.businessRuleId);
|
||||
final Report reportId = this.reportRepository.findOne(newValue);
|
||||
if(reportId == null){ throw new ReportNotFoundException(newValue);}
|
||||
if (reportId == null) { throw new ReportNotFoundException(newValue); }
|
||||
emailCampaign.updateBusinessRuleId(reportId);
|
||||
|
||||
}
|
||||
|
||||
if(!changes.isEmpty()){
|
||||
if (!changes.isEmpty()) {
|
||||
this.emailCampaignRepository.saveAndFlush(emailCampaign);
|
||||
}
|
||||
return new CommandProcessingResultBuilder() //
|
||||
@@ -211,24 +187,24 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
.withEntityId(resourceId) //
|
||||
.with(changes) //
|
||||
.build();
|
||||
}catch(final DataIntegrityViolationException dve){
|
||||
} catch (final DataIntegrityViolationException dve) {
|
||||
handleDataIntegrityIssues(command, dve);
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult delete(final Long resourceId) {
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
|
||||
this.context.authenticatedUser();
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(resourceId);
|
||||
|
||||
if(emailCampaign == null){ throw new EmailCampaignNotFound(resourceId);}
|
||||
if(emailCampaign.isActive()){ throw new EmailCampaignMustBeClosedToBeDeletedException(emailCampaign.getId());}
|
||||
if (emailCampaign == null) { throw new EmailCampaignNotFound(resourceId); }
|
||||
if (emailCampaign.isActive()) { throw new EmailCampaignMustBeClosedToBeDeletedException(emailCampaign.getId()); }
|
||||
|
||||
/*
|
||||
Do not delete but set a boolean is_visible to zero
|
||||
* Do not delete but set a boolean is_visible to zero
|
||||
*/
|
||||
emailCampaign.delete();
|
||||
this.emailCampaignRepository.saveAndFlush(emailCampaign);
|
||||
@@ -239,31 +215,34 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void insertDirectCampaignIntoEmailOutboundTable(final String emailParams, final String emailSubject,
|
||||
final String messageTemplate,final String campaignName,final Long campaignId){
|
||||
try{
|
||||
HashMap<String,String> campaignParams = new ObjectMapper().readValue(emailParams, new TypeReference<HashMap<String,String>>(){});
|
||||
final String messageTemplate, final String campaignName, final Long campaignId) {
|
||||
try {
|
||||
HashMap<String, String> campaignParams = new ObjectMapper().readValue(emailParams,
|
||||
new TypeReference<HashMap<String, String>>() {});
|
||||
|
||||
HashMap<String,String> queryParamForRunReport = new ObjectMapper().readValue(emailParams, new TypeReference<HashMap<String,String>>(){});
|
||||
HashMap<String, String> queryParamForRunReport = new ObjectMapper().readValue(emailParams,
|
||||
new TypeReference<HashMap<String, String>>() {});
|
||||
|
||||
List<HashMap<String,Object>> runReportObject = this.getRunReportByServiceImpl(campaignParams.get("reportName"),queryParamForRunReport);
|
||||
List<HashMap<String, Object>> runReportObject = this.getRunReportByServiceImpl(campaignParams.get("reportName"),
|
||||
queryParamForRunReport);
|
||||
|
||||
if(runReportObject !=null){
|
||||
for(HashMap<String,Object> entry : runReportObject){
|
||||
if (runReportObject != null) {
|
||||
for (HashMap<String, Object> entry : runReportObject) {
|
||||
String message = this.compileEmailTemplate(messageTemplate, campaignName, entry);
|
||||
Integer clientId = (Integer)entry.get("id");
|
||||
Integer clientId = (Integer) entry.get("id");
|
||||
EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId);
|
||||
Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId.longValue());
|
||||
Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId.longValue());
|
||||
String emailAddress = client.emailAddress();
|
||||
|
||||
if(emailAddress !=null && isValidEmail(emailAddress)) {
|
||||
EmailMessage emailMessage = EmailMessage.pendingEmail(null,client,null,emailCampaign,emailSubject,message,emailAddress,campaignName);
|
||||
if (emailAddress != null && isValidEmail(emailAddress)) {
|
||||
EmailMessage emailMessage = EmailMessage.pendingEmail(null, client, null, emailCampaign, emailSubject, message,
|
||||
emailAddress, campaignName);
|
||||
this.emailMessageRepository.save(emailMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(final IOException e){
|
||||
} catch (final IOException e) {
|
||||
// TODO throw something here
|
||||
}
|
||||
|
||||
@@ -288,42 +267,54 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
@Override
|
||||
@CronTarget(jobName = JobName.UPDATE_EMAIL_OUTBOUND_WITH_CAMPAIGN_MESSAGE)
|
||||
public void storeTemplateMessageIntoEmailOutBoundTable() throws JobExecutionException {
|
||||
final Collection<EmailCampaignData> emailCampaignDataCollection = this.emailCampaignReadPlatformService.retrieveAllScheduleActiveCampaign();
|
||||
if(emailCampaignDataCollection != null){
|
||||
for(EmailCampaignData emailCampaignData : emailCampaignDataCollection){
|
||||
final Collection<EmailCampaignData> emailCampaignDataCollection = this.emailCampaignReadPlatformService
|
||||
.retrieveAllScheduleActiveCampaign();
|
||||
if (emailCampaignDataCollection != null) {
|
||||
for (EmailCampaignData emailCampaignData : emailCampaignDataCollection) {
|
||||
LocalDateTime tenantDateNow = tenantDateTime();
|
||||
LocalDateTime nextTriggerDate = emailCampaignData.getNextTriggerDate().toLocalDateTime();
|
||||
|
||||
logger.info("tenant time " + tenantDateNow.toString() + " trigger time "+nextTriggerDate.toString());
|
||||
if(nextTriggerDate.isBefore(tenantDateNow)){
|
||||
insertDirectCampaignIntoEmailOutboundTable(emailCampaignData.getParamValue(),emailCampaignData.getEmailSubject(), emailCampaignData.getMessage(),emailCampaignData.getCampaignName(),emailCampaignData.getId());
|
||||
logger.info("tenant time " + tenantDateNow.toString() + " trigger time " + nextTriggerDate.toString());
|
||||
if (nextTriggerDate.isBefore(tenantDateNow)) {
|
||||
insertDirectCampaignIntoEmailOutboundTable(emailCampaignData.getParamValue(), emailCampaignData.getEmailSubject(),
|
||||
emailCampaignData.getMessage(), emailCampaignData.getCampaignName(), emailCampaignData.getId());
|
||||
this.updateTriggerDates(emailCampaignData.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTriggerDates(Long campaignId){
|
||||
private void updateTriggerDates(Long campaignId) {
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId);
|
||||
if(emailCampaign == null){
|
||||
throw new EmailCampaignNotFound(campaignId);
|
||||
}
|
||||
if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); }
|
||||
LocalDateTime nextTriggerDate = emailCampaign.getNextTriggerDate();
|
||||
emailCampaign.setLastTriggerDate(nextTriggerDate.toDate());
|
||||
//calculate new trigger date and insert into next trigger date
|
||||
// calculate new trigger date and insert into next trigger date
|
||||
|
||||
/**
|
||||
* next run time has to be in the future if not calculate a new future date
|
||||
* next run time has to be in the future if not calculate a new future
|
||||
* date
|
||||
*/
|
||||
LocalDate nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getNextTriggerDate().toLocalDate(), nextTriggerDate.toLocalDate()) ;
|
||||
if(nextRuntime.isBefore(DateUtils.getLocalDateOfTenant())){ // means next run time is in the past calculate a new future date
|
||||
nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getNextTriggerDate().toLocalDate(),DateUtils.getLocalDateOfTenant()) ;
|
||||
LocalDate nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(),
|
||||
emailCampaign.getNextTriggerDate().toLocalDate(), nextTriggerDate.toLocalDate());
|
||||
if (nextRuntime.isBefore(DateUtils.getLocalDateOfTenant())) { // means
|
||||
// next
|
||||
// run
|
||||
// time is
|
||||
// in the
|
||||
// past
|
||||
// calculate
|
||||
// a new
|
||||
// future
|
||||
// date
|
||||
nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(),
|
||||
emailCampaign.getNextTriggerDate().toLocalDate(), DateUtils.getLocalDateOfTenant());
|
||||
}
|
||||
final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime();
|
||||
final String dateString = nextRuntime.toString() + " " + getTime.getHourOfDay()+":"+getTime.getMinuteOfHour()+":"+getTime.getSecondOfMinute();
|
||||
final String dateString = nextRuntime.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":"
|
||||
+ getTime.getSecondOfMinute();
|
||||
final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
|
||||
final LocalDateTime newTriggerDateWithTime = LocalDateTime.parse(dateString,simpleDateFormat);
|
||||
|
||||
final LocalDateTime newTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat);
|
||||
|
||||
emailCampaign.setNextTriggerDate(newTriggerDateWithTime.toDate());
|
||||
this.emailCampaignRepository.saveAndFlush(emailCampaign);
|
||||
@@ -338,11 +329,7 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId);
|
||||
|
||||
if(emailCampaign == null){
|
||||
throw new EmailCampaignNotFound(campaignId);
|
||||
}
|
||||
|
||||
|
||||
if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); }
|
||||
|
||||
final Locale locale = command.extractLocale();
|
||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||
@@ -352,28 +339,31 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
|
||||
this.emailCampaignRepository.saveAndFlush(emailCampaign);
|
||||
|
||||
if(emailCampaign.isDirect()){
|
||||
insertDirectCampaignIntoEmailOutboundTable(emailCampaign.getParamValue(),emailCampaign.getEmailSubject(),emailCampaign.getEmailMessage(),emailCampaign.getCampaignName(), emailCampaign.getId());
|
||||
}else {
|
||||
if (emailCampaign.isDirect()) {
|
||||
insertDirectCampaignIntoEmailOutboundTable(emailCampaign.getParamValue(), emailCampaign.getEmailSubject(),
|
||||
emailCampaign.getEmailMessage(), emailCampaign.getCampaignName(), emailCampaign.getId());
|
||||
} else {
|
||||
if (emailCampaign.isSchedule()) {
|
||||
|
||||
/**
|
||||
* if recurrence start date is in the future calculate
|
||||
* next trigger date if not use recurrence start date us next trigger
|
||||
* if recurrence start date is in the future calculate next
|
||||
* trigger date if not use recurrence start date us next trigger
|
||||
* date when activating
|
||||
*/
|
||||
LocalDate nextTriggerDate = null;
|
||||
if(emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())){
|
||||
nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant());
|
||||
}else{
|
||||
if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) {
|
||||
nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(),
|
||||
emailCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant());
|
||||
} else {
|
||||
nextTriggerDate = emailCampaign.getRecurrenceStartDate();
|
||||
}
|
||||
// to get time of tenant
|
||||
final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime();
|
||||
|
||||
final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay()+":"+getTime.getMinuteOfHour()+":"+getTime.getSecondOfMinute();
|
||||
final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":"
|
||||
+ getTime.getSecondOfMinute();
|
||||
final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
|
||||
final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString,simpleDateFormat);
|
||||
final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat);
|
||||
|
||||
emailCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate());
|
||||
this.emailCampaignRepository.saveAndFlush(emailCampaign);
|
||||
@@ -381,8 +371,8 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
}
|
||||
|
||||
/*
|
||||
if campaign is direct insert campaign message into email outbound table
|
||||
else if its a schedule create a job process for it
|
||||
* if campaign is direct insert campaign message into email outbound
|
||||
* table else if its a schedule create a job process for it
|
||||
*/
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
@@ -398,15 +388,13 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
this.emailCampaignValidator.validateClosedDate(command.json());
|
||||
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId);
|
||||
if(emailCampaign == null){
|
||||
throw new EmailCampaignNotFound(campaignId);
|
||||
}
|
||||
if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); }
|
||||
|
||||
final Locale locale = command.extractLocale();
|
||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||
final LocalDate closureDate = command.localDateValueOfParameterNamed("closureDate");
|
||||
|
||||
emailCampaign.close(currentUser,fmt,closureDate);
|
||||
emailCampaign.close(currentUser, fmt, closureDate);
|
||||
|
||||
this.emailCampaignRepository.saveAndFlush(emailCampaign);
|
||||
|
||||
@@ -416,7 +404,8 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
.build();
|
||||
}
|
||||
|
||||
private String compileEmailTemplate(final String textMessageTemplate,final String campaignName , final Map<String, Object> emailParams) {
|
||||
private String compileEmailTemplate(final String textMessageTemplate, final String campaignName,
|
||||
final Map<String, Object> emailParams) {
|
||||
final MustacheFactory mf = new DefaultMustacheFactory();
|
||||
final Mustache mustache = mf.compile(new StringReader(textMessageTemplate), campaignName);
|
||||
|
||||
@@ -426,22 +415,25 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
private List<HashMap<String,Object>> getRunReportByServiceImpl(final String reportName,final Map<String, String> queryParams) throws IOException {
|
||||
final String reportType ="report";
|
||||
@SuppressWarnings({ "unused", "rawtypes" })
|
||||
private List<HashMap<String, Object>> getRunReportByServiceImpl(final String reportName, final Map<String, String> queryParams)
|
||||
throws IOException {
|
||||
final String reportType = "report";
|
||||
|
||||
List<HashMap<String, Object>> resultList = new ArrayList<HashMap<String, Object>>();
|
||||
final GenericResultsetData results = this.readReportingService.retrieveGenericResultSetForSmsEmailCampaign(reportName,
|
||||
reportType, queryParams);
|
||||
final GenericResultsetData results = this.readReportingService.retrieveGenericResultSetForSmsEmailCampaign(reportName, reportType,
|
||||
queryParams);
|
||||
final String response = this.genericDataService.generateJsonFromGenericResultsetData(results);
|
||||
resultList = new ObjectMapper().readValue(response, new TypeReference<List<HashMap<String,Object>>>(){});
|
||||
//loop changes array date to string date
|
||||
for(HashMap<String,Object> entry : resultList){
|
||||
for(Map.Entry<String,Object> map: entry.entrySet()){
|
||||
resultList = new ObjectMapper().readValue(response, new TypeReference<List<HashMap<String, Object>>>() {});
|
||||
// loop changes array date to string date
|
||||
for (HashMap<String, Object> entry : resultList) {
|
||||
for (Map.Entry<String, Object> map : entry.entrySet()) {
|
||||
String key = map.getKey();
|
||||
Object ob = map.getValue();
|
||||
if(ob instanceof ArrayList && ((ArrayList) ob).size() == 3){
|
||||
String changeArrayDateToStringDate = ((ArrayList) ob).get(2).toString() +"-"+((ArrayList) ob).get(1).toString() +"-"+((ArrayList) ob).get(0).toString();
|
||||
entry.put(key,changeArrayDateToStringDate);
|
||||
Object ob = map.getValue();
|
||||
if (ob instanceof ArrayList && ((ArrayList) ob).size() == 3) {
|
||||
String changeArrayDateToStringDate = ((ArrayList) ob).get(2).toString() + "-" + ((ArrayList) ob).get(1).toString() + "-"
|
||||
+ ((ArrayList) ob).get(0).toString();
|
||||
entry.put(key, changeArrayDateToStringDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -451,36 +443,40 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
@Override
|
||||
public PreviewCampaignMessage previewMessage(final JsonQuery query) {
|
||||
PreviewCampaignMessage campaignMessage = null;
|
||||
final AppUser currentUser = this.context.authenticatedUser();
|
||||
this.context.authenticatedUser();
|
||||
this.emailCampaignValidator.validatePreviewMessage(query.json());
|
||||
final String emailParams = this.fromJsonHelper.extractStringNamed("paramValue", query.parsedJson()) ;
|
||||
final String emailParams = this.fromJsonHelper.extractStringNamed("paramValue", query.parsedJson());
|
||||
final String textMessageTemplate = this.fromJsonHelper.extractStringNamed("emailMessage", query.parsedJson());
|
||||
|
||||
try{
|
||||
HashMap<String,String> campaignParams = new ObjectMapper().readValue(emailParams, new TypeReference<HashMap<String,String>>(){});
|
||||
try {
|
||||
HashMap<String, String> campaignParams = new ObjectMapper().readValue(emailParams,
|
||||
new TypeReference<HashMap<String, String>>() {});
|
||||
|
||||
HashMap<String,String> queryParamForRunReport = new ObjectMapper().readValue(emailParams, new TypeReference<HashMap<String,String>>(){});
|
||||
HashMap<String, String> queryParamForRunReport = new ObjectMapper().readValue(emailParams,
|
||||
new TypeReference<HashMap<String, String>>() {});
|
||||
|
||||
List<HashMap<String,Object>> runReportObject = this.getRunReportByServiceImpl(campaignParams.get("reportName"),queryParamForRunReport);
|
||||
List<HashMap<String, Object>> runReportObject = this.getRunReportByServiceImpl(campaignParams.get("reportName"),
|
||||
queryParamForRunReport);
|
||||
|
||||
if(runReportObject !=null){
|
||||
for(HashMap<String,Object> entry : runReportObject){
|
||||
if (runReportObject != null) {
|
||||
for (HashMap<String, Object> entry : runReportObject) {
|
||||
// add string object to campaignParam object
|
||||
String textMessage = this.compileEmailTemplate(textMessageTemplate,"EmailCampaign", entry);
|
||||
if(!textMessage.isEmpty()) {
|
||||
String textMessage = this.compileEmailTemplate(textMessageTemplate, "EmailCampaign", entry);
|
||||
if (!textMessage.isEmpty()) {
|
||||
final Integer totalMessage = runReportObject.size();
|
||||
campaignMessage = new PreviewCampaignMessage(textMessage,totalMessage);
|
||||
campaignMessage = new PreviewCampaignMessage(textMessage, totalMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(final IOException e){
|
||||
} catch (final IOException e) {
|
||||
// TODO throw something here
|
||||
}
|
||||
|
||||
return campaignMessage;
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult reactivateEmailCampaign(final Long campaignId, JsonCommand command) {
|
||||
@@ -491,51 +487,53 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId);
|
||||
|
||||
if(emailCampaign == null){ throw new EmailCampaignNotFound(campaignId);}
|
||||
if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); }
|
||||
|
||||
final Locale locale = command.extractLocale();
|
||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||
final LocalDate reactivationDate = command.localDateValueOfParameterNamed("activationDate");
|
||||
emailCampaign.reactivate(currentUser,fmt,reactivationDate);
|
||||
emailCampaign.reactivate(currentUser, fmt, reactivationDate);
|
||||
if (emailCampaign.isSchedule()) {
|
||||
|
||||
/**
|
||||
* if recurrence start date is in the future calculate
|
||||
* next trigger date if not use recurrence start date us next trigger date when activating
|
||||
* if recurrence start date is in the future calculate next trigger
|
||||
* date if not use recurrence start date us next trigger date when
|
||||
* activating
|
||||
*/
|
||||
LocalDate nextTriggerDate = null;
|
||||
if(emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())){
|
||||
nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant());
|
||||
}else{
|
||||
if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) {
|
||||
nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getRecurrenceStartDate(),
|
||||
DateUtils.getLocalDateOfTenant());
|
||||
} else {
|
||||
nextTriggerDate = emailCampaign.getRecurrenceStartDate();
|
||||
}
|
||||
// to get time of tenant
|
||||
final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime();
|
||||
|
||||
final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay()+":"+getTime.getMinuteOfHour()+":"+getTime.getSecondOfMinute();
|
||||
final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":"
|
||||
+ getTime.getSecondOfMinute();
|
||||
final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
|
||||
final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString,simpleDateFormat);
|
||||
final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat);
|
||||
|
||||
emailCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate());
|
||||
this.emailCampaignRepository.saveAndFlush(emailCampaign);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withEntityId(emailCampaign.getId()) //
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
private void handleDataIntegrityIssues(@SuppressWarnings("unused") final JsonCommand command, final DataIntegrityViolationException dve) {
|
||||
private void handleDataIntegrityIssues(@SuppressWarnings("unused") final JsonCommand command,
|
||||
final DataIntegrityViolationException dve) {
|
||||
final Throwable realCause = dve.getMostSpecificCause();
|
||||
|
||||
throw new PlatformDataIntegrityException("error.msg.email.campaign.unknown.data.integrity.issue",
|
||||
"Unknown data integrity issue with resource: " + realCause.getMessage());
|
||||
}
|
||||
|
||||
private LocalDateTime tenantDateTime(){
|
||||
private LocalDateTime tenantDateTime() {
|
||||
LocalDateTime today = new LocalDateTime();
|
||||
final FineractPlatformTenant tenant = ThreadLocalContextUtil.getTenant();
|
||||
|
||||
@@ -545,137 +543,164 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
today = new LocalDateTime(zone);
|
||||
}
|
||||
}
|
||||
return today;
|
||||
return today;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CronTarget(jobName = JobName.EXECUTE_EMAIL)
|
||||
public void sendEmailMessage() throws JobExecutionException {
|
||||
if (IPv4Helper.applicationIsNotRunningOnLocalMachine()){ //remove when testing locally
|
||||
final List<EmailMessage> emailMessages = this.emailMessageRepository.findByStatusType(EmailMessageStatusType.PENDING.getValue()); //retrieve all pending message
|
||||
|
||||
for(final EmailMessage emailMessage : emailMessages) {
|
||||
if (IPv4Helper.applicationIsNotRunningOnLocalMachine()) { // remove when
|
||||
// testing
|
||||
// locally
|
||||
final List<EmailMessage> emailMessages = this.emailMessageRepository
|
||||
.findByStatusType(EmailMessageStatusType.PENDING.getValue()); // retrieve
|
||||
// all
|
||||
// pending
|
||||
// message
|
||||
|
||||
for (final EmailMessage emailMessage : emailMessages) {
|
||||
|
||||
if (isValidEmail(emailMessage.getEmailAddress())) {
|
||||
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(emailMessage.getEmailCampaign().getId()); //
|
||||
|
||||
final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(emailMessage.getEmailCampaign().getId()); //
|
||||
final ScheduledEmailAttachmentFileFormat emailAttachmentFileFormat = ScheduledEmailAttachmentFileFormat
|
||||
.instance(emailCampaign.getEmailAttachmentFileFormat());
|
||||
|
||||
final ScheduledEmailAttachmentFileFormat emailAttachmentFileFormat = ScheduledEmailAttachmentFileFormat.instance(emailCampaign.getEmailAttachmentFileFormat());
|
||||
final List<File> attachmentList = new ArrayList<>();
|
||||
|
||||
final List<File> attachmentList = new ArrayList<>();
|
||||
final StringBuilder errorLog = new StringBuilder();
|
||||
|
||||
final StringBuilder errorLog = new StringBuilder();
|
||||
// check if email attachment format exist
|
||||
if (emailAttachmentFileFormat != null && Arrays.asList(ScheduledEmailAttachmentFileFormat.validValues())
|
||||
.contains(emailAttachmentFileFormat.getId())) {
|
||||
|
||||
//check if email attachment format exist
|
||||
if (emailAttachmentFileFormat != null && Arrays.asList(ScheduledEmailAttachmentFileFormat.validValues()).
|
||||
contains(emailAttachmentFileFormat.getId())) {
|
||||
final Report stretchyReport = emailCampaign.getStretchyReport();
|
||||
|
||||
final Report stretchyReport = emailCampaign.getStretchyReport();
|
||||
final String reportName = (stretchyReport != null) ? stretchyReport.getReportName() : null;
|
||||
|
||||
final String reportName = (stretchyReport != null) ? stretchyReport.getReportName() : null;
|
||||
final HashMap<String, String> reportStretchyParams = this
|
||||
.validateStretchyReportParamMap(emailCampaign.getStretchyReportParamMap());
|
||||
|
||||
final HashMap<String, String> reportStretchyParams = this.validateStretchyReportParamMap(emailCampaign.getStretchyReportParamMap());
|
||||
// there is a probability that a client has one or more
|
||||
// loans or savings therefore we need to send two or
|
||||
// more attachments
|
||||
if (reportStretchyParams.containsKey("selectLoan") || reportStretchyParams.containsKey("loanId")) {
|
||||
// get all ids of the client loans
|
||||
if (emailMessage.getClient() != null) {
|
||||
|
||||
// there is a probability that a client has one or more loans or savings therefore we need to send two or more attachments
|
||||
if (reportStretchyParams.containsKey("selectLoan") || reportStretchyParams.containsKey("loanId")) {
|
||||
//get all ids of the client loans
|
||||
if (emailMessage.getClient() != null) {
|
||||
final List<Loan> loans = this.loanRepository.findLoanByClientId(emailMessage.getClient().getId());
|
||||
|
||||
final List<Loan> loans = this.loanRepository.findLoanByClientId(emailMessage.getClient().getId());
|
||||
HashMap<String, String> reportParams = this
|
||||
.replaceStretchyParamsWithActualClientParams(reportStretchyParams, emailMessage.getClient());
|
||||
|
||||
HashMap<String, String> reportParams = this.replaceStretchyParamsWithActualClientParams(reportStretchyParams, emailMessage.getClient());
|
||||
for (final Loan loan : loans) {
|
||||
if (loan.isOpen()) { // only send attachment
|
||||
// for active loan
|
||||
|
||||
for (final Loan loan : loans) {
|
||||
if (loan.isOpen()) { // only send attachment for active loan
|
||||
if (reportStretchyParams.containsKey("selectLoan")) {
|
||||
|
||||
if (reportStretchyParams.containsKey("selectLoan")) {
|
||||
reportParams.put("SelectLoan", loan.getId().toString());
|
||||
|
||||
reportParams.put("SelectLoan", loan.getId().toString());
|
||||
} else if (reportStretchyParams.containsKey("loanId")) {
|
||||
|
||||
} else if (reportStretchyParams.containsKey("loanId")) {
|
||||
|
||||
reportParams.put("loanId", loan.getId().toString());
|
||||
}
|
||||
File file = this.generateAttachments(emailCampaign, emailAttachmentFileFormat, reportParams, reportName, errorLog);
|
||||
|
||||
if (file != null) {
|
||||
attachmentList.add(file);
|
||||
} else {
|
||||
errorLog.append(reportParams.toString());
|
||||
}
|
||||
reportParams.put("loanId", loan.getId().toString());
|
||||
}
|
||||
}
|
||||
File file = this.generateAttachments(emailCampaign, emailAttachmentFileFormat, reportParams,
|
||||
reportName, errorLog);
|
||||
|
||||
}
|
||||
} else if (reportStretchyParams.containsKey("savingId")) {
|
||||
if (emailMessage.getClient() != null) {
|
||||
|
||||
final List<SavingsAccount> savingsAccounts = this.savingsAccountRepository.findSavingAccountByClientId(emailMessage.getClient().getId());
|
||||
|
||||
HashMap<String, String> reportParams = this.replaceStretchyParamsWithActualClientParams(reportStretchyParams, emailMessage.getClient());
|
||||
|
||||
for (final SavingsAccount savingsAccount : savingsAccounts) {
|
||||
|
||||
if (savingsAccount.isActive()) {
|
||||
|
||||
reportParams.put("savingId", savingsAccount.getId().toString());
|
||||
|
||||
File file = this.generateAttachments(emailCampaign, emailAttachmentFileFormat, reportParams, reportName, errorLog);
|
||||
|
||||
if (file != null) {
|
||||
attachmentList.add(file);
|
||||
} else {
|
||||
errorLog.append(reportParams.toString());
|
||||
}
|
||||
if (file != null) {
|
||||
attachmentList.add(file);
|
||||
} else {
|
||||
errorLog.append(reportParams.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (emailMessage.getClient() != null) {
|
||||
|
||||
HashMap<String, String> reportParams = this.replaceStretchyParamsWithActualClientParams(reportStretchyParams, emailMessage.getClient());
|
||||
}
|
||||
} else if (reportStretchyParams.containsKey("savingId")) {
|
||||
if (emailMessage.getClient() != null) {
|
||||
|
||||
File file = this.generateAttachments(emailCampaign, emailAttachmentFileFormat, reportParams, reportName, errorLog);
|
||||
final List<SavingsAccount> savingsAccounts = this.savingsAccountRepository
|
||||
.findSavingAccountByClientId(emailMessage.getClient().getId());
|
||||
|
||||
if (file != null) {
|
||||
attachmentList.add(file);
|
||||
} else {
|
||||
errorLog.append(reportParams.toString());
|
||||
HashMap<String, String> reportParams = this
|
||||
.replaceStretchyParamsWithActualClientParams(reportStretchyParams, emailMessage.getClient());
|
||||
|
||||
for (final SavingsAccount savingsAccount : savingsAccounts) {
|
||||
|
||||
if (savingsAccount.isActive()) {
|
||||
|
||||
reportParams.put("savingId", savingsAccount.getId().toString());
|
||||
|
||||
File file = this.generateAttachments(emailCampaign, emailAttachmentFileFormat, reportParams,
|
||||
reportName, errorLog);
|
||||
|
||||
if (file != null) {
|
||||
attachmentList.add(file);
|
||||
} else {
|
||||
errorLog.append(reportParams.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final EmailMessageWithAttachmentData emailMessageWithAttachmentData = EmailMessageWithAttachmentData.createNew(emailMessage.getEmailAddress(), emailMessage.getMessage(),
|
||||
emailMessage.getEmailSubject(), attachmentList);
|
||||
|
||||
if (!attachmentList.isEmpty() && attachmentList.size() > 0) { // only send email message if there is an attachment to it
|
||||
|
||||
this.emailMessageJobEmailService.sendEmailWithAttachment(emailMessageWithAttachmentData);
|
||||
|
||||
emailMessage.setStatusType(EmailMessageStatusType.SENT.getValue());
|
||||
|
||||
this.emailMessageRepository.save(emailMessage);
|
||||
} else {
|
||||
emailMessage.updateErrorMessage(errorLog.toString());
|
||||
if (emailMessage.getClient() != null) {
|
||||
|
||||
emailMessage.setStatusType(EmailMessageStatusType.FAILED.getValue());
|
||||
HashMap<String, String> reportParams = this
|
||||
.replaceStretchyParamsWithActualClientParams(reportStretchyParams, emailMessage.getClient());
|
||||
|
||||
this.emailMessageRepository.save(emailMessage);
|
||||
File file = this.generateAttachments(emailCampaign, emailAttachmentFileFormat, reportParams, reportName,
|
||||
errorLog);
|
||||
|
||||
if (file != null) {
|
||||
attachmentList.add(file);
|
||||
} else {
|
||||
errorLog.append(reportParams.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final EmailMessageWithAttachmentData emailMessageWithAttachmentData = EmailMessageWithAttachmentData.createNew(
|
||||
emailMessage.getEmailAddress(), emailMessage.getMessage(), emailMessage.getEmailSubject(), attachmentList);
|
||||
|
||||
if (!attachmentList.isEmpty() && attachmentList.size() > 0) { // only
|
||||
// send
|
||||
// email
|
||||
// message
|
||||
// if
|
||||
// there
|
||||
// is
|
||||
// an
|
||||
// attachment
|
||||
// to
|
||||
// it
|
||||
|
||||
this.emailMessageJobEmailService.sendEmailWithAttachment(emailMessageWithAttachmentData);
|
||||
|
||||
emailMessage.setStatusType(EmailMessageStatusType.SENT.getValue());
|
||||
|
||||
this.emailMessageRepository.save(emailMessage);
|
||||
} else {
|
||||
emailMessage.updateErrorMessage(errorLog.toString());
|
||||
|
||||
emailMessage.setStatusType(EmailMessageStatusType.FAILED.getValue());
|
||||
|
||||
this.emailMessageRepository.save(emailMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This generates the the report and converts it to a file by passing the parameters below
|
||||
* This generates the the report and converts it to a file by passing the
|
||||
* parameters below
|
||||
*
|
||||
* @param emailCampaign
|
||||
* @param emailAttachmentFileFormat
|
||||
* @param reportParams
|
||||
@@ -684,9 +709,9 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
* @return
|
||||
*/
|
||||
private File generateAttachments(final EmailCampaign emailCampaign, final ScheduledEmailAttachmentFileFormat emailAttachmentFileFormat,
|
||||
final Map<String, String> reportParams, final String reportName, final StringBuilder errorLog){
|
||||
final Map<String, String> reportParams, final String reportName, final StringBuilder errorLog) {
|
||||
|
||||
try{
|
||||
try {
|
||||
final ByteArrayOutputStream byteArrayOutputStream = this.readReportingService.generatePentahoReportAsOutputStream(reportName,
|
||||
emailAttachmentFileFormat.getValue(), reportParams, null, emailCampaign.getApprovedBy(), errorLog);
|
||||
|
||||
@@ -700,8 +725,7 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
|
||||
if (byteArrayOutputStream.size() == 0) {
|
||||
errorLog.append("Pentaho report processing failed, empty output stream created");
|
||||
}
|
||||
else if (errorLog.length() == 0 && (byteArrayOutputStream.size() > 0)) {
|
||||
} else if (errorLog.length() == 0 && (byteArrayOutputStream.size() > 0)) {
|
||||
final String fileName = fileNameWithoutExtension + "." + emailAttachmentFileFormat.getValue();
|
||||
|
||||
final File file = new File(fileName);
|
||||
@@ -711,59 +735,62 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
return file;
|
||||
}
|
||||
|
||||
}catch(IOException | PlatformDataIntegrityException e){
|
||||
errorLog.append("The ReportMailingJobWritePlatformServiceImpl.executeReportMailingJobs threw an IOException "
|
||||
+ "exception: " + e.getMessage() + " ---------- ");
|
||||
} catch (IOException | PlatformDataIntegrityException e) {
|
||||
errorLog.append("The ReportMailingJobWritePlatformServiceImpl.executeReportMailingJobs threw an IOException " + "exception: "
|
||||
+ e.getMessage() + " ---------- ");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This matches the the actual values to the key in the report stretchy parameters map
|
||||
* This matches the the actual values to the key in the report stretchy
|
||||
* parameters map
|
||||
*
|
||||
* @param stretchyParams
|
||||
* @param client
|
||||
* @return
|
||||
*/
|
||||
private HashMap<String,String> replaceStretchyParamsWithActualClientParams(final HashMap<String,String> stretchyParams,final Client client){
|
||||
private HashMap<String, String> replaceStretchyParamsWithActualClientParams(final HashMap<String, String> stretchyParams,
|
||||
final Client client) {
|
||||
|
||||
HashMap<String,String> actualParams = new HashMap<>();
|
||||
HashMap<String, String> actualParams = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : stretchyParams.entrySet()) {
|
||||
if(entry.getKey().equals("selectOffice")){
|
||||
//most at times the reports are run by picking the office of the staff Id
|
||||
if(client.getStaff() !=null){
|
||||
actualParams.put(entry.getKey(),client.getStaff().officeId().toString());
|
||||
}else {
|
||||
actualParams.put(entry.getKey(), client.getOffice().getId().toString());
|
||||
}
|
||||
if (entry.getKey().equals("selectOffice")) {
|
||||
// most at times the reports are run by picking the office of
|
||||
// the staff Id
|
||||
if (client.getStaff() != null) {
|
||||
actualParams.put(entry.getKey(), client.getStaff().officeId().toString());
|
||||
} else {
|
||||
actualParams.put(entry.getKey(), client.getOffice().getId().toString());
|
||||
}
|
||||
|
||||
}else if(entry.getKey().equals("selectClient")){
|
||||
} else if (entry.getKey().equals("selectClient")) {
|
||||
|
||||
actualParams.put(entry.getKey(),client.getId().toString());
|
||||
actualParams.put(entry.getKey(), client.getId().toString());
|
||||
|
||||
}else if(entry.getKey().equals("selectLoanofficer")){
|
||||
} else if (entry.getKey().equals("selectLoanofficer")) {
|
||||
|
||||
actualParams.put(entry.getKey(),client.getStaff().getId().toString());
|
||||
actualParams.put(entry.getKey(), client.getStaff().getId().toString());
|
||||
|
||||
}else if(entry.getKey().equals("environementUrl")){
|
||||
} else if (entry.getKey().equals("environementUrl")) {
|
||||
|
||||
actualParams.put(entry.getKey(),entry.getKey());
|
||||
}
|
||||
actualParams.put(entry.getKey(), entry.getKey());
|
||||
}
|
||||
}
|
||||
return actualParams;
|
||||
}
|
||||
|
||||
private HashMap<String, String> validateStretchyReportParamMap(final String stretchyParams) {
|
||||
|
||||
private HashMap<String,String> validateStretchyReportParamMap(final String stretchyParams){
|
||||
|
||||
HashMap<String,String> stretchyReportParamHashMap = new HashMap<>();
|
||||
HashMap<String, String> stretchyReportParamHashMap = new HashMap<>();
|
||||
|
||||
if (!StringUtils.isEmpty(stretchyParams)) {
|
||||
try {
|
||||
stretchyReportParamHashMap = new ObjectMapper().readValue(stretchyParams, new TypeReference<HashMap<String,String>>(){});
|
||||
stretchyReportParamHashMap = new ObjectMapper().readValue(stretchyParams, new TypeReference<HashMap<String, String>>() {});
|
||||
}
|
||||
|
||||
catch(Exception e) {
|
||||
catch (Exception e) {
|
||||
stretchyReportParamHashMap = null;
|
||||
}
|
||||
}
|
||||
@@ -771,5 +798,4 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
|
||||
return stretchyReportParamHashMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+4
-3
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.infrastructure.campaigns.email.service;
|
||||
|
||||
import org.apache.fineract.infrastructure.core.service.Page;
|
||||
import org.apache.fineract.infrastructure.core.service.SearchParameters;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.data.EmailData;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -31,13 +32,13 @@ public interface EmailReadPlatformService {
|
||||
|
||||
EmailData retrieveOne(Long resourceId);
|
||||
|
||||
Collection<EmailData> retrieveAllPending(Integer limit);
|
||||
Collection<EmailData> retrieveAllPending(final SearchParameters searchParameters);
|
||||
|
||||
Collection<EmailData> retrieveAllSent(Integer limit);
|
||||
Collection<EmailData> retrieveAllSent(final SearchParameters searchParameters);
|
||||
|
||||
Collection<EmailData> retrieveAllDelivered(Integer limit);
|
||||
|
||||
Collection<EmailData> retrieveAllFailed(Integer limit);
|
||||
Collection<EmailData> retrieveAllFailed(final SearchParameters searchParameters);
|
||||
|
||||
Page<EmailData> retrieveEmailByStatus(Integer limit, Integer status, Date dateFrom, Date dateTo);
|
||||
|
||||
|
||||
+7
-6
@@ -24,6 +24,7 @@ import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
|
||||
import org.apache.fineract.infrastructure.core.service.Page;
|
||||
import org.apache.fineract.infrastructure.core.service.PaginationHelper;
|
||||
import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
|
||||
import org.apache.fineract.infrastructure.core.service.SearchParameters;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.exception.EmailNotFoundException;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.data.EmailData;
|
||||
import org.apache.fineract.infrastructure.campaigns.email.domain.EmailMessageEnumerations;
|
||||
@@ -129,8 +130,8 @@ public class EmailReadPlatformServiceImpl implements EmailReadPlatformService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EmailData> retrieveAllPending(final Integer limit) {
|
||||
final String sqlPlusLimit = (limit > 0) ? " limit 0, " + limit : "";
|
||||
public Collection<EmailData> retrieveAllPending(final SearchParameters searchParameters) {
|
||||
final String sqlPlusLimit = (searchParameters.getLimit() > 0) ? " limit 0, " + searchParameters.getLimit() : "";
|
||||
final String sql = "select " + this.emailRowMapper.schema() + " where emo.status_enum = "
|
||||
+ EmailMessageStatusType.PENDING.getValue() + sqlPlusLimit;
|
||||
|
||||
@@ -138,8 +139,8 @@ public class EmailReadPlatformServiceImpl implements EmailReadPlatformService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EmailData> retrieveAllSent(final Integer limit) {
|
||||
final String sqlPlusLimit = (limit > 0) ? " limit 0, " + limit : "";
|
||||
public Collection<EmailData> retrieveAllSent(final SearchParameters searchParameters) {
|
||||
final String sqlPlusLimit = (searchParameters.getLimit() > 0) ? " limit 0, " + searchParameters.getLimit() : "";
|
||||
final String sql = "select " + this.emailRowMapper.schema() + " where emo.status_enum = "
|
||||
+ EmailMessageStatusType.SENT.getValue() + sqlPlusLimit;
|
||||
|
||||
@@ -165,8 +166,8 @@ public class EmailReadPlatformServiceImpl implements EmailReadPlatformService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<EmailData> retrieveAllFailed(final Integer limit) {
|
||||
final String sqlPlusLimit = (limit > 0) ? " limit 0, " + limit : "";
|
||||
public Collection<EmailData> retrieveAllFailed(final SearchParameters searchParameters) {
|
||||
final String sqlPlusLimit = (searchParameters.getLimit() > 0) ? " limit 0, " + searchParameters.getLimit() : "";
|
||||
final String sql = "select " + this.emailRowMapper.schema() + " where emo.status_enum = "
|
||||
+ EmailMessageStatusType.FAILED.getValue() + sqlPlusLimit;
|
||||
|
||||
|
||||
+6
-10
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.infrastructure.dataqueries.service;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
@@ -49,16 +50,6 @@ import org.apache.fineract.infrastructure.documentmanagement.contentrepository.F
|
||||
import org.apache.fineract.infrastructure.report.provider.ReportingProcessServiceProvider;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.useradministration.domain.AppUser;
|
||||
import org.pentaho.reporting.engine.classic.core.DefaultReportEnvironment;
|
||||
import org.pentaho.reporting.engine.classic.core.MasterReport;
|
||||
import org.pentaho.reporting.engine.classic.core.ReportProcessingException;
|
||||
import org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.PdfReportUtil;
|
||||
import org.pentaho.reporting.engine.classic.core.modules.output.table.csv.CSVReportUtil;
|
||||
import org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlReportUtil;
|
||||
import org.pentaho.reporting.engine.classic.core.modules.output.table.xls.ExcelReportUtil;
|
||||
import org.pentaho.reporting.libraries.resourceloader.Resource;
|
||||
import org.pentaho.reporting.libraries.resourceloader.ResourceException;
|
||||
import org.pentaho.reporting.libraries.resourceloader.ResourceManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -530,6 +521,8 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
@Override
|
||||
public ByteArrayOutputStream generatePentahoReportAsOutputStream(final String reportName, final String outputTypeParam, final Map<String, String> queryParams,
|
||||
final Locale locale, final AppUser runReportAsUser, final StringBuilder errorLog) {
|
||||
//This complete implementation should be moved to Pentaho Report Service
|
||||
/*
|
||||
String outputType = "HTML";
|
||||
if (StringUtils.isNotBlank(outputTypeParam)) {
|
||||
outputType = outputTypeParam;
|
||||
@@ -600,6 +593,9 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
errorLog.append("ReadReportingServiceImpl.generatePentahoReportAsOutputStream method threw a PlatformDataIntegrityException "
|
||||
+ "exception: No matching Output Type: " + outputType + " ---------- ");
|
||||
throw new PlatformDataIntegrityException("error.msg.invalid.outputType", "No matching Output Type: " + outputType);
|
||||
|
||||
*/
|
||||
return null ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,13 +51,14 @@
|
||||
org.apache.fineract.portfolio.savingsaccount.*,
|
||||
org.apache.fineract.portfolio.*,
|
||||
org.apache.fineract.useradministration.*,
|
||||
org.apache.fineract.mix.*,
|
||||
org.apache.fineract.mix.*,
|
||||
org.apache.fineract.notification.*,
|
||||
org.apache.fineract.template.*,
|
||||
org.apache.fineract.template.service.*,
|
||||
org.apache.fineract.useradministration.*,
|
||||
org.apache.fineract.batch,
|
||||
org.apache.fineract.adhocquery.*">
|
||||
org.apache.fineract.adhocquery.*,
|
||||
org.apache.fineract.infrastructure.campaigns.**">
|
||||
<context:exclude-filter expression="org.springframework.stereotype.Controller"
|
||||
type="annotation" />
|
||||
|
||||
@@ -84,6 +85,8 @@
|
||||
<jpa:repositories base-package="org.apache.fineract.infrastructure.campaigns.sms.domain" />
|
||||
<jpa:repositories base-package="org.apache.fineract.adhocquery.domain" />
|
||||
<jpa:repositories base-package="org.apache.fineract.notification.domain"/>
|
||||
<jpa:repositories base-package="org.apache.fineract.infrastructure.campaigns.email.domain"/>
|
||||
|
||||
|
||||
<import resource="infrastructure.xml" />
|
||||
|
||||
|
||||
+42
-43
@@ -34,78 +34,77 @@ INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `
|
||||
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Loan Approved - Email', 'Email', 'Triggered', 'SELECT mc.id, mc.firstname, mc.middlename as middlename, mc.lastname, mc.display_name as FullName, mc.email_address as EmailAddress, mc.group_name as GroupName,\n mo.name as officename, ifnull(od.phoneNumber,\'\') as officenummber, ml.id as loanId, ml.account_no as accountnumber, ml.principal_amount_proposed as loanamount, ml.annual_nominal_interest_rate as annualinterestrate\n FROM\n m_office mo\n JOIN m_office ounder ON ounder.hierarchy LIKE CONCAT(mo.hierarchy, \'%\')\n AND ounder.hierarchy like CONCAT(\'.\', \'%\')\n LEFT JOIN (\n select \n ml.id as loanId, \n ifnull(mc.id,mc2.id) as id, \n ifnull(mc.firstname,mc2.firstname) as firstname, \n ifnull(mc.middlename,ifnull(mc2.middlename,(\'\'))) as middlename, \n ifnull(mc.lastname,mc2.lastname) as lastname, \n ifnull(mc.display_name,mc2.display_name) as display_name, \n ifnull(mc.status_enum,mc2.status_enum) as status_enum,\n ifnull(mc.email_address,mc2.email_address) as email_address,\n ifnull(mg.office_id,mc2.office_id) as office_id,\n ifnull(mg.staff_id,mc2.staff_id) as staff_id,\n mg.id as group_id, \nmg.display_name as group_name\n from\n m_loan ml\n left join m_group mg on mg.id = ml.group_id\n left join m_group_client mgc on mgc.group_id = mg.id\n left join m_client mc on mc.id = mgc.client_id\n left join m_client mc2 on mc2.id = ml.client_id\n order by loanId\n ) mc on mc.office_id = ounder.id\n left join ml_office_details as od on od.office_id = mo.id\n left join m_loan ml on ml.id = mc.loanId\n WHERE mc.status_enum = 300 and mc.email_address is not null\n and (mo.id = ${officeId} or ${officeId} = -1)\n and (mc.staff_id = ${staffId} or ${staffId} = -1)\nand (ml.id = ${loanId} or ${loanId} = -1)\nand (mc.id = ${clientId} or ${clientId} = -1)\nand (mc.group_id = ${groupId} or ${groupId} = -1)\nand (ml.loan_type_enum = ${loanType} or ${loanType} = -1)', 'Loan and client data of approved loan', '0', '0');
|
||||
INSERT INTO `stretchy_report` (`report_name`, `report_type`, `report_subtype`, `report_sql`, `description`, `core_report`, `use_report`) VALUES ('Loan Repayment - Email', 'Email', 'Triggered', 'select ml.id as loanId,mc.id, mc.firstname, ifnull(mc.middlename,\'\') as middlename, mc.lastname, mc.display_name as FullName, email_address as EmailAddress, mc.group_name as GroupName, round(ml.principal_amount, ml.currency_digits) as LoanAmount, round(ml.`total_outstanding_derived`, ml.currency_digits) as LoanOutstanding,\nifnull(od.phoneNumber,\'\') as officenummber,ml.`account_no` as LoanAccountId, round(mlt.amountPaid, ml.currency_digits) as repaymentAmount\nFROM m_office mo\nJOIN m_office ounder ON ounder.hierarchy LIKE CONCAT(mo.hierarchy, \'%\')\nAND ounder.hierarchy like CONCAT(\'.\', \'%\')\nLEFT JOIN (\n select \n ml.id as loanId, \n ifnull(mc.id,mc2.id) as id, \n ifnull(mc.firstname,mc2.firstname) as firstname, \n ifnull(mc.middlename,ifnull(mc2.middlename,(\'\'))) as middlename, \n ifnull(mc.lastname,mc2.lastname) as lastname, \n ifnull(mc.display_name,mc2.display_name) as display_name, \n ifnull(mc.status_enum,mc2.status_enum) as status_enum,\n ifnull(mc.email_address,mc2.email_address) as email_address,\n ifnull(mg.office_id,mc2.office_id) as office_id,\n ifnull(mg.staff_id,mc2.staff_id) as staff_id,\n mg.id as group_id, \nmg.display_name as group_name\n from\n m_loan ml\n left join m_group mg on mg.id = ml.group_id\n left join m_group_client mgc on mgc.group_id = mg.id\n left join m_client mc on mc.id = mgc.client_id\n left join m_client mc2 on mc2.id = ml.client_id\n order by loanId\n ) mc on mc.office_id = ounder.id\nleft join ml_office_details as od on od.office_id = mo.id\nright join m_loan as ml on mc.loanId = ml.id\nright join(\nselect mlt.amount as amountPaid,mlt.id,mlt.loan_id\nfrom m_loan_transaction mlt\nwhere mlt.is_reversed = 0 \ngroup by mlt.loan_id\n) as mlt on mlt.loan_id = ml.id\nright join m_loan_repayment_schedule as mls1 on ml.id = mls1.loan_id and mls1.`completed_derived` = 0\nand mls1.installment = (SELECT MIN(installment) from m_loan_repayment_schedule where loan_id = ml.id and duedate <= CURDATE() and completed_derived=0)\nwhere mc.status_enum = 300 and email_address is not null and ml.`loan_status_id` = 300\nand (mo.id = ${officeId} or ${officeId} = -1)\nand (mc.staff_id = ${staffId} or ${staffId} = -1)\nand (ml.loan_type_enum = ${loanType} or ${loanType} = -1)\nand ml.id in (select mla.loan_id from m_loan_arrears_aging mla)\ngroup by ml.id', 'Loan Repayment', '0', '0');
|
||||
|
||||
|
||||
INSERT INTO `stretchy_report_parameter` (`report_id`, `parameter_id`, `report_parameter_name`)
|
||||
VALUES
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Prospective Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Prospective Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Prospective Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Loan Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Loan Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Loan Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'cycleX'), 'Cycle X'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Loan Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'cycleY'), 'Cycle Y'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Loan Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Loan Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'cycleXSelect'), 'Cycle X'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Loan Clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'cycleYSelect'), 'Cycle Y'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans in arrears - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans in arrears - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans in arrears - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromX'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans in arrears - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toY'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans in arrears - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans in arrears - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromXSelect'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans in arrears - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toYSelect'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromX'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toY'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'cycleX'), 'Cycle X'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'cycleY'), 'Cycle Y'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromXSelect'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toYSelect'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'cycleXSelect'), 'Cycle X'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans disbursed to clients - Email'), (SELECT id from stretchy_parameter where parameter_name = 'cycleYSelect'), 'Cycle Y'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan payments due - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan payments due - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan payments due - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromX'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan payments due - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toY'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan payments due - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan payments due - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromXSelect'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan payments due - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toYSelect'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Dormant Prospects - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Dormant Prospects - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Dormant Prospects - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Group Leaders - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Group Leaders - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Active Group Leaders - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromX'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toY'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'overdueX'), 'overdueX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'overdueY'), 'overdueY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromXSelect'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toYSelect'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'overdueXSelect'), 'overdueX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Due (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'overdueYSelect'), 'overdueY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Active Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Active Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Active Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromX'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Active Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toY'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Active Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Active Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromXSelect'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Active Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toYSelect'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromX'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toY'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'overdueX'), 'overdueX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'overdueY'), 'overdueY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromXSelect'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toYSelect'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'overdueXSelect'), 'overdueX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Payments Received (Overdue Loans) - Email'), (SELECT id from stretchy_parameter where parameter_name = 'overdueYSelect'), 'overdueY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Happy Birthday - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Happy Birthday - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Happy Birthday - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Fully Repaid - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Fully Repaid - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Fully Repaid - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromX'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Fully Repaid - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toY'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Fully Repaid - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Fully Repaid - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromXSelect'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Fully Repaid - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toYSelect'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans Outstanding after final instalment date - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans Outstanding after final instalment date - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toY'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans Outstanding after final instalment date - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromX'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans Outstanding after final instalment date - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans Outstanding after final instalment date - Email'), (SELECT id from stretchy_parameter where parameter_name = 'toYSelect'), 'toY'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans Outstanding after final instalment date - Email'), (SELECT id from stretchy_parameter where parameter_name = 'fromXSelect'), 'fromX'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loans Outstanding after final instalment date - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Rejected - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Rejected - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Rejected - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Rejected - Email'), (SELECT id from stretchy_parameter where parameter_name = 'DefaultLoan'), 'loanId'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Rejected - Email'), (SELECT id from stretchy_parameter where parameter_name = 'DefaultClient'), 'clientId'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Rejected - Email'), (SELECT id from stretchy_parameter where parameter_name = 'DefaultGroup'), 'groupId'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Rejected - Email'), (SELECT id from stretchy_parameter where parameter_name = 'SelectLoanType'), 'loanType'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Approved - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Approved - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Approved - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Approved - Email'), (SELECT id from stretchy_parameter where parameter_name = 'DefaultLoan'), 'loanId'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Approved - Email'), (SELECT id from stretchy_parameter where parameter_name = 'DefaultClient'), 'clientId'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Approved - Email'), (SELECT id from stretchy_parameter where parameter_name = 'DefaultGroup'), 'groupId'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Approved - Email'), (SELECT id from stretchy_parameter where parameter_name = 'SelectLoanType'), 'loanType'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Repayment - Email'), (SELECT id from stretchy_parameter where parameter_name = 'OfficeIdSelectOne'), 'Office'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Repayment - Email'), (SELECT id from stretchy_parameter where parameter_name = 'LoanOfficerSelectOneRec'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Repayment - Email'), (SELECT id from stretchy_parameter where parameter_name = 'loanOfficerIdSelectAll'), 'Loanofficer'),
|
||||
( (SELECT id from stretchy_report where report_name = 'Loan Repayment - Email'), (SELECT id from stretchy_parameter where parameter_name = 'SelectLoanType'), 'loanType');
|
||||
|
||||
|
||||
|
||||
INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`)
|
||||
VALUES
|
||||
('report', 'READ_Active Clients - Email', 'Active Clients - Email', 'READ', 0),
|
||||
|
||||
Reference in New Issue
Block a user