modification of TDS code

This commit is contained in:
Paramita Pahari 2024-09-03 17:53:20 +05:30
parent 3ce4d952ce
commit 90c19e7d49

View File

@ -4,6 +4,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.time.LocalDate;
@ -49,9 +50,8 @@ public class TDS_Calculation {
//String accNo = (String) accountDetails.get("KEY_1");
//Caclculate the Projected amount.
calculateProjectedAmount(accountDetails);
// calculateProjectedAmount(accountDetails);
//System.out.println("Projected amount for the account:" + accNo + " " + ProjectedAmt);
//insertProjectedAmount(accNo, ProjectedAmt, prodCode);
}
@ -66,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.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"
+ "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"
+ "and DA.CURR_STATUS ='O' and DA.PACS_ID in ('02000','07190','07544') 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.NXT_DUE_DATE,DA.INTT_PROJECTED,dp.INTT_PAYOUT_FREQ,DP.PROD_CODE";
PreparedStatement preparedStatement = conn.prepareStatement(depAccountSql);
@ -119,16 +119,16 @@ public class TDS_Calculation {
// 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 = ?";
PreparedStatement ps = conn.prepareStatement(bDaySql);
try (PreparedStatement ps = conn.prepareStatement(bDaySql)) {
ps.setString(1, CIF_No);
ResultSet rs = ps.executeQuery();
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
try {
birth_date = rs.getString("BIRTH_DATE");
//System.out.println("Birth Date: "+birth_date);
} catch (Exception e) {
} catch (SQLException e) {
System.err.println("null pointer");
}
if (birth_date != null) {
@ -148,21 +148,33 @@ public class TDS_Calculation {
}
if ("PAN CARD".equalsIgnoreCase(ID_TYPE)) {
PanAvailability(KEY_1,INTT_PAID, CIF_No, formType,PACS_ID);
PanAvailability(KEY_1, INTT_PAID, CIF_No, formType, PACS_ID);
} else {
PanNotAvailability(KEY_1,INTT_PAID, CIF_No, formType,PACS_ID);
PanNotAvailability(KEY_1, INTT_PAID, CIF_No, formType, PACS_ID);
}
}
}
} catch (Exception e) {
//System.out.println("Processing done");
e.printStackTrace();
}
}catch (Exception e) {
//System.out.println("Processing done");
e.printStackTrace();
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void PanAvailability(String KEY_1,Double INTT_PAID, String CIF_No, String formType,String PACS_ID) {
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 + " and interest Paid:" +INTT_PAID+ " for PACS ID: " +PACS_ID);
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_H = 300000;
double thresold = 0.0;
@ -174,7 +186,6 @@ public class TDS_Calculation {
thresold = thresold_G;
}
DecimalFormat df_obj = new DecimalFormat("#.####");
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
@ -203,8 +214,8 @@ public class TDS_Calculation {
if (formResultSet.next()) {
FORM_ID = formResultSet.getInt("FORM_ID");
System.out.println("Form Id is for YES PAN.........................." + FORM_ID);
}
/// System.out.println("FORM ID:" + FORM_ID);
// Extract the TXN_ID from the table TDX_TXN with the help of Key_1;
String getTdsTxnData = "select TXN_ID from TDS_TXN where KEY_1= ?";
@ -220,11 +231,14 @@ public class TDS_Calculation {
TXN_ID = rs.getInt("TXN_ID");
}
// System.out.println("TXN ID: " + TXN_ID);
//Including 15g/h logic.
if (FORM_ID != 0) {
System.out.println("FORM ID for having 15g/h for YES PAN:" + FORM_ID);
// Starting of TDS Calculation........
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);
System.out.println("The account number: " + KEY_1 + " has been crossed the thresold:" + INTT_PAID + " having CIF No: " + CIF_No + " for YES PAN");
//Calculate the TDS.//Here TDS will be 10% as PAN is avaiable
System.out.println("Interest Paid: " + INTT_PAID);
@ -248,28 +262,73 @@ public class TDS_Calculation {
insertSmt.setString(6, KEY_1);
insertSmt.setDouble(7, INTT_PAID);
insertSmt.setString(8, "Y");
System.out.println("pre execution");
insertSmt.executeQuery();
System.out.println("post execution");
// Need to insert the deducted amount into corresponding GL.
insrtGLTransaction(KEY_1,PACS_ID, INTT_PAID, tds_amount);
}else{
System.out.println("Interest Paid didn't cross the thresold for YES PAN");
insrtGLTransaction(KEY_1, PACS_ID, INTT_PAID, tds_amount);
} else {
System.out.println("Interest Paid didn't cross the thresold for YES PAN having FORM_ID:" + FORM_ID);
}
// }
//}
} else {
//This block is for calculating TDS for more than 10000 due to 15g/h availability
System.out.println("FORM ID for not having 15g/h:" + FORM_ID);
if (formType.equalsIgnoreCase("H")) {
thresold = 50000;
} else if (formType.equalsIgnoreCase("G")) {
thresold = 40000;
}
System.out.println("NO 15G/H available for YES PAN setting thresold: " +thresold);
if (INTT_PAID != null && INTT_PAID > thresold) {
System.out.println("The account number: " + KEY_1 + " has crossed the thresold:" + INTT_PAID + " having CIF No: " + CIF_No);
//Calculate the TDS.//Here TDS will be 10% as PAN is avaiable
System.out.println("Interest Paid: " + INTT_PAID);
tds_amount = INTT_PAID * 0.10;
System.out.println("TDS Amount is : " + tds_amount);
// deduct the TDS_AMOUNT from INTT_PAID
double deductedAmt = INTT_PAID - tds_amount;
System.out.println("Deducted amount: " + deductedAmt);
// Now need to insert into the table for record.
String InsertTdsSql = " Insert into TDS_CALCULATIONS(TXN_ID,FORM_ID,TDS_AMT,CREATED_AT,TDS_DATE,KEY_1,INTEREST_AMT,PANCARD) values(?,?,?,?,?,?,?,?) ";
PreparedStatement insertSmt = conn.prepareStatement(InsertTdsSql);
insertSmt.setInt(1, TXN_ID);
insertSmt.setInt(2, FORM_ID);
insertSmt.setDouble(3, tds_amount);
insertSmt.setTimestamp(4, Timestamp.valueOf(LocalDateTime.now()));
insertSmt.setDate(5, java.sql.Date.valueOf(LocalDate.now()));
insertSmt.setString(6, KEY_1);
insertSmt.setDouble(7, INTT_PAID);
insertSmt.setString(8, "Y");
insertSmt.executeQuery();
// Need to insert the deducted amount into corresponding GL.
insrtGLTransaction(KEY_1, PACS_ID, INTT_PAID, tds_amount);
} else {
System.out.println("Interest Paid did not cross the thresold for YES PAN having FORM_ID:" + FORM_ID);
}
}
//}
} catch (Exception e) {
e.printStackTrace();
}finally {
} finally {
System.out.println("Processing done for PAN available");
System.out.println("\n");
}
}
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 + " and interest Paid:" +INTT_PAID+ " for PACS ID: " +PACS_ID);
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 + " and interest Paid:" + INTT_PAID + " for PACS ID: " + PACS_ID);
double thresold_G = 250000;
double thresold_H = 300000;
@ -308,6 +367,7 @@ public class TDS_Calculation {
if (formResultSet.next()) {
FORM_ID = formResultSet.getInt("FORM_ID");
System.out.println("Form Id is for NO PAN..........................." + FORM_ID);
}
//System.out.println("FORM ID:" + FORM_ID);
@ -325,16 +385,24 @@ public class TDS_Calculation {
TXN_ID = rs.getInt("TXN_ID");
}
//System.out.println("TXN ID: " + TXN_ID);
//Including 15g/h logic.
if (FORM_ID != 0) {
System.out.println("FORM ID for having 15g/h for NO PAN: " + FORM_ID);
// Starting of TDS Calculation........
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);
System.out.println("The account number: " + KEY_1 + " has been crossed the thresold:" + INTT_PAID + " having CIF No: " + CIF_No + " for NO PAN");
//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: " + INTT_PAID);
tds_amount = INTT_PAID * 0.20;
System.out.println("TDS Amount is FOR NO PAN : " + tds_amount);
System.out.println("TDS Amount is : " + tds_amount);
// deduct the TDS_AMOUNT from INTT_PAID
double deductedAmt = INTT_PAID - tds_amount;
System.out.println("Deducted amount: " + deductedAmt);
// Now need to insert into the table for record.
String InsertTdsSql = " Insert into TDS_CALCULATIONS(TXN_ID,FORM_ID,TDS_AMT,CREATED_AT,TDS_DATE,KEY_1,INTEREST_AMT,PANCARD) values(?,?,?,?,?,?,?,?) ";
@ -347,23 +415,67 @@ public class TDS_Calculation {
insertSmt.setDate(5, java.sql.Date.valueOf(LocalDate.now()));
insertSmt.setString(6, KEY_1);
insertSmt.setDouble(7, INTT_PAID);
insertSmt.setString(8, "N");
insertSmt.setString(8, "Y");
insertSmt.executeQuery();
// Need to insert the deducted amount into corresponding GL.
insrtGLTransaction(KEY_1,PACS_ID, INTT_PAID, tds_amount);
}else{
System.out.println("Interest Paid didn't cross the thresold for No Pan");
insrtGLTransaction(KEY_1, PACS_ID, INTT_PAID, tds_amount);
} else {
System.out.println("Interest Paid did not cross the thresold for NO PAN having FORM_ID:" + FORM_ID);
}
} else {
//This block is for calculating TDS for more than 10000 due to 15g/h availability
System.out.println("FORM ID for not having 15g/h:" + FORM_ID);
System.out.println("NO 15G/H available for NO PAN");
if (formType.equalsIgnoreCase("H")) {
thresold = 50000;
} else if (formType.equalsIgnoreCase("G")) {
thresold = 40000;
}
if (INTT_PAID != null && INTT_PAID > thresold) {
System.out.println("The account number: " + KEY_1 + " has crossed the thresold:" + INTT_PAID + " having CIF No: " + CIF_No+ " for NO PAN");
//Calculate the TDS.//Here TDS will be 10% as PAN is avaiable
System.out.println("Interest Paid: " + INTT_PAID);
tds_amount = INTT_PAID * 0.20;
System.out.println("TDS Amount is : " + tds_amount);
// deduct the TDS_AMOUNT from INTT_PAID
double deductedAmt = INTT_PAID - tds_amount;
System.out.println("Deducted amount: " + deductedAmt);
// Now need to insert into the table for record.
String InsertTdsSql = " Insert into TDS_CALCULATIONS(TXN_ID,FORM_ID,TDS_AMT,CREATED_AT,TDS_DATE,KEY_1,INTEREST_AMT,PANCARD) values(?,?,?,?,?,?,?,?) ";
PreparedStatement insertSmt = conn.prepareStatement(InsertTdsSql);
insertSmt.setInt(1, TXN_ID);
insertSmt.setInt(2, FORM_ID);
insertSmt.setDouble(3, tds_amount);
insertSmt.setTimestamp(4, Timestamp.valueOf(LocalDateTime.now()));
insertSmt.setDate(5, java.sql.Date.valueOf(LocalDate.now()));
insertSmt.setString(6, KEY_1);
insertSmt.setDouble(7, INTT_PAID);
insertSmt.setString(8, "Y");
insertSmt.executeQuery();
// Need to insert the deducted amount into corresponding GL.
insrtGLTransaction(KEY_1, PACS_ID, INTT_PAID, tds_amount);
} else {
System.out.println("Interest Paid did not cross the thresold for NO PAN having FORM_ID:" + FORM_ID);
}
}
// }
//}
// System.out.println("Interest Paid: " + INTT_PAID + " for the account: " +KEY_1);
} catch (Exception e) {
e.printStackTrace();
}finally {
System.out.println("Processing done for PAN not available");
} finally {
System.out.println("Processing done for PAN NOT available");
System.out.println("\n");
}
}
@ -397,11 +509,10 @@ public class TDS_Calculation {
//calculate projected amount
double projectedAmount = INTT_PROJECTED * temp;
System.out.println("Calculation is done for Account No: " + accNum + " and Projected Amount is : " +projectedAmount);
System.out.println("Calculation is done for Account No: " + accNum + " and Projected Amount is : " + projectedAmount);
// return projectedAmount;
insertProjectedAmount(accNum, projectedAmount, prodCode);
}
public static void insertProjectedAmount(String accNo, double projectedAmt, String prodCode) {
@ -425,8 +536,8 @@ public class TDS_Calculation {
ps.setTimestamp(4, Timestamp.valueOf(LocalDateTime.now()));
ps.setDouble(5, projectedAmt);
boolean i= ps.executeUpdate()>0;
System.out.println("inserted Projected amount for : " + accNo );
boolean i = ps.executeUpdate() > 0;
System.out.println("inserted Projected amount for : " + accNo);
} catch (Exception e) {
e.printStackTrace();
@ -498,7 +609,7 @@ public class TDS_Calculation {
}
//This is the method of GL Transaction
public static void insrtGLTransaction(String KEY,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;
double TXN_AMT = INTT_PAID - tds_amount;
@ -530,11 +641,9 @@ public class TDS_Calculation {
// if (KEY_1 == null) {
// System.out.println("No BGL avaiable for TDS of this PACS ID. Kindly check manually in the system.");
// }
if(KEY_1.isEmpty()){
if (KEY_1.isEmpty()) {
System.out.println("No BGL avaiable for TDS of this PACS ID. Kindly check manually in the system.");
}
else {
} else {
long randomNumberGeneration = randomNumberGenerator();