refactor: add lombok to producttoaccountmapping module

This commit is contained in:
Hemant Gupta
2022-08-29 11:10:29 +02:00
committed by Arnold Gálovics
parent 950f6489fe
commit 78c541e992
5 changed files with 42 additions and 99 deletions
@@ -21,13 +21,18 @@ package org.apache.fineract.accounting.producttoaccountmapping.data;
import java.io.Serializable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
import org.apache.fineract.portfolio.charge.data.ChargeData;
@RequiredArgsConstructor
@Getter
@Setter
@Accessors(chain = true)
public class ChargeToGLAccountMapper implements Serializable {
private final ChargeData charge;
private final GLAccountData incomeAccount;
private static final long serialVersionUID = 1L;
private ChargeData charge;
private GLAccountData incomeAccount;
}
@@ -19,15 +19,18 @@
package org.apache.fineract.accounting.producttoaccountmapping.data;
import java.io.Serializable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData;
@RequiredArgsConstructor
@Getter
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class PaymentTypeToGLAccountMapper implements Serializable {
private final PaymentTypeData paymentType;
private final GLAccountData fundSourceAccount;
private static final long serialVersionUID = 1L;
private PaymentTypeData paymentType;
private GLAccountData fundSourceAccount;
}
@@ -24,11 +24,19 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.portfolio.charge.domain.Charge;
import org.apache.fineract.portfolio.paymenttype.domain.PaymentType;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@Entity
@Table(name = "acc_product_mapping", uniqueConstraints = { @UniqueConstraint(columnNames = { "product_id", "product_type",
"financial_account_type", "payment_type" }, name = "financial_action") })
@@ -57,84 +65,9 @@ public class ProductToGLAccountMapping extends AbstractPersistableCustom {
public static ProductToGLAccountMapping createNew(final GLAccount glAccount, final Long productId, final int productType,
final int financialAccountType) {
return new ProductToGLAccountMapping(glAccount, productId, productType, financialAccountType);
}
protected ProductToGLAccountMapping() {
//
}
public ProductToGLAccountMapping(final GLAccount glAccount, final Long productId, final int productType,
final int financialAccountType) {
this(glAccount, productId, productType, financialAccountType, null, null);
}
public ProductToGLAccountMapping(final GLAccount glAccount, final Long productId, final int productType, final int financialAccountType,
final Charge charge) {
this(glAccount, productId, productType, financialAccountType, null, charge);
}
public ProductToGLAccountMapping(final GLAccount glAccount, final Long productId, final int productType, final int financialAccountType,
final PaymentType paymentType) {
this(glAccount, productId, productType, financialAccountType, paymentType, null);
}
private ProductToGLAccountMapping(final GLAccount glAccount, final Long productId, final int productType,
final int financialAccountType, final PaymentType paymentType, final Charge charge) {
this.glAccount = glAccount;
this.productId = productId;
this.productType = productType;
this.financialAccountType = financialAccountType;
this.paymentType = paymentType;
this.charge = charge;
}
public GLAccount getGlAccount() {
return this.glAccount;
}
public void setGlAccount(final GLAccount glAccount) {
this.glAccount = glAccount;
}
public Long getProductId() {
return this.productId;
}
public void setProductId(final Long productId) {
this.productId = productId;
}
public int getProductType() {
return this.productType;
}
public void setProductType(final int productType) {
this.productType = productType;
}
public int getFinancialAccountType() {
return this.financialAccountType;
}
public void setFinancialAccountType(final int financialAccountType) {
this.financialAccountType = financialAccountType;
}
public PaymentType getPaymentType() {
return this.paymentType;
}
public void setPaymentType(final PaymentType paymentType) {
this.paymentType = paymentType;
}
public Charge getCharge() {
return this.charge;
}
public void setCharge(final Charge charge) {
this.charge = charge;
return new ProductToGLAccountMapping().setGlAccount(glAccount).setProductId(productId).setProductType(productType)
.setFinancialAccountType(financialAccountType);
}
}
@@ -66,8 +66,8 @@ public class ProductToGLAccountMappingHelper {
if (accountId != null) { // optional entries may be null
final GLAccount glAccount = getAccountByIdAndType(paramName, expectedAccountType, accountId);
final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping(glAccount, productId,
portfolioProductType.getValue(), placeHolderTypeId);
final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping().setGlAccount(glAccount).setProductId(productId)
.setProductType(portfolioProductType.getValue()).setFinancialAccountType(placeHolderTypeId);
this.accountMappingRepository.saveAndFlush(accountMapping);
}
}
@@ -112,8 +112,8 @@ public class ProductToGLAccountMappingHelper {
if (accountMapping == null) {
final GLAccount glAccount = getAccountByIdAndType(paramName, expectedAccountType, accountId);
changes.put(paramName, accountId);
ProductToGLAccountMapping newAccountMapping = new ProductToGLAccountMapping(glAccount, productId,
portfolioProductType.getValue(), accountTypeId);
ProductToGLAccountMapping newAccountMapping = new ProductToGLAccountMapping().setGlAccount(glAccount)
.setProductId(productId).setProductType(portfolioProductType.getValue()).setFinancialAccountType(accountTypeId);
this.accountMappingRepository.saveAndFlush(newAccountMapping);
} else if (!accountMapping.getGlAccount().getId().equals(accountId)) {
final GLAccount glAccount = getAccountByIdAndType(paramName, expectedAccountType, accountId);
@@ -354,20 +354,21 @@ public class ProductToGLAccountMappingHelper {
/**
* @param productId
* @param jsonObject
*
*/
private void savePaymentChannelToFundSourceMapping(final Long productId, final Long paymentTypeId,
final Long paymentTypeSpecificFundAccountId, final PortfolioProductType portfolioProductType) {
final PaymentType paymentType = this.paymentTypeRepositoryWrapper.findOneWithNotFoundDetection(paymentTypeId);
final GLAccount glAccount = getAccountById(LoanProductAccountingParams.FUND_SOURCE.getValue(), paymentTypeSpecificFundAccountId);
final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping(glAccount, productId,
portfolioProductType.getValue(), CashAccountsForLoan.FUND_SOURCE.getValue(), paymentType);
final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping().setGlAccount(glAccount).setProductId(productId)
.setProductType(portfolioProductType.getValue()).setFinancialAccountType(CashAccountsForLoan.FUND_SOURCE.getValue())
.setPaymentType(paymentType);
this.accountMappingRepository.saveAndFlush(accountMapping);
}
/**
* @param productId
* @param jsonObject
*
*/
private void saveChargeToFundSourceMapping(final Long productId, final Long chargeId, final Long incomeAccountId,
final PortfolioProductType portfolioProductType, final boolean isPenalty) {
@@ -391,8 +392,9 @@ public class ProductToGLAccountMappingHelper {
incomeAccountId);
placeHolderAccountType = CashAccountsForLoan.INCOME_FROM_FEES;
}
final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping(glAccount, productId,
portfolioProductType.getValue(), placeHolderAccountType.getValue(), charge);
final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping().setGlAccount(glAccount).setProductId(productId)
.setProductType(portfolioProductType.getValue()).setFinancialAccountType(placeHolderAccountType.getValue())
.setCharge(charge);
this.accountMappingRepository.saveAndFlush(accountMapping);
}
@@ -246,7 +246,6 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
/**
* @param loanProductId
* @param paymentTypeToGLAccountMappers
* @return
*/
private List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappings(final PortfolioProductType portfolioProductType,
@@ -271,8 +270,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final GLAccountData gLAccountData = new GLAccountData().setId(glAccountId).setName(glAccountName).setGlCode(glCode);
final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeData,
gLAccountData);
final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper()
.setPaymentType(paymentTypeData).setFundSourceAccount(gLAccountData);
paymentTypeToGLAccountMappers.add(paymentTypeToGLAccountMapper);
}
return paymentTypeToGLAccountMappers;
@@ -323,7 +322,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final String chargeName = (String) chargeToIncomeAccountMap.get("chargeName");
final Boolean penalty1 = (Boolean) chargeToIncomeAccountMap.get("penalty");
final ChargeData chargeData = ChargeData.lookup(chargeId, chargeName, penalty1);
final ChargeToGLAccountMapper chargeToGLAccountMapper = new ChargeToGLAccountMapper(chargeData, gLAccountData);
final ChargeToGLAccountMapper chargeToGLAccountMapper = new ChargeToGLAccountMapper().setCharge(chargeData)
.setIncomeAccount(gLAccountData);
chargeToGLAccountMappers.add(chargeToGLAccountMapper);
}
return chargeToGLAccountMappers;