39 changed files with 1318 additions and 291 deletions
-
BINbuild/classes/com/cont_mgmt/dto/Bill.class
-
BINbuild/classes/com/cont_mgmt/repository/FetchExistBillDet.class
-
BINbuild/classes/com/cont_mgmt/repository/FetchExistExtBillDet.class
-
BINbuild/classes/com/cont_mgmt/repository/InsertBillDet.class
-
BINbuild/classes/com/cont_mgmt/repository/InsertExtBillDet.class
-
BINbuild/classes/com/cont_mgmt/repository/UpdateBillDet.class
-
BINbuild/classes/com/cont_mgmt/repository/UpdateExtBillDet.class
-
BINbuild/classes/com/cont_mgmt/service/ExtBillDetService.class
-
BINbuild/classes/com/cont_mgmt/service/NewBillDetService.class
-
BINbuild/classes/com/cont_mgmt/service/UpdBillDetService.class
-
BINbuild/classes/com/cont_mgmt/service/UpdExtBillDetService.class
-
BINbuild/classes/com/cont_mgmt/servlet/ExtBillDetServlet.class
-
BINbuild/classes/com/cont_mgmt/servlet/NewBillDetServlet.class
-
BINbuild/classes/com/cont_mgmt/servlet/UpdBillDetServlet.class
-
BINbuild/classes/com/cont_mgmt/servlet/UpdExtBillDetServlet.class
-
25src/main/java/com/cont_mgmt/dto/Bill.java
-
10src/main/java/com/cont_mgmt/repository/FetchExistBillDet.java
-
6src/main/java/com/cont_mgmt/repository/FetchExistExtBillDet.java
-
6src/main/java/com/cont_mgmt/repository/InsertBillDet.java
-
6src/main/java/com/cont_mgmt/repository/InsertExtBillDet.java
-
82src/main/java/com/cont_mgmt/repository/UpdateBillDet.java
-
81src/main/java/com/cont_mgmt/repository/UpdateExtBillDet.java
-
14src/main/java/com/cont_mgmt/service/ExtBillDetService.java
-
12src/main/java/com/cont_mgmt/service/NewBillDetService.java
-
56src/main/java/com/cont_mgmt/service/UpdBillDetService.java
-
60src/main/java/com/cont_mgmt/service/UpdExtBillDetService.java
-
5src/main/java/com/cont_mgmt/servlet/ExtBillDetServlet.java
-
5src/main/java/com/cont_mgmt/servlet/NewBillDetServlet.java
-
111src/main/java/com/cont_mgmt/servlet/UpdBillDetServlet.java
-
110src/main/java/com/cont_mgmt/servlet/UpdExtBillDetServlet.java
-
3src/main/webapp/WEB-INF/web.xml
-
220src/main/webapp/exist_bill_det_display.jsp
-
71src/main/webapp/exist_ext_bill_det_display.jsp
-
12src/main/webapp/ext_bill_det_entry.jsp
-
40src/main/webapp/js/exist-bill-det-funcs-display.js
-
40src/main/webapp/js/exist-ext-bill-det-funcs-display.js
-
12src/main/webapp/new_bill_det_entry.jsp
-
161src/main/webapp/upd_bill_det_entry.jsp
-
161src/main/webapp/upd_ext_bill_det_entry.jsp
@ -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; |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -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; |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -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; |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -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; |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -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)); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -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)); |
|||
} |
|||
} |
|||
} |
|||
@ -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()">← 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> |
|||
@ -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()">← 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> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue