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 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,
@@ -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) {
@@ -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;
}
}
@@ -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;
}
@@ -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();
}
}
@@ -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
@@ -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);
}
}
}
@@ -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);
}
/**
@@ -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);
@@ -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);
@@ -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,
@@ -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() {
@@ -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) {
@@ -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");
@@ -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");