MIFOSX-60 API template method for loan charges
This commit is contained in:
committed by
Keith Woodlock
parent
1f8b325258
commit
9e25b070fb
@@ -498,6 +498,21 @@ public class LoansApiResource {
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{loanId}/charges/template")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveNewLoanChargeDetails(@Context final UriInfo uriInfo) {
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<ChargeData> chargeOptions = this.chargeReadPlatformService.retrieveLoanApplicableCharges();
|
||||
LoanChargeData loanChargeTemplate = LoanChargeData.template(chargeOptions);
|
||||
|
||||
return this.apiJsonSerializerService.serializeLoanChargeDataToJson(prettyPrint, responseParameters, loanChargeTemplate);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{loanId}/charges/{chargeId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Immutable data object for loan charge data.
|
||||
@@ -17,6 +18,12 @@ public class LoanChargeData {
|
||||
private final EnumOptionData chargeTimeType;
|
||||
private final EnumOptionData chargeCalculationType;
|
||||
|
||||
private final Collection<ChargeData> chargeOptions;
|
||||
|
||||
public static LoanChargeData template(final Collection<ChargeData> chargeOptions){
|
||||
return new LoanChargeData(null,null,null,null,null,null,null, chargeOptions);
|
||||
}
|
||||
|
||||
public LoanChargeData(Long id, Long chargeId, String name, CurrencyData currency, BigDecimal amount,
|
||||
EnumOptionData chargeTimeType, EnumOptionData chargeCalculationType) {
|
||||
this.id = id;
|
||||
@@ -26,6 +33,21 @@ public class LoanChargeData {
|
||||
this.amount = amount;
|
||||
this.chargeTimeType = chargeTimeType;
|
||||
this.chargeCalculationType = chargeCalculationType;
|
||||
|
||||
this.chargeOptions = null;
|
||||
}
|
||||
|
||||
public LoanChargeData(Long id, Long chargeId, String name, CurrencyData currency, BigDecimal amount,
|
||||
EnumOptionData chargeTimeType, EnumOptionData chargeCalculationType,
|
||||
Collection<ChargeData> chargeOptions) {
|
||||
this.id = id;
|
||||
this.chargeId = chargeId;
|
||||
this.name = name;
|
||||
this.currency = currency;
|
||||
this.amount = amount;
|
||||
this.chargeTimeType = chargeTimeType;
|
||||
this.chargeCalculationType = chargeCalculationType;
|
||||
this.chargeOptions = chargeOptions;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
|
||||
+3
@@ -19,6 +19,7 @@ import org.mifosng.platform.api.data.FundData;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.data.GroupData;
|
||||
import org.mifosng.platform.api.data.LoanAccountData;
|
||||
import org.mifosng.platform.api.data.LoanChargeData;
|
||||
import org.mifosng.platform.api.data.LoanProductData;
|
||||
import org.mifosng.platform.api.data.LoanTransactionData;
|
||||
import org.mifosng.platform.api.data.NoteData;
|
||||
@@ -103,6 +104,8 @@ public interface ApiJsonSerializerService {
|
||||
|
||||
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, ChargeData charge);
|
||||
|
||||
String serializeLoanChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanChargeData charge);
|
||||
|
||||
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, StaffData staff);
|
||||
|
||||
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<StaffData> staff);
|
||||
|
||||
+14
-1
@@ -21,6 +21,7 @@ import org.mifosng.platform.api.data.FundData;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.data.GroupData;
|
||||
import org.mifosng.platform.api.data.LoanAccountData;
|
||||
import org.mifosng.platform.api.data.LoanChargeData;
|
||||
import org.mifosng.platform.api.data.LoanProductData;
|
||||
import org.mifosng.platform.api.data.LoanTransactionData;
|
||||
import org.mifosng.platform.api.data.NoteData;
|
||||
@@ -169,6 +170,9 @@ public class GoogleGsonApiJsonSerializerService implements ApiJsonSerializerServ
|
||||
"chargeCalculationType", "chargeCalculationTypeOptions",
|
||||
"chargeAppliesToOptions", "chargeTimeTypeOptions", "currencyOptions"));
|
||||
|
||||
private static final Set<String> LOAN_CHARGES_DATA_PARAMETERS = new HashSet<String>(
|
||||
Arrays.asList("chargeOptions"));
|
||||
|
||||
private final GoogleGsonSerializerHelper helper;
|
||||
|
||||
@Autowired
|
||||
@@ -549,7 +553,16 @@ public class GoogleGsonApiJsonSerializerService implements ApiJsonSerializerServ
|
||||
return helper.serializedJsonFrom(gsonDeserializer, charge);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String serializeLoanChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanChargeData charge) {
|
||||
final Gson gsonDeserializer = helper
|
||||
.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||
LOAN_CHARGES_DATA_PARAMETERS, prettyPrint,
|
||||
responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, charge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeStaffDataToJson(boolean prettyPrint,
|
||||
Set<String> responseParameters, StaffData staff) {
|
||||
final Gson gsonDeserializer = helper
|
||||
|
||||
Reference in New Issue
Block a user