diff --git a/build/classes/com/cont_mgmt/dto/Bill.class b/build/classes/com/cont_mgmt/dto/Bill.class index 37eb9b2..8fa4d9b 100644 Binary files a/build/classes/com/cont_mgmt/dto/Bill.class and b/build/classes/com/cont_mgmt/dto/Bill.class differ diff --git a/build/classes/com/cont_mgmt/repository/FetchExistBillDet.class b/build/classes/com/cont_mgmt/repository/FetchExistBillDet.class index fc58ffd..6c2e606 100644 Binary files a/build/classes/com/cont_mgmt/repository/FetchExistBillDet.class and b/build/classes/com/cont_mgmt/repository/FetchExistBillDet.class differ diff --git a/build/classes/com/cont_mgmt/repository/FetchExistExtBillDet.class b/build/classes/com/cont_mgmt/repository/FetchExistExtBillDet.class index b5fbc1b..0a386bd 100644 Binary files a/build/classes/com/cont_mgmt/repository/FetchExistExtBillDet.class and b/build/classes/com/cont_mgmt/repository/FetchExistExtBillDet.class differ diff --git a/build/classes/com/cont_mgmt/repository/InsertBillDet.class b/build/classes/com/cont_mgmt/repository/InsertBillDet.class index 8a261bf..a7c4a02 100644 Binary files a/build/classes/com/cont_mgmt/repository/InsertBillDet.class and b/build/classes/com/cont_mgmt/repository/InsertBillDet.class differ diff --git a/build/classes/com/cont_mgmt/repository/InsertExtBillDet.class b/build/classes/com/cont_mgmt/repository/InsertExtBillDet.class index 847b3bf..5ef43a0 100644 Binary files a/build/classes/com/cont_mgmt/repository/InsertExtBillDet.class and b/build/classes/com/cont_mgmt/repository/InsertExtBillDet.class differ diff --git a/build/classes/com/cont_mgmt/repository/UpdateBillDet.class b/build/classes/com/cont_mgmt/repository/UpdateBillDet.class new file mode 100644 index 0000000..85da609 Binary files /dev/null and b/build/classes/com/cont_mgmt/repository/UpdateBillDet.class differ diff --git a/build/classes/com/cont_mgmt/repository/UpdateExtBillDet.class b/build/classes/com/cont_mgmt/repository/UpdateExtBillDet.class new file mode 100644 index 0000000..dda6bfa Binary files /dev/null and b/build/classes/com/cont_mgmt/repository/UpdateExtBillDet.class differ diff --git a/build/classes/com/cont_mgmt/service/ExtBillDetService.class b/build/classes/com/cont_mgmt/service/ExtBillDetService.class index e453a36..f10530b 100644 Binary files a/build/classes/com/cont_mgmt/service/ExtBillDetService.class and b/build/classes/com/cont_mgmt/service/ExtBillDetService.class differ diff --git a/build/classes/com/cont_mgmt/service/NewBillDetService.class b/build/classes/com/cont_mgmt/service/NewBillDetService.class index a63840d..d0f8bed 100644 Binary files a/build/classes/com/cont_mgmt/service/NewBillDetService.class and b/build/classes/com/cont_mgmt/service/NewBillDetService.class differ diff --git a/build/classes/com/cont_mgmt/service/UpdBillDetService.class b/build/classes/com/cont_mgmt/service/UpdBillDetService.class new file mode 100644 index 0000000..6f6e68c Binary files /dev/null and b/build/classes/com/cont_mgmt/service/UpdBillDetService.class differ diff --git a/build/classes/com/cont_mgmt/service/UpdExtBillDetService.class b/build/classes/com/cont_mgmt/service/UpdExtBillDetService.class new file mode 100644 index 0000000..e533493 Binary files /dev/null and b/build/classes/com/cont_mgmt/service/UpdExtBillDetService.class differ diff --git a/build/classes/com/cont_mgmt/servlet/ExtBillDetServlet.class b/build/classes/com/cont_mgmt/servlet/ExtBillDetServlet.class index 264d83a..7e334de 100644 Binary files a/build/classes/com/cont_mgmt/servlet/ExtBillDetServlet.class and b/build/classes/com/cont_mgmt/servlet/ExtBillDetServlet.class differ diff --git a/build/classes/com/cont_mgmt/servlet/NewBillDetServlet.class b/build/classes/com/cont_mgmt/servlet/NewBillDetServlet.class index 806d76b..ff65cd4 100644 Binary files a/build/classes/com/cont_mgmt/servlet/NewBillDetServlet.class and b/build/classes/com/cont_mgmt/servlet/NewBillDetServlet.class differ diff --git a/build/classes/com/cont_mgmt/servlet/UpdBillDetServlet.class b/build/classes/com/cont_mgmt/servlet/UpdBillDetServlet.class new file mode 100644 index 0000000..d9dc220 Binary files /dev/null and b/build/classes/com/cont_mgmt/servlet/UpdBillDetServlet.class differ diff --git a/build/classes/com/cont_mgmt/servlet/UpdExtBillDetServlet.class b/build/classes/com/cont_mgmt/servlet/UpdExtBillDetServlet.class new file mode 100644 index 0000000..eeb2867 Binary files /dev/null and b/build/classes/com/cont_mgmt/servlet/UpdExtBillDetServlet.class differ diff --git a/src/main/java/com/cont_mgmt/dto/Bill.java b/src/main/java/com/cont_mgmt/dto/Bill.java index 6922a73..486b709 100644 --- a/src/main/java/com/cont_mgmt/dto/Bill.java +++ b/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; } - + } diff --git a/src/main/java/com/cont_mgmt/repository/FetchExistBillDet.java b/src/main/java/com/cont_mgmt/repository/FetchExistBillDet.java index 9d15253..402be1a 100644 --- a/src/main/java/com/cont_mgmt/repository/FetchExistBillDet.java +++ b/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); } diff --git a/src/main/java/com/cont_mgmt/repository/FetchExistExtBillDet.java b/src/main/java/com/cont_mgmt/repository/FetchExistExtBillDet.java index e10c852..e35a797 100644 --- a/src/main/java/com/cont_mgmt/repository/FetchExistExtBillDet.java +++ b/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); } diff --git a/src/main/java/com/cont_mgmt/repository/InsertBillDet.java b/src/main/java/com/cont_mgmt/repository/InsertBillDet.java index 82862d0..026c426 100644 --- a/src/main/java/com/cont_mgmt/repository/InsertBillDet.java +++ b/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); diff --git a/src/main/java/com/cont_mgmt/repository/InsertExtBillDet.java b/src/main/java/com/cont_mgmt/repository/InsertExtBillDet.java index 5689473..734d01f 100644 --- a/src/main/java/com/cont_mgmt/repository/InsertExtBillDet.java +++ b/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); diff --git a/src/main/java/com/cont_mgmt/repository/UpdateBillDet.java b/src/main/java/com/cont_mgmt/repository/UpdateBillDet.java new file mode 100644 index 0000000..3b8e600 --- /dev/null +++ b/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; + + } + +} diff --git a/src/main/java/com/cont_mgmt/repository/UpdateExtBillDet.java b/src/main/java/com/cont_mgmt/repository/UpdateExtBillDet.java new file mode 100644 index 0000000..f37cf7a --- /dev/null +++ b/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; + + } + +} diff --git a/src/main/java/com/cont_mgmt/service/ExtBillDetService.java b/src/main/java/com/cont_mgmt/service/ExtBillDetService.java index 1c6c652..1d3db43 100644 --- a/src/main/java/com/cont_mgmt/service/ExtBillDetService.java +++ b/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; diff --git a/src/main/java/com/cont_mgmt/service/NewBillDetService.java b/src/main/java/com/cont_mgmt/service/NewBillDetService.java index 76827ea..45f8b37 100644 --- a/src/main/java/com/cont_mgmt/service/NewBillDetService.java +++ b/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; diff --git a/src/main/java/com/cont_mgmt/service/UpdBillDetService.java b/src/main/java/com/cont_mgmt/service/UpdBillDetService.java new file mode 100644 index 0000000..bf1173b --- /dev/null +++ b/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; + } + } + +} diff --git a/src/main/java/com/cont_mgmt/service/UpdExtBillDetService.java b/src/main/java/com/cont_mgmt/service/UpdExtBillDetService.java new file mode 100644 index 0000000..295d986 --- /dev/null +++ b/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; + } + } + +} diff --git a/src/main/java/com/cont_mgmt/servlet/ExtBillDetServlet.java b/src/main/java/com/cont_mgmt/servlet/ExtBillDetServlet.java index 7d9f9e2..b1f5e57 100644 --- a/src/main/java/com/cont_mgmt/servlet/ExtBillDetServlet.java +++ b/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) { diff --git a/src/main/java/com/cont_mgmt/servlet/NewBillDetServlet.java b/src/main/java/com/cont_mgmt/servlet/NewBillDetServlet.java index 1357f18..f11ab2f 100644 --- a/src/main/java/com/cont_mgmt/servlet/NewBillDetServlet.java +++ b/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) { diff --git a/src/main/java/com/cont_mgmt/servlet/UpdBillDetServlet.java b/src/main/java/com/cont_mgmt/servlet/UpdBillDetServlet.java new file mode 100644 index 0000000..2f7d4f3 --- /dev/null +++ b/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)); + } + + } + +} diff --git a/src/main/java/com/cont_mgmt/servlet/UpdExtBillDetServlet.java b/src/main/java/com/cont_mgmt/servlet/UpdExtBillDetServlet.java new file mode 100644 index 0000000..ff2ce33 --- /dev/null +++ b/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)); + } + } +} diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 1be1948..92d4dd7 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,5 +1,5 @@ - + ContractManagementSystem index.html @@ -10,7 +10,6 @@ default.htm login.jsp - Oracle DB Connection Details for Contract Management System jdbc/ContractDB diff --git a/src/main/webapp/exist_bill_det_display.jsp b/src/main/webapp/exist_bill_det_display.jsp index 90602b1..50d4a06 100644 --- a/src/main/webapp/exist_bill_det_display.jsp +++ b/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 extContList = new ArrayList(); - 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 extContList = new ArrayList(); +if (isExtendedFlag == 1) { + extContList = existExtContDetService.getExtContDet(null, contNum); +} %> @@ -61,14 +63,15 @@ Contract Management System - + <%@include file="includes/header.jsp"%> - <% - 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 @@ %>
-
- -
- <% - if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) { - %> +
+ +
+ <% + if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) { + %>

Contract Details

<% } else if (reqSrc.equalsIgnoreCase("exp_cont_det_display_page")) { @@ -97,11 +100,11 @@ <% } else if (reqSrc.equalsIgnoreCase("cust_rep_det_display_page")) { %> -

Custom Reports Contract Details

+

Custom Reports Contract Details

<% - } - if (contDetListWrapper != null && !contDetListWrapper.getContList().isEmpty()) { - %> + } + if (contDetListWrapper != null && !contDetListWrapper.getContList().isEmpty()) { + %>

@@ -110,9 +113,8 @@ - + value="<%=vendName%>">

@@ -125,19 +127,21 @@
-
-

Work Order Amount : - ₹ <%=String.format("%,.2f", contDetListWrapper.getContList().get(0).getContAmt())%> -

+
+

+ Work Order Amount : ₹ + <%=String.format("%,.2f", contDetListWrapper.getContList().get(0).getContAmt())%> +

-
-
+
+

AS File :

@@ -146,23 +150,23 @@ if (!contDetListWrapper.getContList().get(0).getContLOAFilePath().trim().equals("-")) { %>
-

+

LOA File :

-

+

Agreement File :

@@ -171,12 +175,12 @@ } else { %>
-

+

Agreement File :

@@ -189,70 +193,73 @@ WO File :

-
- <% - if (!contDetListWrapper.getContList().get(0).getContEMDFilePath().trim().equals("-")) { - %> -
+
+ <% + if (!contDetListWrapper.getContList().get(0).getContEMDFilePath().trim().equals("-")) { + %> +

EMD File :

- <% - } if (!contDetListWrapper.getContList().get(0).getContSDFilePath().trim().equals("-")) { - %> -
+ <% + } + if (!contDetListWrapper.getContList().get(0).getContSDFilePath().trim().equals("-")) { + %> +

SD File :

- <% - } if (!contDetListWrapper.getContList().get(0).getContASDFilePath().trim().equals("-")) { - %> -
+ <% + } + if (!contDetListWrapper.getContList().get(0).getContASDFilePath().trim().equals("-")) { + %> +

ASD File :

- <% - } - %> + <% + } + %>
<% } %>
-
-

+

+

Remarks : <%=contDetListWrapper.getContList().get(0).getContRmrk()%>

-
+

Bill Details

<% @@ -262,8 +269,7 @@
-
+
<% if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) { %> @@ -279,15 +285,14 @@

<%=errorMessage%>

<% - } else if ((billDetListWrapper == null) && (contDetListWrapper != null || - !contDetListWrapper.getContList().isEmpty())) { + } else if ((billDetListWrapper == null) + && (contDetListWrapper != null || !contDetListWrapper.getContList().isEmpty())) { %>
-
+
<% if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) { %> @@ -305,23 +310,25 @@

No results found for the given criteria.

<% - } 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; %>
-
+
<% - 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) { %> + <% - } else if (lockAmount < thresholdAmt) { + } else if (lockAmount < thresholdAmt) { %> + + + <% + } else if (rtgsFileFlag && billFileFlag) { + %> + <% } else if (rtgsFileFlag) { %> <% - } if ((amtDueFlag <= 0 || diffInDaysFlag < 0) && (sdFileFlag)) { + } + if ((amtDueFlag <= 0 || diffInDaysFlag < 0) && (sdFileFlag)) { %> <% } - } + } %>
<% if (isExtendedFlag == 1) { %> -
-
- @@ -417,111 +444,158 @@ SNA Ret.Amount Total Amount <% - if (contDetListWrapper.getContList().get(0) - .getInvoiceBillTypeName() - .equalsIgnoreCase("PERCENTAGE BASED PAYMENT")) { + if (contDetListWrapper.getContList().get(0).getInvoiceBillTypeName().equalsIgnoreCase("PERCENTAGE BASED PAYMENT")) { %> Percent Applied <% } %> Balance To Be Claimed + Days Passed after Invoice Upload + Days Passed after Payment Upload View Files - <% - 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; - } - %> - - - <%= bill.getInvoiceBillingPeriod() %> - <%= bill.getInvoiceStartDate() %> - <%= bill.getInvoiceEndDate() %> - <%= bill.getInvoiceBillDate() %> - <%= bill.getBillStatName() %> - ₹ - <% - double currentAmt = bill.getTotAmt() + bill.getAmtDue(); - if (bill.getBillStatName().equals("CLAIMED")) { - out.print(String.format("%,.2f", currentAmt)); - } else { - out.print(String.format("%,.2f", lastClaimedAmountDue)); - } - %> - - ₹ <%= String.format("%,.2f", bill.getAmtExclTax()) %> - ₹ <%= String.format("%,.2f", bill.getCgstAmt()) %> - ₹ <%= String.format("%,.2f", bill.getSgstAmt()) %> - ₹ <%= String.format("%,.2f", bill.getIgstAmt()) %> - ₹ <%= String.format("%,.2f", bill.getItTaxAmt())%> - ₹ <%= String.format("%,.2f", bill.getSnaRetAmt())%> - ₹ <%= String.format("%,.2f", bill.getTotAmt()) %> - <% if (contDetListWrapper.getContList().get(0) - .getInvoiceBillTypeName() - .equalsIgnoreCase("PERCENTAGE BASED PAYMENT")) { %> - <%= bill.getPercentApplied()%> % - <% } %> - ₹ <%= String.format("%,.2f", amtDue) %> - -
- - - <% if (!bill.getRtgsFilePath().equals("-")) { %> - - <% } %> -
- - - <% } %> - + <% + 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; + } + %> + + + <%=bill.getInvoiceBillingPeriod()%> + <%=bill.getInvoiceStartDate()%> + <%=bill.getInvoiceEndDate()%> + <%=bill.getInvoiceBillDate()%> + <%=bill.getBillStatName()%> + ₹ <% + double currentAmt = bill.getTotAmt() + bill.getAmtDue(); + if (bill.getBillStatName().equals("CLAIMED")) { + out.print(String.format("%,.2f", currentAmt)); + } else { + out.print(String.format("%,.2f", lastClaimedAmountDue)); + } + %> + + ₹ <%=String.format("%,.2f", bill.getAmtExclTax())%> + ₹ <%=String.format("%,.2f", bill.getCgstAmt())%> + ₹ <%=String.format("%,.2f", bill.getSgstAmt())%> + ₹ <%=String.format("%,.2f", bill.getIgstAmt())%> + ₹ <%=String.format("%,.2f", bill.getItTaxAmt())%> + ₹ <%=String.format("%,.2f", bill.getSnaRetAmt())%> + ₹ <%=String.format("%,.2f", bill.getTotAmt())%> + <% + if (contDetListWrapper.getContList().get(0).getInvoiceBillTypeName().equalsIgnoreCase("PERCENTAGE BASED PAYMENT")) { + %> + <%=bill.getPercentApplied()%> % + <% + } + %> + ₹ <%=String.format("%,.2f", amtDue)%> + <% + 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("" + diffDays + " Days"); + } else if (!bill.getBillFilePath().equals("-") && !bill.getInvoiceFilePath().equals("-")) { + out.println("Invoice and Payment Files are uploaded"); + } + diffMillis = 0L; + diffDays = 0l; + %> + <% + 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("" + diffDays + " Days"); + } 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; + %> + + +
+ <% if (!bill.getBillFilePath().equals("-")) { %> + + <% } %> + + <% + if (!bill.getRtgsFilePath().equals("-")) { + %> + + <% + } + %> +
+ + + <% + } + %> +
<%@include file="export_pdf.html"%> - <% } %> + <% + } + %>  
- - - - "> + + + ">
- <%@include file="pdf_modal.html" %> + <%@include file="pdf_modal.html"%> <%@include file="includes/footer.jsp"%> diff --git a/src/main/webapp/exist_ext_bill_det_display.jsp b/src/main/webapp/exist_ext_bill_det_display.jsp index 3ff2366..7bf3c5a 100644 --- a/src/main/webapp/exist_ext_bill_det_display.jsp +++ b/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; %> @@ -308,9 +310,13 @@ if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) { name="new_ext_bill_det_btn" onclick="redirectToAddNewExtBillPage()"> Add Ext.Bill + <% } else if (lockAmount < thresholdAmt) { @@ -319,16 +325,31 @@ if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) { name="new_bill_det_btn" onclick="redirectToAddNewExtBillPage()"> Add Ext.Bill + + + <% + } else if (rtgsFileFlag && billFileFlag) { + %> + <% } else if (rtgsFileFlag) { %> - <% } if ((amtDueFlag <= 0 || diffInDaysFlag < 0) && (sdFileFlag)) { @@ -382,6 +403,8 @@ if (reqSrc.equalsIgnoreCase("exist_cont_det_display_page")) { } %> Balance To Be Claimed + Days Passed after Invoice Upload + Days Passed after Payment Upload View Files @@ -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")) { %> <%= bill.getPercentApplied()%> % <% } %> - ₹ <%= String.format("%,.2f", amtDue) %> + ₹ <%= String.format("%,.2f", amtDue) %> + <% + 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("" + diffDays + " Days"); + } else if (!bill.getBillFilePath().equals("-") && !bill.getInvoiceFilePath().equals("-")) { + out.println("Invoice and Payment Files are uploaded"); + } + diffMillis = 0L; + diffDays = 0l; + %> + <% + 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("" + diffDays + " Days"); + } 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; + %> +
+ <% if (!bill.getBillFilePath().equals("-")) { %> + <% } %>
-
-
- - -
-
<% } else { %>
@@ -322,11 +315,6 @@ for (BillStat billStat : billStatDetList) {
-
- - -
<% } %>
diff --git a/src/main/webapp/js/exist-bill-det-funcs-display.js b/src/main/webapp/js/exist-bill-det-funcs-display.js index 6f3e265..9e9e35d 100644 --- a/src/main/webapp/js/exist-bill-det-funcs-display.js +++ b/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; diff --git a/src/main/webapp/js/exist-ext-bill-det-funcs-display.js b/src/main/webapp/js/exist-ext-bill-det-funcs-display.js index 8d69017..980c36e 100644 --- a/src/main/webapp/js/exist-ext-bill-det-funcs-display.js +++ b/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; diff --git a/src/main/webapp/new_bill_det_entry.jsp b/src/main/webapp/new_bill_det_entry.jsp index 2229d2c..498dcef 100644 --- a/src/main/webapp/new_bill_det_entry.jsp +++ b/src/main/webapp/new_bill_det_entry.jsp @@ -296,12 +296,6 @@ required>
-
-
- - -
-
<% } else { %>
@@ -326,12 +320,6 @@ class="form-control" name="invoice_file" accept=".pdf" required>
-
- - -
<% } %>
diff --git a/src/main/webapp/upd_bill_det_entry.jsp b/src/main/webapp/upd_bill_det_entry.jsp new file mode 100644 index 0000000..82ba1a7 --- /dev/null +++ b/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 contDetList = contDetListWrapper != null ? contDetListWrapper.getContList() : new ArrayList(); + +// Fetch BillDetList +BillDetListWrapper billDetListWrapper = new BillDetListWrapper(existBillDetService.getBillDet(reqContNum)); +List billDetList = billDetListWrapper != null ? billDetListWrapper.getBillDetList() : new ArrayList(); + +//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 sortedPeriods = new TreeMap(); + +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 "; +} +%> + + + + + +Contract Management System + +<%@include file="includes/header.jsp"%> + + + <%@include file="includes/exist_navbar.jsp"%> +
+
+
+ +
+

Upload Payment File

+
+
+
+ + + + +
+
+
+
+ + +
+
+ + + +
+
+
+ +
+
+
+
+ <%@include file="includes/footer.jsp"%> + + + \ No newline at end of file diff --git a/src/main/webapp/upd_ext_bill_det_entry.jsp b/src/main/webapp/upd_ext_bill_det_entry.jsp new file mode 100644 index 0000000..e979630 --- /dev/null +++ b/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 contDetList = contDetListWrapper != null ? contDetListWrapper.getContList() : new ArrayList(); + +//Fetch BillDetList +BillDetListWrapper billDetListWrapper = new BillDetListWrapper(existExtBillDetService.getExtBillDet(reqContNum)); +List billDetList = billDetListWrapper != null ? billDetListWrapper.getBillDetList() : new ArrayList(); + +//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 sortedPeriods = new TreeMap(); + +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 "; +} +%> + + + + + +Contract Management System + +<%@include file="includes/header.jsp"%> + + + <%@include file="includes/exist_navbar.jsp"%> +
+
+
+ +
+

Modify Extension Bill Status

+
+
+
+ + + + +
+
+
+
+ + +
+
+ + + +
+
+
+ +
+
+
+
+ <%@include file="includes/footer.jsp"%> + + + \ No newline at end of file