Added new modification

This commit is contained in:
Paramita Pahari 2024-08-22 17:03:40 +05:30
parent 99789f78a4
commit 3ce4d952ce

View File

@ -46,15 +46,13 @@ public class TDS_Calculation {
//Calculate the Projected value and insert into the table TDS_TXN //Calculate the Projected value and insert into the table TDS_TXN
for (Map<String, Object> accountDetails : depAccountsDetails) { for (Map<String, Object> accountDetails : depAccountsDetails) {
String accNo = (String) accountDetails.get("KEY_1"); //String accNo = (String) accountDetails.get("KEY_1");
Double INTT_PROJECTED = (Double) accountDetails.get(("INTT_PROJECTED"));
System.out.println("Interest Paid:" + INTT_PROJECTED); //Caclculate the Projected amount.
String INTT_PAYOUT_FREQ = (String) accountDetails.get("INTT_PAYOUT_FREQ"); calculateProjectedAmount(accountDetails);
System.out.println("INTT_PAYOUT_FREQ:" + INTT_PAYOUT_FREQ); //System.out.println("Projected amount for the account:" + accNo + " " + ProjectedAmt);
double ProjectedAmt = calculateProjectedAmount(accountDetails);
System.out.println("Projected amount for the account:" + accNo + " " + ProjectedAmt); //insertProjectedAmount(accNo, ProjectedAmt, prodCode);
String prodCode = (String) accountDetails.get("PROD_CODE");
insertProjectedAmount(accNo, ProjectedAmt, prodCode);
} }
} }
@ -68,7 +66,7 @@ public class TDS_Calculation {
+ "DA.INTT_PAID,DP.PROD_CODE,DA.INTT_SOP_DATE,DA.INTT_EOP_DATE,DA.TERM_VALUE,DA.MAT_VALUE,DA.MAT_DT,DA.TERM_LENGTH,\n" + "DA.INTT_PAID,DP.PROD_CODE,DA.INTT_SOP_DATE,DA.INTT_EOP_DATE,DA.TERM_VALUE,DA.MAT_VALUE,DA.MAT_DT,DA.TERM_LENGTH,\n"
+ "DA.NXT_DUE_DATE,DA.INTT_PROJECTED,dp.INTT_PAYOUT_FREQ FROM DEP_ACCOUNT DA ,dep_product dp\n" + "DA.NXT_DUE_DATE,DA.INTT_PROJECTED,dp.INTT_PAYOUT_FREQ FROM DEP_ACCOUNT DA ,dep_product dp\n"
+ "where DA.DEP_PROD_ID=dp.ID and substr(dp.prod_code,1,1) in ('2','3') and substr(DA.GL_CLASS_CODE,9,2)='14'\n" + "where DA.DEP_PROD_ID=dp.ID and substr(dp.prod_code,1,1) in ('2','3') and substr(DA.GL_CLASS_CODE,9,2)='14'\n"
+ "and DA.CURR_STATUS ='O'and DA.PACS_ID not in ('02000')and da.INTT_PAID >100000 group by DA.KEY_1,DA.PACS_ID,DA.CURR_STATUS,DA.CUSTOMER_NO,DA.ACCT_OPEN_DT,\n" + "and DA.CURR_STATUS ='O'and da.INTT_PAID >100000 group by DA.KEY_1,DA.PACS_ID,DA.CURR_STATUS,DA.CUSTOMER_NO,DA.ACCT_OPEN_DT,\n"
+ "DA.INTT_PAID,DA.INTT_SOP_DATE,DA.INTT_EOP_DATE,DA.TERM_VALUE,DA.MAT_VALUE,DA.MAT_DT,DA.TERM_LENGTH,\n" + "DA.INTT_PAID,DA.INTT_SOP_DATE,DA.INTT_EOP_DATE,DA.TERM_VALUE,DA.MAT_VALUE,DA.MAT_DT,DA.TERM_LENGTH,\n"
+ "DA.NXT_DUE_DATE,DA.INTT_PROJECTED,dp.INTT_PAYOUT_FREQ,DP.PROD_CODE"; + "DA.NXT_DUE_DATE,DA.INTT_PROJECTED,dp.INTT_PAYOUT_FREQ,DP.PROD_CODE";
PreparedStatement preparedStatement = conn.prepareStatement(depAccountSql); PreparedStatement preparedStatement = conn.prepareStatement(depAccountSql);
@ -112,9 +110,12 @@ public class TDS_Calculation {
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) { try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
for (Map<String, Object> acc : depAccountsDetails) { for (Map<String, Object> acc : depAccountsDetails) {
String CIF_No = (String) acc.get("CUSTOMER_NO"); String CIF_No = (String) acc.get("CUSTOMER_NO");
String KEY_1 = (String) acc.get("KEY_1");
Double INTT_PAID = (Double) acc.get("INTT_PAID");
String PACS_ID = (String) acc.get("PACS_ID");
String ID_TYPE = identificationData.get(CIF_No); String ID_TYPE = identificationData.get(CIF_No);
System.out.println("ID TYPE is: " + ID_TYPE); //System.out.println("ID TYPE is: " + ID_TYPE);
// LocalDate birthDt = null; // LocalDate birthDt = null;
String bDaySql = "SELECT TO_CHAR(TO_DATE(BIRTH_DATE,'DD-MM-YYYY'),'DD-MM-YYYY') AS BIRTH_DATE FROM KYC_HDR WHERE CIF_NO = ?"; String bDaySql = "SELECT TO_CHAR(TO_DATE(BIRTH_DATE,'DD-MM-YYYY'),'DD-MM-YYYY') AS BIRTH_DATE FROM KYC_HDR WHERE CIF_NO = ?";
@ -147,9 +148,9 @@ public class TDS_Calculation {
} }
if ("PAN CARD".equalsIgnoreCase(ID_TYPE)) { if ("PAN CARD".equalsIgnoreCase(ID_TYPE)) {
PanAvailability(depAccountsDetails, CIF_No, formType); PanAvailability(KEY_1,INTT_PAID, CIF_No, formType,PACS_ID);
} else { } else {
PanNotAvailability(depAccountsDetails, CIF_No, formType); PanNotAvailability(KEY_1,INTT_PAID, CIF_No, formType,PACS_ID);
} }
} }
} }
@ -159,9 +160,9 @@ public class TDS_Calculation {
} }
} }
public static void PanAvailability(List<Map<String, Object>> depAccountsDetails, String CIF_No, String formType) { public static void PanAvailability(String KEY_1,Double INTT_PAID, String CIF_No, String formType,String PACS_ID) {
System.out.println("CIF No:" + CIF_No + " is having Pan " + " with Form Type " + formType); System.out.println("CIF No:" + CIF_No + " is having Pan " + " with Form Type " + formType + " and interest Paid:" +INTT_PAID+ " for PACS ID: " +PACS_ID);
double thresold_G = 250000; double thresold_G = 250000;
double thresold_H = 300000; double thresold_H = 300000;
double thresold = 0.0; double thresold = 0.0;
@ -172,28 +173,29 @@ public class TDS_Calculation {
} else if (formType.equalsIgnoreCase("G")) { } else if (formType.equalsIgnoreCase("G")) {
thresold = thresold_G; thresold = thresold_G;
} }
System.out.println("Thresold is : " + thresold);
System.out.println("Form Type is : " + formType);
DecimalFormat df_obj = new DecimalFormat("#.####"); DecimalFormat df_obj = new DecimalFormat("#.####");
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) { try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
for (Map<String, Object> acc : depAccountsDetails) { // for (Map<String, Object> acc : depAccountsDetails) {
String AccCIF_No = (String) acc.get("CUSTOMER_NO"); // String AccCIF_No = (String) acc.get("CUSTOMER_NO");
//
//System.out.println("AccCIF No: " + AccCIF_No); // System.out.println("AccCIF No: " + AccCIF_No);
if (CIF_No.equals(AccCIF_No)) { // if (CIF_No.equals(AccCIF_No)) {
String KEY_1 = (String) acc.get("KEY_1"); // String KEY_1 = (String) acc.get("KEY_1");
Double INTT_PAID = (Double) acc.get("INTT_PAID"); // Double INTT_PAID = (Double) acc.get("INTT_PAID");
double INTT_PROJECTED = (double) acc.get("INTT_PROJECTED"); // // double INTT_PROJECTED = (double) acc.get("INTT_PROJECTED");
// Added for GL_TXN calculations //
String PACS_ID = (String) acc.get("PACS_ID"); //
// // Added for GL_TXN calculations
// String PACS_ID = (String) acc.get("PACS_ID");
// extract the Form _id from FORM15G_H table. // extract the Form _id from FORM15G_H table.
String getFormData = "SELECT FORM_ID,KEY_1 FROM FORM15G_H WHERE KEY_1= ?"; String getFormData = "SELECT FORM_ID,KEY_1 FROM FORM15G_H WHERE KEY_1= ?";
PreparedStatement ps = conn.prepareStatement(getFormData); PreparedStatement ps = conn.prepareStatement(getFormData);
ps.setString(1, AccCIF_No); ps.setString(1, CIF_No);
ResultSet formResultSet = ps.executeQuery(); ResultSet formResultSet = ps.executeQuery();
@ -221,6 +223,8 @@ public class TDS_Calculation {
// System.out.println("TXN ID: " + TXN_ID); // System.out.println("TXN ID: " + TXN_ID);
// Starting of TDS Calculation........ // Starting of TDS Calculation........
if (INTT_PAID != null && INTT_PAID > thresold) { if (INTT_PAID != null && INTT_PAID > thresold) {
System.out.println("The account number: " + KEY_1+ " has been crossed the thresold:" + INTT_PAID + "having CIF No: " +CIF_No);
//Calculate the TDS.//Here TDS will be 10% as PAN is avaiable //Calculate the TDS.//Here TDS will be 10% as PAN is avaiable
System.out.println("Interest Paid: " + INTT_PAID); System.out.println("Interest Paid: " + INTT_PAID);
@ -248,21 +252,24 @@ public class TDS_Calculation {
insertSmt.executeQuery(); insertSmt.executeQuery();
System.out.println("post execution"); System.out.println("post execution");
// Need to insert the deducted amount into corresponding GL. // Need to insert the deducted amount into corresponding GL.
insrtGLTransaction(PACS_ID, INTT_PAID, tds_amount); insrtGLTransaction(KEY_1,PACS_ID, INTT_PAID, tds_amount);
}else{ }else{
System.out.println("INterest Paid didn't cross "); System.out.println("Interest Paid didn't cross the thresold for YES PAN");
} }
} // }
} //}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}finally {
System.out.println("Processing done for PAN available");
} }
} }
public static void PanNotAvailability(List<Map<String, Object>> depAccountsDetails, String CIF_No, String formType) { public static void PanNotAvailability(String KEY_1,Double INTT_PAID, String CIF_No, String formType,String PACS_ID) {
System.out.println("CIF No:" + CIF_No + " is not having Pan " + " with Form Type " + formType); System.out.println("CIF No:" + CIF_No + " is not having Pan " + " with Form Type " + formType + " and interest Paid:" +INTT_PAID+ " for PACS ID: " +PACS_ID);
double thresold_G = 250000; double thresold_G = 250000;
double thresold_H = 300000; double thresold_H = 300000;
@ -276,25 +283,24 @@ public class TDS_Calculation {
} }
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) { try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
for (Map<String, Object> acc : depAccountsDetails) { // for (Map<String, Object> acc : depAccountsDetails) {
String AccCIF_No = (String) acc.get("CUSTOMER_NO"); // String AccCIF_No = (String) acc.get("CUSTOMER_NO");
//
if (CIF_No.equals(AccCIF_No)) { // if (CIF_No.equals(AccCIF_No)) {
String KEY_1 = (String) acc.get("KEY_1"); // String KEY_1 = (String) acc.get("KEY_1");
Double INTT_PAID = (Double) acc.get("INTT_PAID"); // Double INTT_PAID = (Double) acc.get("INTT_PAID");
double INTT_PROJECTED = (double) acc.get("INTT_PROJECTED"); // double INTT_PROJECTED = (double) acc.get("INTT_PROJECTED");
// thresold = formType.equals("H") ? thresold_H : thresold_G; // // thresold = formType.equals("H") ? thresold_H : thresold_G;
//System.out.println(thresold); //
//System.out.println("Form Type is : " + formType); //
// // Added for GL_TXN calculations
// Added for GL_TXN calculations // String PACS_ID = (String) acc.get("PACS_ID");
String PACS_ID = (String) acc.get("PACS_ID");
// extract the Form _id from FORM15G_H table. // extract the Form _id from FORM15G_H table.
String getFormData = "SELECT FORM_ID,KEY_1 FROM FORM15G_H WHERE KEY_1= ?"; String getFormData = "SELECT FORM_ID,KEY_1 FROM FORM15G_H WHERE KEY_1= ?";
PreparedStatement ps = conn.prepareStatement(getFormData); PreparedStatement ps = conn.prepareStatement(getFormData);
ps.setString(1, AccCIF_No); ps.setString(1, CIF_No);
ResultSet formResultSet = ps.executeQuery(); ResultSet formResultSet = ps.executeQuery();
@ -322,6 +328,8 @@ public class TDS_Calculation {
//System.out.println("TXN ID: " + TXN_ID); //System.out.println("TXN ID: " + TXN_ID);
// Starting of TDS Calculation........ // Starting of TDS Calculation........
if (INTT_PAID != null && INTT_PAID > thresold) { if (INTT_PAID != null && INTT_PAID > thresold) {
System.out.println("The account number: " + KEY_1+ " has been crossed the thresold:" + INTT_PAID + "having CIF No: " +CIF_No);
//Calculate the TDS.//Here TDS will be 10% as PAN is avaiable //Calculate the TDS.//Here TDS will be 10% as PAN is avaiable
System.out.println("Interest Paid for NO PAN: " + INTT_PAID); System.out.println("Interest Paid for NO PAN: " + INTT_PAID);
@ -344,24 +352,29 @@ public class TDS_Calculation {
insertSmt.executeQuery(); insertSmt.executeQuery();
// Need to insert the deducted amount into corresponding GL. // Need to insert the deducted amount into corresponding GL.
insrtGLTransaction(PACS_ID, INTT_PAID, tds_amount); insrtGLTransaction(KEY_1,PACS_ID, INTT_PAID, tds_amount);
}else{
System.out.println("Interest Paid didn't cross the thresold for No Pan");
} }
} // }
} //}
// System.out.println("Interest Paid: " + INTT_PAID + " for the account: " +KEY_1); // System.out.println("Interest Paid: " + INTT_PAID + " for the account: " +KEY_1);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}finally {
System.out.println("Processing done for PAN not available");
} }
} }
public static double calculateProjectedAmount(Map<String, Object> accNo) { public static void calculateProjectedAmount(Map<String, Object> accNo) {
int termValue = (int) accNo.get("TERM_VALUE"); // int termValue = (int) accNo.get("TERM_VALUE");
double INTT_PROJECTED = (double) accNo.get("INTT_PROJECTED"); double INTT_PROJECTED = (double) accNo.get("INTT_PROJECTED");
int termLength = (int) accNo.get("TERM_LENGTH"); //in days as per IPKS DB // int termLength = (int) accNo.get("TERM_LENGTH"); //in days as per IPKS DB
String inttPayoutFre = ((String) accNo.get("INTT_PAYOUT_FREQ")).trim(); String inttPayoutFre = ((String) accNo.get("INTT_PAYOUT_FREQ")).trim();
String prodCode = (String) accNo.get("PROD_CODE");
String accNum = (String) accNo.get("KEY_1");
int temp = 0; int temp = 0;
switch (inttPayoutFre) { switch (inttPayoutFre) {
@ -384,8 +397,10 @@ public class TDS_Calculation {
//calculate projected amount //calculate projected amount
double projectedAmount = INTT_PROJECTED * temp; double projectedAmount = INTT_PROJECTED * temp;
return projectedAmount; System.out.println("Calculation is done for Account No: " + accNum + " and Projected Amount is : " +projectedAmount);
//insertProjectedAmount(accNo,projectedAmount); // return projectedAmount;
insertProjectedAmount(accNum, projectedAmount, prodCode);
} }
@ -410,7 +425,8 @@ public class TDS_Calculation {
ps.setTimestamp(4, Timestamp.valueOf(LocalDateTime.now())); ps.setTimestamp(4, Timestamp.valueOf(LocalDateTime.now()));
ps.setDouble(5, projectedAmt); ps.setDouble(5, projectedAmt);
ps.executeUpdate(); boolean i= ps.executeUpdate()>0;
System.out.println("inserted Projected amount for : " + accNo );
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -482,7 +498,7 @@ public class TDS_Calculation {
} }
//This is the method of GL Transaction //This is the method of GL Transaction
public static void insrtGLTransaction(String PACS_ID, double INTT_PAID, double tds_amount) { public static void insrtGLTransaction(String KEY,String PACS_ID, double INTT_PAID, double tds_amount) {
// String KEY_1 = null; // String KEY_1 = null;
double TXN_AMT = INTT_PAID - tds_amount; double TXN_AMT = INTT_PAID - tds_amount;
@ -573,11 +589,11 @@ else {
PreparedStatement ps = conn.prepareStatement(insertGLTxn); PreparedStatement ps = conn.prepareStatement(insertGLTxn);
ps.setString(1, "003"); ps.setString(1, "003");
ps.setString(2, KEY_1); ps.setString(2, KEY_1);
ps.setLong(3, randomNumberGeneration); ps.setString(3, KEY);
ps.setDate(4, java.sql.Date.valueOf(LocalDate.now())); ps.setDate(4, java.sql.Date.valueOf(LocalDate.now()));
ps.setDate(5, java.sql.Date.valueOf(LocalDate.now())); ps.setDate(5, java.sql.Date.valueOf(LocalDate.now()));
ps.setTimestamp(6, Timestamp.valueOf(LocalDateTime.now())); ps.setTimestamp(6, Timestamp.valueOf(LocalDateTime.now()));
ps.setLong(7, randomNumberGeneration); ps.setLong(7, randomNumberGeneration);//randomNumberGeneration
ps.setString(8, "CR"); ps.setString(8, "CR");
ps.setDouble(9, end_bal); ps.setDouble(9, end_bal);
ps.setDouble(10, tds_amount); ps.setDouble(10, tds_amount);