Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #164

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
8 changes: 8 additions & 0 deletions reference-adapter/mgramseva-ifix-adapter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog
All notable changes to this module will be documented in this file.

## 2.1.0 - 2022-09-14

- It runs quartz cron job for regular event (PSPCL) check on fiscal event service.
- After event (PSPCL) collection.
- It reaches to mgramseva echallan service for challan creation.
- It updates payment status by collection service.
- It updates every event(PSPCL) status into table.

## 2.0.1 - 2022-05-11
- Fixed EventTime mapping in the Event Mapper

Expand Down
2 changes: 1 addition & 1 deletion reference-adapter/mgramseva-ifix-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.egov.ifix</groupId>
<artifactId>mgramseva-ifix-adapter</artifactId>
<version>2.0.1</version>
<version>2.1.0</version>

<parent>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -108,7 +107,7 @@ private List<Amount> getAmounts(JsonObject payment, JsonObject data) {
String coaCode = billAccountDetailsJO.get(PAYMENT_RECEIPT_CLIENT_COA_CODE).getAsString();

Amount amount = Amount.builder()
.amount(billAccountDetailsJO.get(PAYMENT_RECEIPT_CLIENT_COA_AMOUNT).getAsBigDecimal())
.amount(billAccountDetailsJO.get(PAYMENT_RECEIPT_CLIENT_COA_ADJUSTED_AMOUNT).getAsBigDecimal())
.coaCode(chartOfAccountService.getResolvedChartOfAccountCode(coaCode))
.fromBillingPeriod(taxPeriodFrom)
.toBillingPeriod(taxPeriodTo).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.Instant;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -107,17 +108,35 @@ private List<Amount> getAmountDetails(JsonObject payment, JsonObject data) {
JsonObject billAccountDetailsJB = billAccountDetailsJE.getAsJsonObject();
String coaCode = billAccountDetailsJB.get(PAYMENT_RECEIPT_CLIENT_COA_CODE).getAsString();

Amount amount = Amount.builder()
.amount(billAccountDetailsJB.get(PAYMENT_RECEIPT_CLIENT_COA_AMOUNT).getAsBigDecimal())
.coaCode(chartOfAccountService.getResolvedChartOfAccountCode(coaCode))
.fromBillingPeriod(taxPeriodFrom)
.toBillingPeriod(taxPeriodTo).build();
BigDecimal calculatedAmount = getBillAccountDetailAmount(coaCode, billAccountDetailsJB);

amountList.add(amount);
if (new BigDecimal(0).compareTo(calculatedAmount) != 0) {

Amount amount = Amount.builder()
.amount(calculatedAmount)
.coaCode(chartOfAccountService.getResolvedChartOfAccountCode(coaCode))
.fromBillingPeriod(taxPeriodFrom)
.toBillingPeriod(taxPeriodTo).build();

amountList.add(amount);
}
});
});
}

return amountList;
}

/**
* @param taxHeadCode
* @param billAccountDetailsJB
* @return
*/
private BigDecimal getBillAccountDetailAmount(@NotNull String taxHeadCode, @NotNull JsonObject billAccountDetailsJB) {
if (taxHeadCode.contains(ADVANCE_TAX_HEAD_CODE_SUBSTRING)) {
return billAccountDetailsJB.get(PAYMENT_RECEIPT_CLIENT_COA_AMOUNT).getAsBigDecimal();
}else {
return billAccountDetailsJB.get(PAYMENT_RECEIPT_CLIENT_COA_ADJUSTED_AMOUNT).getAsBigDecimal();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public FiscalEventResponseDTO collectFiscalEvent(String receivers, String eventT
private FiscalEventSearchRequestDTO wrapFiscalEventSearchRequest(String receiver, String eventType) {
FiscalEventSearchRequestDTO fiscalEventSearchRequestDTO = new FiscalEventSearchRequestDTO();

Long intervalTimeInMilliSecond = dataWrapper.getValidSearchIntervalTime();
Long intervalTimeInMilliSecond = dataWrapper.translateCronExpressionIntoMilliSecond();

Long toIngestionTime = System.currentTimeMillis();
Long fromIngestionTime = toIngestionTime - intervalTimeInMilliSecond;
Expand All @@ -107,7 +107,7 @@ public List<FiscalEvent> resolveDuplicateEvent(List<FiscalEvent> fiscalEventList
List<FiscalEvent> filteredFiscalEvent = new ArrayList<>();

if (fiscalEventList != null && !fiscalEventList.isEmpty()) {
Long intervalTimeInMilliSecond = dataWrapper.getValidSearchIntervalTime();
Long intervalTimeInMilliSecond = dataWrapper.translateCronExpressionIntoMilliSecond();
long endTime = System.currentTimeMillis();
long startTime = endTime - intervalTimeInMilliSecond;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private Optional<String> getDepartmentEntityCode(FiscalEvent fiscalEvent) {
"PSPCL account number is missing from attributes section of fiscal event");
throw new GenericCustomException(PSPCL, "PSPCL account number is missing from attributes section");
} else {
return objectNodeAttribute.get("pspclAccountNumber").asText();
return StringUtils.trimAllWhitespace(objectNodeAttribute.get("pspclAccountNumber").asText());
}
} catch (JsonProcessingException e) {
pspclEventPersistenceService.saveFailedPspclEventDetail(NA, NA, NA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public class ApplicationConfiguration {
@Value("${pspcl.ifix.event.receiver.name}")
private String pspclIfixEventReceiverName;

@Value("${ifix.fiscal.event.search.time.interval.minutes}")
private String ifixFiscalEventSearchTimeIntervalMinutes;
@Value("${ifix.fiscal.event.search.time.overlap.minutes}")
private String ifixFiscalEventSearchTimeOverlapMinutes;

@Value("${adapter.master.data.host}")
private String adapterMasterDataHost;
Expand Down Expand Up @@ -164,4 +164,7 @@ public class ApplicationConfiguration {
@Value("${vendor.owner.locality.code}")
private String vendorOwnerLocalityCode;

@Value("${samplejob.frequency}")
private String sampleJobFrequency;

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
import org.egov.ifix.models.ErrorDataModel;
import org.egov.ifix.models.FiscalEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.scheduling.support.CronSequenceGenerator;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotNull;
import java.time.Duration;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -87,17 +93,59 @@ public String getFiscalEventDetailsInformation(List<FiscalEvent> fiscalEventList
}

/**
* @return
* It calculates time from cron job expression <strong>samplejob.frequency</strong>.
* It also check expression length - which is strict 6.
* It does not throw exception in case of length is greater 6.
*
* @return it returns in millisecond with additional overlap minutes.
*/
public Long getValidSearchIntervalTime() {
String plainTime = applicationConfiguration.getIfixFiscalEventSearchTimeIntervalMinutes();
public @NotNull Long translateCronExpressionIntoMilliSecond() {
String plainTime = applicationConfiguration.getIfixFiscalEventSearchTimeOverlapMinutes();

if (!org.apache.commons.lang3.StringUtils.isNumeric(plainTime)) {
log.error(">>>>> Ifix fiscal event search interval time value is invalid");
throw new GenericCustomException(TIME, "Ifix fiscal event search interval time value is invalid");
log.error(">>>>> Ifix fiscal event search overlap time value is invalid");
throw new GenericCustomException(TIME, "Ifix fiscal event search overlap time value is invalid");
}else {
return Long.parseLong(plainTime) * 60 * 1000;
Long overlapTime = Long.parseLong(plainTime) * 60 * 1000;

String cronExpression = getValidatedCronExpression(applicationConfiguration.getSampleJobFrequency());

CronSequenceGenerator generator = new CronSequenceGenerator(cronExpression);
Date nextRunTime = generator.next(new Date());

Date nextToNextExecution = generator.next(nextRunTime);
Duration durationBetweenExecutions = Duration.between(nextRunTime.toInstant(),
nextToNextExecution.toInstant());

return durationBetweenExecutions.toMillis() + overlapTime;
}
}


/**
* @param expression It can't be null, before breaking this condition cron job will crash.
* @return
*/
private String getValidatedCronExpression(@NonNull String expression) {
StringBuilder cronExpBuilder = new StringBuilder();
String[] fields = StringUtils.tokenizeToStringArray(expression, " ");

if (fields.length > 6) {
log.warn(">>>>> Cron expression elements are more than six and we are considering only six element other " +
"elements will be ignored");

for (int expIndex = 0; expIndex < fields.length - 1; expIndex++) {
if (expIndex < 5) {
cronExpBuilder = cronExpBuilder.append(fields[expIndex] + " ");
}else {
cronExpBuilder = cronExpBuilder.append(fields[expIndex]);
}
}
}else {
cronExpBuilder = cronExpBuilder.append(expression);
}

return cronExpBuilder.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public class EventConstants {
public static final String PAYMENT_RECEIPT_TRANSACTION_DATE = "transactionDate";
public static final String PAYMENT_RECEIPT_FROM_BILLING_PERIOD = "fromPeriod";
public static final String PAYMENT_RECEIPT_TO_BILLING_PERIOD = "toPeriod";
public static final String PAYMENT_RECEIPT_CLIENT_COA_AMOUNT = "adjustedAmount";
public static final String PAYMENT_RECEIPT_CLIENT_COA_ADJUSTED_AMOUNT = "adjustedAmount";
public static final String PAYMENT_RECEIPT_CLIENT_COA_AMOUNT = "amount";
public static final String BILL_ACCOUNT_DETAILS = "billAccountDetails";
public static final String PAYMENT_RECEIPT_CLIENT_COA_CODE = "taxHeadCode";
public static final String CONSUMER_CODE = "consumerCode";
Expand Down Expand Up @@ -88,5 +89,6 @@ public class EventConstants {
public static final String CLIENT_SECRET = "client_secret";
public static final String CLIENT_ID = "client_id";
public static final String OWNER_ROLE_CITIZEN = "CITIZEN";
public static final String ADVANCE_TAX_HEAD_CODE_SUBSTRING = "ADVANCE";

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ifix.department.entity.search.path=/departmentEntity/v1/_search
pspcl.ifix.event.receiver.name=mgramseva-qa

#Value in seconds
ifix.fiscal.event.search.time.interval.minutes=10
ifix.fiscal.event.search.time.overlap.minutes=15


#------------------------------------------------------
Expand Down
16 changes: 16 additions & 0 deletions reference-adapter/pspcl-ifix-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>6.4.3</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.69</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.5.0</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package client.stub;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@AllArgsConstructor
@NoArgsConstructor
@Setter
@Getter
public class BillResultData {
@JsonProperty("ACNO")
private String accountNumber;

@JsonProperty("CNAME")
private String cosumerName;

@JsonProperty("MBNO")
private String mobileNumber;

@JsonProperty("EMAIL")
private String email;

@JsonProperty("ADDRESS")
private String address;

@JsonProperty("SUBDIVISION")
private String subDivision;

@JsonProperty("DIVISION")
private String division;

@JsonProperty("CIRCLE")
private String circle;

@JsonProperty("BILLNO")
private String billNumber;

@JsonProperty("BILLCYC")
private String billCycle;

@JsonProperty("BILISSDT")
private String billIssueDate;

@JsonProperty("BILLCAT")
private String tariffType;


@JsonProperty("DUEDTCASH")
private String dueDateByCash;


@JsonProperty("DUEDTCHQ")
private String dueDateByCheque;


@JsonProperty("DUEAMOUNT")
private String dueAmount;

@JsonProperty("SURCHARGE")
private String surCharge;


@JsonProperty("GROSSAMOUNT")
private String grossAmount;

@JsonProperty("SANCTIONEDLOAD")
private String sanctionLoad;

@JsonProperty("CONSUMEDUNITS")
private String cosumedUnit;

}
Loading