refactor: add lombok to GLAccount module

This commit is contained in:
Hemant Gupta
2022-08-22 14:45:56 +02:00
committed by Arnold Gálovics
parent 340516c1a3
commit f86a7c726f
15 changed files with 120 additions and 356 deletions
@@ -102,7 +102,8 @@ public class FinancialActivityAccountReadPlatformServiceImpl implements Financia
final String glAccountName = rs.getString("glAccountName"); final String glAccountName = rs.getString("glAccountName");
final String glCode = rs.getString("glCode"); 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 FinancialActivityData financialActivityData = FinancialActivity.toFinancialActivityData(financialActivityId);
final FinancialActivityAccountData financialActivityAccountData = new FinancialActivityAccountData(id, financialActivityData, final FinancialActivityAccountData financialActivityAccountData = new FinancialActivityAccountData(id, financialActivityData,
@@ -252,9 +252,18 @@ public class GLAccountsApiResource {
final Collection<CodeValueData> allowedExpensesTagOptions = this.codeValueReadPlatformService final Collection<CodeValueData> allowedExpensesTagOptions = this.codeValueReadPlatformService
.retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME); .retrieveCodeValuesByCode(AccountingConstants.EXPENSES_TAG_OPTION_CODE_NAME);
return new GLAccountData(glAccountData, accountTypeOptions, usageOptions, assetHeaderAccountOptions, liabilityHeaderAccountOptions, return new GLAccountData().setId(glAccountData.getId()).setName(glAccountData.getName()).setParentId(glAccountData.getParentId())
equityHeaderAccountOptions, incomeHeaderAccountOptions, expenseHeaderAccountOptions, allowedAssetsTagOptions, .setGlCode(glAccountData.getGlCode()).setDisabled(glAccountData.getDisabled())
allowedLiabilitiesTagOptions, allowedEquityTagOptions, allowedIncomeTagOptions, allowedExpensesTagOptions); .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) { private List<GLAccountData> defaultIfEmpty(final List<GLAccountData> list) {
@@ -21,6 +21,9 @@ package org.apache.fineract.accounting.glaccount.data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.List; 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.common.AccountingEnumerations;
import org.apache.fineract.accounting.glaccount.domain.GLAccountType; import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
import org.apache.fineract.accounting.glaccount.domain.GLAccountUsage; 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. * 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 { public class GLAccountData implements Serializable {
private final Long id; private Long id;
private final String name; private String name;
private final Long parentId; private Long parentId;
private final String glCode; private String glCode;
private final Boolean disabled; private Boolean disabled;
private final Boolean manualEntriesAllowed; private Boolean manualEntriesAllowed;
private final EnumOptionData type; private EnumOptionData type;
private final EnumOptionData usage; private EnumOptionData usage;
private final String description; private String description;
private final String nameDecorated; private String nameDecorated;
private final CodeValueData tagId; private CodeValueData tagId;
private final Long organizationRunningBalance; private Long organizationRunningBalance;
// templates // templates
final List<EnumOptionData> accountTypeOptions; private List<EnumOptionData> accountTypeOptions;
final List<EnumOptionData> usageOptions; private List<EnumOptionData> usageOptions;
final List<GLAccountData> assetHeaderAccountOptions; private List<GLAccountData> assetHeaderAccountOptions;
final List<GLAccountData> liabilityHeaderAccountOptions; private List<GLAccountData> liabilityHeaderAccountOptions;
final List<GLAccountData> equityHeaderAccountOptions; private List<GLAccountData> equityHeaderAccountOptions;
final List<GLAccountData> incomeHeaderAccountOptions; private List<GLAccountData> incomeHeaderAccountOptions;
final List<GLAccountData> expenseHeaderAccountOptions; private List<GLAccountData> expenseHeaderAccountOptions;
final Collection<CodeValueData> allowedAssetsTagOptions; private Collection<CodeValueData> allowedAssetsTagOptions;
final Collection<CodeValueData> allowedLiabilitiesTagOptions; private Collection<CodeValueData> allowedLiabilitiesTagOptions;
final Collection<CodeValueData> allowedEquityTagOptions; private Collection<CodeValueData> allowedEquityTagOptions;
final Collection<CodeValueData> allowedIncomeTagOptions; private Collection<CodeValueData> allowedIncomeTagOptions;
final Collection<CodeValueData> allowedExpensesTagOptions; private Collection<CodeValueData> allowedExpensesTagOptions;
// import fields // import fields
private transient Integer rowIndex; private transient Integer rowIndex;
public static GLAccountData importInstance(String name, Long parentId, String glCode, Boolean manualEntriesAllowed, EnumOptionData type, public static GLAccountData importInstance(String name, Long parentId, String glCode, Boolean manualEntriesAllowed, EnumOptionData type,
EnumOptionData usage, String description, CodeValueData tagId, Integer rowIndex) { 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) { public static GLAccountData createFrom(final Long id) {
return new GLAccountData(id);
}
private GLAccountData(final Long id) { return new GLAccountData().setId(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;
} }
public static GLAccountData sensibleDefaultsForNewGLAccountCreation(final Integer glAccType) { 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 disabled = false;
final boolean manualEntriesAllowed = true; final boolean manualEntriesAllowed = true;
final EnumOptionData type; final EnumOptionData type;
@@ -216,63 +92,7 @@ public class GLAccountData implements Serializable {
type = AccountingEnumerations.gLAccountType(GLAccountType.ASSET); type = AccountingEnumerations.gLAccountType(GLAccountType.ASSET);
} }
final EnumOptionData usage = AccountingEnumerations.gLAccountUsage(GLAccountUsage.DETAIL); 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, return new GLAccountData().setDisabled(disabled).setManualEntriesAllowed(manualEntriesAllowed).setType(type).setUsage(usage);
organizationRunningBalance);
} }
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;
}
} }
@@ -18,14 +18,19 @@
*/ */
package org.apache.fineract.accounting.glaccount.data; package org.apache.fineract.accounting.glaccount.data;
import lombok.Getter; import java.io.Serializable;
import lombok.RequiredArgsConstructor; import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@RequiredArgsConstructor @Data
@Getter @NoArgsConstructor
public class GLAccountDataForLookup { @Accessors(chain = true)
public class GLAccountDataForLookup implements Serializable {
private final Long id; private static final long serialVersionUID = 1L;
private final String name;
private final String glCode; private Long id;
private String name;
private String glCode;
} }
@@ -30,8 +30,10 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.BooleanUtils; import lombok.Getter;
import org.apache.commons.lang3.StringUtils; import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.fineract.accounting.glaccount.api.GLAccountJsonInputParams; import org.apache.fineract.accounting.glaccount.api.GLAccountJsonInputParams;
import org.apache.fineract.infrastructure.codes.domain.CodeValue; import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -39,6 +41,10 @@ import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@Entity @Entity
@Table(name = "acc_gl_account", uniqueConstraints = { @UniqueConstraint(columnNames = { "gl_code" }, name = "acc_gl_code") }) @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 { public class GLAccount extends AbstractPersistableCustom {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@@ -59,7 +65,7 @@ public class GLAccount extends AbstractPersistableCustom {
private String glCode; private String glCode;
@Column(name = "disabled", nullable = false) @Column(name = "disabled", nullable = false)
private boolean disabled = false; private boolean disabled;
@Column(name = "manual_journal_entries_allowed", nullable = false) @Column(name = "manual_journal_entries_allowed", nullable = false)
private boolean manualEntriesAllowed = true; private boolean manualEntriesAllowed = true;
@@ -77,23 +83,6 @@ public class GLAccount extends AbstractPersistableCustom {
@JoinColumn(name = "tag_id") @JoinColumn(name = "tag_id")
private CodeValue tagId; 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) { public static GLAccount fromJson(final GLAccount parent, final JsonCommand command, final CodeValue glAccountTagType) {
final String name = command.stringValueOfParameterNamed(GLAccountJsonInputParams.NAME.getValue()); final String name = command.stringValueOfParameterNamed(GLAccountJsonInputParams.NAME.getValue());
final String glCode = command.stringValueOfParameterNamed(GLAccountJsonInputParams.GL_CODE.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 usage = command.integerValueSansLocaleOfParameterNamed(GLAccountJsonInputParams.USAGE.getValue());
final Integer type = command.integerValueSansLocaleOfParameterNamed(GLAccountJsonInputParams.TYPE.getValue()); final Integer type = command.integerValueSansLocaleOfParameterNamed(GLAccountJsonInputParams.TYPE.getValue());
final String description = command.stringValueOfParameterNamed(GLAccountJsonInputParams.DESCRIPTION.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) { public Map<String, Object> update(final JsonCommand command) {
@@ -192,34 +183,6 @@ public class GLAccount extends AbstractPersistableCustom {
return GLAccountUsage.HEADER.getValue().equals(this.usage); 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() { public void generateHierarchy() {
if (this.parent != null) { if (this.parent != null) {
@@ -236,13 +199,4 @@ public class GLAccount extends AbstractPersistableCustom {
public boolean isDetailAccount() { public boolean isDetailAccount() {
return GLAccountUsage.DETAIL.getValue().equals(this.usage); 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();
}
} }
@@ -25,10 +25,18 @@ import java.util.Objects;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; 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; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@Entity @Entity
@Table(name = "m_trial_balance") @Table(name = "m_trial_balance")
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class TrialBalance extends AbstractPersistableCustom { public class TrialBalance extends AbstractPersistableCustom {
@Column(name = "office_id", nullable = false) @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, public static TrialBalance getInstance(final Long officeId, final Long glAccountId, final BigDecimal amount, final LocalDate entryDate,
final LocalDate transactionDate) { final LocalDate transactionDate) {
return new TrialBalance(officeId, glAccountId, amount, entryDate, transactionDate); return new TrialBalance().setOfficeId(officeId).setGlAccountId(glAccountId).setAmount(amount).setEntryDate(entryDate)
} .setTransactionDate(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;
} }
@Override @Override
@@ -99,8 +99,9 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe
if (associationParametersData.isRunningBalanceRequired()) { if (associationParametersData.isRunningBalanceRequired()) {
organizationRunningBalance = rs.getLong("organizationRunningBalance"); organizationRunningBalance = rs.getLong("organizationRunningBalance");
} }
return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, accountType, usage, description, return new GLAccountData().setId(id).setName(name).setParentId(parentId).setGlCode(glCode).setDisabled(disabled)
nameDecorated, tagId, organizationRunningBalance); .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 Long id = JdbcSupport.getLong(rs, "id");
final String name = rs.getString("name"); final String name = rs.getString("name");
final String glCode = rs.getString("glCode"); final String glCode = rs.getString("glCode");
return new GLAccountDataForLookup(id, name, glCode);
}
return new GLAccountDataForLookup().setId(id).setName(name).setGlCode(glCode);
}
} }
} }
@@ -129,7 +129,8 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
// is the new parent valid // is the new parent valid
if (changesOnly.containsKey(GLAccountJsonInputParams.PARENT_ID.getValue())) { if (changesOnly.containsKey(GLAccountJsonInputParams.PARENT_ID.getValue())) {
final GLAccount parentAccount = validateParentGLAccount(parentId); final GLAccount parentAccount = validateParentGLAccount(parentId);
glAccount.updateParentAccount(parentAccount); glAccount.setParent(parentAccount);
glAccount.generateHierarchy();
} }
if (changesOnly.containsKey(GLAccountJsonInputParams.TAGID.getValue())) { if (changesOnly.containsKey(GLAccountJsonInputParams.TAGID.getValue())) {
@@ -139,7 +140,7 @@ public class GLAccountWritePlatformServiceJpaRepositoryImpl implements GLAccount
if (tagIdLongValue != null) { if (tagIdLongValue != null) {
tagID = retrieveTagId(tagIdLongValue, accountType); tagID = retrieveTagId(tagIdLongValue, accountType);
} }
glAccount.updateTagId(tagID); glAccount.setTagId(tagID);
} }
/** /**
@@ -18,6 +18,8 @@
*/ */
package org.apache.fineract.accounting.journalentry.service; package org.apache.fineract.accounting.journalentry.service;
import static java.util.Objects.requireNonNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@@ -404,7 +406,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
final JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData(); final JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData();
final GLAccountData contraAccount = this.glAccountReadPlatformService.retrieveGLAccountById(contraId, associationParametersData); 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( throw new GeneralPlatformDomainRuleException(
"error.msg.configuration.opening.balance.contra.account.value.is.invalid.account.type", "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); "Global configuration 'office-opening-balances-contra-account' value is not an equity type account", contraId);
@@ -116,7 +116,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode"); 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)) { if (glAccountForLoan.equals(CashAccountsForLoan.FUND_SOURCE)) {
accountMappingDetails.put(LoanProductAccountingDataParams.FUND_SOURCE.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.FUND_SOURCE.getValue(), gLAccountData);
@@ -150,7 +150,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode"); 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)) { if (glAccountForLoan.equals(AccrualAccountsForLoan.FUND_SOURCE)) {
accountMappingDetails.put(LoanProductAccountingDataParams.FUND_SOURCE.getValue(), gLAccountData); accountMappingDetails.put(LoanProductAccountingDataParams.FUND_SOURCE.getValue(), gLAccountData);
@@ -206,7 +206,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode"); 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)) { if (glAccountForSavings.equals(CashAccountsForSavings.SAVINGS_REFERENCE)) {
accountMappingDetails.put(SavingProductAccountingDataParams.SAVINGS_REFERENCE.getValue(), gLAccountData); accountMappingDetails.put(SavingProductAccountingDataParams.SAVINGS_REFERENCE.getValue(), gLAccountData);
@@ -268,7 +268,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode"); 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, final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeData,
gLAccountData); gLAccountData);
@@ -317,7 +318,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) chargeToIncomeAccountMap.get("glAccountId"); final Long glAccountId = (Long) chargeToIncomeAccountMap.get("glAccountId");
final String glAccountName = (String) chargeToIncomeAccountMap.get("glAccountName"); final String glAccountName = (String) chargeToIncomeAccountMap.get("glAccountName");
final String glCode = (String) chargeToIncomeAccountMap.get("glCode"); 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 Long chargeId = (Long) chargeToIncomeAccountMap.get("chargeId");
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");
@@ -347,7 +348,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName");
final String glCode = (String) productToGLAccountMap.get("glCode"); 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)) { if (glAccountForShares.equals(CashAccountsForShares.SHARES_REFERENCE)) {
accountMappingDetails.put(SharesProductAccountingParams.SHARES_REFERENCE.getValue(), gLAccountData); accountMappingDetails.put(SharesProductAccountingParams.SHARES_REFERENCE.getValue(), gLAccountData);
@@ -113,8 +113,8 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
: null; : null;
} else { } else {
creditTags = null; creditTags = null;
final GLAccountDataForLookup creditAccount = new GLAccountDataForLookup(accountToCreditId, creditAccountName, final GLAccountDataForLookup creditAccount = new GLAccountDataForLookup().setId(accountToCreditId)
creditAccountGLCode); .setName(creditAccountName).setGlCode(creditAccountGLCode);
creditAccounts = new ArrayList<>(Arrays.asList(creditAccount)); creditAccounts = new ArrayList<>(Arrays.asList(creditAccount));
} }
if (accountToDebitId == null) { if (accountToDebitId == null) {
@@ -125,8 +125,8 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
: null; : null;
} else { } else {
debitTags = null; debitTags = null;
final GLAccountDataForLookup debitAccount = new GLAccountDataForLookup(accountToDebitId, debitAccountName, final GLAccountDataForLookup debitAccount = new GLAccountDataForLookup().setId(accountToDebitId)
debitAccountGLCode); .setName(debitAccountName).setGlCode(debitAccountGLCode);
debitAccounts = new ArrayList<>(Arrays.asList(debitAccount)); debitAccounts = new ArrayList<>(Arrays.asList(debitAccount));
} }
accountingRuleData = new AccountingRuleData(id, officeId, officeName, name, description, systemDefined, accountingRuleData = new AccountingRuleData(id, officeId, officeName, name, description, systemDefined,
@@ -26,6 +26,10 @@ import javax.persistence.MappedSuperclass;
import javax.persistence.PostLoad; import javax.persistence.PostLoad;
import javax.persistence.PrePersist; import javax.persistence.PrePersist;
import javax.persistence.Transient; import javax.persistence.Transient;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.domain.Persistable; 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). * (it's usually implemented based on the Id), because "we end up with issues on OpenJPA" (TODO clarify this).
*/ */
@MappedSuperclass @MappedSuperclass
@Getter
@Setter
@NoArgsConstructor
public abstract class AbstractPersistableCustom implements Persistable<Long>, Serializable { public abstract class AbstractPersistableCustom implements Persistable<Long>, Serializable {
private static final long serialVersionUID = 9181640245194392646L; private static final long serialVersionUID = 9181640245194392646L;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter(onMethod = @__(@Override))
private Long id; private Long id;
@Transient @Transient
@Setter(value = AccessLevel.NONE)
@Getter(onMethod = @__(@Override))
private boolean isNew = true; 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 @PrePersist
@PostLoad @PostLoad
void markNotNew() { void markNotNew() {
@@ -661,7 +661,7 @@ public class Charge extends AbstractPersistableCustom {
final EnumOptionData feeFrequencyType = ChargeEnumerations.chargePaymentMode(this.feeFrequency); final EnumOptionData feeFrequencyType = ChargeEnumerations.chargePaymentMode(this.feeFrequency);
GLAccountData accountData = null; GLAccountData accountData = null;
if (account != 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; TaxGroupData taxGroupData = null;
if (this.taxGroup != null) { if (this.taxGroup != null) {
@@ -363,7 +363,7 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
final String glCode = rs.getString("glCode"); final String glCode = rs.getString("glCode");
GLAccountData glAccountData = null; GLAccountData glAccountData = null;
if (glAccountId != 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"); final Long taxGroupId = JdbcSupport.getLong(rs, "taxGroupId");
@@ -147,7 +147,7 @@ public class TaxReadPlatformServiceImpl implements TaxReadPlatformService {
final Long debitAccountId = rs.getLong("debitAccountId"); final Long debitAccountId = rs.getLong("debitAccountId");
final String debitAccountName = rs.getString("debitAccountName"); final String debitAccountName = rs.getString("debitAccountName");
final String debitAccountGlCode = rs.getString("debitAccountGlCode"); 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"); final Integer creditAccountTypeEnum = JdbcSupport.getIntegerDefaultToNullIfZero(rs, "creditAccountTypeEnum");
@@ -160,7 +160,7 @@ public class TaxReadPlatformServiceImpl implements TaxReadPlatformService {
final Long creditAccountId = rs.getLong("creditAccountId"); final Long creditAccountId = rs.getLong("creditAccountId");
final String creditAccountName = rs.getString("creditAccountName"); final String creditAccountName = rs.getString("creditAccountName");
final String creditAccountGlCode = rs.getString("creditAccountGlCode"); 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"); final LocalDate startDate = JdbcSupport.getLocalDate(rs, "startDate");