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

Develop #600

Merged
merged 31 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e5a404e
PFM-4640
rahuldevgarg Sep 26, 2023
f36c3ee
PFM-4592
rahuldevgarg Sep 26, 2023
a0dc6aa
PFM-4589
rahuldevgarg Sep 27, 2023
f2a408a
PFM-4592
rahuldevgarg Sep 27, 2023
3f6927c
PFM-4793
rahuldevgarg Sep 27, 2023
1740e16
PFM-4408 Payment date is not reflecting
Saloni-eGov Oct 4, 2023
8916f0f
Merge pull request #587 from egovernments/PFM-4114
Ramkrishna-egov Oct 4, 2023
56e19d1
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 5, 2023
2eeec6c
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 5, 2023
d471c7d
PFM-4871: added chnnages for concerened service that are sending SMS …
Oct 5, 2023
4fe1ac9
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 5, 2023
ead650d
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 5, 2023
1ccdb4e
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 5, 2023
fe1b344
Merge pull request #589 from egovernments/PFM-4871
pradeepkumarcm-egov Oct 5, 2023
f9818bc
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 6, 2023
2153189
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 6, 2023
8d6abf9
Merge pull request #592 from egovernments/PFM-4871
pradeepkumarcm-egov Oct 6, 2023
16a1b53
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 6, 2023
6714da9
Merge pull request #594 from egovernments/PFM-4871
pradeepkumarcm-egov Oct 6, 2023
2f244bd
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 6, 2023
7e8eff7
Merge pull request #595 from egovernments/PFM-4871
debasishchakraborty-egovt Oct 6, 2023
0a5ea72
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 6, 2023
a2b31fd
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 6, 2023
2552179
Merge pull request #596 from egovernments/PFM-4871
pradeepkumarcm-egov Oct 6, 2023
6bae8da
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 6, 2023
2fac40e
Merge pull request #597 from egovernments/PFM-4871
debasishchakraborty-egovt Oct 6, 2023
d73b95d
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 6, 2023
68353fc
Merge pull request #598 from egovernments/PFM-4871
debasishchakraborty-egovt Oct 6, 2023
8658549
PFM-4871: added the changes to persist sms in a table in mgramseva
Oct 9, 2023
2512c87
Merge pull request #599 from egovernments/PFM-4871
debasishchakraborty-egovt Oct 9, 2023
9abdb9d
Update build-config.yml
debasishchakraborty-egovt Oct 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/build-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ config:
- work-dir: "core-services/egov-notification-sms"
image-name: "egov-notification-sms"
dockerfile: "build/maven/Dockerfile"
- work-dir: "core-services/egov-notification-sms/src/main/resources/db"
image-name: "egov-notification-sms-db"
- name: "builds/mGramSeva/utilities/mdms-read-cronjob"
build:
- work-dir: "utilities/mdms-read-cronjob"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ private void sendNotification(BillRequest billReq) {
Map<String, Object> request = new HashMap<>();
request.put("mobileNumber", phNo);
request.put("message", message);
request.put("tenantId", bill.getTenantId());
log.info("Msg sent to user : " + message);
if(isSmsForBillNotificationEnabled) {
producer.send(smsTopic, smsTopickey, request);
Expand Down
12 changes: 12 additions & 0 deletions core-services/egov-notification-sms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public class SMSProperties {
@Value("${sms.enabled:false}")
private boolean smsEnabled;

@Value("${save.sms.entity.topic}")
private String saveSmsTopic;

@Value("${save.sms.entity.enabled}")
private boolean isSaveSmsEnable;

@Setter(AccessLevel.PROTECTED) private List<Pattern> whitelistPatterns;
@Setter(AccessLevel.PROTECTED) private List<Pattern> blacklistPatterns;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public class SMSRequest {

public Sms toDomain() {
if (category == null) {
return new Sms(mobileNumber, message, Category.OTHERS, expiryTime,templateId);
return new Sms(mobileNumber, message, Category.OTHERS, expiryTime,templateId,null);

} else {
return new Sms(mobileNumber, message, category, expiryTime, templateId);
return new Sms(mobileNumber, message, category, expiryTime, templateId,tenantId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ResponseEntity<?> test(@RequestParam(value="number", required = true) Str

//Sms sms = new Sms(number, sms, Category.OTP, expirytime);

Sms sms = new Sms(number, msg, category, expirytime, "123");
Sms sms = new Sms(number, msg, category, expirytime, "123","pb");

smsService.sendSMS(sms);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Sms {
private Category category;
private Long expiryTime;
private String templateId;
private String tenantId;
public boolean isValid() {

return isNotEmpty(mobileNumber) && isNotEmpty(message);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.egov.web.notification.sms.models;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.ToString;

import static org.apache.commons.lang3.StringUtils.isNotEmpty;

@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
public class SmsSaveRequest {
private Long id;
private String mobileNumber;
private String message;
private Category category;
private Long createdtime;
private String templateId;
private String tenantId;
public boolean isValid() {

return isNotEmpty(mobileNumber) && isNotEmpty(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.egov.web.notification.sms.producer;

import lombok.extern.slf4j.Slf4j;
import org.egov.tracer.kafka.CustomKafkaTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class Producer {

@Autowired
private CustomKafkaTemplate<String, Object> kafkaTemplate;

public void push(String topic, Object value) {
kafkaTemplate.send(topic, value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.egov.web.notification.sms.repository.builder;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.jdbc.core.JdbcTemplate;

@Component
@Slf4j
@Repository
public class SmsNotificationRepository {

@Autowired
private JdbcTemplate jdbcTemplate;

public static final String SELECT_NEXT_SEQUENCE_USER = "select nextval('seq_eg_notification_sms')";

public Long getNextSequence() {
return jdbcTemplate.queryForObject(SELECT_NEXT_SEQUENCE_USER, Long.class);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.apache.http.impl.client.*;
import org.egov.web.notification.sms.config.*;
import org.egov.web.notification.sms.models.*;
import org.egov.web.notification.sms.producer.Producer;
import org.egov.web.notification.sms.repository.builder.SmsNotificationRepository;
import org.springframework.asm.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.core.*;
Expand Down Expand Up @@ -41,6 +43,12 @@ abstract public class BaseSMSService implements SMSService, SMSBodyBuilder {
@Autowired
protected Environment env;

@Autowired
private Producer producer;

@Autowired
private SmsNotificationRepository smsNotificationRepository;

@PostConstruct
public void init() {
List<HttpMessageConverter<?>> converters = restTemplate.getMessageConverters();
Expand Down Expand Up @@ -75,6 +83,14 @@ public void sendSMS(Sms sms) {
return;
}
log.info("calling submitToExternalSmsService() method");
if(smsProperties.isSaveSmsEnable()) {
Long id = smsNotificationRepository.getNextSequence();
String mobileNumber = sms.getMobileNumber();
mobileNumber = mobileNumber.substring(0, 2) + mobileNumber.substring(6);
SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().id(id).mobileNumber(mobileNumber).message(sms.getMessage())
.category(sms.getCategory()).templateId(sms.getTemplateId()).tenantId(sms.getTenantId()).createdtime(System.currentTimeMillis()).build();
producer.push(smsProperties.getSaveSmsTopic(), smsSaveRequest);
}
submitToExternalSmsService(sms);
}

Expand Down Expand Up @@ -128,7 +144,7 @@ protected <T> ResponseEntity<T> executeAPI(URI uri, HttpMethod method, HttpEntit
log.error("error response from third party api: info:"+responseMap.get("info"));
throw new RuntimeException(responseMap.get("info"));
}

log.info("executeAPI() end");
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ sms.extra.config.map={'extraParam': 'abc'}
# this should be the name of class with first letter in small
sms.url.dont_encode_url = true


# DB CONNECTION CONFIGURATIONS
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/devdb
spring.datasource.username=postgres
spring.datasource.password=postgres

# FLYWAY CONFIGURATIONS
flyway.url=jdbc:postgresql://localhost:5432/devdb
flyway.user=postgres
flyway.password=postgres
flyway.baseline-on-migrate=true
flyway.outOfOrder=true
flyway.locations=classpath:/db/migration/main
flyway.enabled=true
flyway.table=eg_notification_sms_schema

# KAFKA CONSUMER CONFIGURATIONS
spring.kafka.consumer.auto_commit=true
spring.kafka.consumer.auto_commit_interval=100
Expand Down Expand Up @@ -87,4 +104,8 @@ spring.kafka.consumer.properties.spring.deserializer.value.delegate.class=org.eg
#spring.kafka.consumer.properties.spring.deserializer.value.delegate.class=org.springframework.kafka.support.serializer.JsonDeserializer
spring.kafka.consumer.properties.spring.json.trusted.packages=org.egov
spring.kafka.consumer.properties.spring.json.type.mapping=smsRequest:org.egov.web.notification.sms.consumer.contract.SMSRequest
spring.kafka.listener.missing-topics-fatal=false
spring.kafka.listener.missing-topics-fatal=false

#persister topic of sms
save.sms.entity.topic = save-sms-entity-application
save.sms.entity.enabled = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM egovio/flyway:4.1.2

COPY ./migration/main /flyway/sql

COPY migrate.sh /usr/bin/migrate.sh

RUN chmod +x /usr/bin/migrate.sh

CMD ["/usr/bin/migrate.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE IF NOT EXISTS eg_notification_sms (
id bigint NOT NULL,
mobile_no VARCHAR(20) NOT NULL,
message TEXT,
category VARCHAR(50),
template_id VARCHAR(50),
createdtime bigint,
tenant_id VARCHAR(50)
);
CREATE SEQUENCE seq_eg_notification_sms
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE eg_notification_sms ADD CONSTRAINT eg_notification_sms_pkey PRIMARY KEY (id);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ class ExpensesDetailsModel {
expensesAmount?.first.amount ?? totalAmount?.toInt().toString() ?? '';
billDateCtrl.text = DateFormats.timeStampToDate(billDate);
paidDateCtrl.text =
paidDate == 0 ? '' : DateFormats.timeStampToDate(paidDate);
paidDate == null || paidDate == 0 ? '' : DateFormats.timeStampToDate(paidDate);
billIssuedDateCtrl.text =
billIssuedDate == 0 ? '' : DateFormats.timeStampToDate(billIssuedDate);
isBillPaid ??= false;
isBillPaid = paidDate != null && paidDate != 0 ? isBillPaid : false;
challanNumberCtrl.text = challanNo?.toString() ?? '';
fromDateCtrl.text = DateFormats.timeStampToDate(taxPeriodFrom);
toDateCtrl.text = DateFormats.timeStampToDate(taxPeriodTo);
Expand All @@ -179,7 +179,7 @@ class ExpensesDetailsModel {
selectedVendor = Vendor(vendorName ?? '', vendorId ?? '');
}

if (isBillPaid!) {
if (isBillPaid! && paidDate != null && paidDate != 0) {
allowEdit = false;
} else {
paidDateCtrl.text = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ class HouseholdRegisterProvider with ChangeNotifier {
TableData('${name ?? ''}'),
TableData('${fatherName ?? ''}'),
TableData(
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '${connection.additionalDetails?.collectionPendingAmount}' : '-'}'),
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-'}'),
TableData(
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '').abs()}' : '-' : '-'}'),
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-' : '-'}'),
TableData(
'${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}',
style: TextStyle(
Expand Down Expand Up @@ -405,8 +405,8 @@ class HouseholdRegisterProvider with ChangeNotifier {
'${connection.connectionNo ?? ''} ${connection.connectionType == 'Metered' ? '- M' : ''}',
'${connection.connectionHolders?.first.name ?? ''}',
'${connection.connectionHolders?.first.fatherOrHusbandName ?? ''}',
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '${connection.additionalDetails?.collectionPendingAmount}' : '-'}',
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '- ₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '').abs()}' : '₹ 0' : '₹ 0'}',
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-'}',
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '₹ 0' : '₹ 0'}',
'${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}',
'${connection.additionalDetails?.lastDemandGeneratedDate != null && connection.additionalDetails?.lastDemandGeneratedDate != '' ? DateFormats.timeStampToDate(int.parse(connection.additionalDetails?.lastDemandGeneratedDate ?? '')) : '-'}'
])
Expand All @@ -418,8 +418,8 @@ class HouseholdRegisterProvider with ChangeNotifier {
'${connection.oldConnectionNo ?? ''}',
'${connection.connectionHolders?.first.name ?? ''}',
'${connection.connectionHolders?.first.fatherOrHusbandName ?? ''}',
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '${connection.additionalDetails?.collectionPendingAmount}' : '-'}',
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '- ₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '').abs()}' : '₹ 0' : '₹ 0'}',
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-'}',
'${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '₹ 0' : '₹ 0'}',
'${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}',
'${connection.additionalDetails?.lastDemandGeneratedDate != null && connection.additionalDetails?.lastDemandGeneratedDate != '' ? DateFormats.timeStampToDate(int.parse(connection.additionalDetails?.lastDemandGeneratedDate ?? '')) : '-'}'
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class _ExpenseDetailsState extends State<ExpenseDetails> {
FilteringTextInputFormatter.allow(
RegExp(r"^[1-9][0-9]{0,5}$"))
],
placeHolder: '${i18.expense.AMOUNT} (₹)',
labelSuffix: '(₹)',
isDisabled: (expenseDetails.allowEdit ?? true)
? false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class _PaymentSuccessState extends State<PaymentSuccess> {
backButton: false,
isWithoutLogin: true,
isConsumer: true,
amount: '${transactionObject.transaction!.first.currencyCode! ?? ''} ${transactionObject.transaction!.first.txnAmount! ?? '0'}',
amount: '${transactionObject.transaction!.first.txnAmount! ?? '0'}',
)
: NoLoginFailurePage(i18.payment.PAYMENT_FAILED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class SMSRequest {
private String mobileNumber;
private String message;
private String templateId;
private String tenantid;
private String[] users;

}
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public void sendNewExpenditureEvent(RequestInfo requestInfo) {
System.out.println("New Expenditure SMS :: " + message);

SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(message)
.tenantid(tenantId)
.templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY))
.users(new String[] { map.getValue() }).build();
if(config.isSmsForExpenditureEnabled()) {
Expand Down Expand Up @@ -452,6 +453,7 @@ public void sendMarkExpensebillEvent(RequestInfo requestInfo) {
// value.
System.out.println("Mark expense bills SMS::" + message);
SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(message)
.tenantid(tenantId)
.templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY))
.users(new String[] { map.getValue() }).build();
if(config.isSmsForMarkBillEnabled()) {
Expand Down Expand Up @@ -583,6 +585,7 @@ public void sendMonthSummaryEvent(RequestInfo requestInfo) {
message = message.replace("{user}", uuidUsername);
System.out.println("SMS Notification::" + message);
SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(message)
.tenantid(tenantId)
.templateId(messageMap.get(NotificationUtil.TEMPLATE_KEY))
.users(new String[] { uuidUsername }).build();
if(config.isSmsForMonthlySummaryEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ private void generateDemandAndSendnotification(RequestInfo requestInfo, String t
System.out.println("Demand GP USER SMS1::" + msg);
if(!map.getKey().equals(config.getPspclVendorNumber())) {
SMSRequest smsRequest = SMSRequest.builder().mobileNumber(map.getKey()).message(msg)
.tenantid(tenantId)
.category(Category.TRANSACTION).build();
if(config.isSmsForDemandEnable()) {
producer.push(config.getSmsNotifTopic(), smsRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void enrichSMSRequest(DemandNotificationObj notificationObj, List<SMSReq
enrichNotificationReceivers(receiverList, notificationObj);
receiverList.forEach(receiver -> {
String message = util.getAppliedMsg(receiver, messageTemplate, notificationObj);
SMSRequest sms = SMSRequest.builder().mobileNumber(receiver.getMobileNumber()).message(message).category(Category.TRANSACTION).build();
SMSRequest sms = SMSRequest.builder().mobileNumber(receiver.getMobileNumber()).message(message).category(Category.TRANSACTION).tenantid(tenantId).build();
smsRequest.add(sms);
});
}
Expand Down
Loading
Loading