diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java index 1caf7dec1..d029584ff 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/journalentry/service/JournalEntryReadPlatformServiceImpl.java @@ -29,7 +29,6 @@ import org.mifosplatform.accounting.journalentry.data.OfficeOpeningBalancesData; import org.mifosplatform.accounting.journalentry.data.TransactionDetailData; import org.mifosplatform.accounting.journalentry.data.TransactionTypeEnumData; import org.mifosplatform.accounting.journalentry.exception.JournalEntriesNotFoundException; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.core.domain.JdbcSupport; import org.mifosplatform.infrastructure.core.exception.GeneralPlatformDomainRuleException; @@ -37,15 +36,16 @@ import org.mifosplatform.infrastructure.core.service.DateUtils; import org.mifosplatform.infrastructure.core.service.Page; import org.mifosplatform.infrastructure.core.service.PaginationHelper; import org.mifosplatform.infrastructure.core.service.RoutingDataSource; +import org.mifosplatform.infrastructure.core.service.SearchParameters; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.organisation.office.data.OfficeData; import org.mifosplatform.organisation.office.service.OfficeReadPlatformService; import org.mifosplatform.portfolio.account.PortfolioAccountType; -import org.mifosplatform.infrastructure.core.service.SearchParameters; import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionEnumData; import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations; import org.mifosplatform.portfolio.note.data.NoteData; import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionEnumData; import org.mifosplatform.portfolio.savings.service.SavingsEnumerations; import org.springframework.beans.factory.annotation.Autowired; @@ -66,8 +66,9 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat private final PaginationHelper paginationHelper = new PaginationHelper<>(); @Autowired - public JournalEntryReadPlatformServiceImpl(final RoutingDataSource dataSource, final GLAccountReadPlatformService glAccountReadPlatformService, - final OfficeReadPlatformService officeReadPlatformService, final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepositoryWrapper) { + public JournalEntryReadPlatformServiceImpl(final RoutingDataSource dataSource, + final GLAccountReadPlatformService glAccountReadPlatformService, final OfficeReadPlatformService officeReadPlatformService, + final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepositoryWrapper) { this.jdbcTemplate = new JdbcTemplate(dataSource); this.glAccountReadPlatformService = glAccountReadPlatformService; this.officeReadPlatformService = officeReadPlatformService; @@ -106,8 +107,8 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat } if (associationParametersData.isTransactionDetailsRequired()) { sb.append(" ,pd.receipt_number as receiptNumber, ").append(" pd.check_number as checkNumber, ") - .append(" pd.account_number as accountNumber, ").append(" cdv.code_value as paymentTypeName, ") - .append(" pd.payment_type_cv_id as paymentTypeId,").append(" pd.bank_number as bankNumber, ") + .append(" pd.account_number as accountNumber, ").append(" pt.value as paymentTypeName, ") + .append(" pd.payment_type_id as paymentTypeId,").append(" pd.bank_number as bankNumber, ") .append(" pd.routing_code as routingCode, ").append(" note.id as noteId, ") .append(" note.note as transactionNote, ").append(" lt.transaction_type_enum as loanTransactionType, ") .append(" st.transaction_type_enum as savingsTransactionType "); @@ -121,7 +122,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat sb.append(" left join m_loan_transaction as lt on journalEntry.loan_transaction_id = lt.id ") .append(" left join m_savings_account_transaction as st on journalEntry.savings_transaction_id = st.id ") .append(" left join m_payment_detail as pd on lt.payment_detail_id = pd.id or st.payment_detail_id = pd.id") - .append(" left join m_code_value as cdv on cdv.id = pd.payment_type_cv_id ") + .append(" left join m_payment_type as pt on pt.id = pd.payment_type_id ") .append(" left join m_note as note on lt.id = note.loan_transaction_id or st.id = note.savings_account_transaction_id "); } return sb.toString(); @@ -184,7 +185,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentTypeId"); if (paymentTypeId != null) { final String typeName = rs.getString("paymentTypeName"); - final CodeValueData paymentType = CodeValueData.instance(paymentTypeId, typeName); + final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName); final String accountNumber = rs.getString("accountNumber"); final String checkNumber = rs.getString("checkNumber"); final String routingCode = rs.getString("routingCode"); @@ -356,12 +357,12 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat @Override public OfficeOpeningBalancesData retrieveOfficeOpeningBalances(final Long officeId) { - final FinancialActivityAccount financialActivityAccountId = this.financialActivityAccountRepositoryWrapper.findByFinancialActivityTypeWithNotFoundDetection(300); - final Long contraId = financialActivityAccountId.getGlAccount().getId(); - if (contraId == null) { throw new GeneralPlatformDomainRuleException( + final FinancialActivityAccount financialActivityAccountId = this.financialActivityAccountRepositoryWrapper + .findByFinancialActivityTypeWithNotFoundDetection(300); + final Long contraId = financialActivityAccountId.getGlAccount().getId(); + if (contraId == null) { throw new GeneralPlatformDomainRuleException( "error.msg.financial.activity.mapping.opening.balance.contra.account.cannot.be.null", - "office-opening-balances-contra-account value can not be null", - "office-opening-balances-contra-account");} + "office-opening-balances-contra-account value can not be null", "office-opening-balances-contra-account"); } final JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData(); final GLAccountData contraAccount = this.glAccountReadPlatformService.retrieveGLAccountById(contraId, associationParametersData); @@ -448,7 +449,8 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat final String transactionId = ""; final Page contraJournalEntries = retrieveContraTransactions(officeId, contraId, transactionId); if (!CollectionUtils.isEmpty(contraJournalEntries.getPageItems())) { - final JournalEntryData contraTransaction = contraJournalEntries.getPageItems().get(contraJournalEntries.getPageItems().size()-1); + final JournalEntryData contraTransaction = contraJournalEntries.getPageItems().get( + contraJournalEntries.getPageItems().size() - 1); return contraTransaction.getTransactionId(); } return transactionId; 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 3f2788c2b..b0479c17c 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 @@ -39,7 +39,6 @@ import org.mifosplatform.accounting.journalentry.serialization.JournalEntryComma import org.mifosplatform.accounting.rule.domain.AccountingRule; import org.mifosplatform.accounting.rule.domain.AccountingRuleRepository; import org.mifosplatform.accounting.rule.exception.AccountingRuleNotFoundException; -import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService; import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.data.ApiParameterError; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/data/PaymentTypeToGLAccountMapper.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/data/PaymentTypeToGLAccountMapper.java index af0367419..54d3a636b 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/data/PaymentTypeToGLAccountMapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/data/PaymentTypeToGLAccountMapper.java @@ -6,16 +6,16 @@ package org.mifosplatform.accounting.producttoaccountmapping.data; import org.mifosplatform.accounting.glaccount.data.GLAccountData; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; public class PaymentTypeToGLAccountMapper { @SuppressWarnings("unused") - private final CodeValueData paymentType; + private final PaymentTypeData paymentType; @SuppressWarnings("unused") private final GLAccountData fundSourceAccount; - public PaymentTypeToGLAccountMapper(final CodeValueData paymentType, final GLAccountData fundSourceAccount) { + public PaymentTypeToGLAccountMapper(final PaymentTypeData paymentType, final GLAccountData fundSourceAccount) { this.paymentType = paymentType; this.fundSourceAccount = fundSourceAccount; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/domain/ProductToGLAccountMapping.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/domain/ProductToGLAccountMapping.java index 92c2ad962..75c7fdb53 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/domain/ProductToGLAccountMapping.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/domain/ProductToGLAccountMapping.java @@ -14,8 +14,8 @@ import javax.persistence.Table; import javax.persistence.UniqueConstraint; import org.mifosplatform.accounting.glaccount.domain.GLAccount; -import org.mifosplatform.infrastructure.codes.domain.CodeValue; import org.mifosplatform.portfolio.charge.domain.Charge; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentType; import org.springframework.data.jpa.domain.AbstractPersistable; @Entity @@ -32,7 +32,7 @@ public class ProductToGLAccountMapping extends AbstractPersistable { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "payment_type", nullable = true) - private CodeValue paymentType; + private PaymentType paymentType; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "charge_id", nullable = true) @@ -63,12 +63,12 @@ public class ProductToGLAccountMapping extends AbstractPersistable { } public ProductToGLAccountMapping(final GLAccount glAccount, final Long productId, final int productType, - final int financialAccountType, final CodeValue paymentType) { + final int financialAccountType, final PaymentType paymentType) { this(glAccount, productId, productType, financialAccountType, paymentType, null); } private ProductToGLAccountMapping(final GLAccount glAccount, final Long productId, final int productType, - final int financialAccountType, final CodeValue paymentType, final Charge charge) { + final int financialAccountType, final PaymentType paymentType, final Charge charge) { this.glAccount = glAccount; this.productId = productId; this.productType = productType; @@ -109,11 +109,11 @@ public class ProductToGLAccountMapping extends AbstractPersistable { this.financialAccountType = financialAccountType; } - public CodeValue getPaymentType() { + public PaymentType getPaymentType() { return this.paymentType; } - public void setPaymentType(final CodeValue paymentType) { + public void setPaymentType(final PaymentType paymentType) { this.paymentType = paymentType; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/LoanProductToGLAccountMappingHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/LoanProductToGLAccountMappingHelper.java index 1ef834190..af450b5bc 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/LoanProductToGLAccountMappingHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/LoanProductToGLAccountMappingHelper.java @@ -21,6 +21,7 @@ import org.mifosplatform.infrastructure.codes.domain.CodeValueRepositoryWrapper; import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -33,9 +34,9 @@ public class LoanProductToGLAccountMappingHelper extends ProductToGLAccountMappi public LoanProductToGLAccountMappingHelper(final GLAccountRepository glAccountRepository, final ProductToGLAccountMappingRepository glAccountMappingRepository, final FromJsonHelper fromApiJsonHelper, final CodeValueRepositoryWrapper codeValueRepositoryWrapper, final ChargeRepositoryWrapper chargeRepositoryWrapper, - final GLAccountRepositoryWrapper accountRepositoryWrapper) { + final GLAccountRepositoryWrapper accountRepositoryWrapper, final PaymentTypeRepositoryWrapper paymentTypeRepositoryWrapper) { super(glAccountRepository, glAccountMappingRepository, fromApiJsonHelper, codeValueRepositoryWrapper, chargeRepositoryWrapper, - accountRepositoryWrapper); + accountRepositoryWrapper, paymentTypeRepositoryWrapper); } /*** Set of abstractions for saving Loan Products to GL Account Mappings ***/ diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java index 9424ae503..830befc9c 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java @@ -23,13 +23,13 @@ import org.mifosplatform.accounting.producttoaccountmapping.domain.ProductToGLAc import org.mifosplatform.accounting.producttoaccountmapping.domain.ProductToGLAccountMappingRepository; import org.mifosplatform.accounting.producttoaccountmapping.exception.ProductToGLAccountMappingInvalidException; import org.mifosplatform.accounting.producttoaccountmapping.exception.ProductToGLAccountMappingNotFoundException; -import org.mifosplatform.infrastructure.codes.domain.CodeValue; import org.mifosplatform.infrastructure.codes.domain.CodeValueRepositoryWrapper; import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; import org.mifosplatform.portfolio.charge.domain.Charge; import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentType; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -46,18 +46,20 @@ public class ProductToGLAccountMappingHelper { protected final FromJsonHelper fromApiJsonHelper; private final CodeValueRepositoryWrapper codeValueRepositoryWrapper; private final ChargeRepositoryWrapper chargeRepositoryWrapper; + private final PaymentTypeRepositoryWrapper paymentTypeRepositoryWrapper; @Autowired public ProductToGLAccountMappingHelper(final GLAccountRepository glAccountRepository, final ProductToGLAccountMappingRepository glAccountMappingRepository, final FromJsonHelper fromApiJsonHelper, final CodeValueRepositoryWrapper codeValueRepositoryWrapper, final ChargeRepositoryWrapper chargeRepositoryWrapper, - final GLAccountRepositoryWrapper accountRepositoryWrapper) { + final GLAccountRepositoryWrapper accountRepositoryWrapper, PaymentTypeRepositoryWrapper paymentTypeRepositoryWrapper) { this.accountRepository = glAccountRepository; this.accountMappingRepository = glAccountMappingRepository; this.fromApiJsonHelper = fromApiJsonHelper; this.codeValueRepositoryWrapper = codeValueRepositoryWrapper; this.chargeRepositoryWrapper = chargeRepositoryWrapper; this.accountRepositoryWrapper = accountRepositoryWrapper; + this.paymentTypeRepositoryWrapper = paymentTypeRepositoryWrapper; } @@ -332,8 +334,7 @@ public class ProductToGLAccountMappingHelper { */ private void savePaymentChannelToFundSourceMapping(final Long productId, final Long paymentTypeId, final Long paymentTypeSpecificFundAccountId, final PortfolioProductType portfolioProductType) { - final CodeValue paymentType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection( - PaymentDetailConstants.paymentTypeCodeName, paymentTypeId); + final PaymentType paymentType = this.paymentTypeRepositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(), GLAccountType.ASSET, paymentTypeSpecificFundAccountId); final ProductToGLAccountMapping accountMapping = new ProductToGLAccountMapping(glAccount, productId, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java index 7d5e789c5..29acf3ee5 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java @@ -22,10 +22,10 @@ import org.mifosplatform.accounting.glaccount.data.GLAccountData; import org.mifosplatform.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper; import org.mifosplatform.accounting.producttoaccountmapping.domain.PortfolioProductType; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.domain.JdbcSupport; import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.portfolio.charge.data.ChargeData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; @@ -46,11 +46,11 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product public String schema() { return " mapping.id as id, mapping.gl_account_id as glAccountId,glaccount.name as name,glaccount.gl_code as code," + " mapping.product_id as productId, mapping.product_type as productType,mapping.financial_account_type as financialAccountType, " - + " mapping.payment_type as paymentTypeId,cv.code_value codeValue, mapping.charge_id as chargeId, charge.is_penalty as penalty, " + + " mapping.payment_type as paymentTypeId,pt.value as paymentTypeValue, mapping.charge_id as chargeId, charge.is_penalty as penalty, " + " charge.name as chargeName " + " from acc_product_mapping mapping left join m_charge charge on mapping.charge_id=charge.id " + " left join acc_gl_account as glaccount on mapping.gl_account_id = glaccount.id" - + " left join m_code_value cv on mapping.payment_type=cv.id" + " where mapping.product_type= ? "; + + " left join m_payment_type pt on mapping.payment_type=pt.id" + " where mapping.product_type= ? "; } @Override @@ -62,7 +62,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentTypeId"); final Long chargeId = rs.getLong("chargeId"); final Integer productType = rs.getInt("productType"); - final String paymentTypeValue = rs.getString("codeValue"); + final String paymentTypeValue = rs.getString("paymentTypeValue"); final Integer financialAccountType = rs.getInt("financialAccountType"); final String glAccountName = rs.getString("name"); final String glCode = rs.getString("code"); @@ -249,13 +249,14 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product } final Long paymentTypeId = (Long) productToGLAccountMap.get("paymentTypeId"); final String paymentTypeValue = (String) productToGLAccountMap.get("paymentTypeValue"); - final CodeValueData codeValueData = CodeValueData.instance(paymentTypeId, paymentTypeValue); + final PaymentTypeData paymentTypeData = PaymentTypeData.instance(paymentTypeId, paymentTypeValue); final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId"); final String glAccountName = (String) productToGLAccountMap.get("glAccountName"); final String glCode = (String) productToGLAccountMap.get("glCode"); final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode); - final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(codeValueData, gLAccountData); + final PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeData, + gLAccountData); paymentTypeToGLAccountMappers.add(paymentTypeToGLAccountMapper); } return paymentTypeToGLAccountMappers; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java index b4650d3ab..59537e092 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java @@ -20,6 +20,7 @@ import org.mifosplatform.infrastructure.codes.domain.CodeValueRepositoryWrapper; import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -32,9 +33,9 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa public SavingsProductToGLAccountMappingHelper(final GLAccountRepository glAccountRepository, final ProductToGLAccountMappingRepository glAccountMappingRepository, final FromJsonHelper fromApiJsonHelper, final CodeValueRepositoryWrapper codeValueRepositoryWrapper, final ChargeRepositoryWrapper chargeRepositoryWrapper, - final GLAccountRepositoryWrapper accountRepositoryWrapper) { + final GLAccountRepositoryWrapper accountRepositoryWrapper, final PaymentTypeRepositoryWrapper paymentTypeRepositoryWrapper) { super(glAccountRepository, glAccountMappingRepository, fromApiJsonHelper, codeValueRepositoryWrapper, chargeRepositoryWrapper, - accountRepositoryWrapper); + accountRepositoryWrapper, paymentTypeRepositoryWrapper); } /*** Set of abstractions for saving Saving Products to GL Account Mappings ***/ diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java index f088e3488..7b0182a51 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java @@ -1016,4 +1016,8 @@ public class CommandWrapper { public boolean isEntityMappingResource() { return this.entityName.equalsIgnoreCase("ENTITYMAPPING"); } + + public boolean isPaymentTypeResource() { + return this.entityName.equalsIgnoreCase("PAYMENTTYPE"); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java index 987e2cb57..ae9099f74 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java @@ -2353,4 +2353,29 @@ public class CommandWrapperBuilder { this.href = "/entitytoentitymapping/" + mapId; return this; } + + public CommandWrapperBuilder createPaymentType() { + this.actionName = "CREATE"; + this.entityName = "PAYMENTTYPE"; + this.entityId = null; + this.href = "/paymenttype"; + return this; + } + + public CommandWrapperBuilder updatePaymentType(final Long paymentTypeId) { + this.actionName = "UPDATE"; + this.entityName = "PAYMENTTYPE"; + this.entityId = paymentTypeId; + this.href = "/paymenttype/" + paymentTypeId; + return this; + } + + public CommandWrapperBuilder deletePaymentType(final Long paymentTypeId) { + this.actionName = "DELETE"; + this.entityName = "PAYMENTTYPE"; + this.entityId = paymentTypeId; + this.href = "/paymenttype/" + paymentTypeId; + return this; + } + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java index a891ed8bd..2010e2614 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java @@ -923,6 +923,18 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer } else { throw new UnsupportedCommandException(wrapper.commandName()); } + + } else if (wrapper.isPaymentTypeResource()) { + if (wrapper.isCreate()) { + handler = this.applicationContext.getBean("createPaymentTypeCommandHandler", NewCommandSourceHandler.class); + } else if (wrapper.isUpdate()) { + handler = this.applicationContext.getBean("updatePaymentTypeCommandHandler", NewCommandSourceHandler.class); + } else if (wrapper.isDelete()) { + handler = this.applicationContext.getBean("deletePaymentTypeCommandHandler", NewCommandSourceHandler.class); + } else { + throw new UnsupportedCommandException(wrapper.commandName()); + } + } else { throw new UnsupportedCommandException(wrapper.commandName()); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java index 211538081..461e7ac7e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java @@ -417,9 +417,9 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement startDate = cashierData.getStartDate(); endDate = cashierData.getEndDate(); } - //Fetching all currency type from m_organisation_currency table + // Fetching all currency type from m_organisation_currency table final Collection currencyOptions = this.currencyReadPlatformService.retrieveAllowedCurrencies(); - + return CashierTransactionData.template(cashierId, tellerId, tellerName, officeId, officeName, cashierName, cashierData, startDate, endDate, currencyOptions); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java index bc9e1bf88..0b21aa45b 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/api/LoanTransactionsApiResource.java @@ -5,11 +5,26 @@ */ package org.mifosplatform.portfolio.loanaccount.api; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + import org.apache.commons.lang.StringUtils; import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; @@ -19,20 +34,12 @@ import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSeria import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData; import org.mifosplatform.portfolio.loanaccount.service.LoanReadPlatformService; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - @Path("/loans/{loanId}/transactions") @Component @Scope("singleton") @@ -49,19 +56,21 @@ public class LoanTransactionsApiResource { private final DefaultToApiJsonSerializer toApiJsonSerializer; private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; private final CodeValueReadPlatformService codeValueReadPlatformService; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public LoanTransactionsApiResource(final PlatformSecurityContext context, final LoanReadPlatformService loanReadPlatformService, final ApiRequestParameterHelper apiRequestParameterHelper, final DefaultToApiJsonSerializer toApiJsonSerializer, final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, - final CodeValueReadPlatformService codeValueReadPlatformService) { + final CodeValueReadPlatformService codeValueReadPlatformService, PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.context = context; this.loanReadPlatformService = loanReadPlatformService; this.apiRequestParameterHelper = apiRequestParameterHelper; this.toApiJsonSerializer = toApiJsonSerializer; this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; this.codeValueReadPlatformService = codeValueReadPlatformService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } private boolean is(final String commandParam, final String commandValue) { @@ -96,14 +105,11 @@ public class LoanTransactionsApiResource { transactionData = this.loanReadPlatformService.retrieveRecoveryPaymentTemplate(loanId); } else if (is(commandParam, "prepayLoan")) { transactionData = this.loanReadPlatformService.retrieveLoanPrePaymentTemplate(loanId); - } - else if (is(commandParam, "refundbycash")) { + } else if (is(commandParam, "refundbycash")) { transactionData = this.loanReadPlatformService.retrieveRefundByCashTemplate(loanId); - } - else if (is(commandParam, "refundbytransfer")) { + } else if (is(commandParam, "refundbytransfer")) { transactionData = this.loanReadPlatformService.retrieveDisbursalTemplate(loanId, true); - } - else { + } else { throw new UnrecognizedQueryParamException("command", commandParam); } @@ -123,8 +129,7 @@ public class LoanTransactionsApiResource { LoanTransactionData transactionData = this.loanReadPlatformService.retrieveLoanTransaction(loanId, transactionId); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); if (settings.isTemplate()) { - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); transactionData = LoanTransactionData.templateOnTop(transactionData, paymentTypeOptions); } @@ -161,11 +166,10 @@ public class LoanTransactionsApiResource { } else if (is(commandParam, "recoverypayment")) { final CommandWrapper commandRequest = builder.loanRecoveryPaymentTransaction(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - } - else if (is(commandParam, "refundByCash")) { + } else if (is(commandParam, "refundByCash")) { final CommandWrapper commandRequest = builder.refundLoanTransactionByCash(loanId).build(); result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); - } + } if (result == null) { throw new UnrecognizedQueryParamException("command", commandParam); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTransactionData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTransactionData.java index 6c742623a..3503865d1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTransactionData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/data/LoanTransactionData.java @@ -9,10 +9,10 @@ import java.math.BigDecimal; import java.util.Collection; import org.joda.time.LocalDate; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.portfolio.account.data.AccountTransferData; import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; /** * Immutable data object representing a loan transaction. @@ -47,10 +47,10 @@ public class LoanTransactionData { private final boolean manuallyReversed; // templates - final Collection paymentTypeOptions; + final Collection paymentTypeOptions; public static LoanTransactionData templateOnTop(final LoanTransactionData loanTransactionData, - final Collection paymentTypeOptions) { + final Collection paymentTypeOptions) { return new LoanTransactionData(loanTransactionData.id, loanTransactionData.officeId, loanTransactionData.officeName, loanTransactionData.type, loanTransactionData.paymentDetailData, loanTransactionData.currency, loanTransactionData.date, loanTransactionData.amount, loanTransactionData.principalPortion, loanTransactionData.interestPortion, @@ -76,7 +76,7 @@ public class LoanTransactionData { final PaymentDetailData paymentDetailData, final CurrencyData currency, final LocalDate date, final BigDecimal amount, final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, BigDecimal unrecognizedIncomePortion, - final Collection paymentTypeOptions, final String externalId, final AccountTransferData transfer, + final Collection paymentTypeOptions, final String externalId, final AccountTransferData transfer, final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance,boolean manuallyReversed) { this(id, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, overpaymentPortion, unrecognizedIncomePortion, paymentTypeOptions, externalId, @@ -98,7 +98,7 @@ public class LoanTransactionData { final PaymentDetailData paymentDetailData, final CurrencyData currency, final LocalDate date, final BigDecimal amount, final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion, final BigDecimal penaltyChargesPortion, final BigDecimal overpaymentPortion, final BigDecimal unrecognizedIncomePortion, - final Collection paymentTypeOptions, final String externalId, final AccountTransferData transfer, + final Collection paymentTypeOptions, final String externalId, final AccountTransferData transfer, final BigDecimal fixedEmiAmount, BigDecimal outstandingLoanBalance, final LocalDate submittedOnDate,final boolean manuallyReversed) { this.id = id; this.officeId = officeId; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java index 05f7cb466..74b5e4faf 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/domain/DecliningBalanceInterestLoanScheduleGenerator.java @@ -91,7 +91,7 @@ public class DecliningBalanceInterestLoanScheduleGenerator extends AbstractLoanS Money interestForPeriod = interestForThisInstallment; if (interestForPeriod.isGreaterThanZero()) { interestForPeriod = interestForPeriod.minus(cumulatingInterestPaymentDueToGrace); - }else{ + } else { interestForPeriod = result.interestPaymentDueToGrace().minus(cumulatingInterestPaymentDueToGrace); } Money principalForThisInstallment = loanApplicationTerms.calculateTotalPrincipalForPeriod(calculator, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java index 74aedb485..e29c9d714 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java @@ -271,6 +271,7 @@ public class LoanScheduleAssembler { } final BigDecimal principalThresholdForLastInstalment = loanProduct.getPrincipalThresholdForLastInstallment(); + final Integer installmentAmountInMultiplesOf = loanProduct.getInstallmentAmountInMultiplesOf(); return LoanApplicationTerms.assembleFrom(applicationCurrency, loanTermFrequency, loanTermPeriodFrequencyType, numberOfRepayments, @@ -463,6 +464,7 @@ public class LoanScheduleAssembler { return loanScheduleGenerator.calculatePrepaymentAmount(installments, currency, onDate, loanApplicationTerms, mc, loanCharges, holidayDetailDTO); + } private void validateDisbursementDateIsOnNonWorkingDay(final LocalDate disbursementDate, final WorkingDays workingDays) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index cf308cfd6..b8cd1ee64 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -99,8 +99,9 @@ import org.mifosplatform.portfolio.loanproduct.data.TransactionProcessingStrateg import org.mifosplatform.portfolio.loanproduct.service.LoanDropdownReadPlatformService; import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations; import org.mifosplatform.portfolio.loanproduct.service.LoanProductReadPlatformService; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.mifosplatform.useradministration.domain.AppUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; @@ -138,6 +139,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { private final HolidayRepository holidayRepository; private final ConfigurationDomainService configurationDomainService; private final WorkingDaysRepositoryWrapper workingDaysRepository; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public LoanReadPlatformServiceImpl(final PlatformSecurityContext context, final LoanRepository loanRepository, @@ -150,7 +152,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final CalendarReadPlatformService calendarReadPlatformService, final StaffReadPlatformService staffReadPlatformService, final LoanScheduleGeneratorFactory loanScheduleFactory, final CalendarInstanceRepository calendarInstanceRepository, final HolidayRepository holidayRepository, final ConfigurationDomainService configurationDomainService, - final WorkingDaysRepositoryWrapper workingDaysRepository) { + final WorkingDaysRepositoryWrapper workingDaysRepository, PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.context = context; this.loanRepository = loanRepository; this.loanTransactionRepository = loanTransactionRepository; @@ -171,6 +173,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { this.holidayRepository = holidayRepository; this.configurationDomainService = configurationDomainService; this.workingDaysRepository = workingDaysRepository; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } @Override @@ -383,8 +386,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = loan.possibleNextRepaymentInstallment(); final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.REPAYMENT); - final Collection paymentOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); final BigDecimal outstandingLoanBalance = null; final BigDecimal unrecognizedIncomePortion = null; return new LoanTransactionData(null, null, null, transactionType, null, currencyData, earliestUnpaidInstallmentDate, @@ -425,8 +427,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = loan.fetchPrepaymentDetail(this.loanScheduleFactory, restCalendarInstance, holidayDetailDTO); final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.REPAYMENT); - final Collection paymentOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); final BigDecimal outstandingLoanBalance = loanRepaymentScheduleInstallment.getPrincipalOutstanding(currency).getAmount(); final BigDecimal unrecognizedIncomePortion = null; return new LoanTransactionData(null, null, null, transactionType, null, currencyData, earliestUnpaidInstallmentDate, @@ -491,9 +492,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final Loan loan = this.loanRepository.findOne(loanId); if (loan == null) { throw new LoanNotFoundException(loanId); } final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.DISBURSEMENT); - Collection paymentOptions = null; + Collection paymentOptions = null; if (paymentDetailsRequired) { - paymentOptions = this.codeValueReadPlatformService.retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); } final BigDecimal outstandingLoanBalance = null; final BigDecimal unrecognizedIncomePortion = null; @@ -1135,11 +1136,11 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { + " tr.unrecognized_income_portion as unrecognizedIncome," + " tr.submitted_on_date as submittedOnDate, " + " tr.manually_adjusted_or_reversed as manuallyReversed, " - + " pd.payment_type_cv_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, " + + " pd.payment_type_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, " + " pd.receipt_number as receiptNumber, pd.bank_number as bankNumber,pd.routing_code as routingCode, " + " l.currency_code as currencyCode, l.currency_digits as currencyDigits, l.currency_multiplesof as inMultiplesOf, rc.`name` as currencyName, " + " rc.display_symbol as currencyDisplaySymbol, rc.internationalized_name_code as currencyNameCode, " - + " cv.code_value as paymentTypeName, tr.external_id as externalId, tr.office_id as officeId, office.name as officeName, " + + " pt.value as paymentTypeName, tr.external_id as externalId, tr.office_id as officeId, office.name as officeName, " + " fromtran.id as fromTransferId, fromtran.is_reversed as fromTransferReversed," + " fromtran.transaction_date as fromTransferDate, fromtran.amount as fromTransferAmount," + " fromtran.description as fromTransferDescription," @@ -1148,8 +1149,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { + " totran.description as toTransferDescription " + " from m_loan l join m_loan_transaction tr on tr.loan_id = l.id" + " join m_currency rc on rc.`code` = l.currency_code " + " left JOIN m_payment_detail pd ON tr.payment_detail_id = pd.id" - + " left join m_code_value cv on pd.payment_type_cv_id = cv.id" - + " left join m_office office on office.id=tr.office_id" + + " left join m_payment_type pt on pd.payment_type_id = pt.id" + " left join m_office office on office.id=tr.office_id" + " left join m_account_transfer_transaction fromtran on fromtran.from_loan_transaction_id = tr.id " + " left join m_account_transfer_transaction totran on totran.to_loan_transaction_id = tr.id "; } @@ -1179,7 +1179,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentType"); if (paymentTypeId != null) { final String typeName = rs.getString("paymentTypeName"); - final CodeValueData paymentType = CodeValueData.instance(paymentTypeId, typeName); + final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName); final String accountNumber = rs.getString("accountNumber"); final String checkNumber = rs.getString("checkNumber"); final String routingCode = rs.getString("routingCode"); @@ -1642,8 +1642,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final Loan loan = this.loanRepository.findOne(loanId); if (loan == null) { throw new LoanNotFoundException(loanId); } final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.RECOVERY_REPAYMENT); - final Collection paymentOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); BigDecimal outstandingLoanBalance = null; final BigDecimal unrecognizedIncomePortion = null; return new LoanTransactionData(null, null, null, transactionType, null, null, null, loan.getTotalWrittenOff(), null, null, null, @@ -1866,8 +1865,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService { final LocalDate earliestUnpaidInstallmentDate = new LocalDate(); final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.REFUND_FOR_ACTIVE_LOAN); - final Collection paymentOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); + return new LoanTransactionData(null, null, null, transactionType, null, currencyData, earliestUnpaidInstallmentDate, retrieveTotalPaidInAdvance(loan.getId()).getPaidInAdvance(), null, null, null, null, null, null, paymentOptions, null, null, null, null, false); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java index 71bec9c97..a4030ed01 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/api/LoanProductsApiResource.java @@ -32,7 +32,6 @@ import org.mifosplatform.accounting.producttoaccountmapping.service.ProductToGLA import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.core.api.ApiParameterHelper; import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; @@ -54,7 +53,8 @@ import org.mifosplatform.portfolio.loanproduct.productmix.data.ProductMixData; import org.mifosplatform.portfolio.loanproduct.productmix.service.ProductMixReadPlatformService; import org.mifosplatform.portfolio.loanproduct.service.LoanDropdownReadPlatformService; import org.mifosplatform.portfolio.loanproduct.service.LoanProductReadPlatformService; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -96,6 +96,7 @@ public class LoanProductsApiResource { private final DefaultToApiJsonSerializer productMixDataApiJsonSerializer; private final ProductMixReadPlatformService productMixReadPlatformService; private final DropdownReadPlatformService commonDropdownReadPlatformService; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public LoanProductsApiResource(final PlatformSecurityContext context, final LoanProductReadPlatformService readPlatformService, @@ -109,7 +110,8 @@ public class LoanProductsApiResource { final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService, final DefaultToApiJsonSerializer productMixDataApiJsonSerializer, final ProductMixReadPlatformService productMixReadPlatformService, - final DropdownReadPlatformService commonDropdownReadPlatformService) { + final DropdownReadPlatformService commonDropdownReadPlatformService, + PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.context = context; this.loanProductReadPlatformService = readPlatformService; this.chargeReadPlatformService = chargeReadPlatformService; @@ -125,6 +127,7 @@ public class LoanProductsApiResource { this.productMixDataApiJsonSerializer = productMixDataApiJsonSerializer; this.productMixReadPlatformService = productMixReadPlatformService; this.commonDropdownReadPlatformService = commonDropdownReadPlatformService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } @POST @@ -205,7 +208,8 @@ public class LoanProductsApiResource { .accountingRuleType().getId().intValue()); paymentChannelToFundSourceMappings = this.accountMappingReadPlatformService .fetchPaymentTypeToFundSourceMappingsForLoanProduct(productId); - feeToGLAccountMappings = this.accountMappingReadPlatformService.fetchFeeToIncomeOrLiabilityAccountMappingsForLoanProduct(productId); + feeToGLAccountMappings = this.accountMappingReadPlatformService + .fetchFeeToIncomeOrLiabilityAccountMappingsForLoanProduct(productId); penaltyToGLAccountMappings = this.accountMappingReadPlatformService .fetchPenaltyToIncomeAccountMappingsForLoanProduct(productId); loanProduct = LoanProductData.withAccountingDetails(loanProduct, accountingMappings, paymentChannelToFundSourceMappings, @@ -252,8 +256,7 @@ public class LoanProductsApiResource { final List repaymentFrequencyTypeOptions = this.dropdownReadPlatformService.retrieveRepaymentFrequencyTypeOptions(); final List interestRateFrequencyTypeOptions = this.dropdownReadPlatformService .retrieveInterestRateFrequencyTypeOptions(); - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); Collection fundOptions = this.fundReadPlatformService.retrieveAllFunds(); if (fundOptions.isEmpty()) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java index 69e534557..d21a27011 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/data/LoanProductData.java @@ -17,7 +17,6 @@ import org.mifosplatform.accounting.common.AccountingRuleType; import org.mifosplatform.accounting.glaccount.data.GLAccountData; import org.mifosplatform.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.portfolio.calendar.data.CalendarData; @@ -32,6 +31,7 @@ import org.mifosplatform.portfolio.loanproduct.domain.AmortizationMethod; import org.mifosplatform.portfolio.loanproduct.domain.InterestCalculationPeriodMethod; import org.mifosplatform.portfolio.loanproduct.domain.InterestMethod; import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; import org.springframework.util.CollectionUtils; /** @@ -103,7 +103,7 @@ public class LoanProductData { // template related private final Collection fundOptions; @SuppressWarnings("unused") - private final Collection paymentTypeOptions; + private final Collection paymentTypeOptions; @SuppressWarnings("unused") private final Collection currencyOptions; private final List repaymentFrequencyTypeOptions; @@ -483,7 +483,7 @@ public class LoanProductData { } public LoanProductData(final LoanProductData productData, final Collection chargeOptions, - final Collection penaltyOptions, final Collection paymentTypeOptions, + final Collection penaltyOptions, final Collection paymentTypeOptions, final Collection currencyOptions, final List amortizationTypeOptions, final List interestTypeOptions, final List interestCalculationPeriodTypeOptions, final List repaymentFrequencyTypeOptions, final List interestRateFrequencyTypeOptions, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/data/PaymentDetailData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/data/PaymentDetailData.java index 7bd675cab..0c0c12f27 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/data/PaymentDetailData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/data/PaymentDetailData.java @@ -5,7 +5,7 @@ */ package org.mifosplatform.portfolio.paymentdetail.data; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; /** * Immutable data object representing a payment. @@ -15,7 +15,7 @@ public class PaymentDetailData { @SuppressWarnings("unused") private final Long id; @SuppressWarnings("unused") - private final CodeValueData paymentType; + private final PaymentTypeData paymentType; @SuppressWarnings("unused") private final String accountNumber; @SuppressWarnings("unused") @@ -27,7 +27,7 @@ public class PaymentDetailData { @SuppressWarnings("unused") private final String bankNumber; - public PaymentDetailData(final Long id, final CodeValueData paymentType, final String accountNumber, final String checkNumber, + public PaymentDetailData(final Long id, final PaymentTypeData paymentType, final String accountNumber, final String checkNumber, final String routingCode, final String receiptNumber, final String bankNumber) { this.id = id; this.paymentType = paymentType; @@ -37,5 +37,7 @@ public class PaymentDetailData { this.receiptNumber = receiptNumber; this.bankNumber = bankNumber; } + + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/domain/PaymentDetail.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/domain/PaymentDetail.java index 5b9d6529b..02f01404c 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/domain/PaymentDetail.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/domain/PaymentDetail.java @@ -14,11 +14,11 @@ import javax.persistence.ManyToOne; import javax.persistence.Table; import org.apache.commons.lang.StringUtils; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; -import org.mifosplatform.infrastructure.codes.domain.CodeValue; import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentType; import org.springframework.data.jpa.domain.AbstractPersistable; @Entity @@ -26,8 +26,8 @@ import org.springframework.data.jpa.domain.AbstractPersistable; public final class PaymentDetail extends AbstractPersistable { @ManyToOne - @JoinColumn(name = "payment_type_cv_id", nullable = false) - private CodeValue paymentType; + @JoinColumn(name = "payment_type_id", nullable = false) + private PaymentType paymentType; @Column(name = "account_number", length = 50) private String accountNumber; @@ -48,7 +48,7 @@ public final class PaymentDetail extends AbstractPersistable { } - public static PaymentDetail generatePaymentDetail(final CodeValue paymentType, final JsonCommand command, + public static PaymentDetail generatePaymentDetail(final PaymentType paymentType, final JsonCommand command, final Map changes) { final String accountNumber = command.stringValueOfParameterNamed(PaymentDetailConstants.accountNumberParamName); final String checkNumber = command.stringValueOfParameterNamed(PaymentDetailConstants.checkNumberParamName); @@ -76,12 +76,12 @@ public final class PaymentDetail extends AbstractPersistable { return paymentDetail; } - public static PaymentDetail instance(final CodeValue paymentType, final String accountNumber, final String checkNumber, + public static PaymentDetail instance(final PaymentType paymentType, final String accountNumber, final String checkNumber, final String routingCode, final String receiptNumber, final String bankNumber) { return new PaymentDetail(paymentType, accountNumber, checkNumber, routingCode, receiptNumber, bankNumber); } - private PaymentDetail(final CodeValue paymentType, final String accountNumber, final String checkNumber, final String routingCode, + private PaymentDetail(final PaymentType paymentType, final String accountNumber, final String checkNumber, final String routingCode, final String receiptNumber, final String bankNumber) { this.paymentType = paymentType; this.accountNumber = accountNumber; @@ -92,13 +92,13 @@ public final class PaymentDetail extends AbstractPersistable { } public PaymentDetailData toData() { - final CodeValueData paymentTypeData = this.paymentType.toData(); + final PaymentTypeData paymentTypeData = this.paymentType.toData(); final PaymentDetailData paymentDetailData = new PaymentDetailData(getId(), paymentTypeData, this.accountNumber, this.checkNumber, this.routingCode, this.receiptNumber, this.bankNumber); return paymentDetailData; } - public CodeValue getPaymentType() { + public PaymentType getPaymentType() { return this.paymentType; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/domain/PaymentDetailAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/domain/PaymentDetailAssembler.java index ee035aacd..ecab762c7 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/domain/PaymentDetailAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/domain/PaymentDetailAssembler.java @@ -5,10 +5,10 @@ */ package org.mifosplatform.portfolio.paymentdetail.domain; -import org.mifosplatform.infrastructure.codes.domain.CodeValue; -import org.mifosplatform.infrastructure.codes.domain.CodeValueRepositoryWrapper; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentType; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -18,20 +18,19 @@ import com.google.gson.JsonObject; public class PaymentDetailAssembler { private final FromJsonHelper fromApiJsonHelper; - private final CodeValueRepositoryWrapper codeValueRepositoryWrapper; + private final PaymentTypeRepositoryWrapper repositoryWrapper; @Autowired - public PaymentDetailAssembler(final FromJsonHelper fromApiJsonHelper, final CodeValueRepositoryWrapper codeValueRepositoryWrapper) { + public PaymentDetailAssembler(final FromJsonHelper fromApiJsonHelper, final PaymentTypeRepositoryWrapper repositoryWrapper) { this.fromApiJsonHelper = fromApiJsonHelper; - this.codeValueRepositoryWrapper = codeValueRepositoryWrapper; + this.repositoryWrapper = repositoryWrapper; } public PaymentDetail fetchPaymentDetail(final JsonObject json) { final Long paymentTypeId = this.fromApiJsonHelper.extractLongNamed(PaymentDetailConstants.paymentTypeParamName, json); if (paymentTypeId == null) { return null; } - final CodeValue paymentType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection( - PaymentDetailConstants.paymentTypeCodeName, paymentTypeId); + final PaymentType paymentType = this.repositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); final String accountNumber = this.fromApiJsonHelper.extractStringNamed(PaymentDetailConstants.accountNumberParamName, json); final String checkNumber = this.fromApiJsonHelper.extractStringNamed(PaymentDetailConstants.checkNumberParamName, json); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/service/PaymentDetailWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/service/PaymentDetailWritePlatformServiceJpaRepositoryImpl.java index 7d6d998ae..bb91ff6b5 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/service/PaymentDetailWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymentdetail/service/PaymentDetailWritePlatformServiceJpaRepositoryImpl.java @@ -7,12 +7,12 @@ package org.mifosplatform.portfolio.paymentdetail.service; import java.util.Map; -import org.mifosplatform.infrastructure.codes.domain.CodeValue; -import org.mifosplatform.infrastructure.codes.domain.CodeValueRepositoryWrapper; import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail; import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetailRepository; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentType; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,13 +21,14 @@ import org.springframework.transaction.annotation.Transactional; public class PaymentDetailWritePlatformServiceJpaRepositoryImpl implements PaymentDetailWritePlatformService { private final PaymentDetailRepository paymentDetailRepository; - private final CodeValueRepositoryWrapper codeValueRepositoryWrapper; + // private final CodeValueRepositoryWrapper codeValueRepositoryWrapper; + private final PaymentTypeRepositoryWrapper paymentTyperepositoryWrapper; @Autowired public PaymentDetailWritePlatformServiceJpaRepositoryImpl(final PaymentDetailRepository paymentDetailRepository, - final CodeValueRepositoryWrapper codeValueRepositoryWrapper) { + final PaymentTypeRepositoryWrapper paymentTyperepositoryWrapper) { this.paymentDetailRepository = paymentDetailRepository; - this.codeValueRepositoryWrapper = codeValueRepositoryWrapper; + this.paymentTyperepositoryWrapper = paymentTyperepositoryWrapper; } @Override @@ -35,8 +36,7 @@ public class PaymentDetailWritePlatformServiceJpaRepositoryImpl implements Payme final Long paymentTypeId = command.longValueOfParameterNamed(PaymentDetailConstants.paymentTypeParamName); if (paymentTypeId == null) { return null; } - final CodeValue paymentType = this.codeValueRepositoryWrapper.findOneByCodeNameAndIdWithNotFoundDetection( - PaymentDetailConstants.paymentTypeCodeName, paymentTypeId); + final PaymentType paymentType = this.paymentTyperepositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); final PaymentDetail paymentDetail = PaymentDetail.generatePaymentDetail(paymentType, command, changes); return paymentDetail; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/api/PaymentTypeApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/api/PaymentTypeApiResource.java new file mode 100644 index 000000000..a91d5c878 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/api/PaymentTypeApiResource.java @@ -0,0 +1,123 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.api; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + +import org.mifosplatform.commands.domain.CommandWrapper; +import org.mifosplatform.commands.service.CommandWrapperBuilder; +import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; +import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; +import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; +import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; +import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer; +import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Path("/paymenttype") +@Component +public class PaymentTypeApiResource { + + private final PlatformSecurityContext securityContext; + private final DefaultToApiJsonSerializer jsonSerializer; + private final PaymentTypeReadPlatformService readPlatformService; + private final PortfolioCommandSourceWritePlatformService commandWritePlatformService; + private final ApiRequestParameterHelper apiRequestParameterHelper; + private final String resourceNameForPermissions = "PAYMENT_TYPE"; + private final Set RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "value", "description", "isCashPayment")); + + @Autowired + public PaymentTypeApiResource(PlatformSecurityContext securityContext, DefaultToApiJsonSerializer jsonSerializer, + PaymentTypeReadPlatformService readPlatformService, ApiRequestParameterHelper apiRequestParameterHelper, + PortfolioCommandSourceWritePlatformService commandWritePlatformService) { + super(); + this.securityContext = securityContext; + this.jsonSerializer = jsonSerializer; + this.readPlatformService = readPlatformService; + this.apiRequestParameterHelper = apiRequestParameterHelper; + this.commandWritePlatformService = commandWritePlatformService; + } + + @GET + @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) + @Produces(MediaType.APPLICATION_JSON) + public String getAllPaymentTypes(@Context final UriInfo uriInfo) { + this.securityContext.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); + final Collection paymentTypes = this.readPlatformService.retrieveAllPaymentTypes(); + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return this.jsonSerializer.serialize(settings, paymentTypes, this.RESPONSE_DATA_PARAMETERS); + } + + + @GET + @Path("{paymentTypeId}") + @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) + @Produces(MediaType.APPLICATION_JSON) + public String retrieveOnePaymentType(@PathParam("paymentTypeId") final Long paymentTypeId,@Context final UriInfo uriInfo) { + this.securityContext.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); + final PaymentTypeData paymentTypes = this.readPlatformService.retrieveOne(paymentTypeId); + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); + return this.jsonSerializer.serialize(settings, paymentTypes, this.RESPONSE_DATA_PARAMETERS); + } + + @POST + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String createPaymentType(final String apiRequestBodyAsJson) { + + final CommandWrapper commandRequest = new CommandWrapperBuilder().createPaymentType().withJson(apiRequestBodyAsJson).build(); + + final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(commandRequest); + + return this.jsonSerializer.serialize(result); + } + + @PUT + @Path("{paymentTypeId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String updatePaymentType(@PathParam("paymentTypeId") final Long paymentTypeId, final String apiRequestBodyAsJson) { + + final CommandWrapper commandRequest = new CommandWrapperBuilder().updatePaymentType(paymentTypeId).withJson(apiRequestBodyAsJson) + .build(); + + final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(commandRequest); + + return this.jsonSerializer.serialize(result); + } + + @DELETE + @Path("{paymentTypeId}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public String deleteCode(@PathParam("paymentTypeId") final Long paymentTypeId) { + + final CommandWrapper commandRequest = new CommandWrapperBuilder().deletePaymentType(paymentTypeId).build(); + + final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(commandRequest); + + return this.jsonSerializer.serialize(result); + } + +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/api/PaymentTypeApiResourceConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/api/PaymentTypeApiResourceConstants.java new file mode 100644 index 000000000..a12afa9cd --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/api/PaymentTypeApiResourceConstants.java @@ -0,0 +1,28 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.api; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class PaymentTypeApiResourceConstants { + + public static final String resourceNameForPermissions = "PAYMENTTYPE"; + public static final String ID = "id"; + public static final String NAME = "name"; + public static final String DESCRIPTION = "description"; + public static final String ISCASHPAYMENT = "isCashPayment"; + public static final String POSITION = "position"; + + public final Set RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(ID, NAME, DESCRIPTION, ISCASHPAYMENT)); + + public static final Set CREATE_PAYMENT_TYPE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(NAME, DESCRIPTION, + ISCASHPAYMENT, POSITION)); + + public static final Set UPDATE_PAYMENT_TYPE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(NAME, DESCRIPTION, + ISCASHPAYMENT, POSITION)); +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/data/PaymentTypeData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/data/PaymentTypeData.java new file mode 100644 index 000000000..7f136a6a6 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/data/PaymentTypeData.java @@ -0,0 +1,40 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.data; + +public class PaymentTypeData { + + @SuppressWarnings("unused") + private Long id; + @SuppressWarnings("unused") + private String name; + @SuppressWarnings("unused") + private String description; + @SuppressWarnings("unused") + private Boolean isCashPayment; + @SuppressWarnings("unused") + private Long position; + + public PaymentTypeData(final Long id, final String name, final String description, final Boolean isCashPayment, final Long position) { + this.id = id; + this.name = name; + this.description = description; + this.isCashPayment = isCashPayment; + this.position = position; + } + + public static PaymentTypeData instance(final Long id, final String name, final String description, final Boolean isCashPayment, + final Long position) { + return new PaymentTypeData(id, name, description, isCashPayment, position); + } + + public static PaymentTypeData instance(final Long id, final String name) { + String description = null; + Boolean isCashPayment = null; + Long position = null; + return new PaymentTypeData(id, name, description, isCashPayment, position); + } +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/data/PaymentTypeDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/data/PaymentTypeDataValidator.java new file mode 100644 index 000000000..6b52bf0c6 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/data/PaymentTypeDataValidator.java @@ -0,0 +1,121 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.data; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang.StringUtils; +import org.mifosplatform.infrastructure.core.data.ApiParameterError; +import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; +import org.mifosplatform.infrastructure.core.exception.InvalidJsonException; +import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; +import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; +import org.mifosplatform.portfolio.paymenttype.api.PaymentTypeApiResourceConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.gson.JsonElement; +import com.google.gson.reflect.TypeToken; + +@Component +public class PaymentTypeDataValidator { + + private final FromJsonHelper fromApiJsonHelper; + + @Autowired + public PaymentTypeDataValidator(final FromJsonHelper fromApiJsonHelper) { + this.fromApiJsonHelper = fromApiJsonHelper; + } + + public void validateForCreate(final String json) { + + if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } + + final Type typeOfMap = new TypeToken>() {}.getType(); + this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, + PaymentTypeApiResourceConstants.CREATE_PAYMENT_TYPE_REQUEST_DATA_PARAMETERS); + final JsonElement element = this.fromApiJsonHelper.parse(json); + + final List dataValidationErrors = new ArrayList<>(); + + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) + .resource(PaymentTypeApiResourceConstants.resourceNameForPermissions); + + if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.NAME, element)) { + final String name = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.NAME, element); + baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.NAME).value(name).notBlank(); + } + + if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.DESCRIPTION, element)) { + final String description = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.DESCRIPTION, element); + baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.DESCRIPTION).value(description).notExceedingLengthOf(500); + } + + if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.ISCASHPAYMENT, element)) { + final Boolean isCashPayment = this.fromApiJsonHelper + .extractBooleanNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT, element); + baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.ISCASHPAYMENT).value(isCashPayment); + } + + if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.POSITION, element)) { + final Long position = this.fromApiJsonHelper.extractLongNamed(PaymentTypeApiResourceConstants.POSITION, element); + baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.POSITION).value(position).ignoreIfNull() + .integerZeroOrGreater(); + } + + throwExceptionIfValidationWarningsExist(dataValidationErrors); + } + + private void throwExceptionIfValidationWarningsExist(final List dataValidationErrors) { + if (!dataValidationErrors.isEmpty()) { + // + throw new PlatformApiDataValidationException(dataValidationErrors); + } + } + + public void validateForUpdate(final String json) { + if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } + + final Type typeOfMap = new TypeToken>() {}.getType(); + this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, + PaymentTypeApiResourceConstants.UPDATE_PAYMENT_TYPE_REQUEST_DATA_PARAMETERS); + + final JsonElement element = this.fromApiJsonHelper.parse(json); + + final List dataValidationErrors = new ArrayList<>(); + + final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) + .resource(PaymentTypeApiResourceConstants.resourceNameForPermissions); + + if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.NAME, element)) { + final String name = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.NAME, element); + baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.NAME).value(name); + } + + if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.DESCRIPTION, element)) { + final String description = this.fromApiJsonHelper.extractStringNamed(PaymentTypeApiResourceConstants.DESCRIPTION, element); + baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.DESCRIPTION).value(description).notExceedingLengthOf(500); + } + + if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.ISCASHPAYMENT, element)) { + final Boolean isCashPayment = this.fromApiJsonHelper + .extractBooleanNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT, element); + baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.ISCASHPAYMENT).value(isCashPayment); + } + + if (this.fromApiJsonHelper.parameterExists(PaymentTypeApiResourceConstants.POSITION, element)) { + final Long position = this.fromApiJsonHelper.extractLongNamed(PaymentTypeApiResourceConstants.POSITION, element); + baseDataValidator.reset().parameter(PaymentTypeApiResourceConstants.POSITION).value(position).ignoreIfNull() + .integerZeroOrGreater(); + } + + throwExceptionIfValidationWarningsExist(dataValidationErrors); + + } +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/domain/PaymentType.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/domain/PaymentType.java new file mode 100644 index 000000000..c1e195379 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/domain/PaymentType.java @@ -0,0 +1,84 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.domain; + +import java.util.LinkedHashMap; +import java.util.Map; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +import org.apache.commons.lang.StringUtils; +import org.mifosplatform.infrastructure.core.api.JsonCommand; +import org.mifosplatform.portfolio.paymenttype.api.PaymentTypeApiResourceConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.springframework.data.jpa.domain.AbstractPersistable; + +@Entity +@Table(name = "m_payment_type") +public class PaymentType extends AbstractPersistable { + + @Column(name = "value") + private String name; + + @Column(name = "description") + private String description; + + @Column(name = "is_cash_payment") + private Boolean isCashPayment; + + @Column(name = "order_position") + private Long position; + + protected PaymentType() {} + + public PaymentType(final String name, final String description, final Boolean isCashPayment, final Long position) { + this.name = name; + this.description = description; + this.isCashPayment = isCashPayment; + this.position = position; + } + + public static PaymentType create(String name, String description, Boolean isCashPayment, Long position) { + return new PaymentType(name, description, isCashPayment, position); + } + + public Map update(final JsonCommand command) { + + final Map actualChanges = new LinkedHashMap<>(3); + + if (command.isChangeInStringParameterNamed(PaymentTypeApiResourceConstants.NAME, this.name)) { + final String newValue = command.stringValueOfParameterNamed(PaymentTypeApiResourceConstants.NAME); + actualChanges.put(PaymentTypeApiResourceConstants.NAME, newValue); + this.name = StringUtils.defaultIfEmpty(newValue, null); + } + + if (command.isChangeInStringParameterNamed(PaymentTypeApiResourceConstants.DESCRIPTION, this.description)) { + final String newDescription = command.stringValueOfParameterNamed(PaymentTypeApiResourceConstants.DESCRIPTION); + actualChanges.put(PaymentTypeApiResourceConstants.DESCRIPTION, newDescription); + this.description = StringUtils.defaultIfEmpty(newDescription, null); + } + + if (command.isChangeInBooleanParameterNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT, this.isCashPayment)) { + final Boolean newCashPaymentType = command.booleanObjectValueOfParameterNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT); + actualChanges.put(PaymentTypeApiResourceConstants.ISCASHPAYMENT, newCashPaymentType); + this.isCashPayment = newCashPaymentType.booleanValue(); + } + + if (command.isChangeInLongParameterNamed(PaymentTypeApiResourceConstants.POSITION, this.position)) { + final Long newPosition = command.longValueOfParameterNamed(PaymentTypeApiResourceConstants.POSITION); + actualChanges.put(PaymentTypeApiResourceConstants.POSITION, newPosition); + this.position = newPosition; + } + + return actualChanges; + } + + public PaymentTypeData toData() { + return PaymentTypeData.instance(getId(), this.name, this.description, this.isCashPayment, this.position); + } +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/domain/PaymentTypeRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/domain/PaymentTypeRepository.java new file mode 100644 index 000000000..85abead2a --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/domain/PaymentTypeRepository.java @@ -0,0 +1,13 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.domain; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +public interface PaymentTypeRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/domain/PaymentTypeRepositoryWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/domain/PaymentTypeRepositoryWrapper.java new file mode 100644 index 000000000..ea65222bc --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/domain/PaymentTypeRepositoryWrapper.java @@ -0,0 +1,28 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.domain; + +import org.mifosplatform.portfolio.paymenttype.exception.PaymentTypeNotFoundException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class PaymentTypeRepositoryWrapper { + + private final PaymentTypeRepository repository; + + @Autowired + public PaymentTypeRepositoryWrapper(final PaymentTypeRepository repository) { + this.repository = repository; + } + + public PaymentType findOneWithNotFoundDetection(final Long id) { + final PaymentType paymentType = this.repository.findOne(id); + if (paymentType == null) { throw new PaymentTypeNotFoundException(id); } + return paymentType; + } + +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/exception/PaymentTypeNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/exception/PaymentTypeNotFoundException.java new file mode 100644 index 000000000..09af36ed0 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/exception/PaymentTypeNotFoundException.java @@ -0,0 +1,19 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.exception; + +import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + + +public class PaymentTypeNotFoundException extends AbstractPlatformResourceNotFoundException { + + public PaymentTypeNotFoundException(final Long id) { + super("error.msg.payment.type.invalid", "PaymentType with " + id + " does not exist", id); + } +} + + + diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/handler/CreatePaymentTypeCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/handler/CreatePaymentTypeCommandHandler.java new file mode 100644 index 000000000..dde2bcd95 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/handler/CreatePaymentTypeCommandHandler.java @@ -0,0 +1,32 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.handler; + +import javax.transaction.Transactional; + +import org.mifosplatform.commands.handler.NewCommandSourceHandler; +import org.mifosplatform.infrastructure.core.api.JsonCommand; +import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeWriteService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class CreatePaymentTypeCommandHandler implements NewCommandSourceHandler { + + private final PaymentTypeWriteService paymentTypeWriteService; + + @Autowired + public CreatePaymentTypeCommandHandler(final PaymentTypeWriteService paymentTypeWriteService) { + this.paymentTypeWriteService = paymentTypeWriteService; + } + + @Override + @Transactional + public CommandProcessingResult processCommand(JsonCommand command) { + return this.paymentTypeWriteService.createPaymentType(command); + } +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/handler/DeletePaymentTypeCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/handler/DeletePaymentTypeCommandHandler.java new file mode 100644 index 000000000..adc128ff5 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/handler/DeletePaymentTypeCommandHandler.java @@ -0,0 +1,32 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.handler; + +import javax.transaction.Transactional; + +import org.mifosplatform.commands.handler.NewCommandSourceHandler; +import org.mifosplatform.infrastructure.core.api.JsonCommand; +import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeWriteService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class DeletePaymentTypeCommandHandler implements NewCommandSourceHandler { + + private final PaymentTypeWriteService paymentTypeWriteService; + + @Autowired + public DeletePaymentTypeCommandHandler(final PaymentTypeWriteService paymentTypeWriteService) { + this.paymentTypeWriteService = paymentTypeWriteService; + } + + @Override + @Transactional + public CommandProcessingResult processCommand(JsonCommand command) { + return this.paymentTypeWriteService.deletePaymentType(command.entityId()); + } +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/handler/UpdatePaymentTypeCommandHandler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/handler/UpdatePaymentTypeCommandHandler.java new file mode 100644 index 000000000..cf6a7db89 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/handler/UpdatePaymentTypeCommandHandler.java @@ -0,0 +1,32 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.handler; + +import javax.transaction.Transactional; + +import org.mifosplatform.commands.handler.NewCommandSourceHandler; +import org.mifosplatform.infrastructure.core.api.JsonCommand; +import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeWriteService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class UpdatePaymentTypeCommandHandler implements NewCommandSourceHandler { + + private final PaymentTypeWriteService paymentTypeWriteService; + + @Autowired + public UpdatePaymentTypeCommandHandler(final PaymentTypeWriteService paymentTypeWriteService) { + this.paymentTypeWriteService = paymentTypeWriteService; + } + + @Override + @Transactional + public CommandProcessingResult processCommand(JsonCommand command) { + return this.paymentTypeWriteService.updatePaymentType(command.entityId(),command); + } +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java new file mode 100644 index 000000000..0f6bd8463 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeReadPlatformService.java @@ -0,0 +1,17 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.service; + +import java.util.Collection; + +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; + +public interface PaymentTypeReadPlatformService { + + Collection retrieveAllPaymentTypes(); + PaymentTypeData retrieveOne(Long paymentTypeId); + +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java new file mode 100644 index 000000000..5b60c5ac2 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeReadPlatformServiceImpl.java @@ -0,0 +1,74 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.service; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collection; + +import org.mifosplatform.infrastructure.core.service.RoutingDataSource; +import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Service; + +@Service +public class PaymentTypeReadPlatformServiceImpl implements PaymentTypeReadPlatformService { + + private final JdbcTemplate jdbcTemplate; + private final PlatformSecurityContext context; + + @Autowired + public PaymentTypeReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) { + this.context = context; + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + @Override + public Collection retrieveAllPaymentTypes() { + // TODO Auto-generated method stub + this.context.authenticatedUser(); + + final PaymentTypeMapper ptm = new PaymentTypeMapper(); + final String sql = "select " + ptm.schema() + "order by position"; + + return this.jdbcTemplate.query(sql, ptm, new Object[] {}); + } + + @Override + public PaymentTypeData retrieveOne(Long paymentTypeId) { + // TODO Auto-generated method stub + this.context.authenticatedUser(); + + final PaymentTypeMapper ptm = new PaymentTypeMapper(); + final String sql = "select " + ptm.schema() + "where pt.id = ?"; + + return this.jdbcTemplate.queryForObject(sql, ptm, new Object[] { paymentTypeId }); + } + + private static final class PaymentTypeMapper implements RowMapper { + + public String schema() { + return " pt.id as id, pt.value as name, pt.description as description,pt.is_cash_payment as isCashPayment,pt.order_position as position from m_payment_type pt "; + } + + @Override + public PaymentTypeData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { + + final Long id = rs.getLong("id"); + final String name = rs.getString("name"); + final String description = rs.getString("description"); + final boolean isCashPayment = rs.getBoolean("isCashPayment"); + final Long position = rs.getLong("position"); + + return PaymentTypeData.instance(id, name, description, isCashPayment, position); + } + + } + +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeWriteService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeWriteService.java new file mode 100644 index 000000000..13dd11182 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeWriteService.java @@ -0,0 +1,18 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.service; + +import org.mifosplatform.infrastructure.core.api.JsonCommand; +import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; + +public interface PaymentTypeWriteService { + + CommandProcessingResult createPaymentType(final JsonCommand command); + + CommandProcessingResult updatePaymentType(final Long id, final JsonCommand command); + + CommandProcessingResult deletePaymentType(final Long id); +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeWriteServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeWriteServiceImpl.java new file mode 100644 index 000000000..437445a81 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/paymenttype/service/PaymentTypeWriteServiceImpl.java @@ -0,0 +1,92 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.mifosplatform.portfolio.paymenttype.service; + +import java.util.Map; + +import org.mifosplatform.infrastructure.core.api.JsonCommand; +import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; +import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder; +import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; +import org.mifosplatform.portfolio.paymenttype.api.PaymentTypeApiResourceConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeDataValidator; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentType; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentTypeRepository; +import org.mifosplatform.portfolio.paymenttype.domain.PaymentTypeRepositoryWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.stereotype.Service; + +@Service +public class PaymentTypeWriteServiceImpl implements PaymentTypeWriteService { + + // private final static Logger logger = + // LoggerFactory.getLogger(MifosEntityAccessWriteServiceImpl.class); + private final PaymentTypeRepository repository; + private final PaymentTypeRepositoryWrapper repositoryWrapper; + + /* + * private final CodeValueRepositoryWrapper codeValueRepositoryWrapper; + * private final MifosEntityAccessRepository entityAccessRepository; private + * final MifosEntityRelationRepositoryWrapper + * mifosEntityRelationRepositoryWrapper; private final + * MifosEntityToEntityMappingRepository + * mifosEntityToEntityMappingRepository; private final + * MifosEntityToEntityMappingRepositoryWrapper + * mifosEntityToEntityMappingRepositoryWrapper; + */ + private final PaymentTypeDataValidator fromApiJsonDeserializer; + + @Autowired + public PaymentTypeWriteServiceImpl(PaymentTypeRepository repository, PaymentTypeRepositoryWrapper repositoryWrapper, + PaymentTypeDataValidator fromApiJsonDeserializer) { + this.repository = repository; + this.repositoryWrapper = repositoryWrapper; + this.fromApiJsonDeserializer = fromApiJsonDeserializer; + + } + + @Override + public CommandProcessingResult createPaymentType(JsonCommand command) { + this.fromApiJsonDeserializer.validateForCreate(command.json()); + String name = command.stringValueOfParameterNamed(PaymentTypeApiResourceConstants.NAME); + String description = command.stringValueOfParameterNamed(PaymentTypeApiResourceConstants.DESCRIPTION); + Boolean isCashPayment = command.booleanObjectValueOfParameterNamed(PaymentTypeApiResourceConstants.ISCASHPAYMENT); + Long position = command.longValueOfParameterNamed(PaymentTypeApiResourceConstants.POSITION); + + PaymentType newPaymentType = PaymentType.create(name, description, isCashPayment, position); + this.repository.save(newPaymentType); + return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(newPaymentType.getId()).build(); + } + + @Override + public CommandProcessingResult updatePaymentType(Long paymentTypeId, JsonCommand command) { + // TODO Auto-generated method stub + this.fromApiJsonDeserializer.validateForUpdate(command.json()); + final PaymentType paymentType = this.repositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); + final Map changes = paymentType.update(command); + + if (!changes.isEmpty()) { + this.repository.save(paymentType); + } + + return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.entityId()).build(); + } + + @Override + public CommandProcessingResult deletePaymentType(Long paymentTypeId) { + // TODO Auto-generated method stub + final PaymentType paymentType = this.repositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); + try { + this.repository.delete(paymentType); + } catch (final DataIntegrityViolationException e) { + throw new PlatformDataIntegrityException("error.msg.cund.unknown.data.integrity.issue", + "Unknown data integrity issue with resource: " + e.getMostSpecificCause()); + } + return new CommandProcessingResultBuilder().withEntityId(paymentType.getId()).build(); + } + +} diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/FixedDepositAccountTransactionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/FixedDepositAccountTransactionsApiResource.java index 5409d7c60..88707e750 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/FixedDepositAccountTransactionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/FixedDepositAccountTransactionsApiResource.java @@ -22,7 +22,6 @@ import org.apache.commons.lang.StringUtils; import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; @@ -30,7 +29,8 @@ import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamExc import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.DepositsApiConstants; import org.mifosplatform.portfolio.savings.SavingsApiConstants; @@ -51,6 +51,7 @@ public class FixedDepositAccountTransactionsApiResource { private final ApiRequestParameterHelper apiRequestParameterHelper; private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; private final CodeValueReadPlatformService codeValueReadPlatformService; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public FixedDepositAccountTransactionsApiResource(final PlatformSecurityContext context, @@ -58,13 +59,14 @@ public class FixedDepositAccountTransactionsApiResource { final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, final ApiRequestParameterHelper apiRequestParameterHelper, final SavingsAccountReadPlatformService savingsAccountReadPlatformService, - final CodeValueReadPlatformService codeValueReadPlatformService) { + final CodeValueReadPlatformService codeValueReadPlatformService, PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.context = context; this.toApiJsonSerializer = toApiJsonSerializer; this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; this.apiRequestParameterHelper = apiRequestParameterHelper; this.savingsAccountReadPlatformService = savingsAccountReadPlatformService; this.codeValueReadPlatformService = codeValueReadPlatformService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } private boolean is(final String commandParam, final String commandValue) { @@ -83,8 +85,8 @@ public class FixedDepositAccountTransactionsApiResource { SavingsAccountTransactionData savingsAccount = this.savingsAccountReadPlatformService.retrieveDepositTransactionTemplate( fixedDepositAccountId, DepositAccountType.FIXED_DEPOSIT); - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); + savingsAccount = SavingsAccountTransactionData.templateOnTop(savingsAccount, paymentTypeOptions); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); @@ -104,8 +106,7 @@ public class FixedDepositAccountTransactionsApiResource { fixedDepositAccountId, transactionId, DepositAccountType.FIXED_DEPOSIT); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); if (settings.isTemplate()) { - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); transactionData = SavingsAccountTransactionData.templateOnTop(transactionData, paymentTypeOptions); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/FixedDepositProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/FixedDepositProductsApiResource.java index 21f65a373..6bfa488a8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/FixedDepositProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/FixedDepositProductsApiResource.java @@ -32,7 +32,6 @@ import org.mifosplatform.accounting.producttoaccountmapping.service.ProductToGLA import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; @@ -47,7 +46,8 @@ import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService; import org.mifosplatform.portfolio.common.service.DropdownReadPlatformService; import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData; import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartReadPlatformService; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.DepositsApiConstants; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; @@ -84,6 +84,7 @@ public class FixedDepositProductsApiResource { private final InterestRateChartReadPlatformService interestRateChartReadPlatformService; private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService; private final DropdownReadPlatformService dropdownReadPlatformService; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public FixedDepositProductsApiResource(final DepositProductReadPlatformService depositProductReadPlatformService, @@ -97,7 +98,8 @@ public class FixedDepositProductsApiResource { final ChargeReadPlatformService chargeReadPlatformService, final InterestRateChartReadPlatformService chartReadPlatformService, final InterestRateChartReadPlatformService interestRateChartReadPlatformService, final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService, - final DropdownReadPlatformService dropdownReadPlatformService) { + final DropdownReadPlatformService dropdownReadPlatformService, + final PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.depositProductReadPlatformService = depositProductReadPlatformService; this.savingsDropdownReadPlatformService = savingsDropdownReadPlatformService; this.currencyReadPlatformService = currencyReadPlatformService; @@ -113,6 +115,7 @@ public class FixedDepositProductsApiResource { this.interestRateChartReadPlatformService = interestRateChartReadPlatformService; this.depositsDropdownReadPlatformService = depositsDropdownReadPlatformService; this.dropdownReadPlatformService = dropdownReadPlatformService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } @POST @@ -253,8 +256,7 @@ public class FixedDepositProductsApiResource { final Collection withdrawalFeeTypeOptions = this.savingsDropdownReadPlatformService .retrievewithdrawalFeeTypeOptions(); - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); final Collection accountingRuleOptions = this.accountingDropdownReadPlatformService .retrieveAccountingRuleTypeOptions(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java index d45ce9730..143d79a1b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java @@ -22,7 +22,6 @@ import org.apache.commons.lang.StringUtils; import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; @@ -30,7 +29,8 @@ import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamExc import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.DepositsApiConstants; import org.mifosplatform.portfolio.savings.SavingsApiConstants; @@ -53,6 +53,7 @@ public class RecurringDepositAccountTransactionsApiResource { private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; private final DepositAccountReadPlatformService depositAccountReadPlatformService; private final CodeValueReadPlatformService codeValueReadPlatformService; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public RecurringDepositAccountTransactionsApiResource(final PlatformSecurityContext context, @@ -61,7 +62,7 @@ public class RecurringDepositAccountTransactionsApiResource { final ApiRequestParameterHelper apiRequestParameterHelper, final SavingsAccountReadPlatformService savingsAccountReadPlatformService, final DepositAccountReadPlatformService depositAccountReadPlatformService, - final CodeValueReadPlatformService codeValueReadPlatformService) { + final CodeValueReadPlatformService codeValueReadPlatformService, PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.context = context; this.toApiJsonSerializer = toApiJsonSerializer; this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; @@ -69,6 +70,7 @@ public class RecurringDepositAccountTransactionsApiResource { this.savingsAccountReadPlatformService = savingsAccountReadPlatformService; this.depositAccountReadPlatformService = depositAccountReadPlatformService; this.codeValueReadPlatformService = codeValueReadPlatformService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } private boolean is(final String commandParam, final String commandValue) { @@ -105,8 +107,7 @@ public class RecurringDepositAccountTransactionsApiResource { savingsAccount = SavingsAccountTransactionData.withWithDrawalTransactionDetails(savingsAccount); } - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); savingsAccount = SavingsAccountTransactionData.templateOnTop(savingsAccount, paymentTypeOptions); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); @@ -126,8 +127,7 @@ public class RecurringDepositAccountTransactionsApiResource { recurringDepositAccountId, transactionId, DepositAccountType.RECURRING_DEPOSIT); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); if (settings.isTemplate()) { - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); transactionData = SavingsAccountTransactionData.templateOnTop(transactionData, paymentTypeOptions); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositProductsApiResource.java index 02e2ace89..f98127e58 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositProductsApiResource.java @@ -32,7 +32,6 @@ import org.mifosplatform.accounting.producttoaccountmapping.service.ProductToGLA import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; @@ -47,7 +46,8 @@ import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService; import org.mifosplatform.portfolio.common.service.DropdownReadPlatformService; import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData; import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartReadPlatformService; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.DepositsApiConstants; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; @@ -84,6 +84,7 @@ public class RecurringDepositProductsApiResource { private final InterestRateChartReadPlatformService interestRateChartReadPlatformService; private final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService; private final DropdownReadPlatformService dropdownReadPlatformService; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public RecurringDepositProductsApiResource(final DepositProductReadPlatformService depositProductReadPlatformService, @@ -97,7 +98,8 @@ public class RecurringDepositProductsApiResource { final ChargeReadPlatformService chargeReadPlatformService, final InterestRateChartReadPlatformService chartReadPlatformService, final InterestRateChartReadPlatformService interestRateChartReadPlatformService, final DepositsDropdownReadPlatformService depositsDropdownReadPlatformService, - final DropdownReadPlatformService dropdownReadPlatformService) { + final DropdownReadPlatformService dropdownReadPlatformService, + final PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.depositProductReadPlatformService = depositProductReadPlatformService; this.savingsDropdownReadPlatformService = savingsDropdownReadPlatformService; this.currencyReadPlatformService = currencyReadPlatformService; @@ -113,6 +115,7 @@ public class RecurringDepositProductsApiResource { this.interestRateChartReadPlatformService = interestRateChartReadPlatformService; this.depositsDropdownReadPlatformService = depositsDropdownReadPlatformService; this.dropdownReadPlatformService = dropdownReadPlatformService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } @POST @@ -254,8 +257,7 @@ public class RecurringDepositProductsApiResource { final Collection withdrawalFeeTypeOptions = this.savingsDropdownReadPlatformService .retrievewithdrawalFeeTypeOptions(); - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); final Collection accountingRuleOptions = this.accountingDropdownReadPlatformService .retrieveAccountingRuleTypeOptions(); final Map> accountingMappingOptions = this.accountingDropdownReadPlatformService diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsAccountTransactionsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsAccountTransactionsApiResource.java index f2cfae597..d3071c4dc 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsAccountTransactionsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsAccountTransactionsApiResource.java @@ -22,7 +22,6 @@ import org.apache.commons.lang.StringUtils; import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; @@ -31,7 +30,8 @@ import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamExc import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.SavingsApiConstants; import org.mifosplatform.portfolio.savings.data.SavingsAccountTransactionData; @@ -53,6 +53,7 @@ public class SavingsAccountTransactionsApiResource { private final ApiRequestParameterHelper apiRequestParameterHelper; private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; private final CodeValueReadPlatformService codeValueReadPlatformService; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public SavingsAccountTransactionsApiResource(final PlatformSecurityContext context, @@ -60,13 +61,14 @@ public class SavingsAccountTransactionsApiResource { final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, final ApiRequestParameterHelper apiRequestParameterHelper, final SavingsAccountReadPlatformService savingsAccountReadPlatformService, - final CodeValueReadPlatformService codeValueReadPlatformService) { + final CodeValueReadPlatformService codeValueReadPlatformService,PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.context = context; this.toApiJsonSerializer = toApiJsonSerializer; this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; this.apiRequestParameterHelper = apiRequestParameterHelper; this.savingsAccountReadPlatformService = savingsAccountReadPlatformService; this.codeValueReadPlatformService = codeValueReadPlatformService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } private boolean is(final String commandParam, final String commandValue) { @@ -87,8 +89,8 @@ public class SavingsAccountTransactionsApiResource { // both deposit/withdrawal templates SavingsAccountTransactionData savingsAccount = this.savingsAccountReadPlatformService.retrieveDepositTransactionTemplate(savingsId, DepositAccountType.SAVINGS_DEPOSIT); - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService + .retrieveAllPaymentTypes(); savingsAccount = SavingsAccountTransactionData.templateOnTop(savingsAccount, paymentTypeOptions); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); @@ -108,8 +110,7 @@ public class SavingsAccountTransactionsApiResource { transactionId, DepositAccountType.SAVINGS_DEPOSIT); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); if (settings.isTemplate()) { - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); transactionData = SavingsAccountTransactionData.templateOnTop(transactionData, paymentTypeOptions); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsProductsApiResource.java index 2cc67ea9f..1e5cbe22b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/SavingsProductsApiResource.java @@ -32,7 +32,6 @@ import org.mifosplatform.accounting.producttoaccountmapping.service.ProductToGLA import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.service.CommandWrapperBuilder; import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper; import org.mifosplatform.infrastructure.core.data.CommandProcessingResult; @@ -44,7 +43,8 @@ import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.mifosplatform.portfolio.savings.SavingsApiConstants; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType; @@ -75,6 +75,7 @@ public class SavingsProductsApiResource { private final CodeValueReadPlatformService codeValueReadPlatformService; private final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService; private final ChargeReadPlatformService chargeReadPlatformService; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public SavingsProductsApiResource(final SavingsProductReadPlatformService savingProductReadPlatformService, @@ -85,7 +86,7 @@ public class SavingsProductsApiResource { final ApiRequestParameterHelper apiRequestParameterHelper, final CodeValueReadPlatformService codeValueReadPlatformService, final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService, final ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService, - final ChargeReadPlatformService chargeReadPlatformService) { + final ChargeReadPlatformService chargeReadPlatformService, PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.savingProductReadPlatformService = savingProductReadPlatformService; this.dropdownReadPlatformService = dropdownReadPlatformService; this.currencyReadPlatformService = currencyReadPlatformService; @@ -97,6 +98,7 @@ public class SavingsProductsApiResource { this.accountingDropdownReadPlatformService = accountingDropdownReadPlatformService; this.accountMappingReadPlatformService = accountMappingReadPlatformService; this.chargeReadPlatformService = chargeReadPlatformService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } @POST @@ -229,8 +231,8 @@ public class SavingsProductsApiResource { final Collection withdrawalFeeTypeOptions = this.dropdownReadPlatformService.retrievewithdrawalFeeTypeOptions(); - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); + final Collection accountingRuleOptions = this.accountingDropdownReadPlatformService .retrieveAccountingRuleTypeOptions(); final Map> accountingMappingOptions = this.accountingDropdownReadPlatformService diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/DepositProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/DepositProductData.java index 00c8ddbc5..23b299165 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/DepositProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/DepositProductData.java @@ -14,11 +14,11 @@ import org.mifosplatform.accounting.common.AccountingRuleType; import org.mifosplatform.accounting.glaccount.data.GLAccountData; import org.mifosplatform.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; /** * Immutable data object represents a partial data of Deposit Proucts. @@ -63,7 +63,7 @@ public class DepositProductData { protected final Collection interestCalculationDaysInYearTypeOptions; protected final Collection lockinPeriodFrequencyTypeOptions; protected final Collection withdrawalFeeTypeOptions; - protected final Collection paymentTypeOptions; + protected final Collection paymentTypeOptions; protected final Collection accountingRuleOptions; protected final Map> accountingMappingOptions; protected final Collection chargeOptions; @@ -78,7 +78,7 @@ public class DepositProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection chargeOptions, final Collection penaltyOptions, final InterestRateChartData chartTemplate) { @@ -132,7 +132,7 @@ public class DepositProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection chargeOptions, final Collection penaltyOptions, final InterestRateChartData chartTemplate) { @@ -162,7 +162,7 @@ public class DepositProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection chargeOptions = null; @@ -198,7 +198,7 @@ public class DepositProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection chargeOptions = null; @@ -243,7 +243,7 @@ public class DepositProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection charges = null; @@ -292,7 +292,7 @@ public class DepositProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection charges, final Collection chargeOptions, final Collection penaltyOptions, final Collection feeToIncomeAccountMappings, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/FixedDepositAccountData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/FixedDepositAccountData.java index 2ff007b15..c7b5f1204 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/FixedDepositAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/FixedDepositAccountData.java @@ -11,12 +11,12 @@ import java.util.Collection; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.joda.time.LocalDate; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.organisation.staff.data.StaffData; import org.mifosplatform.portfolio.account.data.PortfolioAccountData; import org.mifosplatform.portfolio.charge.data.ChargeData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.service.SavingsEnumerations; @@ -52,7 +52,7 @@ public class FixedDepositAccountData extends DepositAccountData { // for account close private Collection onAccountClosureOptions; - private Collection paymentTypeOptions; + private Collection paymentTypeOptions; public static FixedDepositAccountData instance(final DepositAccountData depositAccountData, final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest, final EnumOptionData preClosurePenalInterestOnType, final Integer minDepositTerm, @@ -67,7 +67,7 @@ public class FixedDepositAccountData extends DepositAccountData { final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue()); final Collection onAccountClosureOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection savingsAccountDatas = null; return new FixedDepositAccountData(depositAccountData.id, depositAccountData.accountNo, depositAccountData.externalId, @@ -230,7 +230,7 @@ public class FixedDepositAccountData extends DepositAccountData { final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue()); final Collection onAccountClosureOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection savingsAccountDatas = null; return new FixedDepositAccountData(id, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName, @@ -248,7 +248,7 @@ public class FixedDepositAccountData extends DepositAccountData { } public static FixedDepositAccountData preClosureDetails(final Long accountId, BigDecimal maturityAmount, - final Collection onAccountClosureOptions, final Collection paymentTypeOptions, + final Collection onAccountClosureOptions, final Collection paymentTypeOptions, final Collection savingsAccountDatas) { final Long groupId = null; @@ -327,7 +327,7 @@ public class FixedDepositAccountData extends DepositAccountData { } public static FixedDepositAccountData withClosureTemplateDetails(final FixedDepositAccountData account, - final Collection onAccountClosureOptions, final Collection paymentTypeOptions, + final Collection onAccountClosureOptions, final Collection paymentTypeOptions, final Collection savingsAccountDatas) { return new FixedDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName, @@ -375,7 +375,7 @@ public class FixedDepositAccountData extends DepositAccountData { final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency, final Collection periodFrequencyTypeOptions, final EnumOptionData depositType, final EnumOptionData onAccountClosure, final Collection onAccountClosureOptions, - final Collection paymentTypeOptions, final Collection savingsAccountDatas, + final Collection paymentTypeOptions, final Collection savingsAccountDatas, final PortfolioAccountData linkedAccount, final Boolean transferInterestToSavings) { super(id, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName, fieldofficerId, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/FixedDepositProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/FixedDepositProductData.java index de3498615..67d3a004d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/FixedDepositProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/FixedDepositProductData.java @@ -13,11 +13,11 @@ import java.util.Map; import org.mifosplatform.accounting.glaccount.data.GLAccountData; import org.mifosplatform.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; /** * Immutable data object representing a Fixed Deposit product. @@ -49,7 +49,7 @@ public class FixedDepositProductData extends DepositProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection chargeOptions, final Collection penaltyOptions, final InterestRateChartData chartTemplate, final Collection preClosurePenalInterestOnTypeOptions, @@ -129,7 +129,7 @@ public class FixedDepositProductData extends DepositProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection chargeOptions, final Collection penaltyOptions, final InterestRateChartData chartTemplate, final Collection preClosurePenalInterestOnTypeOptions, @@ -167,7 +167,7 @@ public class FixedDepositProductData extends DepositProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection chargeOptions = null; @@ -208,7 +208,7 @@ public class FixedDepositProductData extends DepositProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection chargeOptions = null; @@ -261,7 +261,7 @@ public class FixedDepositProductData extends DepositProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection charges = null; @@ -335,7 +335,7 @@ public class FixedDepositProductData extends DepositProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection charges, final Collection chargeOptions, final Collection penaltyOptions, final Collection feeToIncomeAccountMappings, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/RecurringDepositAccountData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/RecurringDepositAccountData.java index 1e56c8b3b..3eac29892 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/RecurringDepositAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/RecurringDepositAccountData.java @@ -11,11 +11,11 @@ import java.util.Collection; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.joda.time.LocalDate; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.organisation.staff.data.StaffData; import org.mifosplatform.portfolio.charge.data.ChargeData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.service.SavingsEnumerations; @@ -59,7 +59,7 @@ public class RecurringDepositAccountData extends DepositAccountData { // for account close private final Collection onAccountClosureOptions; - private final Collection paymentTypeOptions; + private final Collection paymentTypeOptions; public static RecurringDepositAccountData instance(final DepositAccountData depositAccountData, final boolean preClosurePenalApplicable, final BigDecimal preClosurePenalInterest, @@ -77,7 +77,7 @@ public class RecurringDepositAccountData extends DepositAccountData { final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.FIXED_DEPOSIT.getValue()); final Collection onAccountClosureOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection savingsAccountDatas = null; final Integer recurringFrequency = null; final EnumOptionData recurringFrequencyType = null; @@ -270,7 +270,7 @@ public class RecurringDepositAccountData extends DepositAccountData { final EnumOptionData depositType = SavingsEnumerations.depositType(DepositAccountType.RECURRING_DEPOSIT.getValue()); final Collection onAccountClosureOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection savingsAccountDatas = null; final LocalDate expectedFirstDepositOnDate = null; @@ -300,7 +300,7 @@ public class RecurringDepositAccountData extends DepositAccountData { } public static RecurringDepositAccountData preClosureDetails(final Long accountId, final BigDecimal maturityAmount, - final Collection onAccountClosureOptions, final Collection paymentTypeOptions, + final Collection onAccountClosureOptions, final Collection paymentTypeOptions, final Collection savingsAccountDatas) { final String accountNo = null; @@ -389,7 +389,7 @@ public class RecurringDepositAccountData extends DepositAccountData { } public static RecurringDepositAccountData withClosureTemplateDetails(final RecurringDepositAccountData account, - final Collection onAccountClosureOptions, final Collection paymentTypeOptions, + final Collection onAccountClosureOptions, final Collection paymentTypeOptions, final Collection savingsAccountDatas) { return new RecurringDepositAccountData(account.id, account.accountNo, account.externalId, account.groupId, account.groupName, @@ -439,7 +439,7 @@ public class RecurringDepositAccountData extends DepositAccountData { final LocalDate maturityDate, final Integer depositPeriod, final EnumOptionData depositPeriodFrequency, final BigDecimal mandatoryRecommendedDepositAmount, final Collection periodFrequencyTypeOptions, final EnumOptionData depositType, final EnumOptionData onAccountClosure, - final Collection onAccountClosureOptions, final Collection paymentTypeOptions, + final Collection onAccountClosureOptions, final Collection paymentTypeOptions, final Collection savingsAccountDatas, final LocalDate expectedFirstDepositOnDate, final BigDecimal totalOverdueAmount, final Integer noOfOverdueInstallments, final boolean isMandatoryDeposit, final boolean allowWithdrawal, final boolean adjustAdvanceTowardsFuturePayments, final boolean isCalendarInherited, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/RecurringDepositProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/RecurringDepositProductData.java index d86122ded..480be264d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/RecurringDepositProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/RecurringDepositProductData.java @@ -13,11 +13,11 @@ import java.util.Map; import org.mifosplatform.accounting.glaccount.data.GLAccountData; import org.mifosplatform.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; /** * Immutable data object represent a Recurring Deposit product. @@ -51,7 +51,7 @@ public class RecurringDepositProductData extends DepositProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection chargeOptions, final Collection penaltyOptions, final InterestRateChartData chartTemplate, final Collection preClosurePenalInterestOnTypeOptions, @@ -137,7 +137,7 @@ public class RecurringDepositProductData extends DepositProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection chargeOptions, final Collection penaltyOptions, final InterestRateChartData chartTemplate, final Collection preClosurePenalInterestOnTypeOptions, @@ -177,7 +177,7 @@ public class RecurringDepositProductData extends DepositProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection chargeOptions = null; @@ -221,7 +221,7 @@ public class RecurringDepositProductData extends DepositProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection chargeOptions = null; @@ -276,7 +276,7 @@ public class RecurringDepositProductData extends DepositProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection charges = null; @@ -350,7 +350,7 @@ public class RecurringDepositProductData extends DepositProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection charges, final Collection chargeOptions, final Collection penaltyOptions, final Collection feeToIncomeAccountMappings, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountTransactionData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountTransactionData.java index 3d73c5bc5..e53e8554b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountTransactionData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsAccountTransactionData.java @@ -14,6 +14,7 @@ import org.mifosplatform.infrastructure.core.service.DateUtils; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.portfolio.account.data.AccountTransferData; import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; import org.mifosplatform.portfolio.savings.SavingsAccountTransactionType; import org.mifosplatform.portfolio.savings.service.SavingsEnumerations; @@ -37,13 +38,13 @@ public class SavingsAccountTransactionData { private final LocalDate submittedOnDate; // templates - final Collection paymentTypeOptions; + final Collection paymentTypeOptions; public static SavingsAccountTransactionData create(final Long id, final SavingsAccountTransactionEnumData transactionType, final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date, final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed, final AccountTransferData transfer) { - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; return new SavingsAccountTransactionData(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, date, currency, amount, runningBalance, reversed, transfer, paymentTypeOptions); } @@ -52,7 +53,7 @@ public class SavingsAccountTransactionData { final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date, final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed, final AccountTransferData transfer,final LocalDate submittedOnDate) { - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; return new SavingsAccountTransactionData(id, transactionType, paymentDetailData, savingsId, savingsAccountNo, date, currency, amount, runningBalance, reversed, transfer, paymentTypeOptions,submittedOnDate); } @@ -71,7 +72,7 @@ public class SavingsAccountTransactionData { } public static SavingsAccountTransactionData templateOnTop(final SavingsAccountTransactionData savingsAccountTransactionData, - final Collection paymentTypeOptions) { + final Collection paymentTypeOptions) { return new SavingsAccountTransactionData(savingsAccountTransactionData.id, savingsAccountTransactionData.transactionType, savingsAccountTransactionData.paymentDetailData, savingsAccountTransactionData.accountId, savingsAccountTransactionData.accountNo, savingsAccountTransactionData.date, savingsAccountTransactionData.currency, @@ -82,7 +83,7 @@ public class SavingsAccountTransactionData { private SavingsAccountTransactionData(final Long id, final SavingsAccountTransactionEnumData transactionType, final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date, final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed, - final AccountTransferData transfer, final Collection paymentTypeOptions) { + final AccountTransferData transfer, final Collection paymentTypeOptions) { this(id,transactionType,paymentDetailData,savingsId, savingsAccountNo,date, currency,amount,runningBalance, reversed, @@ -93,7 +94,7 @@ public class SavingsAccountTransactionData { private SavingsAccountTransactionData(final Long id, final SavingsAccountTransactionEnumData transactionType, final PaymentDetailData paymentDetailData, final Long savingsId, final String savingsAccountNo, final LocalDate date, final CurrencyData currency, final BigDecimal amount, final BigDecimal runningBalance, final boolean reversed, - final AccountTransferData transfer, final Collection paymentTypeOptions,final LocalDate submittedOnDate) { + final AccountTransferData transfer, final Collection paymentTypeOptions,final LocalDate submittedOnDate) { this.id = id; this.transactionType = transactionType; this.paymentDetailData = paymentDetailData; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java index 8afa842fd..112e2dba8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/SavingsProductData.java @@ -14,10 +14,10 @@ import org.mifosplatform.accounting.common.AccountingRuleType; import org.mifosplatform.accounting.glaccount.data.GLAccountData; import org.mifosplatform.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.portfolio.charge.data.ChargeData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; /** * Immutable data object represent a savings product. @@ -62,7 +62,7 @@ public class SavingsProductData { private final Collection interestCalculationDaysInYearTypeOptions; private final Collection lockinPeriodFrequencyTypeOptions; private final Collection withdrawalFeeTypeOptions; - private final Collection paymentTypeOptions; + private final Collection paymentTypeOptions; private final Collection accountingRuleOptions; private final Map> accountingMappingOptions; private final Collection chargeOptions; @@ -76,7 +76,7 @@ public class SavingsProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection chargeOptions, final Collection penaltyOptions) { @@ -135,7 +135,7 @@ public class SavingsProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection chargeOptions, final Collection penaltyOptions) { @@ -167,7 +167,7 @@ public class SavingsProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection chargeOptions = null; @@ -206,7 +206,7 @@ public class SavingsProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection chargeOptions = null; @@ -256,7 +256,7 @@ public class SavingsProductData { final Collection interestCalculationDaysInYearTypeOptions = null; final Collection lockinPeriodFrequencyTypeOptions = null; final Collection withdrawalFeeTypeOptions = null; - final Collection paymentTypeOptions = null; + final Collection paymentTypeOptions = null; final Collection accountingRuleOptions = null; final Map> accountingMappingOptions = null; final Collection charges = null; @@ -288,7 +288,7 @@ public class SavingsProductData { final Collection interestCalculationTypeOptions, final Collection interestCalculationDaysInYearTypeOptions, final Collection lockinPeriodFrequencyTypeOptions, final Collection withdrawalFeeTypeOptions, - final Collection paymentTypeOptions, final Collection accountingRuleOptions, + final Collection paymentTypeOptions, final Collection accountingRuleOptions, final Map> accountingMappingOptions, final Collection charges, final Collection chargeOptions, final Collection penaltyOptions, final Collection feeToIncomeAccountMappings, diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/DepositAccountPreMatureCalculationPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/DepositAccountPreMatureCalculationPlatformServiceImpl.java index 2eceba125..3f371f903 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/DepositAccountPreMatureCalculationPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/DepositAccountPreMatureCalculationPlatformServiceImpl.java @@ -10,13 +10,13 @@ import static org.mifosplatform.portfolio.savings.DepositsApiConstants.closedOnD import java.util.Collection; import org.joda.time.LocalDate; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService; import org.mifosplatform.infrastructure.core.api.JsonQuery; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper; -import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.mifosplatform.portfolio.savings.DepositAccountOnClosureType; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.data.DepositAccountData; @@ -43,19 +43,21 @@ public class DepositAccountPreMatureCalculationPlatformServiceImpl implements De private final CodeValueReadPlatformService codeValueReadPlatformService; private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; private final ConfigurationDomainService configurationDomainService; + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public DepositAccountPreMatureCalculationPlatformServiceImpl(final FromJsonHelper fromJsonHelper, final DepositAccountTransactionDataValidator depositAccountTransactionDataValidator, final DepositAccountAssembler depositAccountAssembler, final CodeValueReadPlatformService codeValueReadPlatformService, final SavingsAccountReadPlatformService savingsAccountReadPlatformService, - final ConfigurationDomainService configurationDomainService) { + final ConfigurationDomainService configurationDomainService, PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.fromJsonHelper = fromJsonHelper; this.depositAccountTransactionDataValidator = depositAccountTransactionDataValidator; this.depositAccountAssembler = depositAccountAssembler; this.codeValueReadPlatformService = codeValueReadPlatformService; this.savingsAccountReadPlatformService = savingsAccountReadPlatformService; this.configurationDomainService = configurationDomainService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } @@ -63,12 +65,11 @@ public class DepositAccountPreMatureCalculationPlatformServiceImpl implements De @Override public DepositAccountData calculatePreMatureAmount(final Long accountId, final JsonQuery query, final DepositAccountType depositAccountType) { - - final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService - .isSavingsInterestPostingAtCurrentPeriodEnd(); - final Integer financialYearBeginningMonth = this.configurationDomainService - .retrieveFinancialYearBeginningMonth(); - + + final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService + .isSavingsInterestPostingAtCurrentPeriodEnd(); + final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth(); + this.depositAccountTransactionDataValidator.validatePreMatureAmountCalculation(query.json(), depositAccountType); final SavingsAccount account = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType); @@ -76,8 +77,7 @@ public class DepositAccountPreMatureCalculationPlatformServiceImpl implements De Collection onAccountClosureOptions = SavingsEnumerations .depositAccountOnClosureType(new DepositAccountOnClosureType[] { DepositAccountOnClosureType.WITHDRAW_DEPOSIT, DepositAccountOnClosureType.TRANSFER_TO_SAVINGS }); - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); final Collection savingsAccountDatas = this.savingsAccountReadPlatformService.retrieveActiveForLookup( account.clientId(), DepositAccountType.SAVINGS_DEPOSIT); final JsonElement element = this.fromJsonHelper.parse(query.json()); @@ -88,16 +88,14 @@ public class DepositAccountPreMatureCalculationPlatformServiceImpl implements De if (depositAccountType.isFixedDeposit()) { final FixedDepositAccount fd = (FixedDepositAccount) account; - accountData = FixedDepositAccountData.preClosureDetails(account.getId(), - fd.calculatePreMatureAmount(interestCalculatedToDate, isPreMatureClosure, - isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth), - onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas); + accountData = FixedDepositAccountData.preClosureDetails(account.getId(), fd.calculatePreMatureAmount(interestCalculatedToDate, + isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth), onAccountClosureOptions, + paymentTypeOptions, savingsAccountDatas); } else if (depositAccountType.isRecurringDeposit()) { final RecurringDepositAccount rd = (RecurringDepositAccount) account; - accountData = RecurringDepositAccountData.preClosureDetails(account.getId(), - rd.calculatePreMatureAmount(interestCalculatedToDate, isPreMatureClosure, - isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth), - onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas); + accountData = RecurringDepositAccountData.preClosureDetails(account.getId(), rd.calculatePreMatureAmount( + interestCalculatedToDate, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth), + onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas); } return accountData; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java index 42629583a..42091cf67 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/DepositAccountReadPlatformServiceImpl.java @@ -15,7 +15,6 @@ import java.util.Map; import org.joda.time.LocalDate; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.core.data.PaginationParameters; @@ -51,6 +50,8 @@ import org.mifosplatform.portfolio.interestratechart.data.InterestRateChartData; import org.mifosplatform.portfolio.interestratechart.service.InterestRateChartReadPlatformService; import org.mifosplatform.portfolio.paymentdetail.PaymentDetailConstants; import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; +import org.mifosplatform.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.mifosplatform.portfolio.savings.DepositAccountOnClosureType; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.DepositsApiConstants; @@ -109,6 +110,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead private final DropdownReadPlatformService dropdownReadPlatformService; private final CalendarReadPlatformService calendarReadPlatformService; private final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); + private final PaymentTypeReadPlatformService paymentTypeReadPlatformService; @Autowired public DepositAccountReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource, @@ -122,7 +124,8 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead final InterestRateChartReadPlatformService productChartReadPlatformService, final CodeValueReadPlatformService codeValueReadPlatformService, final SavingsAccountReadPlatformService savingsAccountReadPlatformService, - final DropdownReadPlatformService dropdownReadPlatformService, final CalendarReadPlatformService calendarReadPlatformService) { + final DropdownReadPlatformService dropdownReadPlatformService, final CalendarReadPlatformService calendarReadPlatformService, + PaymentTypeReadPlatformService paymentTypeReadPlatformService) { this.context = context; this.jdbcTemplate = new JdbcTemplate(dataSource); this.accountChartReadPlatformService = chartReadPlatformService; @@ -141,6 +144,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead this.rdTransactionTemplateMapper = new RecurringAccountDepositTransactionTemplateMapper(); this.dropdownReadPlatformService = dropdownReadPlatformService; this.calendarReadPlatformService = calendarReadPlatformService; + this.paymentTypeReadPlatformService = paymentTypeReadPlatformService; } @Override @@ -250,8 +254,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead accountId, depositAccountType.getValue() }); Collection onAccountClosureOptions = SavingsEnumerations .depositAccountOnClosureType(DepositAccountOnClosureType.values()); - final Collection paymentTypeOptions = this.codeValueReadPlatformService - .retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName); + final Collection paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes(); final Collection savingsAccountDatas = this.savingsAccountReadPlatformService.retrieveActiveForLookup( account.clientId(), DepositAccountType.SAVINGS_DEPOSIT); if (depositAccountType.isFixedDeposit()) { @@ -941,20 +944,20 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead sqlBuilder.append("totran.transaction_date as toTransferDate, totran.amount as toTransferAmount,"); sqlBuilder.append("totran.description as toTransferDescription,"); sqlBuilder.append("sa.id as savingsId, sa.account_no as accountNo,"); - sqlBuilder.append("pd.payment_type_cv_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, "); + sqlBuilder.append("pd.payment_type_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, "); sqlBuilder.append("pd.receipt_number as receiptNumber, pd.bank_number as bankNumber,pd.routing_code as routingCode, "); sqlBuilder .append("sa.currency_code as currencyCode, sa.currency_digits as currencyDigits, sa.currency_multiplesof as inMultiplesOf, "); sqlBuilder.append("curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, "); sqlBuilder.append("curr.display_symbol as currencyDisplaySymbol, "); - sqlBuilder.append("cv.code_value as paymentTypeName "); + sqlBuilder.append("pt.value as paymentTypeName "); sqlBuilder.append("from m_savings_account sa "); sqlBuilder.append("join m_savings_account_transaction tr on tr.savings_account_id = sa.id "); sqlBuilder.append("join m_currency curr on curr.code = sa.currency_code "); sqlBuilder.append("left join m_account_transfer_transaction fromtran on fromtran.from_savings_transaction_id = tr.id "); sqlBuilder.append("left join m_account_transfer_transaction totran on totran.to_savings_transaction_id = tr.id "); sqlBuilder.append("left join m_payment_detail pd on tr.payment_detail_id = pd.id "); - sqlBuilder.append("left join m_code_value cv on pd.payment_type_cv_id = cv.id "); + sqlBuilder.append("left join m_payment_type pt on pd.payment_type_id = pt.id "); this.schemaSql = sqlBuilder.toString(); } @@ -982,7 +985,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentType"); if (paymentTypeId != null) { final String typeName = rs.getString("paymentTypeName"); - final CodeValueData paymentType = CodeValueData.instance(paymentTypeId, typeName); + final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName); final String accountNumber = rs.getString("accountNumber"); final String checkNumber = rs.getString("checkNumber"); final String routingCode = rs.getString("routingCode"); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java index d3decb6c7..0739b8fd1 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java @@ -14,13 +14,13 @@ import java.util.Collection; import org.apache.commons.lang.StringUtils; import org.joda.time.LocalDate; -import org.mifosplatform.infrastructure.codes.data.CodeValueData; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.core.domain.JdbcSupport; import org.mifosplatform.infrastructure.core.service.DateUtils; import org.mifosplatform.infrastructure.core.service.Page; import org.mifosplatform.infrastructure.core.service.PaginationHelper; import org.mifosplatform.infrastructure.core.service.RoutingDataSource; +import org.mifosplatform.infrastructure.core.service.SearchParameters; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.organisation.staff.data.StaffData; @@ -32,8 +32,8 @@ import org.mifosplatform.portfolio.client.data.ClientData; import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; import org.mifosplatform.portfolio.group.data.GroupGeneralData; import org.mifosplatform.portfolio.group.service.GroupReadPlatformService; -import org.mifosplatform.infrastructure.core.service.SearchParameters; import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData; +import org.mifosplatform.portfolio.paymenttype.data.PaymentTypeData; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType; import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType; @@ -660,20 +660,20 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead sqlBuilder.append("totran.transaction_date as toTransferDate, totran.amount as toTransferAmount,"); sqlBuilder.append("totran.description as toTransferDescription,"); sqlBuilder.append("sa.id as savingsId, sa.account_no as accountNo,"); - sqlBuilder.append("pd.payment_type_cv_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, "); + sqlBuilder.append("pd.payment_type_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, "); sqlBuilder.append("pd.receipt_number as receiptNumber, pd.bank_number as bankNumber,pd.routing_code as routingCode, "); sqlBuilder .append("sa.currency_code as currencyCode, sa.currency_digits as currencyDigits, sa.currency_multiplesof as inMultiplesOf, "); sqlBuilder.append("curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, "); sqlBuilder.append("curr.display_symbol as currencyDisplaySymbol, "); - sqlBuilder.append("cv.code_value as paymentTypeName "); + sqlBuilder.append("pt.value as paymentTypeName "); sqlBuilder.append("from m_savings_account sa "); sqlBuilder.append("join m_savings_account_transaction tr on tr.savings_account_id = sa.id "); sqlBuilder.append("join m_currency curr on curr.code = sa.currency_code "); sqlBuilder.append("left join m_account_transfer_transaction fromtran on fromtran.from_savings_transaction_id = tr.id "); sqlBuilder.append("left join m_account_transfer_transaction totran on totran.to_savings_transaction_id = tr.id "); sqlBuilder.append("left join m_payment_detail pd on tr.payment_detail_id = pd.id "); - sqlBuilder.append("left join m_code_value cv on pd.payment_type_cv_id = cv.id "); + sqlBuilder.append("left join m_payment_type pt on pd.payment_type_id = pt.id "); this.schemaSql = sqlBuilder.toString(); } @@ -702,7 +702,7 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead final Long paymentTypeId = JdbcSupport.getLong(rs, "paymentType"); if (paymentTypeId != null) { final String typeName = rs.getString("paymentTypeName"); - final CodeValueData paymentType = CodeValueData.instance(paymentTypeId, typeName); + final PaymentTypeData paymentType = PaymentTypeData.instance(paymentTypeId, typeName); final String accountNumber = rs.getString("accountNumber"); final String checkNumber = rs.getString("checkNumber"); final String routingCode = rs.getString("routingCode"); diff --git a/mifosng-provider/src/main/resources/sql/migrations/core_db/V249__paymentType_table.sql b/mifosng-provider/src/main/resources/sql/migrations/core_db/V249__paymentType_table.sql new file mode 100644 index 000000000..7d6a49814 --- /dev/null +++ b/mifosng-provider/src/main/resources/sql/migrations/core_db/V249__paymentType_table.sql @@ -0,0 +1,46 @@ +CREATE TABLE `m_payment_type` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `value` VARCHAR(100) NULL DEFAULT NULL, + `description` VARCHAR(500) NULL DEFAULT NULL, + `is_cash_payment` TINYINT(1) NULL DEFAULT '0', + `order_position` INT(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) +COLLATE='utf8_general_ci'; + +INSERT INTO m_payment_type (id,value,description,order_position) +SELECT id,code_value,code_description,order_position +FROM m_code_value +where code_id in +(select mc.id +from m_code mc where mc.code_name='PaymentType' +); + +ALTER TABLE `m_payment_detail` + DROP FOREIGN KEY `FK_m_payment_detail_m_code_value`; + +ALTER TABLE `m_payment_detail` + CHANGE COLUMN `payment_type_cv_id` `payment_type_id` INT(11) NULL DEFAULT NULL AFTER `id`; + +ALTER TABLE `m_payment_detail` + ADD CONSTRAINT `FK_m_payment_detail_m_payment_type` FOREIGN KEY (`payment_type_id`) REFERENCES `m_payment_type` (`id`); + +ALTER TABLE `acc_product_mapping` + DROP FOREIGN KEY `FK_acc_product_mapping_m_code_value`; + +ALTER TABLE `acc_product_mapping` + ADD CONSTRAINT `FK_acc_product_mapping_m_payment_type` FOREIGN KEY (`payment_type`) REFERENCES `m_payment_type` (`id`); + +DELETE from m_code_value +WHERE +m_code_value.code_id in +(SELECT mc.id +FROM m_code mc where mc.code_name='PaymentType' ); + +DELETE FROM m_code WHERE code_name="PaymentType"; + +INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'CREATE_PAYMENTTYPE', 'PAYMENTTYPE', 'CREATE', 0); + +INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'UPDATE_PAYMENTTYPE', 'PAYMENTTYPE', 'UPDATE', 0); + +INSERT INTO `m_permission` (`grouping`, `code`, `entity_name`, `action_name`, `can_maker_checker`) VALUES ('portfolio', 'DELETE_PAYMENTTYPE', 'PAYMENTTYPE', 'DELETE', 0);