From 062ae8905ecae8af56eb90fd7e60d664a2568ae9 Mon Sep 17 00:00:00 2001 From: Vishwas Babu A J Date: Sat, 8 Feb 2014 16:54:52 +0530 Subject: [PATCH] MifosX-872 optionally capture payment type for a manual journal entry --- api-docs/apiLive.htm | 38 ++++++++++++- ...yment_detail_id_in_ac_gl_journal_entry.sql | 3 + .../api/JournalEntryJsonInputParams.java | 3 +- .../command/JournalEntryCommand.java | 25 ++++++-- .../journalentry/domain/JournalEntry.java | 22 +++++-- ...alEntryCommandFromApiJsonDeserializer.java | 10 +++- .../service/AccountingProcessorHelper.java | 39 +++++++------ ...WritePlatformServiceJpaRepositoryImpl.java | 57 +++++++++++-------- 8 files changed, 144 insertions(+), 53 deletions(-) create mode 100644 mifosng-db/migrations/core_db/V140_1__added_payment_detail_id_in_ac_gl_journal_entry.sql diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 5861617b8..eae601083 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -12699,6 +12699,12 @@ Content-Type: application/json Allows passing multiple credit entries for the accounting rule + + paymentTypeId + + + Allows passing multiple credit entries for the accounting rule + @@ -20354,6 +20360,21 @@ No Request Body: Additional details of transaction like payment details and notes . + + paymentTypeId + + + Maps to a Code value of a system defined Code with the name "PaymentType". This is used to optionally identify the mode of payment (Ex: checks, Cash etc) associated with a Journal Entry + + + + accountNumber, checkNumber, routingCode, receiptNumber, bankNumber + + + Various properties associated with a payment type + + @@ -20614,6 +20635,15 @@ GET https://DomainName/api/v1/journalentries?transactionId=PB37X8Y21EQUY4S +
+ + + + + + + +
Optional Fields
paymentTypeId, accountNumber, checkNumber, routingCode, receiptNumber, bankNumber
@@ -20639,7 +20669,13 @@ Request Body: "amount":5000}, {"glAccountId":4, "amount":5000} - ] + ], +"paymentTypeId": "12", +"accountNumber": "accno123", +"checkNumber": "chec123", +"routingCode": "rou123", +"receiptNumber": "rec123", +"bankNumber": "ban123" } diff --git a/mifosng-db/migrations/core_db/V140_1__added_payment_detail_id_in_ac_gl_journal_entry.sql b/mifosng-db/migrations/core_db/V140_1__added_payment_detail_id_in_ac_gl_journal_entry.sql new file mode 100644 index 000000000..8bdc81b23 --- /dev/null +++ b/mifosng-db/migrations/core_db/V140_1__added_payment_detail_id_in_ac_gl_journal_entry.sql @@ -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`); \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntryJsonInputParams.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntryJsonInputParams.java index bb09ed89c..b45ebb489 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntryJsonInputParams.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/api/JournalEntryJsonInputParams.java @@ -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; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/command/JournalEntryCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/command/JournalEntryCommand.java index e5e63be61..c35b4aaff 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/command/JournalEntryCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/command/JournalEntryCommand.java @@ -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) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java index 75c8a63ab..31c69f75b 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/domain/JournalEntry.java @@ -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 { @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 { @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 { // } - 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 { this.currencyCode = currencyCode; this.loanTransaction = loanTransaction; this.savingsTransaction = savingsTransaction; + this.paymentDetail=paymentDetail; } public boolean isDebitEntry() { @@ -166,5 +172,9 @@ public class JournalEntry extends AbstractAuditableCustom { public SavingsAccountTransaction getSavingsTransaction() { return this.savingsTransaction; } + + public PaymentDetail getPaymentDetails(){ + return this.paymentDetail; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/serialization/JournalEntryCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/serialization/JournalEntryCommandFromApiJsonDeserializer.java index c4b02edd4..b0c496497 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/serialization/JournalEntryCommandFromApiJsonDeserializer.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/serialization/JournalEntryCommandFromApiJsonDeserializer.java @@ -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); } /** diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java index 585cdcd9e..4bf1e82ed 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/AccountingProcessorHelper.java @@ -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); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java index 41cc38794..432e891a5 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryWritePlatformServiceJpaRepositoryImpl.java @@ -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 changes = new LinkedHashMap(); + 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); } }