Logic Modification

This commit is contained in:
Paramita Pahari 2024-09-06 18:05:06 +05:30
parent 90c19e7d49
commit 407de7bf7a
2 changed files with 95 additions and 34 deletions

View File

@ -0,0 +1,41 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package TDS_Calculate;
/**
*
* @author 1121947
*/
public class ID_Type {
private String idNo ;
private String IDType;
public String getIdNo() {
return idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public String getIDType() {
return IDType;
}
public void setIDType(String IDType) {
this.IDType = IDType;
}
public ID_Type(String idNo, String IDType) {
this.idNo = idNo;
this.IDType = IDType;
}
}

View File

@ -36,10 +36,10 @@ public class TDS_Calculation {
//System.out.println(hSize); //System.out.println(hSize);
//Get the PAN Data //Get the PAN Data
Map<String, String> identificationData = fetchPANDetails(depAccountsDetails); Map<String, ID_Type> identificationData = fetchPANDetails(depAccountsDetails);
//print the fetched data //print the fetched data
// for (Map.Entry<String, String> panDetails : identificationData.entrySet()) { // for (Map.Entry<String, String> panDetails : identificationData.entrySet()) {
// System.out.println("cif_no: " + panDetails.getKey() + "ID Type:" + panDetails.getValue()); // System.out.println("cif_no: " + panDetails.getKey() + " having ID Type:" + panDetails.getValue());
// } // }
//Get the 15GH/PAN details as per the customerNumber from the Previous method //Get the 15GH/PAN details as per the customerNumber from the Previous method
@ -50,7 +50,7 @@ public class TDS_Calculation {
//String accNo = (String) accountDetails.get("KEY_1"); //String accNo = (String) accountDetails.get("KEY_1");
//Caclculate the Projected amount. //Caclculate the Projected amount.
// calculateProjectedAmount(accountDetails); calculateProjectedAmount(accountDetails);
//System.out.println("Projected amount for the account:" + accNo + " " + ProjectedAmt); //System.out.println("Projected amount for the account:" + accNo + " " + ProjectedAmt);
//insertProjectedAmount(accNo, ProjectedAmt, prodCode); //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.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 in ('02000','07190','07544') 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 ('07190') 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);
@ -102,7 +102,7 @@ public class TDS_Calculation {
return depAccountsDetails; return depAccountsDetails;
} }
private static void checkIdentificationAvailability(List<Map<String, Object>> depAccountsDetails, Map<String, String> identificationData) { private static void checkIdentificationAvailability(List<Map<String, Object>> depAccountsDetails, Map<String, ID_Type> identificationData) {
String formType = null; String formType = null;
String birth_date = null; String birth_date = null;
@ -114,8 +114,12 @@ public class TDS_Calculation {
Double INTT_PAID = (Double) acc.get("INTT_PAID"); Double INTT_PAID = (Double) acc.get("INTT_PAID");
String PACS_ID = (String) acc.get("PACS_ID"); String PACS_ID = (String) acc.get("PACS_ID");
String ID_TYPE = identificationData.get(CIF_No); ID_Type id_data = identificationData.get(CIF_No);
//System.out.println("ID TYPE is: " + ID_TYPE);
String id_num = id_data.getIdNo();
String ID_TYPE = id_data.getIDType();
System.out.println("ID TYPE is: " + ID_TYPE + " for cif no:" + CIF_No + " and ID_NO: " + id_num);
// 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 = ?";
@ -158,13 +162,11 @@ public class TDS_Calculation {
//System.out.println("Processing done"); //System.out.println("Processing done");
e.printStackTrace(); e.printStackTrace();
} }
}catch (Exception e) { } catch (Exception e) {
//System.out.println("Processing done"); //System.out.println("Processing done");
e.printStackTrace(); e.printStackTrace();
} }
} }
} catch (Exception ex) { } catch (Exception ex) {
@ -174,7 +176,7 @@ public class TDS_Calculation {
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 + " of the a/c no: " + KEY_1);
double thresold_G = 250000; double thresold_G = 250000;
double thresold_H = 300000; double thresold_H = 300000;
double thresold = 0.0; double thresold = 0.0;
@ -266,7 +268,7 @@ 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(KEY_1, 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 the thresold for YES PAN having FORM_ID:" + FORM_ID); System.out.println("Interest Paid didn't cross the thresold for YES PAN having FORM_ID:" + FORM_ID);
} }
@ -274,14 +276,13 @@ public class TDS_Calculation {
//This block is for calculating TDS for more than 10000 due to 15g/h availability //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("FORM ID for not having 15g/h:" + FORM_ID);
if (formType.equalsIgnoreCase("H")) { if (formType.equalsIgnoreCase("H")) {
thresold = 50000; thresold = 50000;
} else if (formType.equalsIgnoreCase("G")) { } else if (formType.equalsIgnoreCase("G")) {
thresold = 40000; thresold = 40000;
} }
System.out.println("NO 15G/H available for YES PAN setting thresold: " +thresold); System.out.println("NO 15G/H available for YES PAN setting thresold: " + thresold);
if (INTT_PAID != null && INTT_PAID > 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); System.out.println("The account number: " + KEY_1 + " has crossed the thresold:" + INTT_PAID + " having CIF No: " + CIF_No);
@ -312,7 +313,7 @@ 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(KEY_1, PACS_ID, INTT_PAID, tds_amount); insrtGLTransaction(KEY_1, PACS_ID, INTT_PAID, tds_amount);
} else { } else {
System.out.println("Interest Paid did not cross the thresold for YES PAN having FORM_ID:" + FORM_ID); System.out.println("Interest Paid did not cross the thresold for YES PAN having FORM_ID:" + FORM_ID);
} }
@ -328,7 +329,7 @@ public class TDS_Calculation {
} }
public static void PanNotAvailability(String KEY_1, Double INTT_PAID, String CIF_No, String formType, String 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); 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 + " of the a/c no: " + KEY_1);
double thresold_G = 250000; double thresold_G = 250000;
double thresold_H = 300000; double thresold_H = 300000;
@ -367,7 +368,7 @@ public class TDS_Calculation {
if (formResultSet.next()) { if (formResultSet.next()) {
FORM_ID = formResultSet.getInt("FORM_ID"); FORM_ID = formResultSet.getInt("FORM_ID");
System.out.println("Form Id is for NO PAN..........................." + FORM_ID); System.out.println("Form Id is for NO PAN..........................." + FORM_ID);
} }
//System.out.println("FORM ID:" + FORM_ID); //System.out.println("FORM ID:" + FORM_ID);
@ -420,7 +421,7 @@ 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(KEY_1, PACS_ID, INTT_PAID, tds_amount); insrtGLTransaction(KEY_1, PACS_ID, INTT_PAID, tds_amount);
} else { } else {
System.out.println("Interest Paid did not cross the thresold for NO PAN having FORM_ID:" + FORM_ID); System.out.println("Interest Paid did not cross the thresold for NO PAN having FORM_ID:" + FORM_ID);
} }
@ -436,7 +437,7 @@ public class 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 crossed the thresold:" + INTT_PAID + " having CIF No: " + CIF_No+ " for NO PAN"); 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 //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);
@ -464,7 +465,7 @@ 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(KEY_1, PACS_ID, INTT_PAID, tds_amount); insrtGLTransaction(KEY_1, PACS_ID, INTT_PAID, tds_amount);
} else { } else {
System.out.println("Interest Paid did not cross the thresold for NO PAN having FORM_ID:" + FORM_ID); System.out.println("Interest Paid did not cross the thresold for NO PAN having FORM_ID:" + FORM_ID);
} }
@ -544,9 +545,10 @@ public class TDS_Calculation {
} }
} }
private static Map<String, String> fetchPANDetails(List<Map<String, Object>> depAccountsDetails) { private static Map<String, ID_Type> fetchPANDetails(List<Map<String, Object>> depAccountsDetails) {
Map<String, ID_Type> PanData = new HashMap<>();
Map<String, String> PanData = new HashMap<>();
List<String> cif_No = new ArrayList<>(); List<String> cif_No = new ArrayList<>();
// String formType = null; // String formType = null;
@ -571,7 +573,8 @@ public class TDS_Calculation {
//System.out.println("batch cif no:" + batchCifNos); //System.out.println("batch cif no:" + batchCifNos);
//Create a list of CIF No. //Create a list of CIF No.
StringBuilder stringbuilder = new StringBuilder("SELECT CIF_NO,ID_NO,ID_TYPE,BIRTH_DATE FROM KYC_DETAILS where CIF_NO IN("); StringBuilder stringbuilder = new StringBuilder("SELECT KH.CIF_NO as CIF_NO,KD.ID_NO as ID_NO,m.DOCUMENT_DTL as ID_TYPE,KH.BIRTH_DATE as BIRTH_DATE from KYC_HDR KH,"
+ "PACS_MASTER PM,kyc_dtl KD,kyc_document_mst m where KH.PACS_ID=PM.PACS_ID and KH.CIF_NO = KD.CIF_NO and KD.kyc_document_mst_id = m.id AND KH.CIF_NO in (");
for (int i = 0; i < batchCifNos.size(); i++) { for (int i = 0; i < batchCifNos.size(); i++) {
stringbuilder.append("?"); stringbuilder.append("?");
if (i < batchCifNos.size() - 1) { if (i < batchCifNos.size() - 1) {
@ -590,17 +593,34 @@ public class TDS_Calculation {
ResultSet resultSet = preparedstatement.executeQuery(); ResultSet resultSet = preparedstatement.executeQuery();
// Create a map to store CIF and their corresponding selected ID type
// Store the PAN No in the map // Store the PAN No in the map
while (resultSet.next()) { while (resultSet.next()) {
String cifNo = resultSet.getString("CIF_NO"); String cifNo = resultSet.getString("CIF_NO");
//String panNo = resultSet.getString("ID_NO"); String id_No = resultSet.getString("ID_NO");
// System.out.println("CIF No: " + cifNo); // System.out.println("CIF No: " + cifNo);
String ID_Type = resultSet.getString("ID_TYPE"); String ID_Type = resultSet.getString("ID_TYPE");
//panavailable = true; //panavailable = true;
// System.out.println("ID Type: " + ID_Type); // System.out.println("ID Type: " + ID_Type);
// Map<String, ID_Type> panData = new HashMap<>();
PanData.put(cifNo, ID_Type); // PanData.put(cifNo, ID_Type);
// Check if the CIF number is already processed
if (!PanData.containsKey(cifNo)) {
PanData.put(cifNo, new ID_Type(id_No, ID_Type));
} else {
// If the CIF number is already processed, prefer PAN
if ("PAN CARD".equalsIgnoreCase(ID_Type)) {
PanData.put(cifNo, new ID_Type(id_No, ID_Type)); // Overwrite if PAN is found
}
}
} }
// print the map data
for (Map.Entry<String, ID_Type> entry : PanData.entrySet()) {
System.out.println("CIF No: " + entry.getKey() + ", ID No: " + entry.getValue().getIdNo() + ", ID Type: " + entry.getValue().getIDType());
}
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();