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