Browse Source

added days calculation for after invoice and payment bill raised

master
yoga-agoy 4 months ago
parent
commit
f3ba275d41
  1. BIN
      build/classes/com/cont_mgmt/dto/Bill.class
  2. BIN
      build/classes/com/cont_mgmt/repository/FetchExistBillDet.class
  3. BIN
      build/classes/com/cont_mgmt/repository/FetchExistExtBillDet.class
  4. BIN
      build/classes/com/cont_mgmt/repository/InsertBillDet.class
  5. BIN
      build/classes/com/cont_mgmt/repository/InsertExtBillDet.class
  6. BIN
      build/classes/com/cont_mgmt/repository/UpdateBillDet.class
  7. BIN
      build/classes/com/cont_mgmt/repository/UpdateExtBillDet.class
  8. BIN
      build/classes/com/cont_mgmt/service/ExtBillDetService.class
  9. BIN
      build/classes/com/cont_mgmt/service/NewBillDetService.class
  10. BIN
      build/classes/com/cont_mgmt/service/UpdBillDetService.class
  11. BIN
      build/classes/com/cont_mgmt/service/UpdExtBillDetService.class
  12. BIN
      build/classes/com/cont_mgmt/servlet/ExtBillDetServlet.class
  13. BIN
      build/classes/com/cont_mgmt/servlet/NewBillDetServlet.class
  14. BIN
      build/classes/com/cont_mgmt/servlet/UpdBillDetServlet.class
  15. BIN
      build/classes/com/cont_mgmt/servlet/UpdExtBillDetServlet.class
  16. 27
      src/main/java/com/cont_mgmt/dto/Bill.java
  17. 20
      src/main/java/com/cont_mgmt/repository/FetchExistBillDet.java
  18. 6
      src/main/java/com/cont_mgmt/repository/FetchExistExtBillDet.java
  19. 6
      src/main/java/com/cont_mgmt/repository/InsertBillDet.java
  20. 6
      src/main/java/com/cont_mgmt/repository/InsertExtBillDet.java
  21. 82
      src/main/java/com/cont_mgmt/repository/UpdateBillDet.java
  22. 81
      src/main/java/com/cont_mgmt/repository/UpdateExtBillDet.java
  23. 14
      src/main/java/com/cont_mgmt/service/ExtBillDetService.java
  24. 12
      src/main/java/com/cont_mgmt/service/NewBillDetService.java
  25. 56
      src/main/java/com/cont_mgmt/service/UpdBillDetService.java
  26. 60
      src/main/java/com/cont_mgmt/service/UpdExtBillDetService.java
  27. 5
      src/main/java/com/cont_mgmt/servlet/ExtBillDetServlet.java
  28. 5
      src/main/java/com/cont_mgmt/servlet/NewBillDetServlet.java
  29. 111
      src/main/java/com/cont_mgmt/servlet/UpdBillDetServlet.java
  30. 110
      src/main/java/com/cont_mgmt/servlet/UpdExtBillDetServlet.java
  31. 3
      src/main/webapp/WEB-INF/web.xml
  32. 508
      src/main/webapp/exist_bill_det_display.jsp
  33. 71
      src/main/webapp/exist_ext_bill_det_display.jsp
  34. 12
      src/main/webapp/ext_bill_det_entry.jsp
  35. 40
      src/main/webapp/js/exist-bill-det-funcs-display.js
  36. 40
      src/main/webapp/js/exist-ext-bill-det-funcs-display.js
  37. 12
      src/main/webapp/new_bill_det_entry.jsp
  38. 161
      src/main/webapp/upd_bill_det_entry.jsp
  39. 161
      src/main/webapp/upd_ext_bill_det_entry.jsp

BIN
build/classes/com/cont_mgmt/dto/Bill.class

BIN
build/classes/com/cont_mgmt/repository/FetchExistBillDet.class

BIN
build/classes/com/cont_mgmt/repository/FetchExistExtBillDet.class

BIN
build/classes/com/cont_mgmt/repository/InsertBillDet.class

BIN
build/classes/com/cont_mgmt/repository/InsertExtBillDet.class

BIN
build/classes/com/cont_mgmt/repository/UpdateBillDet.class

BIN
build/classes/com/cont_mgmt/repository/UpdateExtBillDet.class

BIN
build/classes/com/cont_mgmt/service/ExtBillDetService.class

BIN
build/classes/com/cont_mgmt/service/NewBillDetService.class

BIN
build/classes/com/cont_mgmt/service/UpdBillDetService.class

BIN
build/classes/com/cont_mgmt/service/UpdExtBillDetService.class

BIN
build/classes/com/cont_mgmt/servlet/ExtBillDetServlet.class

BIN
build/classes/com/cont_mgmt/servlet/NewBillDetServlet.class

BIN
build/classes/com/cont_mgmt/servlet/UpdBillDetServlet.class

BIN
build/classes/com/cont_mgmt/servlet/UpdExtBillDetServlet.class

27
src/main/java/com/cont_mgmt/dto/Bill.java

@ -21,6 +21,8 @@ public class Bill {
private double itTaxAmt;
private double percentApplied;
private double snaRetAmt;
private String createdDate;
private String updatedDate;
public double getSnaRetAmt() {
return snaRetAmt;
@ -178,6 +180,22 @@ public class Bill {
this.rtgsFilePath = rtgsFilePath;
}
public String getCreatedDate() {
return createdDate;
}
public void setCreatedDate(String createdDate) {
this.createdDate = createdDate;
}
public String getUpdatedDate() {
return updatedDate;
}
public void setUpdatedDate(String updatedDate) {
this.updatedDate = updatedDate;
}
@Override
public String toString() {
return "Bill [invoiceBillingPeriod=" + invoiceBillingPeriod + ", invoiceStartDate=" + invoiceStartDate
@ -186,13 +204,14 @@ public class Bill {
+ igstAmt + ", totAmt=" + totAmt + ", billStatName=" + billStatName + ", billFilePath=" + billFilePath
+ ", invoiceBillDate=" + invoiceBillDate + ", invoiceFilePath=" + invoiceFilePath + ", rtgsFilePath="
+ rtgsFilePath + ", itTaxAmt=" + itTaxAmt + ", percentApplied=" + percentApplied + ", snaRetAmt="
+ snaRetAmt + "]";
+ snaRetAmt + ", createdDate=" + createdDate + ", updatedDate=" + updatedDate + "]";
}
public Bill(String invoiceBillingPeriod, String invoiceStartDate, String invoiceEndDate, double contAmt,
double amtPaid, double amtDue, double amtExclTax, double cgstAmt, double sgstAmt, double igstAmt,
double totAmt, String billStatName, String billFilePath, String invoiceBillDate, String invoiceFilePath,
String rtgsFilePath, double itTaxAmt, double percentApplied, double snaRetAmt) {
String rtgsFilePath, double itTaxAmt, double percentApplied, double snaRetAmt, String createdDate,
String updatedDate) {
super();
this.invoiceBillingPeriod = invoiceBillingPeriod;
this.invoiceStartDate = invoiceStartDate;
@ -213,6 +232,8 @@ public class Bill {
this.itTaxAmt = itTaxAmt;
this.percentApplied = percentApplied;
this.snaRetAmt = snaRetAmt;
this.createdDate = createdDate;
this.updatedDate = updatedDate;
}
}

20
src/main/java/com/cont_mgmt/repository/FetchExistBillDet.java

@ -34,12 +34,16 @@ public class FetchExistBillDet {
// Fetch bill details based on cont_num
query = "select i.invoice_billing_period, i.amt_paid, i.amt_excl_tax, i.cgst_amt, i.sgst_amt, i.igst_amt, "
+ "i.tot_amt, i.amt_due, i.invoice_start_date, i.invoice_end_date, c.cont_amt, i.it_tax_amt, "
+ "b.bill_stat_type_name, i.invoice_billing_date, i.bill_file_path, i.invoice_file_path, "
+ "i.rtgs_file_path, i.percent_applied, i.sna_ret_amt from tbl_invoice_det i "
+ "inner join tbl_bill_stat_type_det b on i.bill_stat_type_id = b.bill_stat_type_id "
+ "inner join tbl_cont_det c on i.cont_num = c.cont_num where c.cont_num = ? "
+ "order by i.invoice_billing_period, i.invoice_start_date";
+ "i.tot_amt, i.amt_due, i.invoice_start_date, i.invoice_end_date, c.cont_amt, i.it_tax_amt, "
+ "b.bill_stat_type_name, i.invoice_billing_date, i.bill_file_path, i.invoice_file_path, "
+ "i.rtgs_file_path, i.percent_applied, i.sna_ret_amt, "
+ "to_char(i.usr_opr_created_timestamp, 'DD-MM-YYYY') as created_date, "
+ "to_char(i.usr_opr_updated_timestamp, 'DD-MM-YYYY') as updated_date "
+ "from tbl_invoice_det i "
+ "inner join tbl_bill_stat_type_det b on i.bill_stat_type_id = b.bill_stat_type_id "
+ "inner join tbl_cont_det c on i.cont_num = c.cont_num "
+ "where c.cont_num = ? "
+ "order by i.invoice_billing_period, i.invoice_start_date";
ps = con.prepareStatement(query);
ps.setString(1, contNum);
@ -72,7 +76,9 @@ public class FetchExistBillDet {
bill.setRtgsFilePath(rs.getString("rtgs_file_path"));
bill.setPercentApplied(rs.getDouble("percent_applied"));
bill.setSnaRetAmt(rs.getDouble("sna_ret_amt"));
bill.setCreatedDate(rs.getString("created_date"));
bill.setUpdatedDate(rs.getString("updated_date"));
billDetList.add(bill);
}

6
src/main/java/com/cont_mgmt/repository/FetchExistExtBillDet.java

@ -37,7 +37,9 @@ public class FetchExistExtBillDet {
+ "i.ext_igst_amt, i.ext_tot_amt, i.ext_amt_due, i.ext_invoice_start_date, i.ext_invoice_end_date, "
+ "c.ext_cont_amt, i.ext_it_tax_amt, b.bill_stat_type_name, i.ext_invoice_billing_date, "
+ "i.ext_bill_file_path, i.ext_invoice_file_path, i.ext_rtgs_file_path, i.ext_percent_applied, "
+ "i.ext_sna_ret_amt from tbl_ext_invoice_det i inner join tbl_bill_stat_type_det b "
+ "i.ext_sna_ret_amt, to_char(i.usr_opr_created_timestamp, 'DD-MM-YYYY') as created_date, "
+ "to_char(i.usr_opr_updated_timestamp, 'DD-MM-YYYY') as updated_date "
+ "from tbl_ext_invoice_det i inner join tbl_bill_stat_type_det b "
+ "on i.ext_bill_stat_type_id = b.bill_stat_type_id inner join tbl_ext_cont_det c "
+ "on i.ext_cont_num = c.ext_cont_num where c.ext_cont_num = ? order by i.ext_invoice_billing_period, "
+ "i.ext_invoice_start_date";
@ -73,6 +75,8 @@ public class FetchExistExtBillDet {
bill.setRtgsFilePath(rs.getString("ext_rtgs_file_path"));
bill.setPercentApplied(rs.getDouble("ext_percent_applied"));
bill.setSnaRetAmt(rs.getDouble("ext_sna_ret_amt"));
bill.setCreatedDate(rs.getString("created_date"));
bill.setUpdatedDate(rs.getString("updated_date"));
billDetList.add(bill);
}

6
src/main/java/com/cont_mgmt/repository/InsertBillDet.java

@ -14,8 +14,8 @@ public class InsertBillDet {
public int insert(String contNum, Double itTaxAmt, String invoiceBillingPeriod, String invoiceStartDate,
String invoiceEndDate, double invoiceAmt, double contAmt, double amtDue, double amtExclTax,
Double newCGSTAmt, Double newSGSTAmt, Double newIGSTAmt, double totAmt, String billFilePath,
String invoiceFilePath, Integer usrId, String invoiceBilledDate, Double newPercent, Double snaRetAmt)
Double newCGSTAmt, Double newSGSTAmt, Double newIGSTAmt, double totAmt, String invoiceFilePath,
Integer usrId, String invoiceBilledDate, Double newPercent, Double snaRetAmt)
throws SQLException, ClassNotFoundException {
// TODO Auto-generated method stub
@ -49,7 +49,7 @@ public class InsertBillDet {
cs.setDouble(10, newIGSTAmt);
cs.setDouble(11, totAmt);
cs.setDouble(12, amtDue);
cs.setString(13, billFilePath);
cs.setString(13, "-");
cs.setInt(14, usrId);
cs.setString(15, invoiceBilledDate);
cs.setInt(16, -1);

6
src/main/java/com/cont_mgmt/repository/InsertExtBillDet.java

@ -14,8 +14,8 @@ public class InsertExtBillDet {
public int insert(String contNum, Double itTaxAmt, String invoiceBillingPeriod, String invoiceStartDate,
String invoiceEndDate, double invoiceAmt, double contAmt, double amtDue, double amtExclTax,
Double newCGSTAmt, Double newSGSTAmt, Double newIGSTAmt, double totAmt, String billFilePath,
String invoiceFilePath, Integer usrId, String invoiceBilledDate, Double newPercent, Double extSNARetAmt)
Double newCGSTAmt, Double newSGSTAmt, Double newIGSTAmt, double totAmt, String invoiceFilePath,
Integer usrId, String invoiceBilledDate, Double newPercent, Double extSNARetAmt)
throws SQLException, ClassNotFoundException {
// TODO Auto-generated method stub
@ -50,7 +50,7 @@ public class InsertExtBillDet {
cs.setDouble(10, newIGSTAmt);
cs.setDouble(11, totAmt);
cs.setDouble(12, amtDue);
cs.setString(13, billFilePath);
cs.setString(13, "-");
cs.setInt(14, usrId);
cs.setString(15, invoiceBilledDate);
cs.setInt(16, -1);

82
src/main/java/com/cont_mgmt/repository/UpdateBillDet.java

@ -0,0 +1,82 @@
package com.cont_mgmt.repository;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.cont_mgmt.dbconnection.DbCon;
public class UpdateBillDet {
// Call the driver class
private DbCon conn = new DbCon();
public boolean update(String contNum, String invoiceBillPeriod, String billFilePath, Integer usrId)
throws SQLException, ClassNotFoundException {
// TODO Auto-generated method stub
Connection con = null;
String query = null;
PreparedStatement ps = null;
boolean flag = false;
try {
// Establish database connection
con = conn.oracleCon();
con.setAutoCommit(false); // keep your transactional logic
con.rollback(); // clear any leftover uncommitted changes
// Check for null values and throw a meaningful NullPointerException
if (invoiceBillPeriod == null) {
throw new NullPointerException("Invoice Billing Period cannot be empty");
}
query = "UPDATE tbl_invoice_det SET bill_stat_type_id = 1, db_updated_timestamp = SYSTIMESTAMP, "
+ "usr_opr_updated_timestamp = CURRENT_TIMESTAMP, opr_upd_user_id = ?, "
+ "bill_file_path = ? WHERE cont_num = ? and invoice_billing_period = ?";
ps = con.prepareStatement(query);
ps.setInt(1, usrId);
ps.setString(2, billFilePath);
ps.setString(3, contNum);
ps.setString(4, invoiceBillPeriod);
int rowsAffected = ps.executeUpdate(); // Execute the query
if (rowsAffected > 0) {
flag = true;
}
// Commit the transaction
con.commit();
} catch (NullPointerException e) {
throw new NullPointerException("Null value encountered: " + e.getMessage());
} catch (SQLException | ClassNotFoundException e) {
if (con != null) {
try {
// Rollback the transaction in case of error
con.rollback();
} catch (SQLException sqle) {
throw sqle;
}
}
throw e;
} finally {
try {
if (ps != null) {
ps.close();
}
if (con != null) {
con.setAutoCommit(true);
con.close();
}
} catch (SQLException sqle) {
throw sqle;
}
}
return flag;
}
}

81
src/main/java/com/cont_mgmt/repository/UpdateExtBillDet.java

@ -0,0 +1,81 @@
package com.cont_mgmt.repository;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.cont_mgmt.dbconnection.DbCon;
public class UpdateExtBillDet {
// Call the driver class
private DbCon conn = new DbCon();
public boolean update(String contNum, String invoiceBillPeriod, String billFilePath, Integer usrId)
throws SQLException, ClassNotFoundException {
// TODO Auto-generated method stub
Connection con = null;
String query = null;
PreparedStatement ps = null;
boolean flag = false;
try {
// Establish database connection
con = conn.oracleCon();
con.setAutoCommit(false); // keep your transactional logic
con.rollback(); // clear any leftover uncommitted changes
// Check for null values and throw a meaningful NullPointerException
if (invoiceBillPeriod == null) {
throw new NullPointerException("Invoice Billing Period cannot be empty");
}
query = "UPDATE tbl_ext_invoice_det SET ext_bill_stat_type_id = 1, db_updated_timestamp = SYSTIMESTAMP, "
+ "usr_opr_updated_timestamp = CURRENT_TIMESTAMP, opr_upd_user_id = ?, "
+ "ext_bill_file_path = ? WHERE ext_cont_num = ? and ext_invoice_billing_period = ?";
ps = con.prepareStatement(query);
ps.setInt(1, usrId);
ps.setString(2, billFilePath);
ps.setString(3, contNum);
ps.setString(4, invoiceBillPeriod);
int rowsAffected = ps.executeUpdate(); // Execute the query
if (rowsAffected > 0) {
flag = true;
}
// Commit the transaction
con.commit();
} catch (NullPointerException e) {
throw new NullPointerException("Null value encountered: " + e.getMessage());
} catch (SQLException | ClassNotFoundException e) {
if (con != null) {
try {
// Rollback the transaction in case of error
con.rollback();
} catch (SQLException sqle) {
throw sqle;
}
}
throw e;
} finally {
try {
if (ps != null) {
ps.close();
}
if (con != null) {
con.setAutoCommit(true);
con.close();
}
} catch (SQLException sqle) {
throw sqle;
}
}
return flag;
}
}

14
src/main/java/com/cont_mgmt/service/ExtBillDetService.java

@ -103,8 +103,8 @@ public class ExtBillDetService {
public int addExtBillDet(String extContNum, String extInvoiceBillingPeriod, String extInvoiceStartDate,
String extInvoiceEndDate, double extInvoiceAmt, double extContAmt, String extCGSTAmt, String extSGSTAmt,
String extIGSTAmt, String extITTaxAmt, Part extBillFilePart, Part extInvoiceFilePart, String extVendName,
Integer extUsrId, String extBasePath, String extInvoiceBilledDate, Double extPercent, Double extSNARetAmt)
String extIGSTAmt, String extITTaxAmt, Part extInvoiceFilePart, String extVendName, Integer extUsrId,
String extBasePath, String extInvoiceBilledDate, Double extPercent, Double extSNARetAmt)
throws ClassNotFoundException, SQLException, IOException {
// TODO Auto-generated method stub
double extAmtExclTax = 0.0;
@ -183,26 +183,20 @@ public class ExtBillDetService {
extTotAmt = extInvoiceAmt;
fileService.createDirectory("Bill-Ext",
fileService.getContractorDirectory(extVendName, extContNum, extBasePath));
String extBillFileName = "Bill-Ext-" + extInvoiceBillingPeriod;
fileService.createDirectory("Invoice-Ext",
fileService.getContractorDirectory(extVendName, extContNum, extBasePath));
String extInvoiceFileName = "Invoice-Ext-" + extInvoiceBillingPeriod;
// Handle file upload
String extBillFilePath = fileService.saveFile(extVendName, extContNum, extBillFilePart, extBillFileName,
extBasePath, extInvoiceDate);
String extInvoiceFilePath = fileService.saveFile(extVendName, extContNum, extInvoiceFilePart,
extInvoiceFileName, extBasePath, extInvoiceDate);
try {
extInvoiceId = insertExtBillDet.insert(extContNum, newExtITTaxAmt, extInvoiceBillingPeriod,
extInvoiceStartDate, extInvoiceEndDate, extInvoiceAmt, extContAmt, extAmtDue, extAmtExclTax,
newExtCGSTAmt, newExtSGSTAmt, newExtIGSTAmt, extTotAmt, extBillFilePath, extInvoiceFilePath,
extUsrId, extInvoiceBilledDate, newExtPercent, extSNARetAmt);
newExtCGSTAmt, newExtSGSTAmt, newExtIGSTAmt, extTotAmt, extInvoiceFilePath, extUsrId,
extInvoiceBilledDate, newExtPercent, extSNARetAmt);
} catch (SQLException | ClassNotFoundException e) {
try {
fileService.deleteFileIfExists(extBillFilePath);
fileService.deleteFileIfExists(extInvoiceFilePath);
} catch (IOException ioe) {
throw ioe;

12
src/main/java/com/cont_mgmt/service/NewBillDetService.java

@ -40,9 +40,8 @@ public class NewBillDetService {
public int addBillDet(String contNum, String invoiceBillingPeriod, String invoiceStartDate, String invoiceEndDate,
double invoiceAmt, double contAmt, String cgstAmt, String sgstAmt, String igstAmt, String itTaxAmt,
Part billFilePart, Part invoiceFilePart, String vendName, Integer usrId, String basePath,
String invoiceBilledDate, Double percent, Double snaRetAmt)
throws ClassNotFoundException, SQLException, IOException {
Part invoiceFilePart, String vendName, Integer usrId, String basePath, String invoiceBilledDate,
Double percent, Double snaRetAmt) throws ClassNotFoundException, SQLException, IOException {
// TODO Auto-generated method stub
double amtExclTax = 0.0;
double totAmt = 0.0;
@ -118,24 +117,19 @@ public class NewBillDetService {
totAmt = invoiceAmt;
fileService.createDirectory("Bill", fileService.getContractorDirectory(vendName, contNum, basePath));
String billFileName = "Bill-" + invoiceBillingPeriod;
fileService.createDirectory("Invoice", fileService.getContractorDirectory(vendName, contNum, basePath));
String invoiceFileName = "Invoice-" + invoiceBillingPeriod;
// Handle file upload
String billFilePath = fileService.saveFile(vendName, contNum, billFilePart, billFileName, basePath,
invoiceDate);
String invoiceFilePath = fileService.saveFile(vendName, contNum, invoiceFilePart, invoiceFileName, basePath,
invoiceDate);
try {
invoiceId = insertBillDet.insert(contNum, newITTaxAmt, invoiceBillingPeriod, invoiceStartDate,
invoiceEndDate, invoiceAmt, contAmt, amtDue, amtExclTax, newCGSTAmt, newSGSTAmt, newIGSTAmt, totAmt,
billFilePath, invoiceFilePath, usrId, invoiceBilledDate, newPercent, snaRetAmt);
invoiceFilePath, usrId, invoiceBilledDate, newPercent, snaRetAmt);
} catch (SQLException | ClassNotFoundException e) {
try {
fileService.deleteFileIfExists(billFilePath);
fileService.deleteFileIfExists(invoiceFilePath);
} catch (IOException ioe) {
throw ioe;

56
src/main/java/com/cont_mgmt/service/UpdBillDetService.java

@ -0,0 +1,56 @@
package com.cont_mgmt.service;
import java.io.IOException;
import java.sql.SQLException;
import com.cont_mgmt.repository.UpdateBillDet;
import jakarta.servlet.http.Part;
public class UpdBillDetService {
// Call the FileService to create directory
private FileService fileService = new FileService();
// Call the UpdateBillDet to upload payment file
private UpdateBillDet updateBillDet = new UpdateBillDet();
// Call the ExistInvoiceBillDateService to fetch invoice bill date based on
// contNum and invoice billing period
private ExistInvoiceBillDateService existInvoiceBillDateService = new ExistInvoiceBillDateService();
public boolean updateBillDet(String contNum, String invoiceBillPeriod, Part billFilePart, Integer usrId,
String vendName, String basePath)
throws ClassNotFoundException, SQLException, NullPointerException, IOException {
// TODO Auto-generated method stub
boolean flag = false;
String billFilePath = null;
try {
String invoiceDate = existInvoiceBillDateService.getInvoiceBillDate(contNum, invoiceBillPeriod);
fileService.createDirectory("Bill", fileService.getContractorDirectory(vendName, contNum, basePath));
String billFileName = "Bill-" + invoiceBillPeriod;
// Handle file upload
billFilePath = fileService.saveFile(vendName, contNum, billFilePart, billFileName, basePath, invoiceDate);
flag = updateBillDet.update(contNum, invoiceBillPeriod, billFilePath, usrId);
} catch (IOException e) {
// TODO Auto-generated catch block
try {
fileService.deleteFileIfExists(billFilePath);
} catch (IOException ioe) {
throw ioe;
}
throw e;
}
if (flag) {
return flag;
} else {
return flag;
}
}
}

60
src/main/java/com/cont_mgmt/service/UpdExtBillDetService.java

@ -0,0 +1,60 @@
package com.cont_mgmt.service;
import java.io.IOException;
import java.sql.SQLException;
import com.cont_mgmt.repository.UpdateExtBillDet;
import jakarta.servlet.http.Part;
public class UpdExtBillDetService {
// Call the FileService to create directory
private FileService fileService = new FileService();
// Call the UpdateExtBillDet to upload payment file
private UpdateExtBillDet updateExtBillDet = new UpdateExtBillDet();
// Call the ExistExtInvoiceBillDateService to fetch invoice bill date based on
// contNum and invoice billing period
private ExistExtInvoiceBillDateService existExtInvoiceBillDateService = new ExistExtInvoiceBillDateService();
public boolean updateExtBillDet(String extContNum, String extInvoiceBillPeriod, Part extBillFilePart,
Integer extUsrId, String extVendName, String extBsePath)
throws ClassNotFoundException, SQLException, NullPointerException, IOException {
// TODO Auto-generated method stub
boolean flag = false;
String extBillFilePath = null;
try {
String extInvoiceDate = existExtInvoiceBillDateService.getExtInvoiceBillDate(extContNum,
extInvoiceBillPeriod);
fileService.createDirectory("Bill-Ext",
fileService.getContractorDirectory(extVendName, extContNum, extBsePath));
String extBillFileName = "Bill-Ext-" + extInvoiceBillPeriod;
// Handle file upload
extBillFilePath = fileService.saveFile(extVendName, extContNum, extBillFilePart, extBillFileName,
extBsePath, extInvoiceDate);
flag = updateExtBillDet.update(extContNum, extInvoiceBillPeriod, extBillFilePath, extUsrId);
} catch (IOException e) {
// TODO Auto-generated catch block
try {
fileService.deleteFileIfExists(extBillFilePath);
} catch (IOException ioe) {
throw ioe;
}
throw e;
}
if (flag) {
return flag;
} else {
return flag;
}
}
}

5
src/main/java/com/cont_mgmt/servlet/ExtBillDetServlet.java

@ -68,7 +68,6 @@ public class ExtBillDetServlet extends HttpServlet {
String extIGSTAmt = stringUtils.safeParam(request, "ext_igst_amt");
String extITTaxAmt = stringUtils.safeParam(request, "ext_it_tax_amt");
Integer extUsrId = Integer.parseInt(request.getParameter("hid_ext_usr_id"));
Part extBillFilePart = request.getPart("ext_bill_file");
Part extInvoiceFilePart = request.getPart("ext_invoice_file");
String extUsrIPAddr = networkUtils.getClientIpAddr(request).trim();
String extBasePath = request.getServletContext().getRealPath("/").trim();
@ -109,8 +108,8 @@ public class ExtBillDetServlet extends HttpServlet {
try {
extInvoiceId = extBillDetService.addExtBillDet(extContNum, extInvoiceBillingPeriod, extInvoiceStartDate,
extInvoiceEndDate, extInvoiceAmt, extContAmt, extCGSTAmt, extSGSTAmt, extIGSTAmt, extITTaxAmt,
extBillFilePart, extInvoiceFilePart, extVendName, extUsrId, extBasePath, extInvoiceBilledDate,
extPercent, extSNARetAmt);
extInvoiceFilePart, extVendName, extUsrId, extBasePath, extInvoiceBilledDate, extPercent,
extSNARetAmt);
if (extInvoiceId >= 1) {
handleBillSuccess(extInvoiceId, extUsrId, extUsrIPAddr, request, response);
} else if (extInvoiceId == -1) {

5
src/main/java/com/cont_mgmt/servlet/NewBillDetServlet.java

@ -68,7 +68,6 @@ public class NewBillDetServlet extends HttpServlet {
String igstAmt = stringUtils.safeParam(request, "igst_amt");
String itTaxAmt = stringUtils.safeParam(request, "it_tax_amt");
Integer usrId = Integer.parseInt(request.getParameter("hid_usr_id"));
Part billFilePart = request.getPart("bill_file");
Part invoiceFilePart = request.getPart("invoice_file");
String usrIPAddr = networkUtils.getClientIpAddr(request).trim();
String basePath = request.getServletContext().getRealPath("/").trim();
@ -107,8 +106,8 @@ public class NewBillDetServlet extends HttpServlet {
try {
invoiceId = newBillDetService.addBillDet(contNum, invoiceBillingPeriod, invoiceStartDate, invoiceEndDate,
invoiceAmt, contAmt, cgstAmt, sgstAmt, igstAmt, itTaxAmt, billFilePart, invoiceFilePart, vendName,
usrId, basePath, invoiceBilledDate, percent, snaRetAmt);
invoiceAmt, contAmt, cgstAmt, sgstAmt, igstAmt, itTaxAmt, invoiceFilePart, vendName, usrId,
basePath, invoiceBilledDate, percent, snaRetAmt);
if (invoiceId >= 1) {
handleBillSuccess(invoiceId, usrId, usrIPAddr, request, response);
} else if (invoiceId == -1) {

111
src/main/java/com/cont_mgmt/servlet/UpdBillDetServlet.java

@ -0,0 +1,111 @@
package com.cont_mgmt.servlet;
import java.io.IOException;
import java.sql.SQLException;
import com.cont_mgmt.service.LogDetService;
import com.cont_mgmt.service.UpdBillDetService;
import com.cont_mgmt.util.NetworkUtils;
import com.cont_mgmt.util.StringUtils;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.MultipartConfig;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.Part;
/**
* Servlet implementation class UpdBillDetServlet
*/
@MultipartConfig
@WebServlet("/UpdBillDetServlet")
public class UpdBillDetServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
// Call the NetworkUtils
private NetworkUtils networkUtils = new NetworkUtils();
// Call the LogDetService to insert log details
private LogDetService logDetService = new LogDetService();
// Call the StringUtils
private StringUtils stringUtils = new StringUtils();
// Call the ModifyBillStatService
private UpdBillDetService updBillDetService = new UpdBillDetService();
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
// Get form values
String contNum = stringUtils.safeParam(request, "hid_cont_num");
String invoiceBillPeriodParam = stringUtils.safeParam(request, "invoice_bill_period");
Part billFilePart = request.getPart("bill_file");
String vendName = stringUtils.safeParam(request, "hid_vend_name");
String invoiceBillPeriod = null;
Integer usrId = Integer.parseInt(request.getParameter("hid_usr_id"));
String basePath = request.getServletContext().getRealPath("/").trim();
String usrIPAddr = networkUtils.getClientIpAddr(request).trim();
String alertMessage = "";
boolean flag = false;
if (invoiceBillPeriodParam != null && !invoiceBillPeriodParam.equals("0")) {
// Proceed with processing the invoice bill period value
invoiceBillPeriod = invoiceBillPeriodParam.trim(); // Now safe to
// use
// Continue with logic
} else {
// Handle the error if the invoice bill period is not selected or is
// invalid
logDetService.addLogDet(usrId, usrIPAddr, "INVALID BILL PERIOD CHOSEN");
response.getWriter().write(stringUtils.buildFailureResponse("Please select a valid invoice bill period."));
}
if (billFilePart == null || billFilePart.getSize() <= 0) {
// Handle the error if the invoice bill period is not selected or is
// invalid
logDetService.addLogDet(usrId, usrIPAddr, "INVOICE BILL STATUS NOT UPDATED");
response.getWriter().write(stringUtils.buildFailureResponse("Please Upload Payment File."));
}
try {
flag = updBillDetService.updateBillDet(contNum, invoiceBillPeriod, billFilePart, usrId, vendName,
basePath);
if (flag) {
alertMessage = "Invoice Bill Status for ITC No " + contNum + " and bill period " + invoiceBillPeriod
+ " updated successfully.";
logDetService.addLogDet(usrId, usrIPAddr, alertMessage.toUpperCase());
response.getWriter().write(stringUtils.buildSuccessResponse(alertMessage));
} else {
alertMessage = "Failed to update invoice bill status for ITC No " + contNum + " and bill period "
+ invoiceBillPeriod;
logDetService.addLogDet(usrId, usrIPAddr, alertMessage.toUpperCase());
response.getWriter().write(stringUtils.buildFailureResponse(alertMessage));
}
} catch (SQLException | ClassNotFoundException | NullPointerException | IOException e) {
String errorMessage = e.getMessage();
logDetService.addLogDet(usrId, usrIPAddr, errorMessage.toUpperCase());
response.getWriter()
.write(stringUtils.buildFailureResponse("Failed to update invoice bill status for ITC No " + contNum
+ " and bill period " + invoiceBillPeriod + ".\\nError: " + errorMessage));
}
}
}

110
src/main/java/com/cont_mgmt/servlet/UpdExtBillDetServlet.java

@ -0,0 +1,110 @@
package com.cont_mgmt.servlet;
import java.io.IOException;
import java.sql.SQLException;
import com.cont_mgmt.service.LogDetService;
import com.cont_mgmt.service.UpdExtBillDetService;
import com.cont_mgmt.util.NetworkUtils;
import com.cont_mgmt.util.StringUtils;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.MultipartConfig;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.Part;
/**
* Servlet implementation class UpdExtBillDetServlet
*/
@WebServlet("/UpdExtBillDetServlet")
@MultipartConfig
public class UpdExtBillDetServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
// Call the NetworkUtils
private NetworkUtils networkUtils = new NetworkUtils();
// Call the LogDetService to insert log details
private LogDetService logDetService = new LogDetService();
// Call the StringUtils
private StringUtils stringUtils = new StringUtils();
// Call the UpdExtBillDetService
private UpdExtBillDetService updExtBillDetService = new UpdExtBillDetService();
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
// Get form values
String extContNum = stringUtils.safeParam(request, "hid_ext_cont_num");
String extInvoiceBillPeriodParam = stringUtils.safeParam(request, "ext_invoice_bill_period");
Part extBillFilePart = request.getPart("ext_bill_file");
String extVendName = stringUtils.safeParam(request, "hid_ext_vend_name");
String extInvoiceBillPeriod = null;
Integer extUsrId = Integer.parseInt(request.getParameter("hid_ext_usr_id"));
String extBsePath = request.getServletContext().getRealPath("/").trim();
String extUsrIPAddr = networkUtils.getClientIpAddr(request).trim();
String alertMessage = "";
boolean flag = false;
if (extInvoiceBillPeriodParam != null && !extInvoiceBillPeriodParam.equals("0")) {
// Proceed with processing the invoice bill period value
extInvoiceBillPeriod = extInvoiceBillPeriodParam.trim(); // Now safe to
// use
// Continue with logic
} else {
// Handle the error if the invoice bill period is not selected or is
// invalid
logDetService.addLogDet(extUsrId, extUsrIPAddr, "INVALID EXTENSION BILL PERIOD CHOSEN");
response.getWriter()
.write(stringUtils.buildFailureResponse("Please select a valid extension invoice bill period."));
}
if (extBillFilePart == null || extBillFilePart.getSize() <= 0) {
// Handle the error if the invoice bill period is not selected or is
// invalid
logDetService.addLogDet(extUsrId, extUsrIPAddr, "EXTENSION INVOICE BILL STATUS NOT UPDATED");
response.getWriter().write(stringUtils.buildFailureResponse("Please Upload Extension Payment File."));
}
try {
flag = updExtBillDetService.updateExtBillDet(extContNum, extInvoiceBillPeriod, extBillFilePart, extUsrId,
extVendName, extBsePath);
if (flag) {
alertMessage = "Extension Invoice Bill Status for ITC No " + extContNum + " and bill period "
+ extInvoiceBillPeriod + " updated successfully.";
logDetService.addLogDet(extUsrId, extUsrIPAddr, alertMessage.toUpperCase());
response.getWriter().write(stringUtils.buildSuccessResponse(alertMessage));
} else {
alertMessage = "Failed to update extension invoice bill status for ITC No " + extContNum
+ " and bill period " + extInvoiceBillPeriod;
logDetService.addLogDet(extUsrId, extUsrIPAddr, alertMessage.toUpperCase());
response.getWriter().write(stringUtils.buildFailureResponse(alertMessage));
}
} catch (SQLException | ClassNotFoundException | NullPointerException | IOException e) {
String errorMessage = e.getMessage();
logDetService.addLogDet(extUsrId, extUsrIPAddr, errorMessage.toUpperCase());
response.getWriter().write(
stringUtils.buildFailureResponse("Failed to update extension " + "invoice bill status for ITC No "
+ extContNum + " and bill period " + extInvoiceBillPeriod + ".\\nError: " + errorMessage));
}
}
}

3
src/main/webapp/WEB-INF/web.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://jakarta.ee/xml/ns/jakartaee" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd" id="WebApp_ID" version="5.0">
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="5.0">
<display-name>ContractManagementSystem</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
@ -10,7 +10,6 @@
<welcome-file>default.htm</welcome-file>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<!-- JNDI Resource reference -->
<resource-ref>
<description>Oracle DB Connection Details for Contract Management System</description>
<res-ref-name>jdbc/ContractDB</res-ref-name>

508
src/main/webapp/exist_bill_det_display.jsp

@ -2,56 +2,58 @@
pageEncoding="UTF-8"%>
<%@ page language="java" import="com.cont_mgmt.dto.User, java.util.*"%>
<%@ page language="java" import="com.cont_mgmt.dto.Bill,java.net.*"%>
<%@ page language="java" import="com.cont_mgmt.util.TimeUtils, java.text.*"%>
<%@ page language="java"
import="com.cont_mgmt.util.TimeUtils, java.text.*"%>
<%@ page language="java"
import="com.cont_mgmt.wrapper.BillDetListWrapper"%>
<%@ page language="java"
import="com.cont_mgmt.wrapper.ContDetListWrapper"%>
<%@ page language="java" import="com.cont_mgmt.dto.Contract"%>
<%@ page language="java" import="com.cont_mgmt.service.ExistExtContDetService"%>
<%@ page language="java"
import="com.cont_mgmt.service.ExistExtContDetService"%>
<%
// Check if the user is logged in by checking if the user object is not null
User user = (User) session.getAttribute("user");
if (user == null || user.getUserName().equals("")) {
// If not logged in, redirect to logout.jsp
response.sendRedirect("logout.jsp");
return; // Stop further execution of the page
}
String errorMessage = (String) request.getAttribute("errorMessage");
String reqSrc = (String) request.getAttribute("reqSrc");
String vendName = (String) request.getAttribute("vendName");
Integer lockPercent = 0;
Integer lockAmount = 0;
// Call the TimeUtils
TimeUtils timeUtils = new TimeUtils();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
Date currentDate = sdf.parse(sdf.format(new Date()));
// Call the ExistExtContDetService
ExistExtContDetService existExtContDetService = new ExistExtContDetService();
// Retrieve the BillDetListWrapper and ContractDetListWrapper attribute set by the servlet
BillDetListWrapper billDetListWrapper = (BillDetListWrapper) request.getAttribute("billListWrapper");
ContDetListWrapper contDetListWrapper = (ContDetListWrapper) request.getAttribute("contListWrapper");
if (billDetListWrapper != null && !billDetListWrapper.getBillDetList().isEmpty()) {
for (Bill bill : billDetListWrapper.getBillDetList()) {
lockPercent += (int) Math.round(bill.getPercentApplied());
lockAmount += (int) Math.round(bill.getTotAmt());
}
}
Integer thresholdAmt = (int) Math.round(contDetListWrapper.getContList().get(0).getContAmt());
String contNum = contDetListWrapper.getContList().get(0).getContNum();
Integer isExtendedFlag = (int) Math.round(contDetListWrapper.getContList().get(0).getIsExtended());
List<Contract> extContList = new ArrayList<Contract>();
if (isExtendedFlag == 1) {
extContList = existExtContDetService.getExtContDet(null, contNum);
}
User user = (User) session.getAttribute("user");
if (user == null || user.getUserName().equals("")) {
// If not logged in, redirect to logout.jsp
response.sendRedirect("logout.jsp");
return; // Stop further execution of the page
}
String errorMessage = (String) request.getAttribute("errorMessage");
String reqSrc = (String) request.getAttribute("reqSrc");
String vendName = (String) request.getAttribute("vendName");
Integer lockPercent = 0;
Integer lockAmount = 0;
// Call the TimeUtils
TimeUtils timeUtils = new TimeUtils();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
Date currentDate = sdf.parse(sdf.format(new Date()));
// Call the ExistExtContDetService
ExistExtContDetService existExtContDetService = new ExistExtContDetService();
// Retrieve the BillDetListWrapper and ContractDetListWrapper attribute set by the servlet
BillDetListWrapper billDetListWrapper = (BillDetListWrapper) request.getAttribute("billListWrapper");
ContDetListWrapper contDetListWrapper = (ContDetListWrapper) request.getAttribute("contListWrapper");
if (billDetListWrapper != null && !billDetListWrapper.getBillDetList().isEmpty()) {
for (Bill bill : billDetListWrapper.getBillDetList()) {
lockPercent += (int) Math.round(bill.getPercentApplied());
lockAmount += (int) Math.round(bill.getTotAmt());
}
}
Integer thresholdAmt = (int) Math.round(contDetListWrapper.getContList().get(0).getContAmt());
String contNum = contDetListWrapper.getContList().get(0).getContNum();
Integer isExtendedFlag = (int) Math.round(contDetListWrapper.getContList().get(0).getIsExtended());
List<Contract> extContList = new ArrayList<Contract>();
if (isExtendedFlag == 1) {
extContList = existExtContDetService.getExtContDet(null, contNum);
}
%>
<!DOCTYPE html>
<html>
@ -61,14 +63,15 @@
<title>Contract Management System</title>
<link rel="stylesheet" type="text/css" href="css/body-form-style.css">
<link rel="stylesheet" type="text/css" href="css/datatable-styles.css">
<link rel="stylesheet" type="text/css" href="css/exist-bill-det-display.css">
<link rel="stylesheet" type="text/css"
href="css/exist-bill-det-display.css">
<link rel="stylesheet" type="text/css" href="css/btn-secondary.css">
<%@include file="includes/header.jsp"%>
</head>
<body>
<%
if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
%>
<%
if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
%>
<%@include file="includes/exist_navbar.jsp"%>
<%
} else if (reqSrc.equalsIgnoreCase("exp_cont_det_display_page")) {
@ -83,12 +86,12 @@
%>
<div class="container mt-4">
<div class="form-container">
<div class="header-row">
<button class="back-button" onclick="goBack()">&#8592; Back</button>
</div>
<%
if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
%>
<div class="header-row">
<button class="back-button" onclick="goBack()">&#8592; Back</button>
</div>
<%
if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
%>
<h2 class="cont-title">Contract Details</h2>
<%
} else if (reqSrc.equalsIgnoreCase("exp_cont_det_display_page")) {
@ -97,11 +100,11 @@
<%
} else if (reqSrc.equalsIgnoreCase("cust_rep_det_display_page")) {
%>
<h2 class="cont-title">Custom Reports Contract Details</h2>
<h2 class="cont-title">Custom Reports Contract Details</h2>
<%
}
if (contDetListWrapper != null && !contDetListWrapper.getContList().isEmpty()) {
%>
}
if (contDetListWrapper != null && !contDetListWrapper.getContList().isEmpty()) {
%>
<div class="row mb-3">
<div class="col-md-6">
<p>
@ -110,9 +113,8 @@
<input type="hidden" id="hid_vend_id" name="hid_vend_id"
value="<%=contDetListWrapper.getContList().get(0).getVendId()%>">
<input type="hidden" id="hid_vend_name" name="hid_vend_name"
value="<%=vendName%>">
<input type="hidden" id="hid_user_id" name="hid_user_id"
value="<%=user.getUserId()%>">
value="<%=vendName%>"> <input type="hidden"
id="hid_user_id" name="hid_user_id" value="<%=user.getUserId()%>">
</div>
</div>
<div class="row mb-3">
@ -125,19 +127,21 @@
</div>
</div>
<div class="row mb-3">
<div class="col-12">
<p><Strong>Work Order Amount :</Strong>
₹ <%=String.format("%,.2f", contDetListWrapper.getContList().get(0).getContAmt())%>
</div>
<div class="col-12">
<p>
<Strong>Work Order Amount :</Strong> ₹
<%=String.format("%,.2f", contDetListWrapper.getContList().get(0).getContAmt())%>
</div>
</div>
<div id="fileRow" class="row mb-3 d-flex justify-content-between text-center">
<div class="col-12 col-md-3">
<div id="fileRow"
class="row mb-3 d-flex justify-content-between text-center">
<div class="col-12 col-md-3">
<p>
<strong>AS File : </strong>
<button class="btn"
onclick="viewFileInModal('<%=contNum%>','AS',
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContASFilePath(),
"UTF-8").replace("+", "%20")%>')">
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContASFilePath(), "UTF-8").replace("+",
"%20")%>')">
<i class="fas fa-light fa-eye" style="cursor: pointer"></i>
</button>
</p>
@ -146,23 +150,23 @@
if (!contDetListWrapper.getContList().get(0).getContLOAFilePath().trim().equals("-")) {
%>
<div class="col-12 col-md-3">
<p>
<p>
<strong>LOA File :</strong>
<button class="btn"
onclick="viewFileInModal('<%=contNum%>','LOA',
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContLOAFilePath(),
"UTF-8").replace("+", "%20")%>')">
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContLOAFilePath(), "UTF-8").replace("+",
"%20")%>')">
<i class="fas fa-light fa-eye" style="cursor: pointer"></i>
</button>
</p>
</div>
<div class="col-12 col-md-3">
<p>
<p>
<strong>Agreement File :</strong>
<button class="btn"
onclick="viewFileInModal('<%=contNum%>','Agreement',
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContAgreeFilePath(),
"UTF-8").replace("+", "%20")%>')">
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContAgreeFilePath(), "UTF-8")
.replace("+", "%20")%>')">
<i class="fas fa-light fa-eye" style="cursor: pointer"></i>
</button>
</p>
@ -171,12 +175,12 @@
} else {
%>
<div class="col-12 col-md-3">
<p>
<p>
<strong>Agreement File :</strong>
<button class="btn"
onclick="viewFileInModal('<%=contNum%>','Agreement',
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContAgreeFilePath(),
"UTF-8").replace("+", "%20")%>')">
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContAgreeFilePath(), "UTF-8")
.replace("+", "%20")%>')">
<i class="fas fa-light fa-eye" style="cursor: pointer"></i>
</button>
</p>
@ -189,70 +193,73 @@
<strong>WO File : </strong>
<button class="btn"
onclick="viewFileInModal('<%=contNum%>','Work-Order',
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContWOFilePath(),
"UTF-8").replace("+", "%20")%>')">
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContWOFilePath(), "UTF-8").replace("+",
"%20")%>')">
<i class="fas fa-eye" style="cursor: pointer"></i>
</button>
</p>
</div>
</div>
<div id="fileRow2" class="row mb-3 d-flex justify-content-between text-center">
<%
if (!contDetListWrapper.getContList().get(0).getContEMDFilePath().trim().equals("-")) {
%>
<div class="col-12 col-md-3">
<div id="fileRow2"
class="row mb-3 d-flex justify-content-between text-center">
<%
if (!contDetListWrapper.getContList().get(0).getContEMDFilePath().trim().equals("-")) {
%>
<div class="col-12 col-md-3">
<p>
<strong>EMD File : </strong>
<button class="btn"
onclick="viewFileInModal('<%=contNum%>','EMD',
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContEMDFilePath(),
"UTF-8").replace("+", "%20")%>')">
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContEMDFilePath(), "UTF-8").replace("+",
"%20")%>')">
<i class="fas fa-eye" style="cursor: pointer"></i>
</button>
</p>
</div>
<%
} if (!contDetListWrapper.getContList().get(0).getContSDFilePath().trim().equals("-")) {
%>
<div class="col-12 col-md-3">
<%
}
if (!contDetListWrapper.getContList().get(0).getContSDFilePath().trim().equals("-")) {
%>
<div class="col-12 col-md-3">
<p>
<strong>SD File : </strong>
<button class="btn"
onclick="viewFileInModal('<%=contNum%>','SD',
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContSDFilePath(),
"UTF-8").replace("+", "%20")%>')">
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContSDFilePath(), "UTF-8").replace("+",
"%20")%>')">
<i class="fas fa-eye" style="cursor: pointer"></i>
</button>
</p>
</div>
<%
} if (!contDetListWrapper.getContList().get(0).getContASDFilePath().trim().equals("-")) {
%>
<div class="col-12 col-md-3">
<%
}
if (!contDetListWrapper.getContList().get(0).getContASDFilePath().trim().equals("-")) {
%>
<div class="col-12 col-md-3">
<p>
<strong>ASD File : </strong>
<button class="btn"
onclick="viewFileInModal('<%=contNum%>','ASD',
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContASDFilePath(),
"UTF-8").replace("+", "%20")%>')">
'<%=java.net.URLEncoder.encode(contDetListWrapper.getContList().get(0).getContASDFilePath(), "UTF-8").replace("+",
"%20")%>')">
<i class="fas fa-eye" style="cursor: pointer"></i>
</button>
</p>
</div>
<%
}
%>
<%
}
%>
</div>
<%
}
%>
<div class="row mb-3">
<div class="col-md-6">
<p>
<div class="col-md-6">
<p>
<strong>Remarks :</strong>
<%=contDetListWrapper.getContList().get(0).getContRmrk()%>
</p>
</div>
</div>
</div>
<h2 class="bill-title">Bill Details</h2>
<%
@ -262,8 +269,7 @@
<!-- Adds spacing and a responsive layout -->
<div class="col-12 col-md-8 mb-2 mb-md-0">
<!-- Buttons on the left -->
<div class="btn-group" role="group"
aria-label="Options">
<div class="btn-group" role="group" aria-label="Options">
<%
if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
%>
@ -279,15 +285,14 @@
</div>
<p class="text-danger text-center"><%=errorMessage%></p>
<%
} else if ((billDetListWrapper == null) && (contDetListWrapper != null ||
!contDetListWrapper.getContList().isEmpty())) {
} else if ((billDetListWrapper == null)
&& (contDetListWrapper != null || !contDetListWrapper.getContList().isEmpty())) {
%>
<div class="row mb-3">
<!-- Adds spacing and a responsive layout -->
<div class="col-12 col-md-8 mb-2 mb-md-0">
<!-- Buttons on the left -->
<div class="btn-group" role="group"
aria-label="Options">
<div class="btn-group" role="group" aria-label="Options">
<%
if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
%>
@ -305,23 +310,25 @@
<p>No results found for the given criteria.</p>
</div>
<%
} if (billDetListWrapper != null && !billDetListWrapper.getBillDetList().isEmpty()) {
Integer pos = billDetListWrapper.getBillDetList().size() - 1;
String rtgsFile = billDetListWrapper.getBillDetList().get(pos).getRtgsFilePath();
String sdFile = contDetListWrapper.getContList().get(0).getContSDFilePath();
Integer amtDueFlag = (int) Math.round(billDetListWrapper.getBillDetList().get(pos).getAmtDue());
Integer diffInDaysFlag = Integer.parseInt(timeUtils.getExpiryDays(sdf, currentDate,
contDetListWrapper.getContList().get(0).getContEndDate()));
boolean rtgsFileFlag = rtgsFile.trim().equals("-") ? true : false;
boolean sdFileFlag = sdFile.trim().equals("-") ? true : false;
}
if (billDetListWrapper != null && !billDetListWrapper.getBillDetList().isEmpty()) {
Integer pos = billDetListWrapper.getBillDetList().size() - 1;
String rtgsFile = billDetListWrapper.getBillDetList().get(pos).getRtgsFilePath();
String billFile = billDetListWrapper.getBillDetList().get(pos).getBillFilePath();
String sdFile = contDetListWrapper.getContList().get(0).getContSDFilePath();
Integer amtDueFlag = (int) Math.round(billDetListWrapper.getBillDetList().get(pos).getAmtDue());
Integer diffInDaysFlag = Integer
.parseInt(timeUtils.getExpiryDays(sdf, currentDate, contDetListWrapper.getContList().get(0).getContEndDate()));
boolean rtgsFileFlag = rtgsFile.trim().equals("-") ? true : false;
boolean billFileFlag = billFile.trim().equals("-") ? true : false;
boolean sdFileFlag = sdFile.trim().equals("-") ? true : false;
%>
<!-- Button and Filter Bar -->
<div class="row mb-3">
<!-- Adds spacing and a responsive layout -->
<div class="col-12 col-md-8 mb-2 mb-md-0">
<!-- Buttons on the left -->
<div class="btn-group" role="group"
aria-label="Options">
<div class="btn-group" role="group" aria-label="Options">
<button class="btn btn-secondary" id="export_excel"
name="export_excel">
<i class="fas fa-file-excel"></i> Export Excel
@ -331,37 +338,57 @@
<i class="fas fa-file-pdf"></i> Export PDF
</button>
<%
if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
if (lockPercent < 100 && lockAmount < thresholdAmt) {
if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
if (lockPercent < 100 && lockAmount < thresholdAmt) {
%>
<button class="btn btn-secondary" id="new_bill_det_btn"
name="new_bill_det_btn" onclick="redirectToAddNewBillPage()">
<i class="fas fa-circle-plus"></i> Add Bill
</button>
<button class="btn btn-secondary" id="upd_bill_det_btn"
name="upd_bill_det_btn" onclick="redirectToUpdateBillPage()">
<i class="fas fa-light fa-pen"></i> Upload Payment
</button>
<button class="btn btn-secondary" id="modify_bill_det_btn"
name="modify_bill_det_btn" onclick="redirectToModifyBillPage()">
<i class="fas fa-light fa-pen"></i> Modify Bill
<i class="fas fa-light fa-pen"></i> Upload RTGS
</button>
<%
} else if (lockAmount < thresholdAmt) {
} else if (lockAmount < thresholdAmt) {
%>
<button class="btn btn-secondary" id="new_bill_det_btn"
name="new_bill_det_btn" onclick="redirectToAddNewBillPage()">
<i class="fas fa-circle-plus"></i> Add Bill
</button>
<button class="btn btn-secondary" id="upd_bill_det_btn"
name="upd_bill_det_btn" onclick="redirectToUpdateBillPage()">
<i class="fas fa-light fa-pen"></i> Upload Payment
</button>
<button class="btn btn-secondary" id="modify_bill_det_btn"
name="modify_bill_det_btn" onclick="redirectToModifyBillPage()">
<i class="fas fa-light fa-pen"></i> Upload RTGS
</button>
<%
} else if (rtgsFileFlag && billFileFlag) {
%>
<button class="btn btn-secondary" id="upd_bill_det_btn"
name="upd_bill_det_btn" onclick="redirectToUpdateBillPage()">
<i class="fas fa-light fa-pen"></i> Upload Payment
</button>
<button class="btn btn-secondary" id="modify_bill_det_btn"
name="modify_bill_det_btn" onclick="redirectToModifyBillPage()">
<i class="fas fa-light fa-pen"></i> Modify Bill
<i class="fas fa-light fa-pen"></i> Upload RTGS
</button>
<%
} else if (rtgsFileFlag) {
%>
<button class="btn btn-secondary" id="modify_bill_det_btn"
name="modify_bill_det_btn" onclick="redirectToModifyBillPage()">
<i class="fas fa-light fa-pen"></i> Modify Bill
<i class="fas fa-light fa-pen"></i> Upload RTGS
</button>
<%
} if ((amtDueFlag <= 0 || diffInDaysFlag < 0) && (sdFileFlag)) {
}
if ((amtDueFlag <= 0 || diffInDaysFlag < 0) && (sdFileFlag)) {
%>
<button class="btn btn-secondary" id="close_cont_det_btn"
name="close_cont_det_btn" onclick="redirectToCloseContract()">
@ -369,16 +396,16 @@
</button>
<%
}
}
}
%>
</div>
</div>
<%
if (isExtendedFlag == 1) {
%>
<div class="col-md-8" style="padding-top:5px">
<div class="btn-group" role="group" aria-label="Options">
<button class="btn btn-secondary" id="view_ext_det_btn"
<div class="col-md-8" style="padding-top: 5px">
<div class="btn-group" role="group" aria-label="Options">
<button class="btn btn-secondary" id="view_ext_det_btn"
name="view_ext_det_btn" onclick="redirectToViewExtension()">
<i class="fa-solid fa-folder-open"></i> View Ext.Bills
</button>
@ -417,111 +444,158 @@
<th>SNA Ret.Amount</th>
<th>Total Amount</th>
<%
if (contDetListWrapper.getContList().get(0)
.getInvoiceBillTypeName()
.equalsIgnoreCase("PERCENTAGE BASED PAYMENT")) {
if (contDetListWrapper.getContList().get(0).getInvoiceBillTypeName().equalsIgnoreCase("PERCENTAGE BASED PAYMENT")) {
%>
<th>Percent Applied</th>
<%
}
%>
<th>Balance To Be Claimed</th>
<th>Days Passed after Invoice Upload</th>
<th>Days Passed after Payment Upload</th>
<th class="no-export">View Files</th>
</tr>
</thead>
<tbody>
<%
double lastClaimedAmountDue = 0.0;
boolean isFirstRow = true;
for (Bill bill : billDetListWrapper.getBillDetList()) {
boolean isClaimed = bill.getBillStatName().equalsIgnoreCase("CLAIMED");
double amtDue;
if (isFirstRow) {
// First row logic
lastClaimedAmountDue = isClaimed ? bill.getAmtDue() : bill.getContAmt();
amtDue = lastClaimedAmountDue;
isFirstRow = false;
} else {
if (isClaimed) {
// For claimed rows, deduct amount paid
lastClaimedAmountDue -= bill.getAmtPaid();
}
// For unclaimed rows, retain the lastClaimedAmountDue
amtDue = lastClaimedAmountDue;
}
%>
<tr>
<td></td>
<td><%= bill.getInvoiceBillingPeriod() %></td>
<td><%= bill.getInvoiceStartDate() %></td>
<td><%= bill.getInvoiceEndDate() %></td>
<td><%= bill.getInvoiceBillDate() %></td>
<td><%= bill.getBillStatName() %></td>
<td>₹
<%
double currentAmt = bill.getTotAmt() + bill.getAmtDue();
if (bill.getBillStatName().equals("CLAIMED")) {
out.print(String.format("%,.2f", currentAmt));
} else {
out.print(String.format("%,.2f", lastClaimedAmountDue));
}
%>
</td>
<td>₹ <%= String.format("%,.2f", bill.getAmtExclTax()) %></td>
<td>₹ <%= String.format("%,.2f", bill.getCgstAmt()) %></td>
<td>₹ <%= String.format("%,.2f", bill.getSgstAmt()) %></td>
<td>₹ <%= String.format("%,.2f", bill.getIgstAmt()) %></td>
<td>₹ <%= String.format("%,.2f", bill.getItTaxAmt())%></td>
<td>₹ <%= String.format("%,.2f", bill.getSnaRetAmt())%></td>
<td>₹ <%= String.format("%,.2f", bill.getTotAmt()) %></td>
<% if (contDetListWrapper.getContList().get(0)
.getInvoiceBillTypeName()
.equalsIgnoreCase("PERCENTAGE BASED PAYMENT")) { %>
<td><%= bill.getPercentApplied()%> %</td>
<% } %>
<td>₹ <%= String.format("%,.2f", amtDue) %></td> <!-- Corrected Balance To Be Claimed -->
<td class="no-export">
<div style="display: flex; gap :10px; align-items: center">
<button onclick="viewFileInModal('<%= contNum %>','Bill',
'<%= java.net.URLEncoder.encode(bill.getBillFilePath(),
"UTF-8").replace("+", "%20") %>')" style="cursor: pointer;"
class="btn btn-secondary">Bill</button>
<button onclick="viewFileInModal('<%= contNum %>','Invoice',
'<%= java.net.URLEncoder.encode(bill.getInvoiceFilePath(),
"UTF-8").replace("+", "%20") %>')" style="cursor: pointer;"
class="btn btn-secondary">Invoice</button>
<% if (!bill.getRtgsFilePath().equals("-")) { %>
<button onclick="viewFileInModal('<%= contNum %>','RTGS',
'<%= java.net.URLEncoder.encode(bill.getRtgsFilePath(),
"UTF-8").replace("+", "%20") %>')" style="cursor: pointer;"
class="btn btn-secondary">RTGS</button>
<% } %>
</div>
</td>
</tr>
<% } %>
</tbody>
<%
double lastClaimedAmountDue = 0.0;
boolean isFirstRow = true;
for (Bill bill : billDetListWrapper.getBillDetList()) {
boolean isClaimed = bill.getBillStatName().equalsIgnoreCase("CLAIMED");
double amtDue;
long diffMillis = 0L;
long diffDays = 0L;
if (isFirstRow) {
// First row logic
lastClaimedAmountDue = isClaimed ? bill.getAmtDue() : bill.getContAmt();
amtDue = lastClaimedAmountDue;
isFirstRow = false;
} else {
if (isClaimed) {
// For claimed rows, deduct amount paid
lastClaimedAmountDue -= bill.getAmtPaid();
}
// For unclaimed rows, retain the lastClaimedAmountDue
amtDue = lastClaimedAmountDue;
}
%>
<tr>
<td></td>
<td><%=bill.getInvoiceBillingPeriod()%></td>
<td><%=bill.getInvoiceStartDate()%></td>
<td><%=bill.getInvoiceEndDate()%></td>
<td><%=bill.getInvoiceBillDate()%></td>
<td><%=bill.getBillStatName()%></td>
<td>₹ <%
double currentAmt = bill.getTotAmt() + bill.getAmtDue();
if (bill.getBillStatName().equals("CLAIMED")) {
out.print(String.format("%,.2f", currentAmt));
} else {
out.print(String.format("%,.2f", lastClaimedAmountDue));
}
%>
</td>
<td>₹ <%=String.format("%,.2f", bill.getAmtExclTax())%></td>
<td>₹ <%=String.format("%,.2f", bill.getCgstAmt())%></td>
<td>₹ <%=String.format("%,.2f", bill.getSgstAmt())%></td>
<td>₹ <%=String.format("%,.2f", bill.getIgstAmt())%></td>
<td>₹ <%=String.format("%,.2f", bill.getItTaxAmt())%></td>
<td>₹ <%=String.format("%,.2f", bill.getSnaRetAmt())%></td>
<td>₹ <%=String.format("%,.2f", bill.getTotAmt())%></td>
<%
if (contDetListWrapper.getContList().get(0).getInvoiceBillTypeName().equalsIgnoreCase("PERCENTAGE BASED PAYMENT")) {
%>
<td><%=bill.getPercentApplied()%> %</td>
<%
}
%>
<td>₹ <%=String.format("%,.2f", amtDue)%></td>
<td><%
if (bill.getBillFilePath().equals("-") && !bill.getInvoiceFilePath().equals("-")) {
Date createdDate = sdf.parse(bill.getCreatedDate()); // e.g. 15-05-2026
diffMillis = currentDate.getTime() - createdDate.getTime();
diffDays = diffMillis / (1000 * 60 * 60 * 24);
//out.println(diffDays);
out.println("<span style='color:red;font-weight:bold;'>" + diffDays + " Days</span>");
} else if (!bill.getBillFilePath().equals("-") && !bill.getInvoiceFilePath().equals("-")) {
out.println("Invoice and Payment Files are uploaded");
}
diffMillis = 0L;
diffDays = 0l;
%></td>
<td><%
if (!bill.getInvoiceFilePath().equals("-") && !bill.getBillFilePath().equals("-")
&& bill.getRtgsFilePath().equals("-")) {
Date updatedDate = sdf.parse(bill.getUpdatedDate()); // e.g. 17-05-2026
diffMillis = currentDate.getTime() - updatedDate.getTime();
diffDays = diffMillis / (1000 * 60 * 60 * 24);
//out.println(diffDays);
out.println("<span style='color:red;font-weight:bold;'>" + diffDays + " Days</span>");
} else if (!bill.getInvoiceFilePath().equals("-") && !bill.getBillFilePath().equals("-")
&& !bill.getRtgsFilePath().equals("-")) {
out.println("Invoice, Payment and RTGS Files are uploaded");
} else if (!bill.getInvoiceFilePath().equals("-") && bill.getBillFilePath().equals("-")
&& bill.getRtgsFilePath().equals("-")) {
out.println("Only Invoice File Uploaded");
}
diffMillis = 0L;
diffDays = 0l;
%></td>
<!-- Corrected Balance To Be Claimed -->
<td class="no-export">
<div style="display: flex; gap: 10px; align-items: center">
<% if (!bill.getBillFilePath().equals("-")) { %>
<button
onclick="viewFileInModal('<%=contNum%>','Bill',
'<%=java.net.URLEncoder.encode(bill.getBillFilePath(), "UTF-8").replace("+", "%20")%>')"
style="cursor: pointer;" class="btn btn-secondary">Bill</button>
<% } %>
<button
onclick="viewFileInModal('<%=contNum%>','Invoice',
'<%=java.net.URLEncoder.encode(bill.getInvoiceFilePath(), "UTF-8").replace("+", "%20")%>')"
style="cursor: pointer;" class="btn btn-secondary">Invoice</button>
<%
if (!bill.getRtgsFilePath().equals("-")) {
%>
<button
onclick="viewFileInModal('<%=contNum%>','RTGS',
'<%=java.net.URLEncoder.encode(bill.getRtgsFilePath(), "UTF-8").replace("+", "%20")%>')"
style="cursor: pointer;" class="btn btn-secondary">RTGS</button>
<%
}
%>
</div>
</td>
</tr>
<%
}
%>
</tbody>
</table>
</div>
<%@include file="export_pdf.html"%>
<% } %>
<%
}
%>
&nbsp;
<div class="row mb-3">
<div class="col-md-4 text-center" id="custom_info"></div>
<div class="col-md-8" id="custom_pagination"></div>
</div>
</div>
<input type="hidden" value="<%= contDetListWrapper.getContList().get(0).getWorkDesc() %>"
name="hid_work_desc" id="hid_work_desc" class="form-control">
<input type="hidden" value="<%= reqSrc %>" class="form-control" id="hid_req_src"
name="hid_req_src">
<input type="hidden" value="<%= request.getContextPath() %>/ExistExtBillDetServlet"
name="hid_frm_action" id="hid_frm_action" class="form-control">
<input type="hidden" class="form-control" name="hid_type" id="hid_type"
value="<%= reqSrc.equalsIgnoreCase("exp_cont_det_display_page") ? 1 : 0 %>">
<input type="hidden"
value="<%=contDetListWrapper.getContList().get(0).getWorkDesc()%>"
name="hid_work_desc" id="hid_work_desc" class="form-control">
<input type="hidden" value="<%=reqSrc%>" class="form-control"
id="hid_req_src" name="hid_req_src"> <input type="hidden"
value="<%=request.getContextPath()%>/ExistExtBillDetServlet"
name="hid_frm_action" id="hid_frm_action" class="form-control">
<input type="hidden" class="form-control" name="hid_type"
id="hid_type"
value="<%=reqSrc.equalsIgnoreCase("exp_cont_det_display_page") ? 1 : 0%>">
</div>
<%@include file="pdf_modal.html" %>
<%@include file="pdf_modal.html"%>
<%@include file="includes/footer.jsp"%>
<script src="js/go-back.js" type="text/javascript"></script>
<script src="js/adjust-row-class.js" type="text/javascript"></script>

71
src/main/webapp/exist_ext_bill_det_display.jsp

@ -278,11 +278,13 @@ if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
} if (billDetListWrapper != null && !billDetListWrapper.getBillDetList().isEmpty()) {
Integer pos = billDetListWrapper.getBillDetList().size() - 1;
String rtgsFile = billDetListWrapper.getBillDetList().get(pos).getRtgsFilePath();
String billFile = billDetListWrapper.getBillDetList().get(pos).getBillFilePath();
String sdFile = contDetListWrapper.getContList().get(0).getContSDFilePath();
Integer amtDueFlag = (int) Math.round(billDetListWrapper.getBillDetList().get(pos).getAmtDue());
Integer diffInDaysFlag = Integer.parseInt(timeUtils.getExpiryDays(sdf, currentDate,
contDetListWrapper.getContList().get(0).getContEndDate()));
boolean rtgsFileFlag = rtgsFile.trim().equals("-") ? true : false;
boolean billFileFlag = billFile.trim().equals("-") ? true : false;
boolean sdFileFlag = sdFile.trim().equals("-") ? true : false;
%>
<!-- Button and Filter Bar -->
@ -308,9 +310,13 @@ if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
name="new_ext_bill_det_btn" onclick="redirectToAddNewExtBillPage()">
<i class="fas fa-circle-plus"></i> Add Ext.Bill
</button>
<button class="btn btn-secondary" id="upd_ext_bill_det_btn"
name="upd_ext_bill_det_btn" onclick="redirectToUpdateExtBillPage()">
<i class="fas fa-light fa-pen"></i> Upload Ext.Payment
</button>
<button class="btn btn-secondary" id="modify_ext_bill_det_btn"
name="modify_ext_bill_det_btn" onclick="redirectToModifyExtBillPage()">
<i class="fas fa-light fa-pen"></i> Modify Ext.Bill
<i class="fas fa-light fa-pen"></i> Upload Ext.RTGS
</button>
<%
} else if (lockAmount < thresholdAmt) {
@ -319,16 +325,31 @@ if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
name="new_bill_det_btn" onclick="redirectToAddNewExtBillPage()">
<i class="fas fa-circle-plus"></i> Add Ext.Bill
</button>
<button class="btn btn-secondary" id="upd_ext_bill_det_btn"
name="upd_ext_bill_det_btn" onclick="redirectToUpdateExtBillPage()">
<i class="fas fa-light fa-pen"></i> Upload Ext.Payment
</button>
<button class="btn btn-secondary" id="modify_bill_det_btn"
name="modify_bill_det_btn" onclick="redirectToModifyExtBillPage()">
<i class="fas fa-light fa-pen"></i> Upload Ext.RTGS
</button>
<%
} else if (rtgsFileFlag && billFileFlag) {
%>
<button class="btn btn-secondary" id="upd_ext_bill_det_btn"
name="upd_ext_bill_det_btn" onclick="redirectToUpdateExtBillPage()">
<i class="fas fa-light fa-pen"></i> Upload Ext.Payment
</button>
<button class="btn btn-secondary" id="modify_bill_det_btn"
name="modify_bill_det_btn" onclick="redirectToModifyExtBillPage()">
<i class="fas fa-light fa-pen"></i> Modify Ext.Bill
<i class="fas fa-light fa-pen"></i> Upload Ext.RTGS
</button>
<%
} else if (rtgsFileFlag) {
%>
<button class="btn btn-secondary" id="modify_ext_bill_det_btn"
name="modify_ext_bill_det_btn" onclick="redirectToModifyExtBillPage()">
<i class="fas fa-light fa-pen"></i> Modify Ext.Bill
<button class="btn btn-secondary" id="modify_bill_det_btn"
name="modify_bill_det_btn" onclick="redirectToModifyExtBillPage()">
<i class="fas fa-light fa-pen"></i> Upload Ext.RTGS
</button>
<%
} if ((amtDueFlag <= 0 || diffInDaysFlag < 0) && (sdFileFlag)) {
@ -382,6 +403,8 @@ if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
}
%>
<th>Balance To Be Claimed</th>
<th>Days Passed after Invoice Upload</th>
<th>Days Passed after Payment Upload</th>
<th class="no-export">View Files</th>
</tr>
</thead>
@ -393,6 +416,8 @@ if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
for (Bill bill : billDetListWrapper.getBillDetList()) {
boolean isClaimed = bill.getBillStatName().equalsIgnoreCase("CLAIMED");
double amtDue;
long diffMillis = 0L;
long diffDays = 0L;
if (isFirstRow) {
// First row logic
lastClaimedAmountDue = isClaimed ? bill.getAmtDue() : bill.getContAmt();
@ -436,13 +461,47 @@ if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) {
.equalsIgnoreCase("PERCENTAGE BASED PAYMENT")) { %>
<td><%= bill.getPercentApplied()%> %</td>
<% } %>
<td>₹ <%= String.format("%,.2f", amtDue) %></td> <!-- Corrected Balance To Be Claimed -->
<td>₹ <%= String.format("%,.2f", amtDue) %></td>
<td><%
if (bill.getBillFilePath().equals("-") && !bill.getInvoiceFilePath().equals("-")) {
Date createdDate = sdf.parse(bill.getCreatedDate()); // e.g. 15-05-2026
diffMillis = currentDate.getTime() - createdDate.getTime();
diffDays = diffMillis / (1000 * 60 * 60 * 24);
//out.println(diffDays);
out.println("<span style='color:red;font-weight:bold;'>" + diffDays + " Days</span>");
} else if (!bill.getBillFilePath().equals("-") && !bill.getInvoiceFilePath().equals("-")) {
out.println("Invoice and Payment Files are uploaded");
}
diffMillis = 0L;
diffDays = 0l;
%></td>
<td><%
if (!bill.getInvoiceFilePath().equals("-") && !bill.getBillFilePath().equals("-")
&& bill.getRtgsFilePath().equals("-")) {
Date updatedDate = sdf.parse(bill.getUpdatedDate()); // e.g. 17-05-2026
diffMillis = currentDate.getTime() - updatedDate.getTime();
diffDays = diffMillis / (1000 * 60 * 60 * 24);
//out.println(diffDays);
out.println("<span style='color:red;font-weight:bold;'>" + diffDays + " Days</span>");
} else if (!bill.getInvoiceFilePath().equals("-") && !bill.getBillFilePath().equals("-")
&& !bill.getRtgsFilePath().equals("-")) {
out.println("Invoice, Payment and RTGS Files are uploaded");
} else if (!bill.getInvoiceFilePath().equals("-") && bill.getBillFilePath().equals("-")
&& bill.getRtgsFilePath().equals("-")) {
out.println("Only Invoice File Uploaded");
}
diffMillis = 0L;
diffDays = 0l;
%></td>
<!-- Corrected Balance To Be Claimed -->
<td class="no-export">
<div style="display: flex; gap :10px; align-items: center">
<% if (!bill.getBillFilePath().equals("-")) { %>
<button onclick="viewFileInModal('<%= contNum %>','Bill-Ext',
'<%= java.net.URLEncoder.encode(bill.getBillFilePath(),
"UTF-8").replace("+", "%20") %>')" style="cursor: pointer;"
class="btn btn-secondary">Bill</button>
<% } %>
<button onclick="viewFileInModal('<%= contNum %>','Invoice-Ext',
'<%= java.net.URLEncoder.encode(bill.getInvoiceFilePath(),
"UTF-8").replace("+", "%20") %>')" style="cursor: pointer;"

12
src/main/webapp/ext_bill_det_entry.jsp

@ -293,13 +293,6 @@ for (BillStat billStat : billStatDetList) {
accept=".pdf" required>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="ext_bill_file">Payment File: <span class="required">*</span></label>
<input type="file" id="ext_bill_file" class="form-control" name="ext_bill_file"
accept=".pdf" required>
</div>
</div>
<% } else { %>
<div class="form-row">
<div class="form-group">
@ -322,11 +315,6 @@ for (BillStat billStat : billStatDetList) {
<input type="file" id="ext_invoice_file" class="form-control" name="ext_invoice_file"
accept=".pdf" required>
</div>
<div class="form-group">
<label for="ext_bill_file">Payment File: <span class="required">*</span></label>
<input type="file" id="ext_bill_file" class="form-control" name="ext_bill_file"
accept=".pdf" required>
</div>
</div>
<% } %>
<div class="submit-btn">

40
src/main/webapp/js/exist-bill-det-funcs-display.js

@ -31,6 +31,46 @@ function redirectToAddNewBillPage() {
form.submit();
}
function redirectToUpdateBillPage() {
// Retrieve the cont_num and vend_id from the data attribute
var vendId = document.getElementById("hid_vend_id").value;
var contNum = document.getElementById("hid_cont_num").value;
var vendName = document.getElementById("hid_vend_name").value;
// Create a form element
var form = document.createElement("form");
form.method = "POST";
form.action = "upd_bill_det_entry.jsp";
// Set the form's display style to none
form.style.display = "none";
// Create an input element for cont_num and vend_id
var input = document.createElement("input");
input.type = "hidden";
input.name = "vend_id";
input.value = vendId;
var input2 = document.createElement("input");
input2.type = "hidden";
input2.name = "cont_num";
input2.value = contNum;
var input3 = document.createElement("input");
input3.type = "hidden";
input3.name = "vend_name";
input3.value = vendName;
// Append the input to the form
form.appendChild(input);
form.appendChild(input2);
form.appendChild(input3);
// Append the form to the body and submit it
document.body.appendChild(form);
form.submit();
}
function redirectToModifyBillPage() {
// Retrieve the cont_num and vend_id from the data attribute
var vendId = document.getElementById("hid_vend_id").value;

40
src/main/webapp/js/exist-ext-bill-det-funcs-display.js

@ -38,6 +38,46 @@ function redirectToAddNewExtBillPage() {
form.submit();
}
function redirectToUpdateExtBillPage() {
// Retrieve the cont_num and vend_id from the data attribute
var vendId = document.getElementById("hid_ext_vend_id").value;
var contNum = document.getElementById('hid_cont_num').value;
var vendName = document.getElementById("hid_ext_vend_name").value;
// Create a form element
var form = document.createElement("form");
form.method = "POST";
form.action = "upd_ext_bill_det_entry.jsp";
// Set the form's display style to none
form.style.display = "none";
// Create an input element for cont_num and vend_id
var input = document.createElement("input");
input.type = "hidden";
input.name = "vend_id";
input.value = vendId;
var input2 = document.createElement("input");
input2.type = "hidden";
input2.name = "cont_num";
input2.value = contNum;
var input3 = document.createElement("input");
input3.type = "hidden";
input3.name = "vend_name";
input3.value = vendName;
// Append the input to the form
form.appendChild(input);
form.appendChild(input2);
form.appendChild(input3);
// Append the form to the body and submit it
document.body.appendChild(form);
form.submit();
}
function redirectToModifyExtBillPage() {
// Retrieve the cont_num and vend_id from the data attribute
var vendId = document.getElementById("hid_ext_vend_id").value;

12
src/main/webapp/new_bill_det_entry.jsp

@ -296,12 +296,6 @@
required>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="bill_file">Payment File: <span class="required">*</span></label>
<input type="file" id="bill_file" class="form-control" name="bill_file" accept=".pdf" required>
</div>
</div>
<% } else { %>
<div class="form-row">
<div class="form-group">
@ -326,12 +320,6 @@
class="form-control" name="invoice_file" accept=".pdf"
required>
</div>
<div class="form-group">
<label for="bill_file">Payment File: <span class="required">*</span></label>
<input type="file" id="bill_file"
class="form-control" name="bill_file"
accept=".pdf" required>
</div>
</div>
<% } %>
<div class="submit-btn">

161
src/main/webapp/upd_bill_det_entry.jsp

@ -0,0 +1,161 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page language="java" import="com.cont_mgmt.dto.User, java.util.*"%>
<%@ page language="java" import="com.cont_mgmt.dto.Bill"%>
<%@ page language="java"
import="com.cont_mgmt.wrapper.ContDetListWrapper"%>
<%@ page language="java"
import="com.cont_mgmt.wrapper.BillStatDetListWrapper"%>
<%@ page language="java" import="com.cont_mgmt.dto.Contract"%>
<%@ page language="java"
import="com.cont_mgmt.service.ExistContDetService"%>
<%@ page language="java"
import="com.cont_mgmt.service.ExistBillDetService"%>
<%@page language ="java"
import="com.cont_mgmt.wrapper.BillDetListWrapper"%>
<%
// Check if the user is logged in by checking if the user object is not null
User user = (User) session.getAttribute("user");
if (user == null || user.getUserName().equals("")) {
// If not logged in, redirect to logout.jsp
response.sendRedirect("logout.jsp");
return; // Stop further execution of the page
}
// Retrieve values passed via POST method
String reqContNum = request.getParameter("cont_num");
String reqVendId = request.getParameter("vend_id");
String vendName = request.getParameter("vend_name");
// Call the ExistContDetService and ExistBillDetService
ExistContDetService existContDetService = new ExistContDetService();
ExistBillDetService existBillDetService = new ExistBillDetService();
// Fetch ContDetList
ContDetListWrapper contDetListWrapper = new ContDetListWrapper(existContDetService.getContDet(reqVendId, reqContNum));
List<Contract> contDetList = contDetListWrapper != null ? contDetListWrapper.getContList() : new ArrayList<Contract>();
// Fetch BillDetList
BillDetListWrapper billDetListWrapper = new BillDetListWrapper(existBillDetService.getBillDet(reqContNum));
List<Bill> billDetList = billDetListWrapper != null ? billDetListWrapper.getBillDetList() : new ArrayList<Bill>();
//Populate the Invoice Billing Period based on invoice bill type name
String invoiceBillingPeriodOptions = "";
String invoiceBillingPeriod = "";
if (contDetList.isEmpty()) {
throw new IllegalArgumentException("No contract details found.");
}
String invoiceBillTypeName = contDetList.get(0).getInvoiceBillTypeName();
//Determine prefix
if ("QUARTERLY".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "Q";
} else if ("MONTHLY".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "M";
} else if ("HALF YEARLY".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "H";
} else if ("PERCENTAGE BASED PAYMENT".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "P";
} else if ("YEARLY".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "Y";
} else if ("ONE SHOT PAYMENT".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "S";
} else if ("OTHERS".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "O";
} else {
throw new IllegalArgumentException("Unsupported invoice bill type: " + invoiceBillTypeName);
}
//Use TreeMap to sort by the *starting* number of the suffix
Map<Integer, String> sortedPeriods = new TreeMap<Integer, String>();
for (Bill bill : billDetList) {
String period = bill.getInvoiceBillingPeriod(); // e.g., Q1, Q1-Q4
if (period.startsWith(invoiceBillingPeriod)) {
String suffix = period.substring(invoiceBillingPeriod.length());
try {
int sortKey;
if (suffix.contains("-")) {
String startPart = suffix.split("-")[0];
sortKey = Integer.parseInt(startPart);
} else {
sortKey = Integer.parseInt(suffix);
}
sortedPeriods.put(sortKey, period);
} catch (NumberFormatException e) {
// Skip invalid suffix
}
}
}
//Build <option> tags
for (String period : sortedPeriods.values()) {
invoiceBillingPeriodOptions += "<option class='special' value='"
+ period + "'>" + period + "</option>";
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contract Management System</title>
<link rel="stylesheet" type="text/css" href="css/body-form-style.css">
<%@include file="includes/header.jsp"%>
</head>
<body>
<%@include file="includes/exist_navbar.jsp"%>
<div class="container mt-4">
<div class="form-container">
<div class="header-row">
<button class="back-button" onclick="goBack()">&#8592; Back</button>
</div>
<h2 class="form-title">Upload Payment File</h2>
<form method="post" style="font-size: 14px" class="frm"
action="/ContractManagementSystem/UpdBillDetServlet"
id="frm_upd_bill_det_entry" name="frm_upd_bill_det_entry"
enctype="multipart/form-data">
<div class="form-row">
<div class="form-group">
<label for="cont_num">ITC Number : </label>
<input type="text" class="form-control" name="cont_num" id="cont_num"
placeholder="Enter ITC Number"
value="<%= contDetList.get(0).getContNum() %>" disabled>
<input type="hidden" class="form-control" name="hid_cont_num"
id="hid_cont_num" placeholder="Enter ITC Number"
value="<%= contDetList.get(0).getContNum() %>">
<input type="hidden" class="form-control" name="hid_usr_id"
id="hid_usr_id" value="<%= user.getUserId() %>" autocomplete="off">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="invoice_billing_period">Bill Period: <span class="required">*</span>
</label>
<select class="selectpicker form-control" id="invoice_bill_period"
name="invoice_bill_period" required>
<option selected value="" hidden="hidden">Select Bill Period</option>
<%= invoiceBillingPeriodOptions %></select>
</div>
<div class="form-group">
<label for="bill_file">Payment File : <span class="required">*</span>
</label>
<input type="file" required class="form-control" id="bill_file"
name="bill_file" accept=".pdf">
<input type="hidden" class="form-control" name="hid_vend_name"
id="hid_vend_name" value="<%= vendName %>" autocomplete="off">
</div>
</div>
<div class="submit-btn">
<input type="submit" value="Submit">
</div>
</form>
</div>
</div>
<%@include file="includes/footer.jsp"%>
<script src="js/go-back.js" type="text/javascript"></script>
</body>
</html>

161
src/main/webapp/upd_ext_bill_det_entry.jsp

@ -0,0 +1,161 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page language="java" import="com.cont_mgmt.dto.User, java.util.*"%>
<%@ page language="java" import="com.cont_mgmt.dto.Bill"%>
<%@ page language="java"
import="com.cont_mgmt.wrapper.ContDetListWrapper"%>
<%@ page language="java"
import="com.cont_mgmt.wrapper.BillStatDetListWrapper"%>
<%@ page language="java" import="com.cont_mgmt.dto.Contract"%>
<%@ page language="java"
import="com.cont_mgmt.service.ExistExtContDetService"%>
<%@ page language="java"
import="com.cont_mgmt.service.ExistExtBillDetService"%>
<%@page language ="java"
import="com.cont_mgmt.wrapper.BillDetListWrapper"%>
<%
//Check if the user is logged in by checking if the user object is not null
User user = (User) session.getAttribute("user");
if (user == null || user.getUserName().equals("")) {
// If not logged in, redirect to logout.jsp
response.sendRedirect("logout.jsp");
return; // Stop further execution of the page
}
//Retrieve values passed via POST method
String reqContNum = request.getParameter("cont_num");
String reqVendId = request.getParameter("vend_id");
String vendName = request.getParameter("vend_name");
//Call the ExistExtContDetService and ExistExtBillDetService
ExistExtContDetService existExtContDetService = new ExistExtContDetService();
ExistExtBillDetService existExtBillDetService = new ExistExtBillDetService();
//Fetch ContDetList
ContDetListWrapper contDetListWrapper = new ContDetListWrapper(existExtContDetService.getExtContDet(reqVendId, reqContNum));
List<Contract> contDetList = contDetListWrapper != null ? contDetListWrapper.getContList() : new ArrayList<Contract>();
//Fetch BillDetList
BillDetListWrapper billDetListWrapper = new BillDetListWrapper(existExtBillDetService.getExtBillDet(reqContNum));
List<Bill> billDetList = billDetListWrapper != null ? billDetListWrapper.getBillDetList() : new ArrayList<Bill>();
//Populate the Invoice Billing Period based on invoice bill type name
String invoiceBillingPeriodOptions = "";
String invoiceBillingPeriod = "";
if (contDetList.isEmpty()) {
throw new IllegalArgumentException("No contract details found.");
}
String invoiceBillTypeName = contDetList.get(0).getInvoiceBillTypeName();
//Determine prefix
if ("QUARTERLY".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "Q";
} else if ("MONTHLY".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "M";
} else if ("HALF YEARLY".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "H";
} else if ("PERCENTAGE BASED PAYMENT".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "P";
} else if ("YEARLY".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "Y";
} else if ("ONE SHOT PAYMENT".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "S";
} else if ("OTHERS".equals(invoiceBillTypeName)) {
invoiceBillingPeriod = "O";
} else {
throw new IllegalArgumentException("Unsupported invoice bill type: " + invoiceBillTypeName);
}
//Use TreeMap to sort by the *starting* number of the suffix
Map<Integer, String> sortedPeriods = new TreeMap<Integer, String>();
for (Bill bill : billDetList) {
String period = bill.getInvoiceBillingPeriod(); // e.g., Q1, Q1-Q4
if (period.startsWith(invoiceBillingPeriod)) {
String suffix = period.substring(invoiceBillingPeriod.length());
try {
int sortKey;
if (suffix.contains("-")) {
String startPart = suffix.split("-")[0];
sortKey = Integer.parseInt(startPart);
} else {
sortKey = Integer.parseInt(suffix);
}
sortedPeriods.put(sortKey, period);
} catch (NumberFormatException e) {
// Skip invalid suffix
}
}
}
//Build <option> tags
for (String period : sortedPeriods.values()) {
invoiceBillingPeriodOptions += "<option class='special' value='"
+ period + "'>" + period + "</option>";
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contract Management System</title>
<link rel="stylesheet" type="text/css" href="css/body-form-style.css">
<%@include file="includes/header.jsp"%>
</head>
<body>
<%@include file="includes/exist_navbar.jsp"%>
<div class="container mt-4">
<div class="form-container">
<div class="header-row">
<button class="back-button" onclick="goBack()">&#8592; Back</button>
</div>
<h2 class="form-title">Modify Extension Bill Status</h2>
<form method="post" style="font-size: 14px" class="frm"
action="/ContractManagementSystem/UpdExtBillDetServlet"
id="frm_upd_bill_det_entry" name="frm_upd_bill_det_entry"
enctype="multipart/form-data">
<div class="form-row">
<div class="form-group">
<label for="ext_cont_num">Extension ITC Number : </label>
<input type="text" class="form-control" name="ext_cont_num"
id="ext_cont_num" placeholder="Enter ITC Number"
value="<%= contDetList.get(0).getContNum() %>" disabled>
<input type="hidden" class="form-control" name="hid_ext_cont_num"
id="hid_ext_cont_num" placeholder="Enter ITC Number"
value="<%= contDetList.get(0).getContNum() %>">
<input type="hidden" class="form-control" name="hid_ext_usr_id"
id="hid_ext_usr_id" value="<%= user.getUserId() %>" autocomplete="off">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="ext_invoice_billing_period">Extension Bill Period: <span class="required">*</span>
</label>
<select class="selectpicker form-control" id="ext_invoice_bill_period"
name="ext_invoice_bill_period" required>
<option selected value="" hidden="hidden">Select Extension Bill Period</option>
<%= invoiceBillingPeriodOptions %></select>
</div>
<div class="form-group">
<label for="ext_bill_file">Extension Payment File : <span class="required">*</span>
</label>
<input type="file" required class="form-control" id="ext_bill_file"
name="ext_bill_file" accept=".pdf">
<input type="hidden" class="form-control" name="hid_ext_vend_name"
id="hid_ext_vend_name" value="<%= vendName %>" autocomplete="off">
</div>
</div>
<div class="submit-btn">
<input type="submit" value="Submit">
</div>
</form>
</div>
</div>
<%@include file="includes/footer.jsp"%>
<script src="js/go-back.js" type="text/javascript"></script>
</body>
</html>
Loading…
Cancel
Save