Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
ISTE-44: added master map to outside call
Browse files Browse the repository at this point in the history
  • Loading branch information
debasishchakraborty-egovt committed Jun 7, 2024
1 parent f323cc9 commit c301ef0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,10 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t

public void generateDemandInBulk(CalculationReq calculationReq, String billingCycle, Map<String, Object> masterMap,
boolean isSendMessage,String tenantId) {
Map<String, Object> masterMapDemand = (Map<String, Object>) masterMap;
log.info("masterMap:"+masterMap);
try {
if(!tenantId.equals(config.getSmsExcludeTenant())) {
generateDemandInBatch(calculationReq, masterMapDemand, billingCycle, isSendMessage);
generateDemandInBatch(calculationReq, masterMap, billingCycle, isSendMessage);
}

} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Map<String, List> getEstimationMap(CalculationCriteria criteria, RequestI
ArrayList<String> billingSlabIds = new ArrayList<>();
log.info("masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER):"+masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER));
log.info("masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST)" +masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST));
/*// Convert and assign WC_BILLING_SLAB_MASTER
// Convert and assign WC_BILLING_SLAB_MASTER
ArrayList<String> wcBillingSlabList = (ArrayList<String>) masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER);
JSONArray wcBillingSlabArray = new JSONArray();
wcBillingSlabArray.addAll(wcBillingSlabList);
Expand All @@ -89,12 +89,12 @@ public Map<String, List> getEstimationMap(CalculationCriteria criteria, RequestI
ArrayList<String> calculationAttributeList = (ArrayList<String>) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST);
JSONArray calculationAttributeArray = new JSONArray();
calculationAttributeArray.addAll(calculationAttributeList);
billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, calculationAttributeArray);*/
billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST, calculationAttributeArray);

billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER,
/*billingSlabMaster.put(WSCalculationConstant.WC_BILLING_SLAB_MASTER,
(JSONArray) masterData.get(WSCalculationConstant.WC_BILLING_SLAB_MASTER));
billingSlabMaster.put(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST,
(JSONArray) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST));
(JSONArray) masterData.get(WSCalculationConstant.CALCULATION_ATTRIBUTE_CONST));*/
// timeBasedExemptionMasterMap.put(WSCalculationConstant.WC_WATER_CESS_MASTER,
// (JSONArray) (masterData.getOrDefault(WSCalculationConstant.WC_WATER_CESS_MASTER, null)));
// mDataService.setWaterConnectionMasterValues(requestInfo, tenantId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.Map;
import java.util.stream.Collectors;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.egov.common.contract.request.RequestInfo;
import org.egov.common.contract.request.User;
import org.egov.mdms.model.MdmsCriteriaReq;
Expand Down Expand Up @@ -73,6 +75,9 @@ public class WSCalculationServiceImpl implements WSCalculationService {
@Autowired
private DemandAuditSeqBuilder demandAuditSeqBuilder;

@Autowired
ObjectMapper mapper;

/**
* Get CalculationReq and Calculate the Tax Head on Water Charge And Estimation Charge
*/
Expand Down Expand Up @@ -196,10 +201,28 @@ public Calculation getCalculation(RequestInfo requestInfo, CalculationCriteria c

String tenantId = null != property.getTenantId() ? property.getTenantId() : criteria.getTenantId();

@SuppressWarnings("unchecked")
Map<String, TaxHeadCategory> taxHeadCategoryMap = ((List<TaxHeadMaster>) masterMap

/*Map<String, TaxHeadCategory> taxHeadCategoryMap = ((List<TaxHeadMaster>) masterMap
.get(WSCalculationConstant.TAXHEADMASTER_MASTER_KEY)).stream()
.collect(Collectors.toMap(TaxHeadMaster::getCode, TaxHeadMaster::getCategory, (OldValue, NewValue) -> NewValue));
.collect(Collectors.toMap(TaxHeadMaster::getCode, TaxHeadMaster::getCategory, (OldValue, NewValue) -> NewValue));*
*/
Map<String, TaxHeadCategory> taxHeadCategoryMap;
try {
// Deserialize the list
List<TaxHeadMaster> taxHeadMasters = mapper.convertValue(
masterMap.get(WSCalculationConstant.TAXHEADMASTER_MASTER_KEY),
new TypeReference<List<TaxHeadMaster>>() {}
);
// Convert to Map
taxHeadCategoryMap = taxHeadMasters.stream()
.collect(Collectors.toMap(TaxHeadMaster::getCode, TaxHeadMaster::getCategory, (oldValue, newValue) -> newValue));
// Output for verification
System.out.println(taxHeadCategoryMap);
} catch (Exception e) {
e.printStackTrace();
throw new CustomException();
}

BigDecimal taxAmt = BigDecimal.ZERO;
BigDecimal waterCharge = BigDecimal.ZERO;
Expand Down Expand Up @@ -256,10 +279,12 @@ public Calculation getCalculation(RequestInfo requestInfo, CalculationCriteria c
}

BigDecimal totalAmount = taxAmt.add(penalty).add(rebate).add(exemption).add(waterCharge).add(fee).add(advance);

return Calculation.builder().totalAmount(totalAmount).taxAmount(taxAmt).penalty(penalty).exemption(exemption)
.charge(waterCharge).advance(advance).fee(fee).waterConnection(waterConnection).rebate(rebate).tenantId(tenantId)
.taxHeadEstimates(estimates).billingSlabIds(billingSlabIds).connectionNo(criteria.getConnectionNo()).applicationNO(criteria.getApplicationNo())
.build();

}


Expand All @@ -273,7 +298,7 @@ List<Calculation> getCalculations(CalculationReq request, Map<String, Object> ma
List<Calculation> calculations = new ArrayList<>(request.getCalculationCriteria().size());
for (CalculationCriteria criteria : request.getCalculationCriteria()) {
Map<String, List> estimationMap = null;
log.info("Innside get Calculation");
log.info("Innside get Calculationn");
if(request.getIsAdvanceCalculation() == null || (!request.getIsAdvanceCalculation().booleanValue())) {
estimationMap = estimationService.getEstimationMap(criteria, request.getRequestInfo(),
masterMap,request.getIsconnectionCalculation(),false);
Expand Down

0 comments on commit c301ef0

Please sign in to comment.