TDS Calculations

This commit is contained in:
2024-08-14 11:39:26 +05:30
commit 4cac919f42
5 changed files with 744 additions and 0 deletions

36
src/Sample.java Normal file
View File

@@ -0,0 +1,36 @@
import java.time.LocalDate;
import java.util.Random;
/*
* 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
*/
/**
*
* @author 1121947
*/
public class Sample {
public static void main(String[] args) {
int currentYr= LocalDate.now().getYear();
String yrPrfx = String.valueOf(currentYr);
Random random = new Random();
long digits = (long) (random.nextDouble() * 1_000_000_000_00L); // Generates up to 11 digits
// Combine year prefix with random 11 digits
String randomNumber = yrPrfx + String.format("%011d", digits);
System.out.println("The digit is : "+ randomNumber);
//return Long.parseLong(randomNumber);
}
}

View File

@@ -0,0 +1,626 @@
package TDS_Calculate;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
*
* @author 1121947
*/
public class TDS_Calculation {
public static final String URL = "jdbc:oracle:thin:@localhost:1521:IPKSDB";
public static final String USERNAME = "pacs_db";
public static final String PASWORD = "pacs_db";
private static final int batch_length = 1000;
public static void main(String[] args) {
//get the TD/RD account level information
List<Map<String, Object>> depAccountsDetails = getDepAccountsDetails();
int hSize = depAccountsDetails.size();
//System.out.println(hSize);
//Get the PAN Data
Map<String, String> identificationData = fetchPANDetails(depAccountsDetails);
//print the fetched data
// for (Map.Entry<String, String> panDetails : identificationData.entrySet()) {
// System.out.println("cif_no: " + panDetails.getKey() + "ID Type:" + panDetails.getValue());
// }
//Get the 15GH/PAN details as per the customerNumber from the Previous method
checkIdentificationAvailability(depAccountsDetails, identificationData);
//Calculate the Projected value and insert into the table TDS_TXN
for (Map<String, Object> accountDetails : depAccountsDetails) {
String accNo = (String) accountDetails.get("KEY_1");
Double INTT_PROJECTED = (Double) accountDetails.get(("INTT_PROJECTED"));
System.out.println("Interest Paid:" + INTT_PROJECTED);
String INTT_PAYOUT_FREQ = (String) accountDetails.get("INTT_PAYOUT_FREQ");
System.out.println("INTT_PAYOUT_FREQ:" + INTT_PAYOUT_FREQ);
//double ProjectedAmt = calculateProjectedAmount(accountDetails);
// System.out.println("Projected amount for the account:" + accNo + " " + ProjectedAmt);
String prodCode = (String) accountDetails.get("PROD_CODE");
// insertProjectedAmount(accNo, ProjectedAmt, prodCode);
}
}
public static List<Map<String, Object>> getDepAccountsDetails() {
List<Map<String, Object>> depAccountsDetails = new ArrayList<>();
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
String depAccountSql = "SELECT DA.KEY_1,DA.PACS_ID,DA.CURR_STATUS,DA.CUSTOMER_NO,DA.ACCT_OPEN_DT,\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"
+ "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"
+ "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);
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
Map<String, Object> accountDetail = new HashMap<>();
accountDetail.put("KEY_1", resultSet.getString("KEY_1"));
accountDetail.put("PACS_ID", resultSet.getString("PACS_ID"));
accountDetail.put("CURR_STATUS", resultSet.getString("CURR_STATUS"));
accountDetail.put("CUSTOMER_NO", resultSet.getString("CUSTOMER_NO"));
accountDetail.put("ACCT_OPEN_DT", resultSet.getDate("ACCT_OPEN_DT"));
accountDetail.put("INTT_PAID", resultSet.getDouble("INTT_PAID"));
accountDetail.put("PROD_CODE", resultSet.getString("PROD_CODE"));
accountDetail.put("INTT_SOP_DATE", resultSet.getDate("INTT_SOP_DATE"));
accountDetail.put("INTT_EOP_DATE", resultSet.getDate("INTT_EOP_DATE"));
accountDetail.put("TERM_VALUE", resultSet.getInt("TERM_VALUE"));
accountDetail.put("MAT_VALUE", resultSet.getString("MAT_VALUE"));
accountDetail.put("MAT_DT", resultSet.getDate("MAT_DT"));
accountDetail.put("TERM_LENGTH", resultSet.getInt("TERM_LENGTH"));
accountDetail.put("NXT_DUE_DATE", resultSet.getDate("NXT_DUE_DATE"));
accountDetail.put("INTT_PROJECTED", resultSet.getDouble("INTT_PROJECTED"));
accountDetail.put("INTT_PAYOUT_FREQ", resultSet.getString("INTT_PAYOUT_FREQ"));
depAccountsDetails.add(accountDetail);
}
} catch (Exception Ex) {
Ex.printStackTrace();
}
return depAccountsDetails;
}
private static void checkIdentificationAvailability(List<Map<String, Object>> depAccountsDetails, Map<String, String> identificationData) {
String formType = null;
String birth_date = null;
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
for (Map<String, Object> acc : depAccountsDetails) {
String CIF_No = (String) acc.get("CUSTOMER_NO");
String ID_TYPE = identificationData.get(CIF_No);
System.out.println("ID TYPE is: " + ID_TYPE);
// 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);
ps.setString(1, CIF_No);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
try {
birth_date = rs.getString("BIRTH_DATE");
//System.out.println("Birth Date: "+birth_date);
} catch (Exception e) {
System.err.println("null pointer");
}
if (birth_date != null) {
//System.out.println("Birth Date:" + birth_date);
LocalDate submission_date = LocalDate.now();
DateTimeFormatter bdayFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
LocalDate birthdate = LocalDate.parse(birth_date, bdayFormatter);
//if (birth_date != null) {
Period period = Period.between(birthdate, submission_date);
int age = period.getYears(); // Get the years from here.
if (age >= 60) {
formType = "H";
} else {
formType = "G";
}
if ("PAN CARD".equalsIgnoreCase(ID_TYPE)) {
PanAvailability(depAccountsDetails, CIF_No, formType);
} else {
PanNotAvailability(depAccountsDetails, CIF_No, formType);
}
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void PanAvailability(List<Map<String, Object>> depAccountsDetails, String CIF_No, String formType) {
System.out.println("CIF No:" + CIF_No + " is having Pan " + " with Form Type " + formType);
double thresold_G = 250000;
double thresold_H = 300000;
double thresold = 0.0;
double tds_amount = 0.0;
if (formType.equalsIgnoreCase("H")) {
thresold = thresold_H;
} else if (formType.equalsIgnoreCase("G")) {
thresold = thresold_G;
}
System.out.println("Thresold is : " + thresold);
System.out.println("Form Type is : " + formType);
DecimalFormat df_obj = new DecimalFormat("#.####");
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
for (Map<String, Object> acc : depAccountsDetails) {
String AccCIF_No = (String) acc.get("CUSTOMER_NO");
//System.out.println("AccCIF No: " + AccCIF_No);
if (CIF_No.equals(AccCIF_No)) {
String KEY_1 = (String) acc.get("KEY_1");
Double INTT_PAID = (Double) acc.get("INTT_PAID");
double INTT_PROJECTED = (double) acc.get("INTT_PROJECTED");
// Added for GL_TXN calculations
String PACS_ID = (String) acc.get("PACS_ID");
// extract the Form _id from FORM15G_H table.
String getFormData = "SELECT FORM_ID,KEY_1 FROM FORM15G_H WHERE KEY_1= ?";
PreparedStatement ps = conn.prepareStatement(getFormData);
ps.setString(1, AccCIF_No);
ResultSet formResultSet = ps.executeQuery();
int FORM_ID = 0;
if (formResultSet.next()) {
FORM_ID = formResultSet.getInt("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= ?";
PreparedStatement ps1 = conn.prepareStatement(getTdsTxnData);
ps1.setString(1, KEY_1);
ResultSet rs = ps1.executeQuery();
int TXN_ID = 0;
if (rs.next()) {
TXN_ID = rs.getInt("TXN_ID");
}
// System.out.println("TXN ID: " + TXN_ID);
// Starting of TDS Calculation........
if (INTT_PAID != null && INTT_PAID > thresold) {
//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");
System.out.println("pre execution");
insertSmt.executeQuery();
System.out.println("post execution");
// Need to insert the deducted amount into corresponding GL.
insrtGLTransaction(PACS_ID, INTT_PAID, tds_amount);
}else{
System.out.println("INterest Paid didn't cross ");
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void PanNotAvailability(List<Map<String, Object>> depAccountsDetails, String CIF_No, String formType) {
System.out.println("CIF No:" + CIF_No + " is not having Pan " + " with Form Type " + formType);
double thresold_G = 250000;
double thresold_H = 300000;
double thresold = 0;
double tds_amount = 0;
if (formType.equalsIgnoreCase("H")) {
thresold = thresold_H;
} else if (formType.equalsIgnoreCase("G")) {
thresold = thresold_G;
}
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
for (Map<String, Object> acc : depAccountsDetails) {
String AccCIF_No = (String) acc.get("CUSTOMER_NO");
if (CIF_No.equals(AccCIF_No)) {
String KEY_1 = (String) acc.get("KEY_1");
Double INTT_PAID = (Double) acc.get("INTT_PAID");
double INTT_PROJECTED = (double) acc.get("INTT_PROJECTED");
// thresold = formType.equals("H") ? thresold_H : thresold_G;
//System.out.println(thresold);
//System.out.println("Form Type is : " + formType);
// Added for GL_TXN calculations
String PACS_ID = (String) acc.get("PACS_ID");
// extract the Form _id from FORM15G_H table.
String getFormData = "SELECT FORM_ID,KEY_1 FROM FORM15G_H WHERE KEY_1= ?";
PreparedStatement ps = conn.prepareStatement(getFormData);
ps.setString(1, AccCIF_No);
ResultSet formResultSet = ps.executeQuery();
int FORM_ID = 0;
if (formResultSet.next()) {
FORM_ID = formResultSet.getInt("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= ?";
PreparedStatement ps1 = conn.prepareStatement(getTdsTxnData);
ps1.setString(1, KEY_1);
ResultSet rs = ps1.executeQuery();
int TXN_ID = 0;
if (rs.next()) {
TXN_ID = rs.getInt("TXN_ID");
}
//System.out.println("TXN ID: " + TXN_ID);
// Starting of TDS Calculation........
if (INTT_PAID != null && INTT_PAID > thresold) {
//Calculate the TDS.//Here TDS will be 10% as PAN is avaiable
System.out.println("Interest Paid for NO PAN: " + INTT_PAID);
tds_amount = INTT_PAID * 0.20;
System.out.println("TDS Amount is FOR NO PAN : " + tds_amount);
// 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, "N");
insertSmt.executeQuery();
// Need to insert the deducted amount into corresponding GL.
insrtGLTransaction(PACS_ID, INTT_PAID, tds_amount);
}
}
}
// System.out.println("Interest Paid: " + INTT_PAID + " for the account: " +KEY_1);
} catch (Exception e) {
e.printStackTrace();
}
}
public static double calculateProjectedAmount(Map<String, Object> accNo) {
int termValue = (int) accNo.get("TERM_VALUE");
double INTT_PROJECTED = (double) accNo.get("INTT_PROJECTED");
int termLength = (int) accNo.get("TERM_LENGTH"); //in days as per IPKS DB
String inttPayoutFre = ((String) accNo.get("INTT_PAYOUT_FREQ")).trim();
int temp = 0;
switch (inttPayoutFre) {
case "M":
temp = 12;
break;
case "Q":
temp = 4;
break;
case "Y":
temp = 1;
break;
case "O":
temp = 2; // need to be changed here.
break;
default:
throw new IllegalArgumentException("Invalid interest payout frequency: " + inttPayoutFre);
}
//calculate projected amount
double projectedAmount = INTT_PROJECTED * temp;
return projectedAmount;
//insertProjectedAmount(accNo,projectedAmount);
}
public static void insertProjectedAmount(String accNo, double projectedAmt, String prodCode) {
String temp = null;
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
if (prodCode.charAt(0) == '2') {
temp = "TD";
} else if (prodCode.charAt(0) == '3') {
temp = "RD";
}
String insertTxnSql = "insert into TDS_TXN (KEY_1,TXN_DATE,TXN_TYPE,CREATED_AT,PROJ_AMT) values(?,?,?,?,?)";
PreparedStatement ps = conn.prepareStatement(insertTxnSql);
ps.setString(1, accNo);
ps.setDate(2, java.sql.Date.valueOf(LocalDate.now()));
ps.setString(3, temp);
ps.setTimestamp(4, Timestamp.valueOf(LocalDateTime.now()));
ps.setDouble(5, projectedAmt);
ps.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}
}
private static Map<String, String> fetchPANDetails(List<Map<String, Object>> depAccountsDetails) {
Map<String, String> PanData = new HashMap<>();
List<String> cif_No = new ArrayList<>();
// String formType = null;
for (Map<String, Object> acc : depAccountsDetails) {
cif_No.add((String) acc.get("CUSTOMER_NO"));
}
int totalrecords = cif_No.size();
System.out.println("Total:" + totalrecords);
//Boolean panavailable = false;
int numOfBatches = (totalrecords / batch_length) + (totalrecords % batch_length == 0 ? 0 : 1);
System.out.println(numOfBatches);
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
for (int batch = 0; batch < numOfBatches; batch++) {
int startIndex = batch * batch_length;
int endIndex = Math.min(startIndex + batch_length, totalrecords);
// System.out.println("Start:" + startIndex + "end:" + endIndex);
List<String> batchCifNos = cif_No.subList(startIndex, endIndex);
//System.out.println("batch cif no:" + batchCifNos);
//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(");
for (int i = 0; i < batchCifNos.size(); i++) {
stringbuilder.append("?");
if (i < batchCifNos.size() - 1) {
stringbuilder.append(",");
}
}
stringbuilder.append(")");
String checkPanData = stringbuilder.toString();
PreparedStatement preparedstatement = conn.prepareStatement(checkPanData);
// Set the CIF numbers as parameters
for (int i = 0; i < batchCifNos.size(); i++) {
preparedstatement.setString(i + 1, batchCifNos.get(i));
}
ResultSet resultSet = preparedstatement.executeQuery();
// Store the PAN No in the map
while (resultSet.next()) {
String cifNo = resultSet.getString("CIF_NO");
//String panNo = resultSet.getString("ID_NO");
// System.out.println("CIF No: " + cifNo);
String ID_Type = resultSet.getString("ID_TYPE");
//panavailable = true;
// System.out.println("ID Type: " + ID_Type);
PanData.put(cifNo, ID_Type);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return PanData;
}
//This is the method of GL Transaction
public static void insrtGLTransaction(String PACS_ID, double INTT_PAID, double tds_amount) {
// String KEY_1 = null;
double TXN_AMT = INTT_PAID - tds_amount;
System.out.println("TXN Amount is : " + TXN_AMT);
Double end_bal = 0.0;
Double cum_curr_val = 0.0;
Double tot_cr = 0.0;
boolean rowUpdated = false;
try (Connection conn = DriverManager.getConnection(URL, USERNAME, PASWORD)) {
System.out.println("into the GL calculations method");
String getBGLaccNo = "select GA.KEY_1 AS KEY_1 from GL_ACCOUNT GA,GL_PRODUCT GP where GP.ID = GA.GL_PROD_ID and GP.GL_CODE='37506' and GA.STATUS='A' and GA.PACS_ID = ? group by GA.KEY_1";
PreparedStatement BGLpreparestatement = conn.prepareStatement(getBGLaccNo);
BGLpreparestatement.setString(1, PACS_ID);
ResultSet BGLresultSet = BGLpreparestatement.executeQuery();
while (BGLresultSet.next()) {
String KEY_1 = BGLresultSet.getString("KEY_1");
System.out.println("Key_1 is : " + KEY_1);
// 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()){
System.out.println("No BGL avaiable for TDS of this PACS ID. Kindly check manually in the system.");
}
else {
long randomNumberGeneration = randomNumberGenerator();
//Fetch the End Balance and cumm_val from gl_txn and gl_account
String fetchLastRowSql = "Select END_BAL from GL_TXN where ACCT_NO =? ORDER BY POST_TIME DESC FETCH first 1 ROW ONLY";
PreparedStatement fetchpreparestatement = conn.prepareStatement(fetchLastRowSql);
fetchpreparestatement.setString(1, KEY_1);
ResultSet fetchrs = fetchpreparestatement.executeQuery();
while (fetchrs.next()) {
end_bal = fetchrs.getDouble("END_BAL");
if (end_bal == null) {
end_bal = tds_amount;
} else {
end_bal = end_bal + tds_amount;
}
}
String fetchCumVal = "Select cum_curr_val,tot_cr from gl_account where key_1 = ? and pacs_id = ? and gl_prod_id ='061340427'";
PreparedStatement fetchCumValps = conn.prepareStatement(fetchCumVal);
fetchCumValps.setString(1, KEY_1);
fetchCumValps.setString(2, PACS_ID);
ResultSet fetchCumRs = fetchCumValps.executeQuery();
while (fetchCumRs.next()) {
cum_curr_val = fetchCumRs.getDouble("cum_curr_val");
tot_cr = fetchCumRs.getDouble("tot_cr");
if (cum_curr_val == null) {
cum_curr_val = tds_amount;
} else {
cum_curr_val = cum_curr_val + tds_amount;
}
if (tot_cr == null) {
tot_cr = tds_amount;
} else {
tot_cr = tot_cr + tds_amount;
}
}
//Insert Into GL_TXN table
String insertGLTxn = "INSERT INTO GL_TXN (INST_NO,ACCT_NO,CBS_REF_NO,TRAN_DATE,POST_DATE,POST_TIME,JRNL_NO,TRAN_IND,END_BAL,TXN_AMT,NARRATION)\n"
+ "values (?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement ps = conn.prepareStatement(insertGLTxn);
ps.setString(1, "003");
ps.setString(2, KEY_1);
ps.setLong(3, randomNumberGeneration);
ps.setDate(4, java.sql.Date.valueOf(LocalDate.now()));
ps.setDate(5, java.sql.Date.valueOf(LocalDate.now()));
ps.setTimestamp(6, Timestamp.valueOf(LocalDateTime.now()));
ps.setLong(7, randomNumberGeneration);
ps.setString(8, "CR");
ps.setDouble(9, end_bal);
ps.setDouble(10, tds_amount);
ps.setString(11, "TDS Deducted and Credited");
ps.executeUpdate();
System.out.println("Insertion to GL TXN is completed having :" + KEY_1);
//Need to update the GL_ACCOUNT Table as well.
String updateGLAcc = "Update gl_account set cum_curr_val =? ,TOT_CR =? where KEY_1 =? and PACS_ID =? and GL_PROD_ID ='061340427'";
PreparedStatement updatepreparestatement = conn.prepareStatement(updateGLAcc);
updatepreparestatement.setDouble(1, cum_curr_val);
updatepreparestatement.setDouble(2, tot_cr);
updatepreparestatement.setString(3, KEY_1);
updatepreparestatement.setString(4, PACS_ID);
rowUpdated = updatepreparestatement.executeUpdate() > 0;
System.out.println("Row: " + rowUpdated);
}
}
} catch (Exception Ex) {
Ex.printStackTrace();
}
}
private static long randomNumberGenerator() {
int currentYr = LocalDate.now().getYear();
String yrPrfx = String.valueOf(currentYr);
Random random = new Random();
long digits = (long) (random.nextDouble() * 1_000_000_000_00L); // Generates up to 11 digits
// Combine year prefix with random 11 digits
String randomNumber = yrPrfx + String.format("%011d", digits);
return Long.parseLong(randomNumber);
}
}

View File

@@ -0,0 +1,6 @@
db.url=jdbc:oracle:thin:@localhost:1521:IPKSDB
db.username=pacs_db
db.password=pacs_db