|
|
@ -34,6 +34,8 @@ public class GccServicePaymentTrackerService { |
|
|
counts.put("delivery chellan", 0); |
|
|
counts.put("delivery chellan", 0); |
|
|
counts.put("asd", 0); |
|
|
counts.put("asd", 0); |
|
|
counts.put("agreement", 0); |
|
|
counts.put("agreement", 0); |
|
|
|
|
|
counts.put("total", 0); |
|
|
|
|
|
counts.put("status_not_updated", 0); |
|
|
|
|
|
|
|
|
String sql = "SELECT " |
|
|
String sql = "SELECT " |
|
|
+ "CASE WHEN p.type REGEXP '^[0-9]+$' THEN t.type_name ELSE p.type END as type_resolved, " |
|
|
+ "CASE WHEN p.type REGEXP '^[0-9]+$' THEN t.type_name ELSE p.type END as type_resolved, " |
|
|
@ -43,6 +45,20 @@ public class GccServicePaymentTrackerService { |
|
|
+ "WHERE p.is_active = 1 AND p.is_delete = 0 " |
|
|
+ "WHERE p.is_active = 1 AND p.is_delete = 0 " |
|
|
+ "GROUP BY type_resolved"; |
|
|
+ "GROUP BY type_resolved"; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
// Count total active records |
|
|
|
|
|
String sqlTotal = "SELECT COUNT(*) FROM payment_tracking_details WHERE is_active = 1 AND is_delete = 0"; |
|
|
|
|
|
Integer totalCount = jdbcTemplate.queryForObject(sqlTotal, Integer.class); |
|
|
|
|
|
counts.put("total", totalCount != null ? totalCount : 0); |
|
|
|
|
|
|
|
|
|
|
|
// Count records where type is missing |
|
|
|
|
|
String sqlMissingType = "SELECT COUNT(*) FROM payment_tracking_details WHERE is_active = 1 AND is_delete = 0 AND (type IS NULL OR TRIM(type) = '')"; |
|
|
|
|
|
Integer missingTypeCount = jdbcTemplate.queryForObject(sqlMissingType, Integer.class); |
|
|
|
|
|
counts.put("status_not_updated", missingTypeCount != null ? missingTypeCount : 0); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.err.println("Error getting total or missing type counts: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql); |
|
|
List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql); |
|
|
for (Map<String, Object> row : rows) { |
|
|
for (Map<String, Object> row : rows) { |
|
|
@ -90,7 +106,9 @@ public class GccServicePaymentTrackerService { |
|
|
|
|
|
|
|
|
if (type != null && !type.trim().isEmpty()) { |
|
|
if (type != null && !type.trim().isEmpty()) { |
|
|
String category = type.trim().toLowerCase(); |
|
|
String category = type.trim().toLowerCase(); |
|
|
if (category.equals("asd")) { |
|
|
|
|
|
|
|
|
if (category.equals("status_not_updated")) { |
|
|
|
|
|
sql.append(" AND (p.type IS NULL OR TRIM(p.type) = '')"); |
|
|
|
|
|
} else if (category.equals("asd")) { |
|
|
sql.append( |
|
|
sql.append( |
|
|
" AND (LOWER(p.type) = 'asd' OR LOWER(p.type) LIKE '%asd%' OR LOWER(t.type_name) LIKE '%asd%' OR LOWER(t.type_name) LIKE '%additional security%')"); |
|
|
" AND (LOWER(p.type) = 'asd' OR LOWER(p.type) LIKE '%asd%' OR LOWER(t.type_name) LIKE '%asd%' OR LOWER(t.type_name) LIKE '%additional security%')"); |
|
|
} else if (category.equals("agreement")) { |
|
|
} else if (category.equals("agreement")) { |
|
|
@ -132,7 +150,8 @@ public class GccServicePaymentTrackerService { |
|
|
|
|
|
|
|
|
if (status != null && !status.trim().isEmpty()) { |
|
|
if (status != null && !status.trim().isEmpty()) { |
|
|
if (status.trim().matches("^[0-9]+$")) { |
|
|
if (status.trim().matches("^[0-9]+$")) { |
|
|
sql.append(" AND (p.status = ? OR (NOT p.status REGEXP '^[0-9]+$' AND p.status = (SELECT status_name FROM status_list WHERE id = ? LIMIT 1)))"); |
|
|
|
|
|
|
|
|
sql.append( |
|
|
|
|
|
" AND (p.status = ? OR (NOT p.status REGEXP '^[0-9]+$' AND p.status = (SELECT status_name FROM status_list WHERE id = ? LIMIT 1)))"); |
|
|
params.add(status.trim()); |
|
|
params.add(status.trim()); |
|
|
params.add(status.trim()); |
|
|
params.add(status.trim()); |
|
|
} else { |
|
|
} else { |
|
|
@ -268,10 +287,54 @@ public class GccServicePaymentTrackerService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public boolean deleteDetail(int id) { |
|
|
|
|
|
String sql = "UPDATE payment_tracking_details SET is_active = 0, is_delete = 1 WHERE id = ?"; |
|
|
|
|
|
|
|
|
public boolean deleteDetail(int id, String remarks, String updatedBy) { |
|
|
|
|
|
String sql = "UPDATE payment_tracking_details SET is_active = 0, is_delete = 1, remarks = ?, updated_by = ?, updated_date = ? WHERE id = ?"; |
|
|
|
|
|
try { |
|
|
|
|
|
// Retrieve old record first to populate history |
|
|
|
|
|
Map<String, Object> old = null; |
|
|
|
|
|
try { |
|
|
|
|
|
old = jdbcTemplate.queryForMap("SELECT * FROM payment_tracking_details WHERE id = ?", id); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
System.err.println("Could not find old record for history before delete: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int rows = jdbcTemplate.update(sql, remarks, updatedBy, new java.sql.Timestamp(System.currentTimeMillis()), |
|
|
|
|
|
id); |
|
|
|
|
|
|
|
|
|
|
|
if (rows > 0 && old != null) { |
|
|
try { |
|
|
try { |
|
|
int rows = jdbcTemplate.update(sql, id); |
|
|
|
|
|
|
|
|
String histSql = "INSERT INTO payment_tracking_details_history (" |
|
|
|
|
|
+ "detail_id, received_date, vendor_name, subject, amount, invoice_no, receiptno, " |
|
|
|
|
|
+ "invoice_date, type, physical_file_no, remarks, tat, status, followup, myfollowup, " |
|
|
|
|
|
+ "is_active, is_delete, order_by, file_path, cdate, updated_at, updated_by" |
|
|
|
|
|
+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|
|
|
|
|
jdbcTemplate.update(histSql, |
|
|
|
|
|
id, |
|
|
|
|
|
old.get("received_date"), |
|
|
|
|
|
old.get("vendor_name"), |
|
|
|
|
|
old.get("subject"), |
|
|
|
|
|
old.get("amount"), |
|
|
|
|
|
old.get("invoice_no"), |
|
|
|
|
|
old.get("receiptno"), |
|
|
|
|
|
old.get("invoice_date"), |
|
|
|
|
|
old.get("type"), |
|
|
|
|
|
old.get("physical_file_no"), |
|
|
|
|
|
remarks, |
|
|
|
|
|
old.get("tat"), |
|
|
|
|
|
old.get("status"), |
|
|
|
|
|
old.get("followup"), |
|
|
|
|
|
old.get("myfollowup"), |
|
|
|
|
|
0, // is_active = 0 |
|
|
|
|
|
1, // is_delete = 1 |
|
|
|
|
|
old.get("order_by"), |
|
|
|
|
|
old.get("file_path"), |
|
|
|
|
|
old.get("cdate"), |
|
|
|
|
|
new java.sql.Timestamp(System.currentTimeMillis()), |
|
|
|
|
|
updatedBy); |
|
|
|
|
|
} catch (Exception he) { |
|
|
|
|
|
System.err.println("Error saving history during delete: " + he.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return rows > 0; |
|
|
return rows > 0; |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
System.err.println("Error soft-deleting payment tracking detail ID " + id + ": " + e.getMessage()); |
|
|
System.err.println("Error soft-deleting payment tracking detail ID " + id + ": " + e.getMessage()); |
|
|
@ -380,7 +443,8 @@ public class GccServicePaymentTrackerService { |
|
|
try { |
|
|
try { |
|
|
return jdbcTemplate.queryForList(sql, detailId); |
|
|
return jdbcTemplate.queryForList(sql, detailId); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
System.err.println("Error fetching payment tracking history for detail ID " + detailId + ": " + e.getMessage()); |
|
|
|
|
|
|
|
|
System.err.println( |
|
|
|
|
|
"Error fetching payment tracking history for detail ID " + detailId + ": " + e.getMessage()); |
|
|
return new ArrayList<>(); |
|
|
return new ArrayList<>(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|