You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ar...@apache.org on 2022/08/22 12:46:03 UTC
[fineract] branch develop updated: refactor: add lombok to GLAccount module
This is an automated email from the ASF dual-hosted git repository.
arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new f86a7c726 refactor: add lombok to GLAccount module
f86a7c726 is described below
commit f86a7c726f704b35e267afd68fafeacd0654b3e8
Author: Hemant Gupta <gu...@gmail.com>
AuthorDate: Tue Aug 9 16:47:49 2022 +0530
refactor: add lombok to GLAccount module
---
...cialActivityAccountReadPlatformServiceImpl.java | 3 +-
.../glaccount/api/GLAccountsApiResource.java | 15 +-
.../accounting/glaccount/data/GLAccountData.java | 250 +++------------------
.../glaccount/data/GLAccountDataForLookup.java | 21 +-
.../accounting/glaccount/domain/GLAccount.java | 70 +-----
.../accounting/glaccount/domain/TrialBalance.java | 46 +---
.../service/GLAccountReadPlatformServiceImpl.java | 9 +-
...countWritePlatformServiceJpaRepositoryImpl.java | 5 +-
.../JournalEntryReadPlatformServiceImpl.java | 4 +-
...tToGLAccountMappingReadPlatformServiceImpl.java | 13 +-
.../AccountingRuleReadPlatformServiceImpl.java | 8 +-
.../core/domain/AbstractPersistableCustom.java | 24 +-
.../fineract/portfolio/charge/domain/Charge.java | 2 +-
.../service/ChargeReadPlatformServiceImpl.java | 2 +-
.../tax/service/TaxReadPlatformServiceImpl.java | 4 +-
15 files changed, 120 insertions(+), 356 deletions(-)
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/financialactivityaccount/service/FinancialActivityAccountReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/financialactivityaccount/service/FinancialActivityAccountReadPlatformServiceImpl.java
index a2e758077..6c69a934a 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/financialactivityaccount/service/FinancialActivityAccountReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/financialactivityaccount/service/FinancialActivityAccountReadPlatformServiceImpl.java
@@ -102,7 +102,8 @@ public class FinancialActivityAccountReadPlatformServiceImpl implements Financia
final String glAccountName = rs.getString("glAccountName");
final String glCode = rs.getString("glCode");
- final GLAccountData glAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
+ final GLAccountData glAccountData = new GLAccountData().setId(glAccountId).setName(glAccountName).setGlCode(glCode);
+
final FinancialActivityData financialActivityData = FinancialActivity.toFinancialActivityData(financialActivityId);
final FinancialActivityAccountData financialActivityAccountData = new FinancialActivityAccountData(id, financialActivityData,
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/api/GLAccountsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/api/GLAccountsApiResource.java
index 4ae0ddf3d..fcb8696e1 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/api/GLAccountsApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/api/GLAccountsApiResource.java
@@ -252,9 +252,18 @@ public class GLAccountsApiResource {
final Collection<CodeValueData> allowedExpensesTagOptions = this.codeValueReadPlatformService
.retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME);
- return new GLAccountData(glAccountData, accountTypeOptions, usageOptions, assetHeaderAccountOptions, liabilityHeaderAccountOptions,
- equityHeaderAccountOptions, incomeHeaderAccountOptions, expenseHeaderAccountOptions, allowedAssetsTagOptions,
- allowedLiabilitiesTagOptions, allowedEquityTagOptions, allowedIncomeTagOptions, allowedExpensesTagOptions);
+ return new GLAccountData().setId(glAccountData.getId()).setName(glAccountData.getName()).setParentId(glAccountData.getParentId())
+ .setGlCode(glAccountData.getGlCode()).setDisabled(glAccountData.getDisabled())
+ .setManualEntriesAllowed(glAccountData.getManualEntriesAllowed()).setType(glAccountData.getType())
+ .setUsage(glAccountData.getUsage()).setDescription(glAccountData.getDescription())
+ .setNameDecorated(glAccountData.getNameDecorated()).setTagId(glAccountData.getTagId())
+ .setOrganizationRunningBalance(glAccountData.getOrganizationRunningBalance()).setAccountTypeOptions(accountTypeOptions)
+ .setUsageOptions(usageOptions).setAssetHeaderAccountOptions(assetHeaderAccountOptions)
+ .setLiabilityHeaderAccountOptions(liabilityHeaderAccountOptions).setEquityHeaderAccountOptions(equityHeaderAccountOptions)
+ .setIncomeHeaderAccountOptions(incomeHeaderAccountOptions).setExpenseHeaderAccountOptions(expenseHeaderAccountOptions)
+ .setAllowedAssetsTagOptions(allowedAssetsTagOptions).setAllowedLiabilitiesTagOptions(allowedLiabilitiesTagOptions)
+ .setAllowedEquityTagOptions(allowedEquityTagOptions).setAllowedIncomeTagOptions(allowedIncomeTagOptions)
+ .setAllowedExpensesTagOptions(allowedExpensesTagOptions);
}
private List<GLAccountData> defaultIfEmpty(final List<GLAccountData> list) {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/data/GLAccountData.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/data/GLAccountData.java
index ef3d82a15..7996064d2 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/data/GLAccountData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/data/GLAccountData.java
@@ -21,6 +21,9 @@ package org.apache.fineract.accounting.glaccount.data;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
import org.apache.fineract.accounting.common.AccountingEnumerations;
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
import org.apache.fineract.accounting.glaccount.domain.GLAccountUsage;
@@ -32,181 +35,54 @@ import org.apache.fineract.infrastructure.core.data.EnumOptionData;
*
* Note: no getter/setters required as google-gson will produce json from fields of object.
*/
+
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
public class GLAccountData implements Serializable {
- private final Long id;
- private final String name;
- private final Long parentId;
- private final String glCode;
- private final Boolean disabled;
- private final Boolean manualEntriesAllowed;
- private final EnumOptionData type;
- private final EnumOptionData usage;
- private final String description;
- private final String nameDecorated;
- private final CodeValueData tagId;
- private final Long organizationRunningBalance;
+ private Long id;
+ private String name;
+ private Long parentId;
+ private String glCode;
+ private Boolean disabled;
+ private Boolean manualEntriesAllowed;
+ private EnumOptionData type;
+ private EnumOptionData usage;
+ private String description;
+ private String nameDecorated;
+ private CodeValueData tagId;
+ private Long organizationRunningBalance;
// templates
- final List<EnumOptionData> accountTypeOptions;
- final List<EnumOptionData> usageOptions;
- final List<GLAccountData> assetHeaderAccountOptions;
- final List<GLAccountData> liabilityHeaderAccountOptions;
- final List<GLAccountData> equityHeaderAccountOptions;
- final List<GLAccountData> incomeHeaderAccountOptions;
- final List<GLAccountData> expenseHeaderAccountOptions;
- final Collection<CodeValueData> allowedAssetsTagOptions;
- final Collection<CodeValueData> allowedLiabilitiesTagOptions;
- final Collection<CodeValueData> allowedEquityTagOptions;
- final Collection<CodeValueData> allowedIncomeTagOptions;
- final Collection<CodeValueData> allowedExpensesTagOptions;
+ private List<EnumOptionData> accountTypeOptions;
+ private List<EnumOptionData> usageOptions;
+ private List<GLAccountData> assetHeaderAccountOptions;
+ private List<GLAccountData> liabilityHeaderAccountOptions;
+ private List<GLAccountData> equityHeaderAccountOptions;
+ private List<GLAccountData> incomeHeaderAccountOptions;
+ private List<GLAccountData> expenseHeaderAccountOptions;
+ private Collection<CodeValueData> allowedAssetsTagOptions;
+ private Collection<CodeValueData> allowedLiabilitiesTagOptions;
+ private Collection<CodeValueData> allowedEquityTagOptions;
+ private Collection<CodeValueData> allowedIncomeTagOptions;
+ private Collection<CodeValueData> allowedExpensesTagOptions;
// import fields
private transient Integer rowIndex;
public static GLAccountData importInstance(String name, Long parentId, String glCode, Boolean manualEntriesAllowed, EnumOptionData type,
EnumOptionData usage, String description, CodeValueData tagId, Integer rowIndex) {
- return new GLAccountData(name, parentId, glCode, manualEntriesAllowed, type, usage, description, tagId, rowIndex);
+ return new GLAccountData().setName(name).setParentId(parentId).setGlCode(glCode).setManualEntriesAllowed(manualEntriesAllowed)
+ .setType(type).setUsage(usage).setDescription(description).setTagId(tagId).setRowIndex(rowIndex);
}
public static GLAccountData createFrom(final Long id) {
- return new GLAccountData(id);
- }
-
- private GLAccountData(final Long id) {
-
- this.name = null;
- this.parentId = null;
- this.glCode = null;
- this.manualEntriesAllowed = null;
- this.type = null;
- this.usage = null;
- this.description = null;
- this.tagId = null;
- this.rowIndex = null;
- this.id = id;
- this.disabled = null;
- this.nameDecorated = null;
- this.organizationRunningBalance = null;
- this.accountTypeOptions = null;
- this.usageOptions = null;
- this.assetHeaderAccountOptions = null;
- this.liabilityHeaderAccountOptions = null;
- this.equityHeaderAccountOptions = null;
- this.incomeHeaderAccountOptions = null;
- this.expenseHeaderAccountOptions = null;
- this.allowedAssetsTagOptions = null;
- this.allowedLiabilitiesTagOptions = null;
- this.allowedEquityTagOptions = null;
- this.allowedIncomeTagOptions = null;
- this.allowedExpensesTagOptions = null;
- }
-
- private GLAccountData(String name, Long parentId, String glCode, Boolean manualEntriesAllowed, EnumOptionData type,
- EnumOptionData usage, String description, CodeValueData tagId, Integer rowIndex) {
-
- this.name = name;
- this.parentId = parentId;
- this.glCode = glCode;
- this.manualEntriesAllowed = manualEntriesAllowed;
- this.type = type;
- this.usage = usage;
- this.description = description;
- this.tagId = tagId;
- this.rowIndex = rowIndex;
- this.id = null;
- this.disabled = null;
- this.nameDecorated = null;
- this.organizationRunningBalance = null;
- this.accountTypeOptions = null;
- this.usageOptions = null;
- this.assetHeaderAccountOptions = null;
- this.liabilityHeaderAccountOptions = null;
- this.equityHeaderAccountOptions = null;
- this.incomeHeaderAccountOptions = null;
- this.expenseHeaderAccountOptions = null;
- this.allowedAssetsTagOptions = null;
- this.allowedLiabilitiesTagOptions = null;
- this.allowedEquityTagOptions = null;
- this.allowedIncomeTagOptions = null;
- this.allowedExpensesTagOptions = null;
- }
-
- public Integer getRowIndex() {
- return rowIndex;
- }
-
- public CodeValueData getTagId() {
- return tagId;
- }
-
- public GLAccountData(final Long id, final String name, final Long parentId, final String glCode, final boolean disabled,
- final boolean manualEntriesAllowed, final EnumOptionData type, final EnumOptionData usage, final String description,
- final String nameDecorated, final CodeValueData tagId, final Long organizationRunningBalance) {
- this.id = id;
- this.name = name;
- this.parentId = parentId;
- this.glCode = glCode;
- this.disabled = disabled;
- this.manualEntriesAllowed = manualEntriesAllowed;
- this.type = type;
- this.usage = usage;
- this.description = description;
- this.nameDecorated = nameDecorated;
- this.tagId = tagId;
- this.organizationRunningBalance = organizationRunningBalance;
- this.accountTypeOptions = null;
- this.usageOptions = null;
- this.assetHeaderAccountOptions = null;
- this.liabilityHeaderAccountOptions = null;
- this.equityHeaderAccountOptions = null;
- this.incomeHeaderAccountOptions = null;
- this.expenseHeaderAccountOptions = null;
- this.allowedAssetsTagOptions = null;
- this.allowedLiabilitiesTagOptions = null;
- this.allowedEquityTagOptions = null;
- this.allowedIncomeTagOptions = null;
- this.allowedExpensesTagOptions = null;
- }
- public GLAccountData(final GLAccountData accountData, final List<EnumOptionData> accountTypeOptions,
- final List<EnumOptionData> usageOptions, final List<GLAccountData> assetHeaderAccountOptions,
- final List<GLAccountData> liabilityHeaderAccountOptions, final List<GLAccountData> equityHeaderAccountOptions,
- final List<GLAccountData> incomeHeaderAccountOptions, final List<GLAccountData> expenseHeaderAccountOptions,
- final Collection<CodeValueData> allowedAssetsTagOptions, final Collection<CodeValueData> allowedLiabilitiesTagOptions,
- final Collection<CodeValueData> allowedEquityTagOptions, final Collection<CodeValueData> allowedIncomeTagOptions,
- final Collection<CodeValueData> allowedExpensesTagOptions) {
- this.id = accountData.id;
- this.name = accountData.name;
- this.parentId = accountData.parentId;
- this.glCode = accountData.glCode;
- this.disabled = accountData.disabled;
- this.manualEntriesAllowed = accountData.manualEntriesAllowed;
- this.type = accountData.type;
- this.usage = accountData.usage;
- this.description = accountData.description;
- this.nameDecorated = accountData.nameDecorated;
- this.tagId = accountData.tagId;
- this.organizationRunningBalance = accountData.organizationRunningBalance;
- this.accountTypeOptions = accountTypeOptions;
- this.usageOptions = usageOptions;
- this.assetHeaderAccountOptions = assetHeaderAccountOptions;
- this.liabilityHeaderAccountOptions = liabilityHeaderAccountOptions;
- this.equityHeaderAccountOptions = equityHeaderAccountOptions;
- this.incomeHeaderAccountOptions = incomeHeaderAccountOptions;
- this.expenseHeaderAccountOptions = expenseHeaderAccountOptions;
- this.allowedAssetsTagOptions = allowedAssetsTagOptions;
- this.allowedLiabilitiesTagOptions = allowedLiabilitiesTagOptions;
- this.allowedEquityTagOptions = allowedEquityTagOptions;
- this.allowedIncomeTagOptions = allowedIncomeTagOptions;
- this.allowedExpensesTagOptions = allowedExpensesTagOptions;
+ return new GLAccountData().setId(id);
}
public static GLAccountData sensibleDefaultsForNewGLAccountCreation(final Integer glAccType) {
- final Long id = null;
- final String name = null;
- final Long parentId = null;
- final String glCode = null;
final boolean disabled = false;
final boolean manualEntriesAllowed = true;
final EnumOptionData type;
@@ -216,63 +92,7 @@ public class GLAccountData implements Serializable {
type = AccountingEnumerations.gLAccountType(GLAccountType.ASSET);
}
final EnumOptionData usage = AccountingEnumerations.gLAccountUsage(GLAccountUsage.DETAIL);
- final String description = null;
- final String nameDecorated = null;
- final CodeValueData tagId = null;
- final Long organizationRunningBalance = null;
- return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, type, usage, description, nameDecorated, tagId,
- organizationRunningBalance);
+ return new GLAccountData().setDisabled(disabled).setManualEntriesAllowed(manualEntriesAllowed).setType(type).setUsage(usage);
}
-
- public GLAccountData(final Long id, final String name, final String glCode) {
- this.id = id;
- this.name = name;
- this.parentId = null;
- this.glCode = glCode;
- this.disabled = null;
- this.manualEntriesAllowed = null;
- this.type = null;
- this.usage = null;
- this.description = null;
- this.nameDecorated = null;
- this.tagId = null;
- this.organizationRunningBalance = null;
- this.accountTypeOptions = null;
- this.usageOptions = null;
- this.assetHeaderAccountOptions = null;
- this.liabilityHeaderAccountOptions = null;
- this.equityHeaderAccountOptions = null;
- this.incomeHeaderAccountOptions = null;
- this.expenseHeaderAccountOptions = null;
- this.allowedAssetsTagOptions = null;
- this.allowedLiabilitiesTagOptions = null;
- this.allowedEquityTagOptions = null;
- this.allowedIncomeTagOptions = null;
- this.allowedExpensesTagOptions = null;
- }
-
- public Long getId() {
- return this.id;
- }
-
- public String getName() {
- return this.name;
- }
-
- public String getGlCode() {
- return this.glCode;
- }
-
- public EnumOptionData getType() {
- return this.type;
- }
-
- public Integer getTypeId() {
- if (this.type != null) {
- return this.type.getId().intValue();
- }
- return null;
- }
-
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/data/GLAccountDataForLookup.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/data/GLAccountDataForLookup.java
index 300c2dc67..0c4fcf970 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/data/GLAccountDataForLookup.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/data/GLAccountDataForLookup.java
@@ -18,14 +18,19 @@
*/
package org.apache.fineract.accounting.glaccount.data;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
-@RequiredArgsConstructor
-@Getter
-public class GLAccountDataForLookup {
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+public class GLAccountDataForLookup implements Serializable {
- private final Long id;
- private final String name;
- private final String glCode;
+ private static final long serialVersionUID = 1L;
+
+ private Long id;
+ private String name;
+ private String glCode;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/domain/GLAccount.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/domain/GLAccount.java
index 047391cd8..a20387307 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/domain/GLAccount.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/domain/GLAccount.java
@@ -30,8 +30,10 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.StringUtils;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.Accessors;
import org.apache.fineract.accounting.glaccount.api.GLAccountJsonInputParams;
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -39,6 +41,10 @@ import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@Entity
@Table(name = "acc_gl_account", uniqueConstraints = { @UniqueConstraint(columnNames = { "gl_code" }, name = "acc_gl_code") })
+@Getter
+@Setter
+@NoArgsConstructor
+@Accessors(chain = true)
public class GLAccount extends AbstractPersistableCustom {
@ManyToOne(fetch = FetchType.LAZY)
@@ -59,7 +65,7 @@ public class GLAccount extends AbstractPersistableCustom {
private String glCode;
@Column(name = "disabled", nullable = false)
- private boolean disabled = false;
+ private boolean disabled;
@Column(name = "manual_journal_entries_allowed", nullable = false)
private boolean manualEntriesAllowed = true;
@@ -77,23 +83,6 @@ public class GLAccount extends AbstractPersistableCustom {
@JoinColumn(name = "tag_id")
private CodeValue tagId;
- protected GLAccount() {
- //
- }
-
- private GLAccount(final GLAccount parent, final String name, final String glCode, final boolean disabled,
- final boolean manualEntriesAllowed, final Integer type, final Integer usage, final String description, final CodeValue tagId) {
- this.name = StringUtils.defaultIfEmpty(name, null);
- this.glCode = StringUtils.defaultIfEmpty(glCode, null);
- this.disabled = BooleanUtils.toBooleanDefaultIfNull(disabled, false);
- this.manualEntriesAllowed = BooleanUtils.toBooleanDefaultIfNull(manualEntriesAllowed, true);
- this.usage = usage;
- this.type = type;
- this.description = StringUtils.defaultIfEmpty(description, null);
- this.parent = parent;
- this.tagId = tagId;
- }
-
public static GLAccount fromJson(final GLAccount parent, final JsonCommand command, final CodeValue glAccountTagType) {
final String name = command.stringValueOfParameterNamed(GLAccountJsonInputParams.NAME.getValue());
final String glCode = command.stringValueOfParameterNamed(GLAccountJsonInputParams.GL_CODE.getValue());
@@ -103,7 +92,9 @@ public class GLAccount extends AbstractPersistableCustom {
final Integer usage = command.integerValueSansLocaleOfParameterNamed(GLAccountJsonInputParams.USAGE.getValue());
final Integer type = command.integerValueSansLocaleOfParameterNamed(GLAccountJsonInputParams.TYPE.getValue());
final String description = command.stringValueOfParameterNamed(GLAccountJsonInputParams.DESCRIPTION.getValue());
- return new GLAccount(parent, name, glCode, disabled, manualEntriesAllowed, type, usage, description, glAccountTagType);
+ return new GLAccount().setParent(parent).setName(name).setGlCode(glCode).setDisabled(disabled)
+ .setManualEntriesAllowed(manualEntriesAllowed).setType(type).setUsage(usage).setDescription(description)
+ .setTagId(glAccountTagType);
}
public Map<String, Object> update(final JsonCommand command) {
@@ -192,34 +183,6 @@ public class GLAccount extends AbstractPersistableCustom {
return GLAccountUsage.HEADER.getValue().equals(this.usage);
}
- public Integer getUsage() {
- return this.usage;
- }
-
- public List<GLAccount> getChildren() {
- return this.children;
- }
-
- public boolean isDisabled() {
- return this.disabled;
- }
-
- public boolean isManualEntriesAllowed() {
- return this.manualEntriesAllowed;
- }
-
- public String getGlCode() {
- return this.glCode;
- }
-
- public String getName() {
- return this.name;
- }
-
- public Integer getType() {
- return this.type;
- }
-
public void generateHierarchy() {
if (this.parent != null) {
@@ -236,13 +199,4 @@ public class GLAccount extends AbstractPersistableCustom {
public boolean isDetailAccount() {
return GLAccountUsage.DETAIL.getValue().equals(this.usage);
}
-
- public void updateTagId(final CodeValue tagId) {
- this.tagId = tagId;
- }
-
- public void updateParentAccount(final GLAccount parentAccount) {
- this.parent = parentAccount;
- generateHierarchy();
- }
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/domain/TrialBalance.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/domain/TrialBalance.java
index ba2f2ca10..af20e105a 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/domain/TrialBalance.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/domain/TrialBalance.java
@@ -25,10 +25,18 @@ import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@Entity
@Table(name = "m_trial_balance")
+@Getter
+@Setter
+@NoArgsConstructor
+@Accessors(chain = true)
public class TrialBalance extends AbstractPersistableCustom {
@Column(name = "office_id", nullable = false)
@@ -51,42 +59,8 @@ public class TrialBalance extends AbstractPersistableCustom {
public static TrialBalance getInstance(final Long officeId, final Long glAccountId, final BigDecimal amount, final LocalDate entryDate,
final LocalDate transactionDate) {
- return new TrialBalance(officeId, glAccountId, amount, entryDate, transactionDate);
- }
-
- private TrialBalance(final Long officeId, final Long glAccountId, final BigDecimal amount, final LocalDate entryDate,
- final LocalDate transactionDate) {
- this.officeId = officeId;
- this.glAccountId = glAccountId;
- this.amount = amount;
- this.entryDate = entryDate;
- this.transactionDate = transactionDate;
- }
-
- protected TrialBalance() {}
-
- public Long getOfficeId() {
- return officeId;
- }
-
- public LocalDate getTransactionDate() {
- return transactionDate;
- }
-
- public BigDecimal getAmount() {
- return amount;
- }
-
- public void setClosingBalance(final BigDecimal closingBalance) {
- this.closingBalance = closingBalance;
- }
-
- public LocalDate getEntryDate() {
- return entryDate;
- }
-
- public Long getGlAccountId() {
- return glAccountId;
+ return new TrialBalance().setOfficeId(officeId).setGlAccountId(glAccountId).setAmount(amount).setEntryDate(entryDate)
+ .setTransactionDate(transactionDate);
}
@Override
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java
index 8b471a723..3a230bbe2 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/service/GLAccountReadPlatformServiceImpl.java
@@ -99,8 +99,9 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe
if (associationParametersData.isRunningBalanceRequired()) {
organizationRunningBalance = rs.getLong("organizationRunningBalance");
}
- return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, accountType, usage, description,
- nameDecorated, tagId, organizationRunningBalance);
+ return new GLAccountData().setId(id).setName(name).setParentId(parentId).setGlCode(glCode).setDisabled(disabled)
+ .setManualEntriesAllowed(manualEntriesAllowed).setType(accountType).setUsage(usage).setDescription(description)
+ .setNameDecorated(nameDecorated).setTagId(tagId).setOrganizationRunningBalance(organizationRunningBalance);
}
}
@@ -275,8 +276,8 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe
final Long id = JdbcSupport.getLong(rs, "id");
final String name = rs.getString("name");
final String glCode = rs.getString("glCode");
- return new GLAccountDataForLookup(id, name, glCode);
- }
+ return new GLAccountDataForLookup().setId(id).setName(name).setGlCode(glCode);
+ }
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/service/GLAccountWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/service/GLAccountWritePlatformServiceJpaRepositoryImpl.java
index 2b81f6637..5168a65f9 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/service/GLAccountWritePlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/glaccount/service/GLAccountWritePlatformServiceJpaRepositoryImpl.java
@@ -129,7 +129,8 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
// is the new parent valid
if (changesOnly.containsKey(GLAccountJsonInputParams.PARENT_ID.getValue())) {
final GLAccount parentAccount = validateParentGLAccount(parentId);
- glAccount.updateParentAccount(parentAccount);
+ glAccount.setParent(parentAccount);
+ glAccount.generateHierarchy();
}
if (changesOnly.containsKey(GLAccountJsonInputParams.TAGID.getValue())) {
@@ -139,7 +140,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
if (tagIdLongValue != null) {
tagID = retrieveTagId(tagIdLongValue, accountType);
}
- glAccount.updateTagId(tagID);
+ glAccount.setTagId(tagID);
}
/**
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java
index 081105717..ace5a5d14 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java
@@ -18,6 +18,8 @@
*/
package org.apache.fineract.accounting.journalentry.service;
+import static java.util.Objects.requireNonNull;
+
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -404,7 +406,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
final JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData();
final GLAccountData contraAccount = this.glAccountReadPlatformService.retrieveGLAccountById(contraId, associationParametersData);
- if (!GLAccountType.fromInt(contraAccount.getTypeId()).isEquityType()) {
+ if (!GLAccountType.fromInt(requireNonNull(requireNonNull(contraAccount.getType()).getId()).intValue()).isEquityType()) {
throw new GeneralPlatformDomainRuleException(
"error.msg.configuration.opening.balance.contra.account.value.is.invalid.account.type",
"Global configuration 'office-opening-balances-contra-account' value is not an equity type account", contraId);
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java
index 5c9122534..e7362ed3f 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java
@@ -116,7 +116,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode");
- final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
+ final GLAccountData gLAccountData = new GLAccountData().setId(glAccountId).setName(glAccountName).setGlCode(glCode);
if (glAccountForLoan.equals(CashAccountsForLoan.FUND_SOURCE)) {
accountMappingDetails.put(LoanProductAccountingDataParams.FUND_SOURCE.getValue(), gLAccountData);
@@ -150,7 +150,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode");
- final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
+ final GLAccountData gLAccountData = new GLAccountData().setId(glAccountId).setName(glAccountName).setGlCode(glCode);
if (glAccountForLoan.equals(AccrualAccountsForLoan.FUND_SOURCE)) {
accountMappingDetails.put(LoanProductAccountingDataParams.FUND_SOURCE.getValue(), gLAccountData);
@@ -206,7 +206,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode");
- final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
+ final GLAccountData gLAccountData = new GLAccountData().setId(glAccountId).setName(glAccountName).setGlCode(glCode);
if (glAccountForSavings.equals(CashAccountsForSavings.SAVINGS_REFERENCE)) {
accountMappingDetails.put(SavingProductAccountingDataParams.SAVINGS_REFERENCE.getValue(), gLAccountData);
@@ -268,7 +268,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode");
- final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
+
+ final GLAccountData gLAccountData = new GLAccountData().setId(glAccountId).setName(glAccountName).setGlCode(glCode);
final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeData,
gLAccountData);
@@ -317,7 +318,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) chargeToIncomeAccountMap.get("glAccountId");
final String glAccountName = (String) chargeToIncomeAccountMap.get("glAccountName");
final String glCode = (String) chargeToIncomeAccountMap.get("glCode");
- final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
+ final GLAccountData gLAccountData = new GLAccountData().setId(glAccountId).setName(glAccountName).setGlCode(glCode);
final Long chargeId = (Long) chargeToIncomeAccountMap.get("chargeId");
final String chargeName = (String) chargeToIncomeAccountMap.get("chargeName");
final Boolean penalty1 = (Boolean) chargeToIncomeAccountMap.get("penalty");
@@ -347,7 +348,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode");
- final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
+ final GLAccountData gLAccountData = new GLAccountData().setId(glAccountId).setName(glAccountName).setGlCode(glCode);
if (glAccountForShares.equals(CashAccountsForShares.SHARES_REFERENCE)) {
accountMappingDetails.put(SharesProductAccountingParams.SHARES_REFERENCE.getValue(), gLAccountData);
diff --git a/fineract-provider/src/main/java/org/apache/fineract/accounting/rule/service/AccountingRuleReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/accounting/rule/service/AccountingRuleReadPlatformServiceImpl.java
index 8b15f1f9b..895918bd4 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/accounting/rule/service/AccountingRuleReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/accounting/rule/service/AccountingRuleReadPlatformServiceImpl.java
@@ -113,8 +113,8 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
: null;
} else {
creditTags = null;
- final GLAccountDataForLookup creditAccount = new GLAccountDataForLookup(accountToCreditId, creditAccountName,
- creditAccountGLCode);
+ final GLAccountDataForLookup creditAccount = new GLAccountDataForLookup().setId(accountToCreditId)
+ .setName(creditAccountName).setGlCode(creditAccountGLCode);
creditAccounts = new ArrayList<>(Arrays.asList(creditAccount));
}
if (accountToDebitId == null) {
@@ -125,8 +125,8 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
: null;
} else {
debitTags = null;
- final GLAccountDataForLookup debitAccount = new GLAccountDataForLookup(accountToDebitId, debitAccountName,
- debitAccountGLCode);
+ final GLAccountDataForLookup debitAccount = new GLAccountDataForLookup().setId(accountToDebitId)
+ .setName(debitAccountName).setGlCode(debitAccountGLCode);
debitAccounts = new ArrayList<>(Arrays.asList(debitAccount));
}
accountingRuleData = new AccountingRuleData(id, officeId, officeName, name, description, systemDefined,
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/AbstractPersistableCustom.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/AbstractPersistableCustom.java
index b8e7efe8d..824374341 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/AbstractPersistableCustom.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/AbstractPersistableCustom.java
@@ -26,6 +26,10 @@ import javax.persistence.MappedSuperclass;
import javax.persistence.PostLoad;
import javax.persistence.PrePersist;
import javax.persistence.Transient;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.springframework.data.domain.Persistable;
/**
@@ -39,31 +43,23 @@ import org.springframework.data.domain.Persistable;
* (it's usually implemented based on the Id), because "we end up with issues on OpenJPA" (TODO clarify this).
*/
@MappedSuperclass
+@Getter
+@Setter
+@NoArgsConstructor
public abstract class AbstractPersistableCustom implements Persistable<Long>, Serializable {
private static final long serialVersionUID = 9181640245194392646L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Getter(onMethod = @__(@Override))
private Long id;
@Transient
+ @Setter(value = AccessLevel.NONE)
+ @Getter(onMethod = @__(@Override))
private boolean isNew = true;
- @Override
- public Long getId() {
- return id;
- }
-
- protected void setId(final Long id) {
- this.id = id;
- }
-
- @Override
- public boolean isNew() {
- return isNew;
- }
-
@PrePersist
@PostLoad
void markNotNew() {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/Charge.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/Charge.java
index eb0e63dbe..8d2bf69d8 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/Charge.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/Charge.java
@@ -661,7 +661,7 @@ public class Charge extends AbstractPersistableCustom {
final EnumOptionData feeFrequencyType = ChargeEnumerations.chargePaymentMode(this.feeFrequency);
GLAccountData accountData = null;
if (account != null) {
- accountData = new GLAccountData(account.getId(), account.getName(), account.getGlCode());
+ accountData = new GLAccountData().setId(account.getId()).setName(account.getName()).setGlCode(account.getGlCode());
}
TaxGroupData taxGroupData = null;
if (this.taxGroup != null) {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/service/ChargeReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/service/ChargeReadPlatformServiceImpl.java
index 7e72b3158..1aa993e91 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/service/ChargeReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/service/ChargeReadPlatformServiceImpl.java
@@ -363,7 +363,7 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
final String glCode = rs.getString("glCode");
GLAccountData glAccountData = null;
if (glAccountId != null) {
- glAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
+ glAccountData = new GLAccountData().setId(glAccountId).setName(glAccountName).setGlCode(glCode);
}
final Long taxGroupId = JdbcSupport.getLong(rs, "taxGroupId");
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/service/TaxReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/service/TaxReadPlatformServiceImpl.java
index 0bca52fcf..0c3ef225b 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/service/TaxReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/service/TaxReadPlatformServiceImpl.java
@@ -147,7 +147,7 @@ public class TaxReadPlatformServiceImpl implements TaxReadPlatformService {
final Long debitAccountId = rs.getLong("debitAccountId");
final String debitAccountName = rs.getString("debitAccountName");
final String debitAccountGlCode = rs.getString("debitAccountGlCode");
- debitAccountData = new GLAccountData(debitAccountId, debitAccountName, debitAccountGlCode);
+ debitAccountData = new GLAccountData().setId(debitAccountId).setName(debitAccountName).setGlCode(debitAccountGlCode);
}
final Integer creditAccountTypeEnum = JdbcSupport.getIntegerDefaultToNullIfZero(rs, "creditAccountTypeEnum");
@@ -160,7 +160,7 @@ public class TaxReadPlatformServiceImpl implements TaxReadPlatformService {
final Long creditAccountId = rs.getLong("creditAccountId");
final String creditAccountName = rs.getString("creditAccountName");
final String creditAccountGlCode = rs.getString("creditAccountGlCode");
- creditAccountData = new GLAccountData(creditAccountId, creditAccountName, creditAccountGlCode);
+ creditAccountData = new GLAccountData().setId(creditAccountId).setName(creditAccountName).setGlCode(creditAccountGlCode);
}
final LocalDate startDate = JdbcSupport.getLocalDate(rs, "startDate");