feat: FD/RD GL transaction prefixes + savingsAccountNo in journal entry API
- Use FD/RD transaction ID prefixes for Fixed/Recurring Deposit GL entries via ThreadLocal context set in Cash/AccrualBasedAccountingProcessorForSavings - Add depositAccountType to SavingsDTO and pass from SavingsAccount bridge data - Add savingsAccountNo field to JournalEntryData; populate via LEFT JOIN on m_savings_account (SB/FD/RD) and m_current_account (CA prefix) in read query - Fix JournalEntryMapper MapStruct: ignore savingsAccountNo (SQL-populated) - Fix JournalEntryRunningBalanceUpdateServiceImpl constructor call (27 params) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
be26ba16c9
commit
b25d5a30d2
+109
-108
@@ -1,108 +1,109 @@
|
|||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.fineract.accounting.journalentry;
|
package org.apache.fineract.accounting.journalentry;
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
|
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
|
||||||
import org.apache.fineract.accounting.journalentry.data.JournalEntryData;
|
import org.apache.fineract.accounting.journalentry.data.JournalEntryData;
|
||||||
import org.apache.fineract.accounting.journalentry.domain.JournalEntry;
|
import org.apache.fineract.accounting.journalentry.domain.JournalEntry;
|
||||||
import org.apache.fineract.accounting.journalentry.domain.JournalEntryType;
|
import org.apache.fineract.accounting.journalentry.domain.JournalEntryType;
|
||||||
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
|
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
|
||||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||||
import org.apache.fineract.organisation.monetary.data.CurrencyData;
|
import org.apache.fineract.organisation.monetary.data.CurrencyData;
|
||||||
import org.apache.fineract.portfolio.PortfolioProductType;
|
import org.apache.fineract.portfolio.PortfolioProductType;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Named;
|
import org.mapstruct.Named;
|
||||||
|
|
||||||
@Mapper(config = MapstructMapperConfig.class)
|
@Mapper(config = MapstructMapperConfig.class)
|
||||||
public interface JournalEntryMapper {
|
public interface JournalEntryMapper {
|
||||||
|
|
||||||
@Mapping(target = "id", source = "id")
|
@Mapping(target = "id", source = "id")
|
||||||
@Mapping(target = "officeId", source = "office.id")
|
@Mapping(target = "officeId", source = "office.id")
|
||||||
@Mapping(target = "officeName", source = "office.name")
|
@Mapping(target = "officeName", source = "office.name")
|
||||||
@Mapping(target = "glAccountId", source = "glAccount.id")
|
@Mapping(target = "glAccountId", source = "glAccount.id")
|
||||||
@Mapping(target = "glAccountCode", source = "glAccount.glCode")
|
@Mapping(target = "glAccountCode", source = "glAccount.glCode")
|
||||||
@Mapping(target = "glAccountName", source = "glAccount.name")
|
@Mapping(target = "glAccountName", source = "glAccount.name")
|
||||||
@Mapping(target = "glAccountType", source = "glAccount.type", qualifiedByName = "glAccountType")
|
@Mapping(target = "glAccountType", source = "glAccount.type", qualifiedByName = "glAccountType")
|
||||||
@Mapping(target = "transactionDate", source = "transactionDate")
|
@Mapping(target = "transactionDate", source = "transactionDate")
|
||||||
@Mapping(target = "entryType", source = "type", qualifiedByName = "journalEntryType")
|
@Mapping(target = "entryType", source = "type", qualifiedByName = "journalEntryType")
|
||||||
@Mapping(target = "amount", source = "amount")
|
@Mapping(target = "amount", source = "amount")
|
||||||
@Mapping(target = "entityType", source = "entityType", qualifiedByName = "entityType")
|
@Mapping(target = "entityType", source = "entityType", qualifiedByName = "entityType")
|
||||||
@Mapping(target = "entityId", source = "entityId")
|
@Mapping(target = "entityId", source = "entityId")
|
||||||
@Mapping(target = "submittedOnDate", expression = "java(journalEntry.getCreatedDate().orElse(null))")
|
@Mapping(target = "submittedOnDate", expression = "java(journalEntry.getCreatedDate().orElse(null))")
|
||||||
@Mapping(target = "transactionId", source = "transactionId")
|
@Mapping(target = "transactionId", source = "transactionId")
|
||||||
@Mapping(target = "currency", source = "currencyCode")
|
@Mapping(target = "currency", source = "currencyCode")
|
||||||
@Mapping(target = "manualEntry", source = "manualEntry")
|
@Mapping(target = "manualEntry", source = "manualEntry")
|
||||||
@Mapping(target = "reversed", source = "reversed")
|
@Mapping(target = "reversed", source = "reversed")
|
||||||
@Mapping(target = "referenceNumber", source = "referenceNumber")
|
@Mapping(target = "referenceNumber", source = "referenceNumber")
|
||||||
@Mapping(target = "paymentTypeId", source = "paymentDetail.paymentType.id")
|
@Mapping(target = "paymentTypeId", source = "paymentDetail.paymentType.id")
|
||||||
@Mapping(target = "accountNumber", source = "paymentDetail.accountNumber")
|
@Mapping(target = "accountNumber", source = "paymentDetail.accountNumber")
|
||||||
@Mapping(target = "checkNumber", source = "paymentDetail.checkNumber")
|
@Mapping(target = "checkNumber", source = "paymentDetail.checkNumber")
|
||||||
@Mapping(target = "routingCode", source = "paymentDetail.routingCode")
|
@Mapping(target = "routingCode", source = "paymentDetail.routingCode")
|
||||||
@Mapping(target = "receiptNumber", source = "paymentDetail.receiptNumber")
|
@Mapping(target = "receiptNumber", source = "paymentDetail.receiptNumber")
|
||||||
@Mapping(target = "bankNumber", source = "paymentDetail.bankNumber")
|
@Mapping(target = "bankNumber", source = "paymentDetail.bankNumber")
|
||||||
@Mapping(target = "createdDate", ignore = true)
|
@Mapping(target = "createdDate", ignore = true)
|
||||||
@Mapping(target = "createdByUserId", ignore = true)
|
@Mapping(target = "createdByUserId", ignore = true)
|
||||||
@Mapping(target = "createdByUserName", ignore = true)
|
@Mapping(target = "createdByUserName", ignore = true)
|
||||||
@Mapping(target = "comments", ignore = true)
|
@Mapping(target = "comments", ignore = true)
|
||||||
@Mapping(target = "officeRunningBalance", ignore = true)
|
@Mapping(target = "officeRunningBalance", ignore = true)
|
||||||
@Mapping(target = "organizationRunningBalance", ignore = true)
|
@Mapping(target = "organizationRunningBalance", ignore = true)
|
||||||
@Mapping(target = "runningBalanceComputed", ignore = true)
|
@Mapping(target = "runningBalanceComputed", ignore = true)
|
||||||
@Mapping(target = "rowIndex", ignore = true)
|
@Mapping(target = "rowIndex", ignore = true)
|
||||||
@Mapping(target = "dateFormat", ignore = true)
|
@Mapping(target = "dateFormat", ignore = true)
|
||||||
@Mapping(target = "locale", ignore = true)
|
@Mapping(target = "locale", ignore = true)
|
||||||
@Mapping(target = "credits", ignore = true)
|
@Mapping(target = "credits", ignore = true)
|
||||||
@Mapping(target = "debits", ignore = true)
|
@Mapping(target = "debits", ignore = true)
|
||||||
@Mapping(target = "transactionDetails", ignore = true)
|
@Mapping(target = "transactionDetails", ignore = true)
|
||||||
@Mapping(target = "savingTransactionId", ignore = true)
|
@Mapping(target = "savingTransactionId", ignore = true)
|
||||||
@Mapping(target = "externalAssetOwner", ignore = true)
|
@Mapping(target = "externalAssetOwner", ignore = true)
|
||||||
JournalEntryData map(JournalEntry journalEntry);
|
@Mapping(target = "savingsAccountNo", ignore = true)
|
||||||
|
JournalEntryData map(JournalEntry journalEntry);
|
||||||
@Named("entityType")
|
|
||||||
default PortfolioProductType mapEntityType(Integer entityTypeId) {
|
@Named("entityType")
|
||||||
return PortfolioProductType.fromInt(entityTypeId);
|
default PortfolioProductType mapEntityType(Integer entityTypeId) {
|
||||||
}
|
return PortfolioProductType.fromInt(entityTypeId);
|
||||||
|
}
|
||||||
@Named("glAccountType")
|
|
||||||
default GLAccountType mapGlAccountType(Integer typeId) {
|
@Named("glAccountType")
|
||||||
return GLAccountType.fromInt(typeId);
|
default GLAccountType mapGlAccountType(Integer typeId) {
|
||||||
}
|
return GLAccountType.fromInt(typeId);
|
||||||
|
}
|
||||||
@Named("journalEntryType")
|
|
||||||
default JournalEntryType mapJournalEntryType(Integer typeId) {
|
@Named("journalEntryType")
|
||||||
return JournalEntryType.fromInt(typeId);
|
default JournalEntryType mapJournalEntryType(Integer typeId) {
|
||||||
}
|
return JournalEntryType.fromInt(typeId);
|
||||||
|
}
|
||||||
default EnumOptionData mapGlAccountType(GLAccountType accountType) {
|
|
||||||
return new EnumOptionData((long) accountType.getValue(), accountType.getCode(), accountType.name());
|
default EnumOptionData mapGlAccountType(GLAccountType accountType) {
|
||||||
}
|
return new EnumOptionData((long) accountType.getValue(), accountType.getCode(), accountType.name());
|
||||||
|
}
|
||||||
default EnumOptionData mapJournalEntryType(JournalEntryType journalEntryType) {
|
|
||||||
return new EnumOptionData((long) journalEntryType.getValue(), journalEntryType.getCode(), journalEntryType.name());
|
default EnumOptionData mapJournalEntryType(JournalEntryType journalEntryType) {
|
||||||
}
|
return new EnumOptionData((long) journalEntryType.getValue(), journalEntryType.getCode(), journalEntryType.name());
|
||||||
|
}
|
||||||
default EnumOptionData mapEntityType(PortfolioProductType entityType) {
|
|
||||||
return new EnumOptionData((long) entityType.getValue(), entityType.getCode(), entityType.name());
|
default EnumOptionData mapEntityType(PortfolioProductType entityType) {
|
||||||
}
|
return new EnumOptionData((long) entityType.getValue(), entityType.getCode(), entityType.name());
|
||||||
|
}
|
||||||
default CurrencyData mapCurrency(String currencyCode) {
|
|
||||||
return new CurrencyData(currencyCode);
|
default CurrencyData mapCurrency(String currencyCode) {
|
||||||
}
|
return new CurrencyData(currencyCode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
+291
-287
@@ -1,287 +1,291 @@
|
|||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.fineract.accounting.journalentry.data;
|
package org.apache.fineract.accounting.journalentry.data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
|
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
|
||||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||||
import org.apache.fineract.organisation.monetary.data.CurrencyData;
|
import org.apache.fineract.organisation.monetary.data.CurrencyData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Immutable object representing a General Ledger Account
|
* Immutable object representing a General Ledger Account
|
||||||
*
|
*
|
||||||
* Note: no getter/setters required as google will produce json from fields of object.
|
* Note: no getter/setters required as google will produce json from fields of object.
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class JournalEntryData {
|
public class JournalEntryData {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private Long officeId;
|
private Long officeId;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String officeName;
|
private String officeName;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String glAccountName;
|
private String glAccountName;
|
||||||
private Long glAccountId;
|
private Long glAccountId;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String glAccountCode;
|
private String glAccountCode;
|
||||||
private EnumOptionData glAccountType;
|
private EnumOptionData glAccountType;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private LocalDate transactionDate;
|
private LocalDate transactionDate;
|
||||||
private EnumOptionData entryType;
|
private EnumOptionData entryType;
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private CurrencyData currency;
|
private CurrencyData currency;
|
||||||
private String transactionId;
|
private String transactionId;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Boolean manualEntry;
|
private Boolean manualEntry;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private EnumOptionData entityType;
|
private EnumOptionData entityType;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Long entityId;
|
private Long entityId;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Long createdByUserId;
|
private String savingsAccountNo;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private OffsetDateTime createdDate;
|
private Long createdByUserId;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String createdByUserName;
|
private OffsetDateTime createdDate;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String comments;
|
private String createdByUserName;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Boolean reversed;
|
private String comments;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private String referenceNumber;
|
private Boolean reversed;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private BigDecimal officeRunningBalance;
|
private String referenceNumber;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private BigDecimal organizationRunningBalance;
|
private BigDecimal officeRunningBalance;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Boolean runningBalanceComputed;
|
private BigDecimal organizationRunningBalance;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@SuppressWarnings("unused")
|
private Boolean runningBalanceComputed;
|
||||||
private TransactionDetailData transactionDetails;
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private OffsetDateTime submittedOnDate;
|
private TransactionDetailData transactionDetails;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
// import fields
|
private OffsetDateTime submittedOnDate;
|
||||||
private transient Integer rowIndex;
|
|
||||||
private String dateFormat;
|
// import fields
|
||||||
private String locale;
|
private transient Integer rowIndex;
|
||||||
private List<CreditDebit> credits;
|
private String dateFormat;
|
||||||
private List<CreditDebit> debits;
|
private String locale;
|
||||||
private Long paymentTypeId;
|
private List<CreditDebit> credits;
|
||||||
private String currencyCode;
|
private List<CreditDebit> debits;
|
||||||
private String accountNumber;
|
private Long paymentTypeId;
|
||||||
private String checkNumber;
|
private String currencyCode;
|
||||||
private String routingCode;
|
private String accountNumber;
|
||||||
private String receiptNumber;
|
private String checkNumber;
|
||||||
private String bankNumber;
|
private String routingCode;
|
||||||
private String externalAssetOwner;
|
private String receiptNumber;
|
||||||
private transient Long savingTransactionId;
|
private String bankNumber;
|
||||||
|
private String externalAssetOwner;
|
||||||
public JournalEntryData() {}
|
private transient Long savingTransactionId;
|
||||||
|
|
||||||
// for opening bal bulk import
|
public JournalEntryData() {}
|
||||||
public JournalEntryData(Long officeId, LocalDate transactionDate, String currencyCode, List<CreditDebit> credits,
|
|
||||||
List<CreditDebit> debits, String locale, String dateFormat) {
|
// for opening bal bulk import
|
||||||
this.officeId = officeId;
|
public JournalEntryData(Long officeId, LocalDate transactionDate, String currencyCode, List<CreditDebit> credits,
|
||||||
this.dateFormat = dateFormat;
|
List<CreditDebit> debits, String locale, String dateFormat) {
|
||||||
this.locale = locale;
|
this.officeId = officeId;
|
||||||
this.transactionDate = transactionDate;
|
this.dateFormat = dateFormat;
|
||||||
this.currencyCode = currencyCode;
|
this.locale = locale;
|
||||||
this.credits = credits;
|
this.transactionDate = transactionDate;
|
||||||
this.debits = debits;
|
this.currencyCode = currencyCode;
|
||||||
this.rowIndex = null;
|
this.credits = credits;
|
||||||
this.paymentTypeId = null;
|
this.debits = debits;
|
||||||
this.accountNumber = null;
|
this.rowIndex = null;
|
||||||
this.checkNumber = null;
|
this.paymentTypeId = null;
|
||||||
this.routingCode = null;
|
this.accountNumber = null;
|
||||||
this.receiptNumber = null;
|
this.checkNumber = null;
|
||||||
this.bankNumber = null;
|
this.routingCode = null;
|
||||||
this.comments = null;
|
this.receiptNumber = null;
|
||||||
this.id = null;
|
this.bankNumber = null;
|
||||||
this.officeName = null;
|
this.comments = null;
|
||||||
this.glAccountName = null;
|
this.id = null;
|
||||||
this.glAccountId = null;
|
this.officeName = null;
|
||||||
this.glAccountCode = null;
|
this.glAccountName = null;
|
||||||
this.glAccountType = null;
|
this.glAccountId = null;
|
||||||
this.entryType = null;
|
this.glAccountCode = null;
|
||||||
this.amount = null;
|
this.glAccountType = null;
|
||||||
this.currency = null;
|
this.entryType = null;
|
||||||
this.transactionId = null;
|
this.amount = null;
|
||||||
this.manualEntry = null;
|
this.currency = null;
|
||||||
this.entityType = null;
|
this.transactionId = null;
|
||||||
this.entityId = null;
|
this.manualEntry = null;
|
||||||
this.createdByUserId = null;
|
this.entityType = null;
|
||||||
this.createdDate = null;
|
this.entityId = null;
|
||||||
this.createdByUserName = null;
|
this.createdByUserId = null;
|
||||||
this.reversed = null;
|
this.createdDate = null;
|
||||||
this.referenceNumber = null;
|
this.createdByUserName = null;
|
||||||
this.officeRunningBalance = null;
|
this.reversed = null;
|
||||||
this.organizationRunningBalance = null;
|
this.referenceNumber = null;
|
||||||
this.runningBalanceComputed = null;
|
this.officeRunningBalance = null;
|
||||||
this.transactionDetails = null;
|
this.organizationRunningBalance = null;
|
||||||
this.submittedOnDate = null;
|
this.runningBalanceComputed = null;
|
||||||
}
|
this.transactionDetails = null;
|
||||||
|
this.submittedOnDate = null;
|
||||||
private JournalEntryData(Long officeId, LocalDate transactionDate, String currencyCode, Long paymentTypeId, Integer rowIndex,
|
}
|
||||||
List<CreditDebit> credits, List<CreditDebit> debits, String accountNumber, String checkNumber, String routingCode,
|
|
||||||
String receiptNumber, String bankNumber, String comments, String locale, String dateFormat) {
|
private JournalEntryData(Long officeId, LocalDate transactionDate, String currencyCode, Long paymentTypeId, Integer rowIndex,
|
||||||
|
List<CreditDebit> credits, List<CreditDebit> debits, String accountNumber, String checkNumber, String routingCode,
|
||||||
this.officeId = officeId;
|
String receiptNumber, String bankNumber, String comments, String locale, String dateFormat) {
|
||||||
this.dateFormat = dateFormat;
|
|
||||||
this.locale = locale;
|
this.officeId = officeId;
|
||||||
this.transactionDate = transactionDate;
|
this.dateFormat = dateFormat;
|
||||||
this.currencyCode = currencyCode;
|
this.locale = locale;
|
||||||
this.rowIndex = rowIndex;
|
this.transactionDate = transactionDate;
|
||||||
this.credits = credits;
|
this.currencyCode = currencyCode;
|
||||||
this.debits = debits;
|
this.rowIndex = rowIndex;
|
||||||
this.paymentTypeId = paymentTypeId;
|
this.credits = credits;
|
||||||
this.accountNumber = accountNumber;
|
this.debits = debits;
|
||||||
this.checkNumber = checkNumber;
|
this.paymentTypeId = paymentTypeId;
|
||||||
this.routingCode = routingCode;
|
this.accountNumber = accountNumber;
|
||||||
this.receiptNumber = receiptNumber;
|
this.checkNumber = checkNumber;
|
||||||
this.bankNumber = bankNumber;
|
this.routingCode = routingCode;
|
||||||
this.comments = comments;
|
this.receiptNumber = receiptNumber;
|
||||||
this.id = null;
|
this.bankNumber = bankNumber;
|
||||||
this.officeName = null;
|
this.comments = comments;
|
||||||
this.glAccountName = null;
|
this.id = null;
|
||||||
this.glAccountId = null;
|
this.officeName = null;
|
||||||
this.glAccountCode = null;
|
this.glAccountName = null;
|
||||||
this.glAccountType = null;
|
this.glAccountId = null;
|
||||||
this.entryType = null;
|
this.glAccountCode = null;
|
||||||
this.amount = null;
|
this.glAccountType = null;
|
||||||
this.currency = null;
|
this.entryType = null;
|
||||||
this.transactionId = null;
|
this.amount = null;
|
||||||
this.manualEntry = null;
|
this.currency = null;
|
||||||
this.entityType = null;
|
this.transactionId = null;
|
||||||
this.entityId = null;
|
this.manualEntry = null;
|
||||||
this.createdByUserId = null;
|
this.entityType = null;
|
||||||
this.submittedOnDate = null;
|
this.entityId = null;
|
||||||
this.createdDate = null;
|
this.createdByUserId = null;
|
||||||
this.createdByUserName = null;
|
this.submittedOnDate = null;
|
||||||
this.reversed = null;
|
this.createdDate = null;
|
||||||
this.referenceNumber = null;
|
this.createdByUserName = null;
|
||||||
this.officeRunningBalance = null;
|
this.reversed = null;
|
||||||
this.organizationRunningBalance = null;
|
this.referenceNumber = null;
|
||||||
this.runningBalanceComputed = null;
|
this.officeRunningBalance = null;
|
||||||
this.transactionDetails = null;
|
this.organizationRunningBalance = null;
|
||||||
}
|
this.runningBalanceComputed = null;
|
||||||
|
this.transactionDetails = null;
|
||||||
public JournalEntryData(final Long id, final Long officeId, final String officeName, final String glAccountName, final Long glAccountId,
|
}
|
||||||
final String glAccountCode, final EnumOptionData glAccountClassification, final LocalDate transactionDate,
|
|
||||||
final EnumOptionData entryType, final BigDecimal amount, final String transactionId, final Boolean manualEntry,
|
public JournalEntryData(final Long id, final Long officeId, final String officeName, final String glAccountName, final Long glAccountId,
|
||||||
final EnumOptionData entityType, final Long entityId, final Long createdByUserId, final OffsetDateTime submittedOnDate,
|
final String glAccountCode, final EnumOptionData glAccountClassification, final LocalDate transactionDate,
|
||||||
final String createdByUserName, final String comments, final Boolean reversed, final String referenceNumber,
|
final EnumOptionData entryType, final BigDecimal amount, final String transactionId, final Boolean manualEntry,
|
||||||
final BigDecimal officeRunningBalance, final BigDecimal organizationRunningBalance, final Boolean runningBalanceComputed,
|
final EnumOptionData entityType, final Long entityId, final Long createdByUserId, final OffsetDateTime submittedOnDate,
|
||||||
final TransactionDetailData transactionDetailData, final CurrencyData currency, final String externalAssetOwner) {
|
final String createdByUserName, final String comments, final Boolean reversed, final String referenceNumber,
|
||||||
this.id = id;
|
final BigDecimal officeRunningBalance, final BigDecimal organizationRunningBalance, final Boolean runningBalanceComputed,
|
||||||
this.officeId = officeId;
|
final TransactionDetailData transactionDetailData, final CurrencyData currency, final String externalAssetOwner,
|
||||||
this.officeName = officeName;
|
final String savingsAccountNo) {
|
||||||
this.glAccountName = glAccountName;
|
this.id = id;
|
||||||
this.glAccountId = glAccountId;
|
this.officeId = officeId;
|
||||||
this.glAccountCode = glAccountCode;
|
this.officeName = officeName;
|
||||||
this.glAccountType = glAccountClassification;
|
this.glAccountName = glAccountName;
|
||||||
this.transactionDate = transactionDate;
|
this.glAccountId = glAccountId;
|
||||||
this.entryType = entryType;
|
this.glAccountCode = glAccountCode;
|
||||||
this.amount = amount;
|
this.glAccountType = glAccountClassification;
|
||||||
this.transactionId = transactionId;
|
this.transactionDate = transactionDate;
|
||||||
this.manualEntry = manualEntry;
|
this.entryType = entryType;
|
||||||
this.entityType = entityType;
|
this.amount = amount;
|
||||||
this.entityId = entityId;
|
this.transactionId = transactionId;
|
||||||
this.createdByUserId = createdByUserId;
|
this.manualEntry = manualEntry;
|
||||||
this.createdDate = submittedOnDate;
|
this.entityType = entityType;
|
||||||
this.submittedOnDate = submittedOnDate;
|
this.entityId = entityId;
|
||||||
this.createdByUserName = createdByUserName;
|
this.createdByUserId = createdByUserId;
|
||||||
this.comments = comments;
|
this.createdDate = submittedOnDate;
|
||||||
this.reversed = reversed;
|
this.submittedOnDate = submittedOnDate;
|
||||||
this.referenceNumber = referenceNumber;
|
this.createdByUserName = createdByUserName;
|
||||||
this.officeRunningBalance = officeRunningBalance;
|
this.comments = comments;
|
||||||
this.organizationRunningBalance = organizationRunningBalance;
|
this.reversed = reversed;
|
||||||
this.runningBalanceComputed = runningBalanceComputed;
|
this.referenceNumber = referenceNumber;
|
||||||
this.transactionDetails = transactionDetailData;
|
this.officeRunningBalance = officeRunningBalance;
|
||||||
this.currency = currency;
|
this.organizationRunningBalance = organizationRunningBalance;
|
||||||
this.externalAssetOwner = externalAssetOwner;
|
this.runningBalanceComputed = runningBalanceComputed;
|
||||||
}
|
this.transactionDetails = transactionDetailData;
|
||||||
|
this.currency = currency;
|
||||||
public static JournalEntryData importInstance(Long officeId, LocalDate transactionDate, String currencyCode, Long paymentTypeId,
|
this.externalAssetOwner = externalAssetOwner;
|
||||||
Integer rowIndex, List<CreditDebit> credits, List<CreditDebit> debits, String accountNumber, String checkNumber,
|
this.savingsAccountNo = savingsAccountNo;
|
||||||
String routingCode, String receiptNumber, String bankNumber, String comments, String locale, String dateFormat) {
|
}
|
||||||
return new JournalEntryData(officeId, transactionDate, currencyCode, paymentTypeId, rowIndex, credits, debits, accountNumber,
|
|
||||||
checkNumber, routingCode, receiptNumber, bankNumber, comments, locale, dateFormat);
|
public static JournalEntryData importInstance(Long officeId, LocalDate transactionDate, String currencyCode, Long paymentTypeId,
|
||||||
}
|
Integer rowIndex, List<CreditDebit> credits, List<CreditDebit> debits, String accountNumber, String checkNumber,
|
||||||
|
String routingCode, String receiptNumber, String bankNumber, String comments, String locale, String dateFormat) {
|
||||||
public static JournalEntryData importInstance1(Long officeId, LocalDate transactionDate, String currencyCode, List<CreditDebit> credits,
|
return new JournalEntryData(officeId, transactionDate, currencyCode, paymentTypeId, rowIndex, credits, debits, accountNumber,
|
||||||
List<CreditDebit> debits, String locale, String dateFormat) {
|
checkNumber, routingCode, receiptNumber, bankNumber, comments, locale, dateFormat);
|
||||||
return new JournalEntryData(officeId, transactionDate, currencyCode, credits, debits, locale, dateFormat);
|
}
|
||||||
}
|
|
||||||
|
public static JournalEntryData importInstance1(Long officeId, LocalDate transactionDate, String currencyCode, List<CreditDebit> credits,
|
||||||
public static JournalEntryData fromGLAccountData(final GLAccountData glAccountData) {
|
List<CreditDebit> debits, String locale, String dateFormat) {
|
||||||
|
return new JournalEntryData(officeId, transactionDate, currencyCode, credits, debits, locale, dateFormat);
|
||||||
final Long id = null;
|
}
|
||||||
final Long officeId = null;
|
|
||||||
final String officeName = null;
|
public static JournalEntryData fromGLAccountData(final GLAccountData glAccountData) {
|
||||||
final String glAccountName = glAccountData.getName();
|
|
||||||
final Long glAccountId = glAccountData.getId();
|
final Long id = null;
|
||||||
final String glAccountCode = glAccountData.getGlCode();
|
final Long officeId = null;
|
||||||
final EnumOptionData glAccountClassification = glAccountData.getType();
|
final String officeName = null;
|
||||||
final LocalDate transactionDate = null;
|
final String glAccountName = glAccountData.getName();
|
||||||
final EnumOptionData entryType = null;
|
final Long glAccountId = glAccountData.getId();
|
||||||
final BigDecimal amount = null;
|
final String glAccountCode = glAccountData.getGlCode();
|
||||||
final String transactionId = null;
|
final EnumOptionData glAccountClassification = glAccountData.getType();
|
||||||
final Boolean manualEntry = null;
|
final LocalDate transactionDate = null;
|
||||||
final EnumOptionData entityType = null;
|
final EnumOptionData entryType = null;
|
||||||
final Long entityId = null;
|
final BigDecimal amount = null;
|
||||||
final Long createdByUserId = null;
|
final String transactionId = null;
|
||||||
final OffsetDateTime submittedOnDate = null;
|
final Boolean manualEntry = null;
|
||||||
final String createdByUserName = null;
|
final EnumOptionData entityType = null;
|
||||||
final String comments = null;
|
final Long entityId = null;
|
||||||
final Boolean reversed = null;
|
final Long createdByUserId = null;
|
||||||
final String referenceNumber = null;
|
final OffsetDateTime submittedOnDate = null;
|
||||||
final BigDecimal officeRunningBalance = null;
|
final String createdByUserName = null;
|
||||||
final BigDecimal organizationRunningBalance = null;
|
final String comments = null;
|
||||||
final Boolean runningBalanceComputed = null;
|
final Boolean reversed = null;
|
||||||
final TransactionDetailData transactionDetailData = null;
|
final String referenceNumber = null;
|
||||||
final CurrencyData currency = null;
|
final BigDecimal officeRunningBalance = null;
|
||||||
final String externalAssetOwner = null;
|
final BigDecimal organizationRunningBalance = null;
|
||||||
return new JournalEntryData(id, officeId, officeName, glAccountName, glAccountId, glAccountCode, glAccountClassification,
|
final Boolean runningBalanceComputed = null;
|
||||||
transactionDate, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, submittedOnDate,
|
final TransactionDetailData transactionDetailData = null;
|
||||||
createdByUserName, comments, reversed, referenceNumber, officeRunningBalance, organizationRunningBalance,
|
final CurrencyData currency = null;
|
||||||
runningBalanceComputed, transactionDetailData, currency, externalAssetOwner);
|
final String externalAssetOwner = null;
|
||||||
}
|
return new JournalEntryData(id, officeId, officeName, glAccountName, glAccountId, glAccountCode, glAccountClassification,
|
||||||
|
transactionDate, entryType, amount, transactionId, manualEntry, entityType, entityId, createdByUserId, submittedOnDate,
|
||||||
public Integer getRowIndex() {
|
createdByUserName, comments, reversed, referenceNumber, officeRunningBalance, organizationRunningBalance,
|
||||||
return rowIndex;
|
runningBalanceComputed, transactionDetailData, currency, externalAssetOwner, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getTransactionDate() {
|
public Integer getRowIndex() {
|
||||||
return transactionDate;
|
return rowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDebits(CreditDebit debit) {
|
public LocalDate getTransactionDate() {
|
||||||
this.debits.add(debit);
|
return transactionDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCredits(CreditDebit credit) {
|
public void addDebits(CreditDebit debit) {
|
||||||
this.credits.add(credit);
|
this.debits.add(debit);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void addCredits(CreditDebit credit) {
|
||||||
|
this.credits.add(credit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+39
-38
@@ -1,38 +1,39 @@
|
|||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.fineract.accounting.journalentry.data;
|
package org.apache.fineract.accounting.journalentry.data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class SavingsDTO {
|
public class SavingsDTO {
|
||||||
|
|
||||||
private Long savingsId;
|
private Long savingsId;
|
||||||
private Long savingsProductId;
|
private Long savingsProductId;
|
||||||
private Long officeId;
|
private Long officeId;
|
||||||
private String currencyCode;
|
private String currencyCode;
|
||||||
private boolean cashBasedAccountingEnabled;
|
private boolean cashBasedAccountingEnabled;
|
||||||
private boolean accrualBasedAccountingEnabled;
|
private boolean accrualBasedAccountingEnabled;
|
||||||
private List<SavingsTransactionDTO> newSavingsTransactions;
|
private List<SavingsTransactionDTO> newSavingsTransactions;
|
||||||
}
|
private int depositAccountType;
|
||||||
|
}
|
||||||
|
|||||||
+1409
-1386
File diff suppressed because it is too large
Load Diff
+290
-285
@@ -1,285 +1,290 @@
|
|||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.fineract.accounting.journalentry.service;
|
package org.apache.fineract.accounting.journalentry.service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.fineract.accounting.closure.domain.GLClosure;
|
import org.apache.fineract.accounting.closure.domain.GLClosure;
|
||||||
import org.apache.fineract.accounting.common.AccountingConstants.AccrualAccountsForSavings;
|
import org.apache.fineract.accounting.common.AccountingConstants.AccrualAccountsForSavings;
|
||||||
import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
|
import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
|
||||||
import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO;
|
import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO;
|
||||||
import org.apache.fineract.accounting.journalentry.data.SavingsDTO;
|
import org.apache.fineract.accounting.journalentry.data.SavingsDTO;
|
||||||
import org.apache.fineract.accounting.journalentry.data.SavingsTransactionDTO;
|
import org.apache.fineract.accounting.journalentry.data.SavingsTransactionDTO;
|
||||||
import org.apache.fineract.infrastructure.core.service.MathUtil;
|
import org.apache.fineract.infrastructure.core.service.MathUtil;
|
||||||
import org.apache.fineract.organisation.office.domain.Office;
|
import org.apache.fineract.organisation.office.domain.Office;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AccrualBasedAccountingProcessorForSavings implements AccountingProcessorForSavings {
|
public class AccrualBasedAccountingProcessorForSavings implements AccountingProcessorForSavings {
|
||||||
|
|
||||||
private final AccountingProcessorHelper helper;
|
private final AccountingProcessorHelper helper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createJournalEntriesForSavings(final SavingsDTO savingsDTO) {
|
public void createJournalEntriesForSavings(final SavingsDTO savingsDTO) {
|
||||||
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(savingsDTO.getOfficeId());
|
AccountingProcessorHelper.setDepositAccountTypeContext(savingsDTO.getDepositAccountType());
|
||||||
final Long savingsProductId = savingsDTO.getSavingsProductId();
|
try {
|
||||||
final Long savingsId = savingsDTO.getSavingsId();
|
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(savingsDTO.getOfficeId());
|
||||||
final String currencyCode = savingsDTO.getCurrencyCode();
|
final Long savingsProductId = savingsDTO.getSavingsProductId();
|
||||||
for (final SavingsTransactionDTO savingsTransactionDTO : savingsDTO.getNewSavingsTransactions()) {
|
final Long savingsId = savingsDTO.getSavingsId();
|
||||||
final LocalDate transactionDate = savingsTransactionDTO.getTransactionDate();
|
final String currencyCode = savingsDTO.getCurrencyCode();
|
||||||
final String transactionId = savingsTransactionDTO.getTransactionId();
|
for (final SavingsTransactionDTO savingsTransactionDTO : savingsDTO.getNewSavingsTransactions()) {
|
||||||
final Office office = this.helper.getOfficeById(savingsTransactionDTO.getOfficeId());
|
final LocalDate transactionDate = savingsTransactionDTO.getTransactionDate();
|
||||||
final Long paymentTypeId = savingsTransactionDTO.getPaymentTypeId();
|
final String transactionId = savingsTransactionDTO.getTransactionId();
|
||||||
final boolean isReversal = savingsTransactionDTO.isReversed();
|
final Office office = this.helper.getOfficeById(savingsTransactionDTO.getOfficeId());
|
||||||
final BigDecimal amount = savingsTransactionDTO.getAmount();
|
final Long paymentTypeId = savingsTransactionDTO.getPaymentTypeId();
|
||||||
final BigDecimal overdraftAmount = savingsTransactionDTO.getOverdraftAmount();
|
final boolean isReversal = savingsTransactionDTO.isReversed();
|
||||||
final List<ChargePaymentDTO> feePayments = savingsTransactionDTO.getFeePayments();
|
final BigDecimal amount = savingsTransactionDTO.getAmount();
|
||||||
final List<ChargePaymentDTO> penaltyPayments = savingsTransactionDTO.getPenaltyPayments();
|
final BigDecimal overdraftAmount = savingsTransactionDTO.getOverdraftAmount();
|
||||||
|
final List<ChargePaymentDTO> feePayments = savingsTransactionDTO.getFeePayments();
|
||||||
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
final List<ChargePaymentDTO> penaltyPayments = savingsTransactionDTO.getPenaltyPayments();
|
||||||
|
|
||||||
if (savingsTransactionDTO.getTransactionType().isWithdrawal() && savingsTransactionDTO.isOverdraftTransaction()) {
|
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||||
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
if (savingsTransactionDTO.getTransactionType().isWithdrawal() && savingsTransactionDTO.isOverdraftTransaction()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
||||||
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
FinancialActivity.LIABILITY_TRANSFER.getValue(), savingsProductId, paymentTypeId, savingsId, transactionId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionDate, overdraftAmount, isReversal);
|
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
||||||
if (isPositive) {
|
FinancialActivity.LIABILITY_TRANSFER.getValue(), savingsProductId, paymentTypeId, savingsId, transactionId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
transactionDate, overdraftAmount, isReversal);
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
if (isPositive) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
amount.subtract(overdraftAmount), isReversal);
|
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
} else {
|
amount.subtract(overdraftAmount), isReversal);
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
}
|
||||||
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
} else {
|
||||||
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, overdraftAmount, isReversal);
|
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
||||||
if (isPositive) {
|
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
transactionId, transactionDate, overdraftAmount, isReversal);
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
if (isPositive) {
|
||||||
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
|
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
}
|
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
}
|
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) {
|
}
|
||||||
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
||||||
FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, overdraftAmount, isReversal);
|
FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
||||||
if (isPositive) {
|
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
transactionId, transactionDate, overdraftAmount, isReversal);
|
||||||
FinancialActivity.LIABILITY_TRANSFER.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
if (isPositive) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
amount.subtract(overdraftAmount), isReversal);
|
FinancialActivity.LIABILITY_TRANSFER.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
} else {
|
amount.subtract(overdraftAmount), isReversal);
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
}
|
||||||
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
} else {
|
||||||
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, overdraftAmount, isReversal);
|
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
||||||
if (isPositive) {
|
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
transactionId, transactionDate, overdraftAmount, isReversal);
|
||||||
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
if (isPositive) {
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
|
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
||||||
}
|
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
}
|
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/** Handle Deposits and reversals of deposits **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isDeposit()) {
|
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
/** Handle Deposits and reversals of deposits **/
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
else if (savingsTransactionDTO.getTransactionType().isDeposit()) {
|
||||||
FinancialActivity.LIABILITY_TRANSFER.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
} else {
|
FinancialActivity.LIABILITY_TRANSFER.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
} else {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
|
}
|
||||||
/** Handle Deposits and reversals of Dividend pay outs **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isDividendPayout()) {
|
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
/** Handle Deposits and reversals of Dividend pay outs **/
|
||||||
FinancialActivity.PAYABLE_DIVIDENDS.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
else if (savingsTransactionDTO.getTransactionType().isDividendPayout()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
FinancialActivity.PAYABLE_DIVIDENDS.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
/** Handle withdrawals and reversals of withdrawals **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
/** Handle withdrawals and reversals of withdrawals **/
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
} else {
|
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
} else {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isEscheat()) {
|
}
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), AccrualAccountsForSavings.ESCHEAT_LIABILITY.getValue(),
|
else if (savingsTransactionDTO.getTransactionType().isEscheat()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), AccrualAccountsForSavings.ESCHEAT_LIABILITY.getValue(),
|
||||||
/**
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
* Handle Interest Applications and reversals of Interest Applications
|
}
|
||||||
**/
|
/**
|
||||||
else if (savingsTransactionDTO.getTransactionType().isInterestPosting() && savingsTransactionDTO.isOverdraftTransaction()) {
|
* Handle Interest Applications and reversals of Interest Applications
|
||||||
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
**/
|
||||||
// Post journal entry if earned interest amount is greater than
|
else if (savingsTransactionDTO.getTransactionType().isInterestPosting() && savingsTransactionDTO.isOverdraftTransaction()) {
|
||||||
// zero
|
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
||||||
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
// Post journal entry if earned interest amount is greater than
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
// zero
|
||||||
AccrualAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
|
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, overdraftAmount, isReversal);
|
AccrualAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
|
||||||
if (isPositive) {
|
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
transactionId, transactionDate, overdraftAmount, isReversal);
|
||||||
AccrualAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
|
if (isPositive) {
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
|
AccrualAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
|
||||||
}
|
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
}
|
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) {
|
}
|
||||||
// Post journal entry if earned interest amount is greater than
|
|
||||||
// zero
|
else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) {
|
||||||
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
// Post journal entry if earned interest amount is greater than
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
// zero
|
||||||
AccrualAccountsForSavings.INTEREST_PAYABLE.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
AccrualAccountsForSavings.INTEREST_PAYABLE.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isAccrual()) {
|
}
|
||||||
// Post journal entry for Accrual Recognition
|
|
||||||
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
else if (savingsTransactionDTO.getTransactionType().isAccrual()) {
|
||||||
if (MathUtil.isGreaterThanZero(overdraftAmount)) {
|
// Post journal entry for Accrual Recognition
|
||||||
this.helper.createAccrualBasedDebitJournalEntriesAndReversalsForSavings(office, currencyCode,
|
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
AccrualAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), savingsProductId, paymentTypeId, savingsId,
|
if (MathUtil.isGreaterThanZero(overdraftAmount)) {
|
||||||
transactionId, transactionDate, amount, isReversal);
|
this.helper.createAccrualBasedDebitJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
this.helper.createAccrualBasedCreditJournalEntriesAndReversalsForSavings(office, currencyCode,
|
AccrualAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
AccrualAccountsForSavings.INTEREST_PAYABLE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
transactionId, transactionDate, amount, isReversal);
|
||||||
transactionId, transactionDate, amount, isReversal);
|
this.helper.createAccrualBasedCreditJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
} else {
|
AccrualAccountsForSavings.INTEREST_PAYABLE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
this.helper.createAccrualBasedDebitJournalEntriesAndReversalsForSavings(office, currencyCode,
|
transactionId, transactionDate, amount, isReversal);
|
||||||
AccrualAccountsForSavings.INTEREST_RECEIVABLE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
} else {
|
||||||
transactionId, transactionDate, amount, isReversal);
|
this.helper.createAccrualBasedDebitJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
this.helper.createAccrualBasedCreditJournalEntriesAndReversalsForSavings(office, currencyCode,
|
AccrualAccountsForSavings.INTEREST_RECEIVABLE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
AccrualAccountsForSavings.INCOME_FROM_INTEREST.getValue(), savingsProductId, paymentTypeId, savingsId,
|
transactionId, transactionDate, amount, isReversal);
|
||||||
transactionId, transactionDate, amount, isReversal);
|
this.helper.createAccrualBasedCreditJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
AccrualAccountsForSavings.INCOME_FROM_INTEREST.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
}
|
transactionId, transactionDate, amount, isReversal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isWithholdTax()) {
|
}
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsTax(office, currencyCode,
|
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.SAVINGS_REFERENCE, savingsProductId,
|
else if (savingsTransactionDTO.getTransactionType().isWithholdTax()) {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal,
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsTax(office, currencyCode,
|
||||||
savingsTransactionDTO.getTaxPayments());
|
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.SAVINGS_REFERENCE, savingsProductId,
|
||||||
}
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal,
|
||||||
|
savingsTransactionDTO.getTaxPayments());
|
||||||
/** Handle Fees Deductions and reversals of Fees Deductions **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction() && savingsTransactionDTO.isOverdraftTransaction()) {
|
|
||||||
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
/** Handle Fees Deductions and reversals of Fees Deductions **/
|
||||||
// Is the Charge a penalty?
|
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction() && savingsTransactionDTO.isOverdraftTransaction()) {
|
||||||
if (penaltyPayments.size() > 0) {
|
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
// Is the Charge a penalty?
|
||||||
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, AccrualAccountsForSavings.INCOME_FROM_PENALTIES,
|
if (penaltyPayments.size() > 0) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
penaltyPayments);
|
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, AccrualAccountsForSavings.INCOME_FROM_PENALTIES,
|
||||||
if (isPositive) {
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
penaltyPayments);
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.INCOME_FROM_PENALTIES,
|
if (isPositive) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
amount.subtract(overdraftAmount), isReversal, penaltyPayments);
|
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.INCOME_FROM_PENALTIES,
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
} else {
|
amount.subtract(overdraftAmount), isReversal, penaltyPayments);
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
}
|
||||||
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, AccrualAccountsForSavings.INCOME_FROM_FEES,
|
} else {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
feePayments);
|
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, AccrualAccountsForSavings.INCOME_FROM_FEES,
|
||||||
if (isPositive) {
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
feePayments);
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
if (isPositive) {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal,
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
feePayments);
|
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
||||||
}
|
paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal,
|
||||||
}
|
feePayments);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction()) {
|
}
|
||||||
// Is the Charge a penalty?
|
|
||||||
if (penaltyPayments.size() > 0) {
|
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction()) {
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
// Is the Charge a penalty?
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.INCOME_FROM_PENALTIES, savingsProductId,
|
if (penaltyPayments.size() > 0) {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, penaltyPayments);
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
} else {
|
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.INCOME_FROM_PENALTIES, savingsProductId,
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, penaltyPayments);
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
} else {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
}
|
AccrualAccountsForSavings.SAVINGS_CONTROL, AccrualAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
||||||
}
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
|
||||||
|
}
|
||||||
/** Handle Transfers proposal **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
/** Handle Transfers proposal **/
|
||||||
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), AccrualAccountsForSavings.TRANSFERS_SUSPENSE.getValue(),
|
else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(), AccrualAccountsForSavings.TRANSFERS_SUSPENSE.getValue(),
|
||||||
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
/** Handle Transfer Withdrawal or Acceptance **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer()
|
|
||||||
|| savingsTransactionDTO.getTransactionType().isApproveTransfer()) {
|
/** Handle Transfer Withdrawal or Acceptance **/
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer()
|
||||||
AccrualAccountsForSavings.TRANSFERS_SUSPENSE.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
|| savingsTransactionDTO.getTransactionType().isApproveTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
AccrualAccountsForSavings.TRANSFERS_SUSPENSE.getValue(), AccrualAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
/** overdraft **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isOverdraftInterest()) {
|
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
/** overdraft **/
|
||||||
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(), AccrualAccountsForSavings.INCOME_FROM_INTEREST.getValue(),
|
else if (savingsTransactionDTO.getTransactionType().isOverdraftInterest()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
} else if (savingsTransactionDTO.getTransactionType().isWrittenoff()) {
|
AccrualAccountsForSavings.SAVINGS_REFERENCE.getValue(), AccrualAccountsForSavings.INCOME_FROM_INTEREST.getValue(),
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
AccrualAccountsForSavings.LOSSES_WRITTEN_OFF.getValue(),
|
} else if (savingsTransactionDTO.getTransactionType().isWrittenoff()) {
|
||||||
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, amount, isReversal);
|
AccrualAccountsForSavings.LOSSES_WRITTEN_OFF.getValue(),
|
||||||
} else if (savingsTransactionDTO.getTransactionType().isOverdraftFee()) {
|
AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
transactionId, transactionDate, amount, isReversal);
|
||||||
AccrualAccountsForSavings.SAVINGS_REFERENCE, AccrualAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
} else if (savingsTransactionDTO.getTransactionType().isOverdraftFee()) {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
}
|
AccrualAccountsForSavings.SAVINGS_REFERENCE, AccrualAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
||||||
}
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
AccountingProcessorHelper.clearDepositAccountTypeContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+260
-255
@@ -1,255 +1,260 @@
|
|||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.fineract.accounting.journalentry.service;
|
package org.apache.fineract.accounting.journalentry.service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.fineract.accounting.closure.domain.GLClosure;
|
import org.apache.fineract.accounting.closure.domain.GLClosure;
|
||||||
import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForSavings;
|
import org.apache.fineract.accounting.common.AccountingConstants.CashAccountsForSavings;
|
||||||
import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
|
import org.apache.fineract.accounting.common.AccountingConstants.FinancialActivity;
|
||||||
import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO;
|
import org.apache.fineract.accounting.journalentry.data.ChargePaymentDTO;
|
||||||
import org.apache.fineract.accounting.journalentry.data.SavingsDTO;
|
import org.apache.fineract.accounting.journalentry.data.SavingsDTO;
|
||||||
import org.apache.fineract.accounting.journalentry.data.SavingsTransactionDTO;
|
import org.apache.fineract.accounting.journalentry.data.SavingsTransactionDTO;
|
||||||
import org.apache.fineract.organisation.office.domain.Office;
|
import org.apache.fineract.organisation.office.domain.Office;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CashBasedAccountingProcessorForSavings implements AccountingProcessorForSavings {
|
public class CashBasedAccountingProcessorForSavings implements AccountingProcessorForSavings {
|
||||||
|
|
||||||
private final AccountingProcessorHelper helper;
|
private final AccountingProcessorHelper helper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createJournalEntriesForSavings(final SavingsDTO savingsDTO) {
|
public void createJournalEntriesForSavings(final SavingsDTO savingsDTO) {
|
||||||
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(savingsDTO.getOfficeId());
|
AccountingProcessorHelper.setDepositAccountTypeContext(savingsDTO.getDepositAccountType());
|
||||||
final Long savingsProductId = savingsDTO.getSavingsProductId();
|
try {
|
||||||
final Long savingsId = savingsDTO.getSavingsId();
|
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(savingsDTO.getOfficeId());
|
||||||
final String currencyCode = savingsDTO.getCurrencyCode();
|
final Long savingsProductId = savingsDTO.getSavingsProductId();
|
||||||
for (final SavingsTransactionDTO savingsTransactionDTO : savingsDTO.getNewSavingsTransactions()) {
|
final Long savingsId = savingsDTO.getSavingsId();
|
||||||
final LocalDate transactionDate = savingsTransactionDTO.getTransactionDate();
|
final String currencyCode = savingsDTO.getCurrencyCode();
|
||||||
final String transactionId = savingsTransactionDTO.getTransactionId();
|
for (final SavingsTransactionDTO savingsTransactionDTO : savingsDTO.getNewSavingsTransactions()) {
|
||||||
final Office office = this.helper.getOfficeById(savingsTransactionDTO.getOfficeId());
|
final LocalDate transactionDate = savingsTransactionDTO.getTransactionDate();
|
||||||
final Long paymentTypeId = savingsTransactionDTO.getPaymentTypeId();
|
final String transactionId = savingsTransactionDTO.getTransactionId();
|
||||||
final boolean isReversal = savingsTransactionDTO.isReversed();
|
final Office office = this.helper.getOfficeById(savingsTransactionDTO.getOfficeId());
|
||||||
final BigDecimal amount = savingsTransactionDTO.getAmount();
|
final Long paymentTypeId = savingsTransactionDTO.getPaymentTypeId();
|
||||||
final BigDecimal overdraftAmount = savingsTransactionDTO.getOverdraftAmount();
|
final boolean isReversal = savingsTransactionDTO.isReversed();
|
||||||
final List<ChargePaymentDTO> feePayments = savingsTransactionDTO.getFeePayments();
|
final BigDecimal amount = savingsTransactionDTO.getAmount();
|
||||||
final List<ChargePaymentDTO> penaltyPayments = savingsTransactionDTO.getPenaltyPayments();
|
final BigDecimal overdraftAmount = savingsTransactionDTO.getOverdraftAmount();
|
||||||
|
final List<ChargePaymentDTO> feePayments = savingsTransactionDTO.getFeePayments();
|
||||||
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
final List<ChargePaymentDTO> penaltyPayments = savingsTransactionDTO.getPenaltyPayments();
|
||||||
|
|
||||||
if (savingsTransactionDTO.getTransactionType().isWithdrawal() && savingsTransactionDTO.isOverdraftTransaction()) {
|
this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
|
||||||
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
if (savingsTransactionDTO.getTransactionType().isWithdrawal() && savingsTransactionDTO.isOverdraftTransaction()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
||||||
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
if (isPositive) {
|
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal);
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
if (isPositive) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
amount.subtract(overdraftAmount), isReversal);
|
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
} else {
|
amount.subtract(overdraftAmount), isReversal);
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
}
|
||||||
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
} else {
|
||||||
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId, transactionId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionDate, overdraftAmount, isReversal);
|
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
||||||
if (isPositive) {
|
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), savingsProductId, paymentTypeId, savingsId, transactionId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
transactionDate, overdraftAmount, isReversal);
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
if (isPositive) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
amount.subtract(overdraftAmount), isReversal);
|
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
}
|
amount.subtract(overdraftAmount), isReversal);
|
||||||
} else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) {
|
}
|
||||||
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
}
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
} else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
||||||
FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
if (isPositive) {
|
FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal);
|
||||||
FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
if (isPositive) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
amount.subtract(overdraftAmount), isReversal);
|
FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
} else {
|
amount.subtract(overdraftAmount), isReversal);
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
}
|
||||||
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
} else {
|
||||||
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, overdraftAmount, isReversal);
|
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
||||||
if (isPositive) {
|
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
transactionId, transactionDate, overdraftAmount, isReversal);
|
||||||
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
if (isPositive) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
amount.subtract(overdraftAmount), isReversal);
|
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
}
|
amount.subtract(overdraftAmount), isReversal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/** Handle Deposits and reversals of deposits **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isDeposit()) {
|
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
/** Handle Deposits and reversals of deposits **/
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
else if (savingsTransactionDTO.getTransactionType().isDeposit()) {
|
||||||
FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
} else {
|
FinancialActivity.LIABILITY_TRANSFER.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
} else {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
|
}
|
||||||
/** Handle Deposits and reversals of Dividend pay outs **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isDividendPayout()) {
|
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
/** Handle Deposits and reversals of Dividend pay outs **/
|
||||||
FinancialActivity.PAYABLE_DIVIDENDS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId,
|
else if (savingsTransactionDTO.getTransactionType().isDividendPayout()) {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
FinancialActivity.PAYABLE_DIVIDENDS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(), savingsProductId,
|
||||||
/** Handle withdrawals and reversals of withdrawals **/
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
}
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
/** Handle withdrawals and reversals of withdrawals **/
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
} else {
|
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), FinancialActivity.LIABILITY_TRANSFER.getValue(),
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
} else {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.SAVINGS_REFERENCE.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isEscheat()) {
|
}
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.ESCHEAT_LIABILITY.getValue(),
|
else if (savingsTransactionDTO.getTransactionType().isEscheat()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.ESCHEAT_LIABILITY.getValue(),
|
||||||
/**
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
* Handle Interest Applications and reversals of Interest Applications
|
}
|
||||||
**/
|
/**
|
||||||
else if (savingsTransactionDTO.getTransactionType().isInterestPosting() && savingsTransactionDTO.isOverdraftTransaction()) {
|
* Handle Interest Applications and reversals of Interest Applications
|
||||||
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
**/
|
||||||
// Post journal entry if earned interest amount is greater than
|
else if (savingsTransactionDTO.getTransactionType().isInterestPosting() && savingsTransactionDTO.isOverdraftTransaction()) {
|
||||||
// zero
|
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
||||||
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
// Post journal entry if earned interest amount is greater than
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
// zero
|
||||||
CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
|
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
transactionId, transactionDate, overdraftAmount, isReversal);
|
CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(),
|
||||||
if (isPositive) {
|
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
transactionId, transactionDate, overdraftAmount, isReversal);
|
||||||
CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
if (isPositive) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
amount.subtract(overdraftAmount), isReversal);
|
CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
}
|
amount.subtract(overdraftAmount), isReversal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) {
|
}
|
||||||
// Post journal entry if earned interest amount is greater than
|
|
||||||
// zero
|
else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) {
|
||||||
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
// Post journal entry if earned interest amount is greater than
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
// zero
|
||||||
CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
CashAccountsForSavings.INTEREST_ON_SAVINGS.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
}
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isWithholdTax()) {
|
}
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsTax(office, currencyCode,
|
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.SAVINGS_REFERENCE, savingsProductId, paymentTypeId,
|
else if (savingsTransactionDTO.getTransactionType().isWithholdTax()) {
|
||||||
savingsId, transactionId, transactionDate, amount, isReversal, savingsTransactionDTO.getTaxPayments());
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsTax(office, currencyCode,
|
||||||
}
|
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.SAVINGS_REFERENCE, savingsProductId, paymentTypeId,
|
||||||
|
savingsId, transactionId, transactionDate, amount, isReversal, savingsTransactionDTO.getTaxPayments());
|
||||||
/** Handle Fees Deductions and reversals of Fees Deductions **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction() && savingsTransactionDTO.isOverdraftTransaction()) {
|
|
||||||
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
/** Handle Fees Deductions and reversals of Fees Deductions **/
|
||||||
// Is the Charge a penalty?
|
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction() && savingsTransactionDTO.isOverdraftTransaction()) {
|
||||||
if (penaltyPayments.size() > 0) {
|
boolean isPositive = amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) > 0;
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
// Is the Charge a penalty?
|
||||||
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES,
|
if (penaltyPayments.size() > 0) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
penaltyPayments);
|
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES,
|
||||||
if (isPositive) {
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
penaltyPayments);
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES, savingsProductId,
|
if (isPositive) {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
penaltyPayments);
|
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES, savingsProductId,
|
||||||
}
|
paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal,
|
||||||
} else {
|
penaltyPayments);
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
}
|
||||||
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
} else {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal, feePayments);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
if (isPositive) {
|
CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
paymentTypeId, savingsId, transactionId, transactionDate, overdraftAmount, isReversal, feePayments);
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
if (isPositive) {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
feePayments);
|
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
||||||
}
|
paymentTypeId, savingsId, transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal,
|
||||||
}
|
feePayments);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction()) {
|
}
|
||||||
// Is the Charge a penalty?
|
|
||||||
if (penaltyPayments.size() > 0) {
|
else if (savingsTransactionDTO.getTransactionType().isFeeDeduction()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
// Is the Charge a penalty?
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES, savingsProductId,
|
if (penaltyPayments.size() > 0) {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, penaltyPayments);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
} else {
|
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_PENALTIES, savingsProductId,
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, penaltyPayments);
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
} else {
|
||||||
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
}
|
CashAccountsForSavings.SAVINGS_CONTROL, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId,
|
||||||
}
|
paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
|
||||||
|
}
|
||||||
/** Handle Transfers proposal **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
/** Handle Transfers proposal **/
|
||||||
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.TRANSFERS_SUSPENSE.getValue(),
|
else if (savingsTransactionDTO.getTransactionType().isInitiateTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
CashAccountsForSavings.SAVINGS_CONTROL.getValue(), CashAccountsForSavings.TRANSFERS_SUSPENSE.getValue(),
|
||||||
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
/** Handle Transfer Withdrawal or Acceptance **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer()
|
|
||||||
|| savingsTransactionDTO.getTransactionType().isApproveTransfer()) {
|
/** Handle Transfer Withdrawal or Acceptance **/
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
else if (savingsTransactionDTO.getTransactionType().isWithdrawTransfer()
|
||||||
CashAccountsForSavings.TRANSFERS_SUSPENSE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
|| savingsTransactionDTO.getTransactionType().isApproveTransfer()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
}
|
CashAccountsForSavings.TRANSFERS_SUSPENSE.getValue(), CashAccountsForSavings.SAVINGS_CONTROL.getValue(),
|
||||||
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
/** overdraft **/
|
}
|
||||||
else if (savingsTransactionDTO.getTransactionType().isOverdraftInterest()) {
|
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
/** overdraft **/
|
||||||
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.INCOME_FROM_INTEREST.getValue(),
|
else if (savingsTransactionDTO.getTransactionType().isOverdraftInterest()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
} else if (savingsTransactionDTO.getTransactionType().isWrittenoff()) {
|
CashAccountsForSavings.SAVINGS_REFERENCE.getValue(), CashAccountsForSavings.INCOME_FROM_INTEREST.getValue(),
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
CashAccountsForSavings.LOSSES_WRITTEN_OFF.getValue(), CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
} else if (savingsTransactionDTO.getTransactionType().isWrittenoff()) {
|
||||||
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
} else if (savingsTransactionDTO.getTransactionType().isOverdraftFee()) {
|
CashAccountsForSavings.LOSSES_WRITTEN_OFF.getValue(), CashAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
CashAccountsForSavings.SAVINGS_REFERENCE, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId, paymentTypeId,
|
} else if (savingsTransactionDTO.getTransactionType().isOverdraftFee()) {
|
||||||
savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavingsCharges(office, currencyCode,
|
||||||
}
|
CashAccountsForSavings.SAVINGS_REFERENCE, CashAccountsForSavings.INCOME_FROM_FEES, savingsProductId, paymentTypeId,
|
||||||
}
|
savingsId, transactionId, transactionDate, amount, isReversal, feePayments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
AccountingProcessorHelper.clearDepositAccountTypeContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+765
-757
File diff suppressed because it is too large
Load Diff
+285
-285
@@ -1,285 +1,285 @@
|
|||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.fineract.accounting.journalentry.service;
|
package org.apache.fineract.accounting.journalentry.service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
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.journalentry.api.JournalEntryJsonInputParams;
|
import org.apache.fineract.accounting.journalentry.api.JournalEntryJsonInputParams;
|
||||||
import org.apache.fineract.accounting.journalentry.data.JournalEntryData;
|
import org.apache.fineract.accounting.journalentry.data.JournalEntryData;
|
||||||
import org.apache.fineract.accounting.journalentry.data.JournalEntryDataValidator;
|
import org.apache.fineract.accounting.journalentry.data.JournalEntryDataValidator;
|
||||||
import org.apache.fineract.accounting.journalentry.domain.JournalEntryType;
|
import org.apache.fineract.accounting.journalentry.domain.JournalEntryType;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
|
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||||
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
|
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
|
||||||
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator;
|
import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator;
|
||||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||||
import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
|
import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
|
||||||
import org.springframework.dao.EmptyResultDataAccessException;
|
import org.springframework.dao.EmptyResultDataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntryRunningBalanceUpdateService {
|
public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntryRunningBalanceUpdateService {
|
||||||
|
|
||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
private final OfficeRepositoryWrapper officeRepositoryWrapper;
|
private final OfficeRepositoryWrapper officeRepositoryWrapper;
|
||||||
|
|
||||||
private final JournalEntryDataValidator dataValidator;
|
private final JournalEntryDataValidator dataValidator;
|
||||||
|
|
||||||
private final FromJsonHelper fromApiJsonHelper;
|
private final FromJsonHelper fromApiJsonHelper;
|
||||||
private final DatabaseSpecificSQLGenerator sqlGenerator;
|
private final DatabaseSpecificSQLGenerator sqlGenerator;
|
||||||
|
|
||||||
private final GLJournalEntryMapper entryMapper = new GLJournalEntryMapper();
|
private final GLJournalEntryMapper entryMapper = new GLJournalEntryMapper();
|
||||||
|
|
||||||
private final PlatformSecurityContext platformSecurityContext;
|
private final PlatformSecurityContext platformSecurityContext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateRunningBalance() {
|
public void updateRunningBalance() {
|
||||||
String dateFinder = "select MIN(je.entry_date) as entityDate from acc_gl_journal_entry je "
|
String dateFinder = "select MIN(je.entry_date) as entityDate from acc_gl_journal_entry je "
|
||||||
+ "where je.is_running_balance_calculated=false ";
|
+ "where je.is_running_balance_calculated=false ";
|
||||||
try {
|
try {
|
||||||
LocalDate entityDate = this.jdbcTemplate.queryForObject(dateFinder, LocalDate.class);
|
LocalDate entityDate = this.jdbcTemplate.queryForObject(dateFinder, LocalDate.class);
|
||||||
updateOrganizationRunningBalance(entityDate);
|
updateOrganizationRunningBalance(entityDate);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
} catch (EmptyResultDataAccessException e) {
|
||||||
log.debug("No results found for updation of running balance ");
|
log.debug("No results found for updation of running balance ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult updateOfficeRunningBalance(JsonCommand command) {
|
public CommandProcessingResult updateOfficeRunningBalance(JsonCommand command) {
|
||||||
this.dataValidator.validateForUpdateRunningBalance(command);
|
this.dataValidator.validateForUpdateRunningBalance(command);
|
||||||
final Long officeId = this.fromApiJsonHelper.extractLongNamed(JournalEntryJsonInputParams.OFFICE_ID.getValue(),
|
final Long officeId = this.fromApiJsonHelper.extractLongNamed(JournalEntryJsonInputParams.OFFICE_ID.getValue(),
|
||||||
command.parsedJson());
|
command.parsedJson());
|
||||||
CommandProcessingResultBuilder commandProcessingResultBuilder = new CommandProcessingResultBuilder()
|
CommandProcessingResultBuilder commandProcessingResultBuilder = new CommandProcessingResultBuilder()
|
||||||
.withCommandId(command.commandId());
|
.withCommandId(command.commandId());
|
||||||
if (officeId == null) {
|
if (officeId == null) {
|
||||||
updateRunningBalance();
|
updateRunningBalance();
|
||||||
} else {
|
} else {
|
||||||
this.officeRepositoryWrapper.findOneWithNotFoundDetection(officeId);
|
this.officeRepositoryWrapper.findOneWithNotFoundDetection(officeId);
|
||||||
String dateFinder = "select MIN(je.entry_date) as entityDate " + "from acc_gl_journal_entry je "
|
String dateFinder = "select MIN(je.entry_date) as entityDate " + "from acc_gl_journal_entry je "
|
||||||
+ "where je.is_running_balance_calculated=false and je.office_id=?";
|
+ "where je.is_running_balance_calculated=false and je.office_id=?";
|
||||||
try {
|
try {
|
||||||
LocalDate entityDate = this.jdbcTemplate.queryForObject(dateFinder, LocalDate.class, officeId);
|
LocalDate entityDate = this.jdbcTemplate.queryForObject(dateFinder, LocalDate.class, officeId);
|
||||||
updateRunningBalance(officeId, entityDate);
|
updateRunningBalance(officeId, entityDate);
|
||||||
} catch (EmptyResultDataAccessException e) {
|
} catch (EmptyResultDataAccessException e) {
|
||||||
log.debug("No results found for updation of office running balance with office id: {}", officeId);
|
log.debug("No results found for updation of office running balance with office id: {}", officeId);
|
||||||
}
|
}
|
||||||
commandProcessingResultBuilder.withOfficeId(officeId);
|
commandProcessingResultBuilder.withOfficeId(officeId);
|
||||||
}
|
}
|
||||||
return commandProcessingResultBuilder.build();
|
return commandProcessingResultBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOrganizationRunningBalance(LocalDate entityDate) {
|
private void updateOrganizationRunningBalance(LocalDate entityDate) {
|
||||||
Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5);
|
Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5);
|
||||||
Map<Long, Map<Long, BigDecimal>> officesRunningBalance = new HashMap<>();
|
Map<Long, Map<Long, BigDecimal>> officesRunningBalance = new HashMap<>();
|
||||||
|
|
||||||
final String organizationRunningBalanceQuery = "select je.organization_running_balance as runningBalance,je.account_id as accountId from acc_gl_journal_entry je "
|
final String organizationRunningBalanceQuery = "select je.organization_running_balance as runningBalance,je.account_id as accountId from acc_gl_journal_entry je "
|
||||||
+ "inner join (select max(id) as id from acc_gl_journal_entry where entry_date < ? group by account_id,entry_date) je2 ON je2.id = je.id "
|
+ "inner join (select max(id) as id from acc_gl_journal_entry where entry_date < ? group by account_id,entry_date) je2 ON je2.id = je.id "
|
||||||
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where entry_date < ? group by account_id) je3 ON je.entry_date = je3.date "
|
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where entry_date < ? group by account_id) je3 ON je.entry_date = je3.date "
|
||||||
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
|
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
|
||||||
|
|
||||||
List<Map<String, Object>> list = jdbcTemplate.queryForList(organizationRunningBalanceQuery, // NOSONAR
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(organizationRunningBalanceQuery, // NOSONAR
|
||||||
entityDate, entityDate);
|
entityDate, entityDate);
|
||||||
|
|
||||||
for (Map<String, Object> entries : list) {
|
for (Map<String, Object> entries : list) {
|
||||||
Long accountId = Long.parseLong(entries.get("accountId").toString()); // Drizzle
|
Long accountId = Long.parseLong(entries.get("accountId").toString()); // Drizzle
|
||||||
// is
|
// is
|
||||||
// returning
|
// returning
|
||||||
// Big
|
// Big
|
||||||
// Integer
|
// Integer
|
||||||
// where
|
// where
|
||||||
// as
|
// as
|
||||||
// MySQL
|
// MySQL
|
||||||
// returns
|
// returns
|
||||||
// Long.
|
// Long.
|
||||||
if (!runningBalanceMap.containsKey(accountId)) {
|
if (!runningBalanceMap.containsKey(accountId)) {
|
||||||
runningBalanceMap.put(accountId, (BigDecimal) entries.get("runningBalance"));
|
runningBalanceMap.put(accountId, (BigDecimal) entries.get("runningBalance"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String offlineRunningBalanceQuery = "select je.office_running_balance as runningBalance,je.account_id as accountId,je.office_id as officeId "
|
final String offlineRunningBalanceQuery = "select je.office_running_balance as runningBalance,je.account_id as accountId,je.office_id as officeId "
|
||||||
+ "from acc_gl_journal_entry je "
|
+ "from acc_gl_journal_entry je "
|
||||||
+ "inner join (select max(id) as id from acc_gl_journal_entry where entry_date < ? group by office_id,account_id,entry_date) je2 ON je2.id = je.id "
|
+ "inner join (select max(id) as id from acc_gl_journal_entry where entry_date < ? group by office_id,account_id,entry_date) je2 ON je2.id = je.id "
|
||||||
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where entry_date < ? group by office_id,account_id) je3 ON je.entry_date = je3.date "
|
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where entry_date < ? group by office_id,account_id) je3 ON je.entry_date = je3.date "
|
||||||
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
|
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
|
||||||
|
|
||||||
List<Map<String, Object>> officesRunningBalanceList = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR
|
List<Map<String, Object>> officesRunningBalanceList = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR
|
||||||
entityDate, entityDate);
|
entityDate, entityDate);
|
||||||
for (Map<String, Object> entries : officesRunningBalanceList) {
|
for (Map<String, Object> entries : officesRunningBalanceList) {
|
||||||
Long accountId = Long.parseLong(entries.get("accountId").toString());
|
Long accountId = Long.parseLong(entries.get("accountId").toString());
|
||||||
Long officeId = Long.parseLong(entries.get("officeId").toString());
|
Long officeId = Long.parseLong(entries.get("officeId").toString());
|
||||||
Map<Long, BigDecimal> runningBalance;
|
Map<Long, BigDecimal> runningBalance;
|
||||||
if (officesRunningBalance.containsKey(officeId)) {
|
if (officesRunningBalance.containsKey(officeId)) {
|
||||||
runningBalance = officesRunningBalance.get(officeId);
|
runningBalance = officesRunningBalance.get(officeId);
|
||||||
} else {
|
} else {
|
||||||
runningBalance = new HashMap<>();
|
runningBalance = new HashMap<>();
|
||||||
officesRunningBalance.put(officeId, runningBalance);
|
officesRunningBalance.put(officeId, runningBalance);
|
||||||
}
|
}
|
||||||
if (!runningBalance.containsKey(accountId)) {
|
if (!runningBalance.containsKey(accountId)) {
|
||||||
runningBalance.put(accountId, (BigDecimal) entries.get("runningBalance"));
|
runningBalance.put(accountId, (BigDecimal) entries.get("runningBalance"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<JournalEntryData> entryDataList = jdbcTemplate.query(entryMapper.organizationRunningBalanceSchema(), entryMapper, entityDate);
|
List<JournalEntryData> entryDataList = jdbcTemplate.query(entryMapper.organizationRunningBalanceSchema(), entryMapper, entityDate);
|
||||||
if (entryDataList.size() > 0) {
|
if (entryDataList.size() > 0) {
|
||||||
// run a batch update of 1000 SQL statements at a time
|
// run a batch update of 1000 SQL statements at a time
|
||||||
final int batchUpdateSize = 1000;
|
final int batchUpdateSize = 1000;
|
||||||
List<Object[]> params = new ArrayList<>();
|
List<Object[]> params = new ArrayList<>();
|
||||||
int batchIndex = 0;
|
int batchIndex = 0;
|
||||||
String sql = "UPDATE acc_gl_journal_entry SET is_running_balance_calculated=?, organization_running_balance=?,"
|
String sql = "UPDATE acc_gl_journal_entry SET is_running_balance_calculated=?, organization_running_balance=?,"
|
||||||
+ "office_running_balance=?, last_modified_by=?, last_modified_on_utc=? WHERE id=?";
|
+ "office_running_balance=?, last_modified_by=?, last_modified_on_utc=? WHERE id=?";
|
||||||
for (int index = 0; index < entryDataList.size(); index++) {
|
for (int index = 0; index < entryDataList.size(); index++) {
|
||||||
JournalEntryData entryData = entryDataList.get(index);
|
JournalEntryData entryData = entryDataList.get(index);
|
||||||
Map<Long, BigDecimal> officeRunningBalanceMap;
|
Map<Long, BigDecimal> officeRunningBalanceMap;
|
||||||
if (officesRunningBalance.containsKey(entryData.getOfficeId())) {
|
if (officesRunningBalance.containsKey(entryData.getOfficeId())) {
|
||||||
officeRunningBalanceMap = officesRunningBalance.get(entryData.getOfficeId());
|
officeRunningBalanceMap = officesRunningBalance.get(entryData.getOfficeId());
|
||||||
} else {
|
} else {
|
||||||
officeRunningBalanceMap = new HashMap<>();
|
officeRunningBalanceMap = new HashMap<>();
|
||||||
officesRunningBalance.put(entryData.getOfficeId(), officeRunningBalanceMap);
|
officesRunningBalance.put(entryData.getOfficeId(), officeRunningBalanceMap);
|
||||||
}
|
}
|
||||||
BigDecimal officeRunningBalance = calculateRunningBalance(entryData, officeRunningBalanceMap);
|
BigDecimal officeRunningBalance = calculateRunningBalance(entryData, officeRunningBalanceMap);
|
||||||
BigDecimal runningBalance = calculateRunningBalance(entryData, runningBalanceMap);
|
BigDecimal runningBalance = calculateRunningBalance(entryData, runningBalanceMap);
|
||||||
|
|
||||||
params.add(new Object[] { Boolean.TRUE, runningBalance, officeRunningBalance,
|
params.add(new Object[] { Boolean.TRUE, runningBalance, officeRunningBalance,
|
||||||
platformSecurityContext.authenticatedUser().getId(), DateUtils.getAuditOffsetDateTime(), entryData.getId() });
|
platformSecurityContext.authenticatedUser().getId(), DateUtils.getAuditOffsetDateTime(), entryData.getId() });
|
||||||
batchIndex++;
|
batchIndex++;
|
||||||
if (batchIndex == batchUpdateSize || index == entryDataList.size() - 1) {
|
if (batchIndex == batchUpdateSize || index == entryDataList.size() - 1) {
|
||||||
this.jdbcTemplate.batchUpdate(sql, params);
|
this.jdbcTemplate.batchUpdate(sql, params);
|
||||||
// reset counter and string array
|
// reset counter and string array
|
||||||
batchIndex = 0;
|
batchIndex = 0;
|
||||||
params.clear();
|
params.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRunningBalance(Long officeId, LocalDate entityDate) {
|
private void updateRunningBalance(Long officeId, LocalDate entityDate) {
|
||||||
Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5);
|
Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5);
|
||||||
|
|
||||||
final String offlineRunningBalanceQuery = "select je.office_running_balance as runningBalance,je.account_id as accountId from acc_gl_journal_entry je "
|
final String offlineRunningBalanceQuery = "select je.office_running_balance as runningBalance,je.account_id as accountId from acc_gl_journal_entry je "
|
||||||
+ "inner join (select max(id) as id from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id,entry_date) je2 ON je2.id = je.id "
|
+ "inner join (select max(id) as id from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id,entry_date) je2 ON je2.id = je.id "
|
||||||
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id) je3 ON je.entry_date = je3.date "
|
+ "inner join (select max(entry_date) as date from acc_gl_journal_entry where office_id=? and entry_date < ? group by account_id) je3 ON je.entry_date = je3.date "
|
||||||
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
|
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
|
||||||
|
|
||||||
List<Map<String, Object>> list = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR
|
||||||
officeId, entityDate, officeId, entityDate);
|
officeId, entityDate, officeId, entityDate);
|
||||||
for (Map<String, Object> entries : list) {
|
for (Map<String, Object> entries : list) {
|
||||||
Long accountId = (Long) entries.get("accountId");
|
Long accountId = (Long) entries.get("accountId");
|
||||||
if (!runningBalanceMap.containsKey(accountId)) {
|
if (!runningBalanceMap.containsKey(accountId)) {
|
||||||
runningBalanceMap.put(accountId, (BigDecimal) entries.get("runningBalance"));
|
runningBalanceMap.put(accountId, (BigDecimal) entries.get("runningBalance"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<JournalEntryData> entryDataList = jdbcTemplate.query(entryMapper.officeRunningBalanceSchema(), entryMapper, officeId,
|
List<JournalEntryData> entryDataList = jdbcTemplate.query(entryMapper.officeRunningBalanceSchema(), entryMapper, officeId,
|
||||||
entityDate);
|
entityDate);
|
||||||
List<Object[]> params = new ArrayList<>();
|
List<Object[]> params = new ArrayList<>();
|
||||||
|
|
||||||
String sql = "UPDATE acc_gl_journal_entry SET office_running_balance=?, last_modified_by=?, last_modified_on_utc=? WHERE id=?";
|
String sql = "UPDATE acc_gl_journal_entry SET office_running_balance=?, last_modified_by=?, last_modified_on_utc=? WHERE id=?";
|
||||||
for (JournalEntryData entryData : entryDataList) {
|
for (JournalEntryData entryData : entryDataList) {
|
||||||
BigDecimal runningBalance = calculateRunningBalance(entryData, runningBalanceMap);
|
BigDecimal runningBalance = calculateRunningBalance(entryData, runningBalanceMap);
|
||||||
params.add(new Object[] { runningBalance, platformSecurityContext.authenticatedUser().getId(),
|
params.add(new Object[] { runningBalance, platformSecurityContext.authenticatedUser().getId(),
|
||||||
DateUtils.getAuditOffsetDateTime(), entryData.getId() });
|
DateUtils.getAuditOffsetDateTime(), entryData.getId() });
|
||||||
}
|
}
|
||||||
this.jdbcTemplate.batchUpdate(sql, params);
|
this.jdbcTemplate.batchUpdate(sql, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal calculateRunningBalance(JournalEntryData entry, Map<Long, BigDecimal> runningBalanceMap) {
|
private BigDecimal calculateRunningBalance(JournalEntryData entry, Map<Long, BigDecimal> runningBalanceMap) {
|
||||||
BigDecimal runningBalance = BigDecimal.ZERO;
|
BigDecimal runningBalance = BigDecimal.ZERO;
|
||||||
if (runningBalanceMap.containsKey(entry.getGlAccountId())) {
|
if (runningBalanceMap.containsKey(entry.getGlAccountId())) {
|
||||||
runningBalance = runningBalanceMap.get(entry.getGlAccountId());
|
runningBalance = runningBalanceMap.get(entry.getGlAccountId());
|
||||||
}
|
}
|
||||||
GLAccountType accountType = GLAccountType.fromInt(entry.getGlAccountType().getId().intValue());
|
GLAccountType accountType = GLAccountType.fromInt(entry.getGlAccountType().getId().intValue());
|
||||||
JournalEntryType entryType = JournalEntryType.fromInt(entry.getEntryType().getId().intValue());
|
JournalEntryType entryType = JournalEntryType.fromInt(entry.getEntryType().getId().intValue());
|
||||||
boolean isIncrease = false;
|
boolean isIncrease = false;
|
||||||
switch (accountType) {
|
switch (accountType) {
|
||||||
case ASSET:
|
case ASSET:
|
||||||
case EXPENSE:
|
case EXPENSE:
|
||||||
if (entryType.isDebitType()) {
|
if (entryType.isDebitType()) {
|
||||||
isIncrease = true;
|
isIncrease = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EQUITY:
|
case EQUITY:
|
||||||
case INCOME:
|
case INCOME:
|
||||||
case LIABILITY:
|
case LIABILITY:
|
||||||
if (entryType.isCreditType()) {
|
if (entryType.isCreditType()) {
|
||||||
isIncrease = true;
|
isIncrease = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isIncrease) {
|
if (isIncrease) {
|
||||||
runningBalance = runningBalance.add(entry.getAmount());
|
runningBalance = runningBalance.add(entry.getAmount());
|
||||||
} else {
|
} else {
|
||||||
runningBalance = runningBalance.subtract(entry.getAmount());
|
runningBalance = runningBalance.subtract(entry.getAmount());
|
||||||
}
|
}
|
||||||
runningBalanceMap.put(entry.getGlAccountId(), runningBalance);
|
runningBalanceMap.put(entry.getGlAccountId(), runningBalance);
|
||||||
return runningBalance;
|
return runningBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class GLJournalEntryMapper implements RowMapper<JournalEntryData> {
|
private static final class GLJournalEntryMapper implements RowMapper<JournalEntryData> {
|
||||||
|
|
||||||
public String officeRunningBalanceSchema() {
|
public String officeRunningBalanceSchema() {
|
||||||
return "select je.id as id,je.account_id as glAccountId,je.type_enum as entryType,je.amount as amount, "
|
return "select je.id as id,je.account_id as glAccountId,je.type_enum as entryType,je.amount as amount, "
|
||||||
+ "glAccount.classification_enum as classification,je.office_id as officeId "
|
+ "glAccount.classification_enum as classification,je.office_id as officeId "
|
||||||
+ "from acc_gl_journal_entry je , acc_gl_account glAccount " + "where je.account_id = glAccount.id "
|
+ "from acc_gl_journal_entry je , acc_gl_account glAccount " + "where je.account_id = glAccount.id "
|
||||||
+ "and je.office_id=? and je.entry_date >= ? order by je.entry_date,je.id";
|
+ "and je.office_id=? and je.entry_date >= ? order by je.entry_date,je.id";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String organizationRunningBalanceSchema() {
|
public String organizationRunningBalanceSchema() {
|
||||||
return "select je.id as id,je.account_id as glAccountId," + "je.type_enum as entryType,je.amount as amount, "
|
return "select je.id as id,je.account_id as glAccountId," + "je.type_enum as entryType,je.amount as amount, "
|
||||||
+ "glAccount.classification_enum as classification,je.office_id as officeId "
|
+ "glAccount.classification_enum as classification,je.office_id as officeId "
|
||||||
+ "from acc_gl_journal_entry je , acc_gl_account glAccount " + "where je.account_id = glAccount.id "
|
+ "from acc_gl_journal_entry je , acc_gl_account glAccount " + "where je.account_id = glAccount.id "
|
||||||
+ "and je.entry_date >= ? order by je.entry_date,je.id";
|
+ "and je.entry_date >= ? order by je.entry_date,je.id";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JournalEntryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
public JournalEntryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
|
|
||||||
final Long id = rs.getLong("id");
|
final Long id = rs.getLong("id");
|
||||||
final Long glAccountId = rs.getLong("glAccountId");
|
final Long glAccountId = rs.getLong("glAccountId");
|
||||||
final Long officeId = rs.getLong("officeId");
|
final Long officeId = rs.getLong("officeId");
|
||||||
final int accountTypeId = JdbcSupport.getInteger(rs, "classification");
|
final int accountTypeId = JdbcSupport.getInteger(rs, "classification");
|
||||||
final EnumOptionData accountType = AccountingEnumerations.gLAccountType(accountTypeId);
|
final EnumOptionData accountType = AccountingEnumerations.gLAccountType(accountTypeId);
|
||||||
final BigDecimal amount = rs.getBigDecimal("amount");
|
final BigDecimal amount = rs.getBigDecimal("amount");
|
||||||
final int entryTypeId = JdbcSupport.getInteger(rs, "entryType");
|
final int entryTypeId = JdbcSupport.getInteger(rs, "entryType");
|
||||||
final EnumOptionData entryType = AccountingEnumerations.journalEntryType(entryTypeId);
|
final EnumOptionData entryType = AccountingEnumerations.journalEntryType(entryTypeId);
|
||||||
|
|
||||||
return new JournalEntryData(id, officeId, null, null, glAccountId, null, accountType, null, entryType, amount, null, null, null,
|
return new JournalEntryData(id, officeId, null, null, glAccountId, null, accountType, null, entryType, amount, null, null, null,
|
||||||
null, null, null, null, null, null, null, null, null, null, null, null, null);
|
null, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4044
-4043
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user