Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix FSF-9 #940

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.group.exception;

import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;

public class PortfolioOfficeNotFoundException extends AbstractPlatformDomainRuleException {

public PortfolioOfficeNotFoundException(final String potfolioOffice) {
super("error.msg.portfolio.office.not.found",
"The Portfolio with name `" + potfolioOffice + "` Does not have a matching office created. First created the office", potfolioOffice);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
import org.apache.fineract.portfolio.group.exception.GroupMustBePendingToBeDeletedException;
import org.apache.fineract.portfolio.group.exception.InvalidGroupLevelException;
import org.apache.fineract.portfolio.group.exception.InvalidGroupStateTransitionException;
import org.apache.fineract.portfolio.group.exception.PortfolioOfficeNotFoundException;
import org.apache.fineract.portfolio.group.exception.PrequalificationMappedException;
import org.apache.fineract.portfolio.group.serialization.GroupingTypesDataValidator;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
Expand Down Expand Up @@ -1142,6 +1143,14 @@ public CommandProcessingResult generateCentersByPortfolio(Portfolio portfolio) {

// set values to generate the centers
final Office office = portfolio.getParentOffice();

String portfolioOfficeQuery = "SELECT id from m_office where name=?";
List<Long> portfolioIds = jdbcTemplate.queryForList(portfolioOfficeQuery, Long.class, portfolio.getName());
if (portfolioIds.size()<=0) {
throw new PortfolioOfficeNotFoundException(portfolio.getName());
}
Office portfolioOffice = this.officeRepositoryWrapper.findOneWithNotFoundDetection(portfolioIds.get(0));
// Office portfolioOffice = office.getParent();
final boolean active = true;
final LocalDate activationDate = DateUtils.getLocalDateOfTenant();
final LocalDate submittedOnDate = DateUtils.getLocalDateOfTenant();
Expand All @@ -1157,7 +1166,7 @@ public CommandProcessingResult generateCentersByPortfolio(Portfolio portfolio) {
final Integer meetingStart = rangeTemplateData.getStartDay();
final Integer meetingEnd = rangeTemplateData.getEndDay();

Group newCenter = Group.assembleNewCenterFrom(office, groupLevel, centerName, active, activationDate, submittedOnDate,
Group newCenter = Group.assembleNewCenterFrom(portfolioOffice, groupLevel, centerName, active, activationDate, submittedOnDate,
currentUser, meetingStartTime, meetingEndTime, portfolio, meetingStart, meetingEnd, meetingDayValue);

this.groupRepository.saveAndFlush(newCenter);
Expand Down
Loading