MifosX-872 optionally capture payment type for a manual journal entry
This commit is contained in:
+37
-1
@@ -12699,6 +12699,12 @@ Content-Type: application/json
|
||||
<tr>
|
||||
<td class=fielddesc>Allows passing multiple credit entries for the accounting rule</td>
|
||||
</tr>
|
||||
<tr class=alt>
|
||||
<td>paymentTypeId</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=fielddesc>Allows passing multiple credit entries for the accounting rule</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -20354,6 +20360,21 @@ No Request Body:
|
||||
<td class=fielddesc>Additional details of transaction like payment details and notes .
|
||||
</td>
|
||||
</tr>
|
||||
<tr class=alt>
|
||||
<td>paymentTypeId</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=fielddesc>Maps to a <a href="#configs_codes_codevalues">Code value</a> of a system defined <a href="
|
||||
#configs_codes">Code</a> with the name "PaymentType". This is used to optionally identify the mode of payment (Ex: checks, Cash etc) associated with a Journal Entry
|
||||
</td>
|
||||
</tr>
|
||||
<tr class=alt>
|
||||
<td>accountNumber, checkNumber, routingCode, receiptNumber, bankNumber</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class=fielddesc>Various properties associated with a payment type
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -20614,6 +20635,15 @@ GET https://DomainName/api/v1/journalentries?transactionId=PB37X8Y21EQUY4S
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<table class=matrixHeading>
|
||||
<tr class="matrixHeadingBG">
|
||||
<td><div class="mifosXHeading2">Optional Fields</div></td>
|
||||
</tr>
|
||||
<tr class=alt>
|
||||
<td>paymentTypeId, accountNumber, checkNumber, routingCode, receiptNumber, bankNumber</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="method-example">
|
||||
<code class="method-declaration">
|
||||
@@ -20639,7 +20669,13 @@ Request Body:
|
||||
"amount":5000},
|
||||
{"glAccountId":4,
|
||||
"amount":5000}
|
||||
]
|
||||
],
|
||||
"paymentTypeId": "12",
|
||||
"accountNumber": "accno123",
|
||||
"checkNumber": "chec123",
|
||||
"routingCode": "rou123",
|
||||
"receiptNumber": "rec123",
|
||||
"bankNumber": "ban123"
|
||||
}
|
||||
</code>
|
||||
<code class="method-response">
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `acc_gl_journal_entry`
|
||||
ADD COLUMN `payment_details_id` BIGINT(20) NULL AFTER `organization_running_balance`,
|
||||
ADD CONSTRAINT `FK_acc_gl_journal_entry_m_payment_detail` FOREIGN KEY (`payment_details_id`) REFERENCES `m_payment_detail` (`id`);
|
||||
+2
-1
@@ -14,7 +14,8 @@ import java.util.Set;
|
||||
public enum JournalEntryJsonInputParams {
|
||||
OFFICE_ID("officeId"), TRANSACTION_DATE("transactionDate"), COMMENTS("comments"), CREDITS("credits"), DEBITS("debits"), LOCALE("locale"), DATE_FORMAT(
|
||||
"dateFormat"), REFERENCE_NUMBER("referenceNumber"), USE_ACCOUNTING_RULE("useAccountingRule"), ACCOUNTING_RULE("accountingRule"), AMOUNT(
|
||||
"amount"), CURRENCY_CODE("currencyCode");
|
||||
"amount"), CURRENCY_CODE("currencyCode"), PAYMENT_TYPE_ID("paymentTypeId"), ACCOUNT_NUMBER("accountNumber"), CHECK_NUMBER(
|
||||
"checkNumber"), ROUTING_CODE("routingCode"), RECEIPT_NUMBER("receiptNumber"), BANK_NUMBER("bankNumber");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
+21
-4
@@ -27,13 +27,25 @@ public class JournalEntryCommand {
|
||||
private final String referenceNumber;
|
||||
private final Long accountingRuleId;
|
||||
private final BigDecimal amount;
|
||||
private final Long paymentTypeId;
|
||||
@SuppressWarnings("unused")
|
||||
private final String accountNumber;
|
||||
@SuppressWarnings("unused")
|
||||
private final String checkNumber;
|
||||
@SuppressWarnings("unused")
|
||||
private final String receiptNumber;
|
||||
@SuppressWarnings("unused")
|
||||
private final String bankNumber;
|
||||
@SuppressWarnings("unused")
|
||||
private final String routingCode;
|
||||
|
||||
private final SingleDebitOrCreditEntryCommand[] credits;
|
||||
private final SingleDebitOrCreditEntryCommand[] debits;
|
||||
|
||||
public JournalEntryCommand(final Long officeId, final String currencyCode, final LocalDate transactionDate, final String comments,
|
||||
final SingleDebitOrCreditEntryCommand[] credits, final SingleDebitOrCreditEntryCommand[] debits, final String referenceNumber,
|
||||
final Long accountingRuleId, final BigDecimal amount) {
|
||||
final Long accountingRuleId, final BigDecimal amount, final Long paymentTypeId, final String accountNumber,
|
||||
final String checkNumber, final String receiptNumber, final String bankNumber, final String routingCode) {
|
||||
this.officeId = officeId;
|
||||
this.currencyCode = currencyCode;
|
||||
this.transactionDate = transactionDate;
|
||||
@@ -43,6 +55,13 @@ public class JournalEntryCommand {
|
||||
this.referenceNumber = referenceNumber;
|
||||
this.accountingRuleId = accountingRuleId;
|
||||
this.amount = amount;
|
||||
this.paymentTypeId = paymentTypeId;
|
||||
this.accountNumber = accountNumber;
|
||||
this.checkNumber = checkNumber;
|
||||
this.receiptNumber = receiptNumber;
|
||||
this.bankNumber = bankNumber;
|
||||
this.routingCode = routingCode;
|
||||
|
||||
}
|
||||
|
||||
public void validateForCreate() {
|
||||
@@ -63,9 +82,7 @@ public class JournalEntryCommand {
|
||||
|
||||
baseDataValidator.reset().parameter("accountingRule").value(this.accountingRuleId).ignoreIfNull().longGreaterThanZero();
|
||||
|
||||
baseDataValidator.reset().parameter("credits").value(this.credits).ignoreIfNull();
|
||||
|
||||
baseDataValidator.reset().parameter("debits").value(this.debits).ignoreIfNull();
|
||||
baseDataValidator.reset().parameter("paymentTypeId").value(this.paymentTypeId).ignoreIfNull().longGreaterThanZero();
|
||||
|
||||
// validation for credit array elements
|
||||
if (this.credits != null) {
|
||||
|
||||
+16
-6
@@ -22,6 +22,7 @@ import org.mifosplatform.accounting.glaccount.domain.GLAccount;
|
||||
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
|
||||
import org.mifosplatform.organisation.office.domain.Office;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanTransaction;
|
||||
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
|
||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountTransaction;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
|
||||
@@ -32,11 +33,15 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "office_id", nullable = false)
|
||||
private Office office;
|
||||
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "payment_details_id", nullable = true)
|
||||
private PaymentDetail paymentDetail;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "account_id", nullable = false)
|
||||
private GLAccount glAccount;
|
||||
|
||||
|
||||
@Column(name = "currency_code", length = 3, nullable = false)
|
||||
private String currencyCode;
|
||||
|
||||
@@ -82,12 +87,12 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
|
||||
|
||||
@Column(name = "ref_num")
|
||||
private String referenceNumber;
|
||||
|
||||
public static JournalEntry createNew(final Office office, final GLAccount glAccount, final String currencyCode,
|
||||
|
||||
public static JournalEntry createNew(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount, final String currencyCode,
|
||||
final String transactionId, final boolean manualEntry, final Date transactionDate, final JournalEntryType journalEntryType,
|
||||
final BigDecimal amount, final String description, final Integer entityType, final Long entityId, final String referenceNumber,
|
||||
final LoanTransaction loanTransaction, final SavingsAccountTransaction savingsTransaction) {
|
||||
return new JournalEntry(office, glAccount, currencyCode, transactionId, manualEntry, transactionDate, journalEntryType.getValue(),
|
||||
return new JournalEntry(office, paymentDetail, glAccount, currencyCode, transactionId, manualEntry, transactionDate, journalEntryType.getValue(),
|
||||
amount, description, entityType, entityId, referenceNumber, loanTransaction, savingsTransaction);
|
||||
}
|
||||
|
||||
@@ -95,7 +100,7 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
|
||||
//
|
||||
}
|
||||
|
||||
public JournalEntry(final Office office, final GLAccount glAccount, final String currencyCode, final String transactionId,
|
||||
public JournalEntry(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount, final String currencyCode, final String transactionId,
|
||||
final boolean manualEntry, final Date transactionDate, final Integer type, final BigDecimal amount, final String description,
|
||||
final Integer entityType, final Long entityId, final String referenceNumber, final LoanTransaction loanTransaction,
|
||||
final SavingsAccountTransaction savingsTransaction) {
|
||||
@@ -115,6 +120,7 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
|
||||
this.currencyCode = currencyCode;
|
||||
this.loanTransaction = loanTransaction;
|
||||
this.savingsTransaction = savingsTransaction;
|
||||
this.paymentDetail=paymentDetail;
|
||||
}
|
||||
|
||||
public boolean isDebitEntry() {
|
||||
@@ -166,5 +172,9 @@ public class JournalEntry extends AbstractAuditableCustom<AppUser, Long> {
|
||||
public SavingsAccountTransaction getSavingsTransaction() {
|
||||
return this.savingsTransaction;
|
||||
}
|
||||
|
||||
public PaymentDetail getPaymentDetails(){
|
||||
return this.paymentDetail;
|
||||
}
|
||||
|
||||
}
|
||||
+9
-1
@@ -68,6 +68,14 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr
|
||||
|
||||
final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalNamed(JournalEntryJsonInputParams.AMOUNT.getValue(), element,
|
||||
locale);
|
||||
final Long paymentTypeId = this.fromApiJsonHelper.extractLongNamed(JournalEntryJsonInputParams.PAYMENT_TYPE_ID.getValue(), element);
|
||||
final String accountNumber = this.fromApiJsonHelper.extractStringNamed(JournalEntryJsonInputParams.ACCOUNT_NUMBER.getValue(),
|
||||
element);
|
||||
final String checkNumber = this.fromApiJsonHelper.extractStringNamed(JournalEntryJsonInputParams.CHECK_NUMBER.getValue(), element);
|
||||
final String receiptNumber = this.fromApiJsonHelper.extractStringNamed(JournalEntryJsonInputParams.RECEIPT_NUMBER.getValue(),
|
||||
element);
|
||||
final String bankNumber = this.fromApiJsonHelper.extractStringNamed(JournalEntryJsonInputParams.BANK_NUMBER.getValue(), element);
|
||||
final String routingCode = this.fromApiJsonHelper.extractStringNamed(JournalEntryJsonInputParams.ROUTING_CODE.getValue(), element);
|
||||
|
||||
SingleDebitOrCreditEntryCommand[] credits = null;
|
||||
SingleDebitOrCreditEntryCommand[] debits = null;
|
||||
@@ -82,7 +90,7 @@ public final class JournalEntryCommandFromApiJsonDeserializer extends AbstractFr
|
||||
}
|
||||
}
|
||||
return new JournalEntryCommand(officeId, currencyCode, transactionDate, comments, credits, debits, referenceNumber,
|
||||
accountingRuleId, amount);
|
||||
accountingRuleId, amount, paymentTypeId, accountNumber, checkNumber, receiptNumber, bankNumber, routingCode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+22
-17
@@ -41,6 +41,7 @@ import org.mifosplatform.organisation.office.domain.OfficeRepository;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionEnumData;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanTransaction;
|
||||
import org.mifosplatform.portfolio.loanaccount.domain.LoanTransactionRepository;
|
||||
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
|
||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionEnumData;
|
||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountTransaction;
|
||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountTransactionRepository;
|
||||
@@ -467,7 +468,7 @@ public class AccountingProcessorHelper {
|
||||
totalAmount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LoanTransaction getLoanTransactionById(final long loanTransactionId) {
|
||||
return this.loanTransactionRepository.findOne(loanTransactionId);
|
||||
}
|
||||
@@ -492,14 +493,15 @@ public class AccountingProcessorHelper {
|
||||
final boolean manualEntry = false;
|
||||
LoanTransaction loanTransaction = null;
|
||||
SavingsAccountTransaction savingsAccountTransaction = null;
|
||||
final PaymentDetail paymentDetail = null;
|
||||
String modifiedTransactionId = transactionId;
|
||||
if(StringUtils.isNumeric(transactionId)){
|
||||
if (StringUtils.isNumeric(transactionId)) {
|
||||
long id = Long.parseLong(transactionId);
|
||||
loanTransaction = this.loanTransactionRepository.findOne(id);
|
||||
modifiedTransactionId = LOAN_TRANSACTION_IDENTIFIER + transactionId ;
|
||||
modifiedTransactionId = LOAN_TRANSACTION_IDENTIFIER + transactionId;
|
||||
}
|
||||
final JournalEntry journalEntry = JournalEntry.createNew(office, account, currencyCode, modifiedTransactionId, manualEntry,
|
||||
transactionDate, JournalEntryType.CREDIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId, null,
|
||||
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
||||
manualEntry, transactionDate, JournalEntryType.CREDIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId, null,
|
||||
loanTransaction, savingsAccountTransaction);
|
||||
this.glJournalEntryRepository.saveAndFlush(journalEntry);
|
||||
}
|
||||
@@ -509,15 +511,16 @@ public class AccountingProcessorHelper {
|
||||
final boolean manualEntry = false;
|
||||
LoanTransaction loanTransaction = null;
|
||||
SavingsAccountTransaction savingsAccountTransaction = null;
|
||||
final PaymentDetail paymentDetail = null;
|
||||
String modifiedTransactionId = transactionId;
|
||||
if(StringUtils.isNumeric(transactionId)){
|
||||
if (StringUtils.isNumeric(transactionId)) {
|
||||
long id = Long.parseLong(transactionId);
|
||||
savingsAccountTransaction = this.savingsAccountTransactionRepository.findOne(id);
|
||||
modifiedTransactionId = SAVINGS_TRANSACTION_IDENTIFIER + transactionId;
|
||||
}
|
||||
final JournalEntry journalEntry = JournalEntry.createNew(office, account, currencyCode, modifiedTransactionId, manualEntry,
|
||||
transactionDate, JournalEntryType.CREDIT, amount, null, PortfolioProductType.SAVING.getValue(), savingsId, null,
|
||||
loanTransaction, savingsAccountTransaction);
|
||||
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
||||
manualEntry, transactionDate, JournalEntryType.CREDIT, amount, null, PortfolioProductType.SAVING.getValue(), savingsId,
|
||||
null, loanTransaction, savingsAccountTransaction);
|
||||
this.glJournalEntryRepository.saveAndFlush(journalEntry);
|
||||
}
|
||||
|
||||
@@ -526,14 +529,15 @@ public class AccountingProcessorHelper {
|
||||
final boolean manualEntry = false;
|
||||
LoanTransaction loanTransaction = null;
|
||||
SavingsAccountTransaction savingsAccountTransaction = null;
|
||||
final PaymentDetail paymentDetail = null;
|
||||
String modifiedTransactionId = transactionId;
|
||||
if(StringUtils.isNumeric(transactionId)){
|
||||
if (StringUtils.isNumeric(transactionId)) {
|
||||
long id = Long.parseLong(transactionId);
|
||||
loanTransaction = this.loanTransactionRepository.findOne(id);
|
||||
modifiedTransactionId = LOAN_TRANSACTION_IDENTIFIER + transactionId;
|
||||
}
|
||||
final JournalEntry journalEntry = JournalEntry.createNew(office, account, currencyCode, modifiedTransactionId, manualEntry,
|
||||
transactionDate, JournalEntryType.DEBIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId, null,
|
||||
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
||||
manualEntry, transactionDate, JournalEntryType.DEBIT, amount, null, PortfolioProductType.LOAN.getValue(), loanId, null,
|
||||
loanTransaction, savingsAccountTransaction);
|
||||
this.glJournalEntryRepository.saveAndFlush(journalEntry);
|
||||
}
|
||||
@@ -543,15 +547,16 @@ public class AccountingProcessorHelper {
|
||||
final boolean manualEntry = false;
|
||||
LoanTransaction loanTransaction = null;
|
||||
SavingsAccountTransaction savingsAccountTransaction = null;
|
||||
final PaymentDetail paymentDetail = null;
|
||||
String modifiedTransactionId = transactionId;
|
||||
if(StringUtils.isNumeric(transactionId)){
|
||||
if (StringUtils.isNumeric(transactionId)) {
|
||||
long id = Long.parseLong(transactionId);
|
||||
savingsAccountTransaction = this.savingsAccountTransactionRepository.findOne(id);
|
||||
modifiedTransactionId = SAVINGS_TRANSACTION_IDENTIFIER + transactionId ;
|
||||
modifiedTransactionId = SAVINGS_TRANSACTION_IDENTIFIER + transactionId;
|
||||
}
|
||||
final JournalEntry journalEntry = JournalEntry.createNew(office, account, currencyCode, modifiedTransactionId, manualEntry,
|
||||
transactionDate, JournalEntryType.DEBIT, amount, null, PortfolioProductType.SAVING.getValue(), savingsId, null,
|
||||
loanTransaction, savingsAccountTransaction);
|
||||
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
||||
manualEntry, transactionDate, JournalEntryType.DEBIT, amount, null, PortfolioProductType.SAVING.getValue(), savingsId,
|
||||
null, loanTransaction, savingsAccountTransaction);
|
||||
this.glJournalEntryRepository.saveAndFlush(journalEntry);
|
||||
}
|
||||
|
||||
|
||||
+34
-23
@@ -8,6 +8,7 @@ package org.mifosplatform.accounting.journalentry.service;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -44,6 +45,8 @@ import org.mifosplatform.organisation.office.domain.Office;
|
||||
import org.mifosplatform.organisation.office.domain.OfficeRepository;
|
||||
import org.mifosplatform.organisation.office.domain.OrganisationCurrencyRepositoryWrapper;
|
||||
import org.mifosplatform.organisation.office.exception.OfficeNotFoundException;
|
||||
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
|
||||
import org.mifosplatform.portfolio.paymentdetail.service.PaymentDetailWritePlatformService;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -69,6 +72,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
private final GLAccountReadPlatformService glAccountReadPlatformService;
|
||||
private final OrganisationCurrencyRepositoryWrapper organisationCurrencyRepository;
|
||||
private final PlatformSecurityContext context;
|
||||
private final PaymentDetailWritePlatformService paymentDetailWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public JournalEntryWritePlatformServiceJpaRepositoryImpl(final GLClosureRepository glClosureRepository,
|
||||
@@ -78,8 +82,8 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
final AccountingProcessorForLoanFactory accountingProcessorForLoanFactory,
|
||||
final AccountingProcessorForSavingsFactory accountingProcessorForSavingsFactory,
|
||||
final GLAccountReadPlatformService glAccountReadPlatformService,
|
||||
final OrganisationCurrencyRepositoryWrapper organisationCurrencyRepository,
|
||||
final PlatformSecurityContext context) {
|
||||
final OrganisationCurrencyRepositoryWrapper organisationCurrencyRepository, final PlatformSecurityContext context,
|
||||
final PaymentDetailWritePlatformService paymentDetailWritePlatformService) {
|
||||
this.glClosureRepository = glClosureRepository;
|
||||
this.officeRepository = officeRepository;
|
||||
this.glJournalEntryRepository = glJournalEntryRepository;
|
||||
@@ -92,6 +96,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
this.glAccountReadPlatformService = glAccountReadPlatformService;
|
||||
this.organisationCurrencyRepository = organisationCurrencyRepository;
|
||||
this.context = context;
|
||||
this.paymentDetailWritePlatformService = paymentDetailWritePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -111,6 +116,10 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
|
||||
validateBusinessRulesForJournalEntries(journalEntryCommand);
|
||||
|
||||
/** Capture payment details **/
|
||||
final Map<String, Object> changes = new LinkedHashMap<String, Object>();
|
||||
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
|
||||
|
||||
/** Set a transaction Id and save these Journal entries **/
|
||||
final Date transactionDate = command.DateValueOfParameterNamed(JournalEntryJsonInputParams.TRANSACTION_DATE.getValue());
|
||||
final String transactionId = generateTransactionId(officeId);
|
||||
@@ -130,13 +139,13 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
checkDebitAndCreditAmounts(journalEntryCommand.getCredits(), journalEntryCommand.getDebits());
|
||||
}
|
||||
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, currencyCode, transactionDate,
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, paymentDetail, currencyCode, transactionDate,
|
||||
journalEntryCommand.getCredits(), transactionId, JournalEntryType.CREDIT, referenceNumber);
|
||||
} else {
|
||||
final GLAccount creditAccountHead = accountingRule.getAccountToCredit();
|
||||
validateGLAccountForTransaction(creditAccountHead);
|
||||
validateDebitOrCreditArrayForExistingGLAccount(creditAccountHead, journalEntryCommand.getCredits());
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, currencyCode, transactionDate,
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, paymentDetail, currencyCode, transactionDate,
|
||||
journalEntryCommand.getCredits(), transactionId, JournalEntryType.CREDIT, referenceNumber);
|
||||
}
|
||||
|
||||
@@ -149,22 +158,22 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
checkDebitAndCreditAmounts(journalEntryCommand.getCredits(), journalEntryCommand.getDebits());
|
||||
}
|
||||
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, currencyCode, transactionDate,
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, paymentDetail, currencyCode, transactionDate,
|
||||
journalEntryCommand.getDebits(), transactionId, JournalEntryType.DEBIT, referenceNumber);
|
||||
} else {
|
||||
final GLAccount debitAccountHead = accountingRule.getAccountToDebit();
|
||||
validateGLAccountForTransaction(debitAccountHead);
|
||||
validateDebitOrCreditArrayForExistingGLAccount(debitAccountHead, journalEntryCommand.getDebits());
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, currencyCode, transactionDate,
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, paymentDetail, currencyCode, transactionDate,
|
||||
journalEntryCommand.getDebits(), transactionId, JournalEntryType.DEBIT, referenceNumber);
|
||||
}
|
||||
} else {
|
||||
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, currencyCode, transactionDate, journalEntryCommand.getDebits(),
|
||||
transactionId, JournalEntryType.DEBIT, referenceNumber);
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, paymentDetail, currencyCode, transactionDate,
|
||||
journalEntryCommand.getDebits(), transactionId, JournalEntryType.DEBIT, referenceNumber);
|
||||
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, currencyCode, transactionDate, journalEntryCommand.getCredits(),
|
||||
transactionId, JournalEntryType.CREDIT, referenceNumber);
|
||||
saveAllDebitOrCreditEntries(journalEntryCommand, office, paymentDetail, currencyCode, transactionDate,
|
||||
journalEntryCommand.getCredits(), transactionId, JournalEntryType.CREDIT, referenceNumber);
|
||||
|
||||
}
|
||||
|
||||
@@ -276,15 +285,15 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
final String reversalComment = "Reversal entry for Journal Entry with Entry Id :" + journalEntry.getId()
|
||||
+ " and transaction Id " + command.getTransactionId();
|
||||
if (journalEntry.isDebitEntry()) {
|
||||
reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getGlAccount(),
|
||||
journalEntry.getCurrencyCode(), reversalTransactionId, manualEntry, journalEntry.getTransactionDate(),
|
||||
JournalEntryType.CREDIT, journalEntry.getAmount(), reversalComment, null, null, journalEntry.getReferenceNumber(),
|
||||
journalEntry.getLoanTransaction(), journalEntry.getSavingsTransaction());
|
||||
reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getPaymentDetails(),
|
||||
journalEntry.getGlAccount(), journalEntry.getCurrencyCode(), reversalTransactionId, manualEntry,
|
||||
journalEntry.getTransactionDate(), JournalEntryType.CREDIT, journalEntry.getAmount(), reversalComment, null, null,
|
||||
journalEntry.getReferenceNumber(), journalEntry.getLoanTransaction(), journalEntry.getSavingsTransaction());
|
||||
} else {
|
||||
reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getGlAccount(),
|
||||
journalEntry.getCurrencyCode(), reversalTransactionId, manualEntry, journalEntry.getTransactionDate(),
|
||||
JournalEntryType.DEBIT, journalEntry.getAmount(), reversalComment, null, null, journalEntry.getReferenceNumber(),
|
||||
journalEntry.getLoanTransaction(), journalEntry.getSavingsTransaction());
|
||||
reversalJournalEntry = JournalEntry.createNew(journalEntry.getOffice(), journalEntry.getPaymentDetails(),
|
||||
journalEntry.getGlAccount(), journalEntry.getCurrencyCode(), reversalTransactionId, manualEntry,
|
||||
journalEntry.getTransactionDate(), JournalEntryType.DEBIT, journalEntry.getAmount(), reversalComment, null, null,
|
||||
journalEntry.getReferenceNumber(), journalEntry.getLoanTransaction(), journalEntry.getSavingsTransaction());
|
||||
}
|
||||
// save the reversal entry
|
||||
this.glJournalEntryRepository.saveAndFlush(reversalJournalEntry);
|
||||
@@ -355,9 +364,10 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
checkDebitAndCreditAmounts(credits, debits);
|
||||
}
|
||||
|
||||
private void saveAllDebitOrCreditEntries(final JournalEntryCommand command, final Office office, final String currencyCode,
|
||||
final Date transactionDate, final SingleDebitOrCreditEntryCommand[] singleDebitOrCreditEntryCommands,
|
||||
final String transactionId, final JournalEntryType type, final String referenceNumber) {
|
||||
private void saveAllDebitOrCreditEntries(final JournalEntryCommand command, final Office office, final PaymentDetail paymentDetail,
|
||||
final String currencyCode, final Date transactionDate,
|
||||
final SingleDebitOrCreditEntryCommand[] singleDebitOrCreditEntryCommands, final String transactionId,
|
||||
final JournalEntryType type, final String referenceNumber) {
|
||||
final boolean manualEntry = true;
|
||||
for (final SingleDebitOrCreditEntryCommand singleDebitOrCreditEntryCommand : singleDebitOrCreditEntryCommands) {
|
||||
final GLAccount glAccount = this.glAccountRepository.findOne(singleDebitOrCreditEntryCommand.getGlAccountId());
|
||||
@@ -373,8 +383,9 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
|
||||
/** Validate current code is appropriate **/
|
||||
this.organisationCurrencyRepository.findOneWithNotFoundDetection(currencyCode);
|
||||
|
||||
final JournalEntry glJournalEntry = JournalEntry.createNew(office, glAccount, currencyCode, transactionId, manualEntry,
|
||||
transactionDate, type, singleDebitOrCreditEntryCommand.getAmount(), comments, null, null, referenceNumber, null, null);
|
||||
final JournalEntry glJournalEntry = JournalEntry.createNew(office, paymentDetail, glAccount, currencyCode, transactionId,
|
||||
manualEntry, transactionDate, type, singleDebitOrCreditEntryCommand.getAmount(), comments, null, null, referenceNumber,
|
||||
null, null);
|
||||
this.glJournalEntryRepository.saveAndFlush(glJournalEntry);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user