|
|
|
@ -46,6 +46,7 @@ import com.gcc.communityHall.entity.HallDetailsConcession; |
|
|
|
import com.gcc.communityHall.entity.ReasonDocumentMaster; |
|
|
|
import com.gcc.communityHall.entity.ReasonMaster; |
|
|
|
import com.gcc.communityHall.entity.Settlement; |
|
|
|
import com.gcc.communityHall.entity.SettlementHistory; |
|
|
|
import com.gcc.communityHall.entity.Users; |
|
|
|
import com.gcc.communityHall.exception.SlotOccupiedException; |
|
|
|
import com.gcc.communityHall.others.UserSession; |
|
|
|
@ -65,6 +66,7 @@ import com.gcc.communityHall.repository.GccblockingDocumentsRepo; |
|
|
|
import com.gcc.communityHall.repository.HallDetailsConcessionRepo; |
|
|
|
import com.gcc.communityHall.repository.HallDetailsRepository; |
|
|
|
import com.gcc.communityHall.repository.ReasonMasterRepository; |
|
|
|
import com.gcc.communityHall.repository.SettlementHistoryRepository; |
|
|
|
import com.gcc.communityHall.repository.SettlementRepository; |
|
|
|
import com.gcc.communityHall.repository.UsersRepository; |
|
|
|
import com.gcc.communityHall.service.ApplicationLogService; |
|
|
|
@ -140,6 +142,8 @@ public class BookingServiceImpl implements BookingService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private HttpSession session; |
|
|
|
@Autowired |
|
|
|
private SettlementHistoryRepository settlementHistoryRepository; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private HallDetailsConcessionRepo hallDetailsConcessionRepo; |
|
|
|
@ -1372,15 +1376,172 @@ public class BookingServiceImpl implements BookingService { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
/*@Override |
|
|
|
public BookingDetails getBookingDetailsWithSettlement(int settlementId) { |
|
|
|
Optional<BookingDetails> SettleBookingDetails = Optional.of(bookingDetailsRepository.findBySettlementIdWithBookingDetails(settlementId)); |
|
|
|
if (SettleBookingDetails.isPresent()) { |
|
|
|
System.out.println("settlement list: " + SettleBookingDetails.get()); |
|
|
|
return SettleBookingDetails.get(); |
|
|
|
|
|
|
|
} |
|
|
|
return null; |
|
|
|
}*/ |
|
|
|
//ak |
|
|
|
/*@Override |
|
|
|
public BookingDetails getBookingDetailsWithSettlement(int settlementId) { |
|
|
|
// 🔹 Your existing logic (unchanged) |
|
|
|
Optional<BookingDetails> SettleBookingDetails = |
|
|
|
Optional.of(bookingDetailsRepository.findBySettlementIdWithBookingDetails(settlementId)); |
|
|
|
|
|
|
|
if (SettleBookingDetails.isPresent()) { |
|
|
|
BookingDetails bookingDetails = SettleBookingDetails.get(); |
|
|
|
System.out.println("settlement list: " + bookingDetails); |
|
|
|
|
|
|
|
// 🔹 Keep the same return behavior, but do reset before returning |
|
|
|
if (bookingDetails.getSettlement() == null) { |
|
|
|
Settlement settlement = bookingDetails.getSettlement(); |
|
|
|
|
|
|
|
// ✅ Auto-reset logic (only if approvedFlag=1 and approvedFlagDate != null) |
|
|
|
if (settlement.getApprovedFlag() == 1 && settlement.getApprovedFlagDate() != null) { |
|
|
|
long millisDiff = System.currentTimeMillis() - settlement.getApprovedFlagDate().getTime(); |
|
|
|
long daysDiff = millisDiff / (1000 * 60 * 60 * 24); |
|
|
|
|
|
|
|
System.out.println("Approved Flag Date: " + settlement.getApprovedFlagDate()); |
|
|
|
System.out.println("Current Java Date: " + new Date()); |
|
|
|
System.out.println("Days Difference: " + daysDiff); |
|
|
|
|
|
|
|
if (daysDiff >= 4) { |
|
|
|
settlement.setApprovedFlag(0); |
|
|
|
settlement.setApprovedFlagDate(null); |
|
|
|
settlementRepository.save(settlement); |
|
|
|
System.out.println("✅ Approved flag reset after 4 days for Settlement ID: " + settlement.getSettlementId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// ✅ Return same object (your original logic) |
|
|
|
return bookingDetails; |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
}*/ |
|
|
|
@Override |
|
|
|
public List<Object[]> getSettlementInitiatedReport(String fromDate, String toDate) { |
|
|
|
return bookingDetailsRepository.getSettlementInitiatedReport(fromDate, toDate); |
|
|
|
} |
|
|
|
//ak |
|
|
|
@Override |
|
|
|
public BookingDetails getBookingDetailsWithSettlement(int settlementId) { |
|
|
|
// 🔹 Your existing logic (unchanged) |
|
|
|
Optional<BookingDetails> SettleBookingDetails = |
|
|
|
Optional.ofNullable(bookingDetailsRepository.findBySettlementIdWithBookingDetails(settlementId)); |
|
|
|
//ak |
|
|
|
/* Optional<Settlement> settlementOptional = settlementRepository.findById(settlementId); |
|
|
|
String adminname = (String) session.getAttribute("usertype"); |
|
|
|
if (settlementOptional.isPresent()) { |
|
|
|
Settlement settlement = settlementOptional.get(); |
|
|
|
|
|
|
|
SettlementHistory history = new SettlementHistory(); |
|
|
|
history.setSettlementId(settlement.getSettlementId()); |
|
|
|
history.setComments(settlement.getComments()); |
|
|
|
history.setCdate(settlement.getCdate()); |
|
|
|
history.setDamageAmount(settlement.getDamageAmount()); |
|
|
|
history.setEbAmount(settlement.getEbAmount()); |
|
|
|
history.setDepositAmount(settlement.getDepositAmount()); |
|
|
|
history.setRefundedAmount(settlement.getRefundedAmount()); |
|
|
|
history.setUpdatedDate(new Date()); |
|
|
|
history.setUpdatedId(adminname); |
|
|
|
history.setChallon(settlement.getChallon()); |
|
|
|
history.setDddate(settlement.getDddate()); |
|
|
|
history.setDdnumber(settlement.getDdnumber()); |
|
|
|
history.setBookingDetails(settlement.getBookingDetails()); |
|
|
|
history.setCollectionPending(settlement.getCollectionPending()); |
|
|
|
history.setDdamount(settlement.getDdamount()); |
|
|
|
history.setChallonnumber(settlement.getChallonnumber()); |
|
|
|
history.setCollectionStatus(settlement.getCollectionStatus()); |
|
|
|
history.setChallonamount(settlement.getChallonamount()); |
|
|
|
history.setApprovedFlag(settlement.getApprovedFlag()); |
|
|
|
history.setApprovedFlagDate(settlement.getApprovedFlagDate()); |
|
|
|
history.setShDate(new Date()); |
|
|
|
|
|
|
|
settlementHistoryRepository.save(history); |
|
|
|
System.out.println("✅ Record inserted into SettlementHistory for Settlement ID: " + settlementId); |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (SettleBookingDetails.isPresent()) { |
|
|
|
BookingDetails bookingDetails = SettleBookingDetails.get(); |
|
|
|
System.out.println("settlement list: " + bookingDetails); |
|
|
|
|
|
|
|
|
|
|
|
// 🔹 Only do reset if settlement exists |
|
|
|
if (bookingDetails.getSettlement() != null) { // ✅ FIXED HERE |
|
|
|
Settlement settlement = bookingDetails.getSettlement(); |
|
|
|
|
|
|
|
// ✅ Auto-reset logic (only if approvedFlag=1 and approvedFlagDate != null) |
|
|
|
if (settlement.getApprovedFlag() == 1 && settlement.getApprovedFlagDate() != null) { |
|
|
|
long millisDiff = System.currentTimeMillis() - settlement.getApprovedFlagDate().getTime(); |
|
|
|
long daysDiff = millisDiff / (1000 * 60 * 60 * 24); |
|
|
|
|
|
|
|
System.out.println("Approved Flag Date123: " + settlement.getApprovedFlagDate()); |
|
|
|
System.out.println("Current Java Date: " + new Date()); |
|
|
|
System.out.println("Days Difference: " + daysDiff); |
|
|
|
|
|
|
|
if (daysDiff > 4) { |
|
|
|
//settlement histoty insert |
|
|
|
Optional<Settlement> settlementOptional = settlementRepository.findById(settlementId); |
|
|
|
String adminname = (String) session.getAttribute("usertype"); |
|
|
|
if (settlementOptional.isPresent()) { |
|
|
|
|
|
|
|
|
|
|
|
SettlementHistory history = new SettlementHistory(); |
|
|
|
history.setSettlementId(settlement.getSettlementId()); |
|
|
|
history.setComments(settlement.getComments()); |
|
|
|
history.setCdate(settlement.getCdate()); |
|
|
|
history.setDamageAmount(settlement.getDamageAmount()); |
|
|
|
history.setEbAmount(settlement.getEbAmount()); |
|
|
|
history.setDepositAmount(settlement.getDepositAmount()); |
|
|
|
history.setRefundedAmount(settlement.getRefundedAmount()); |
|
|
|
history.setUpdatedDate(new Date()); |
|
|
|
history.setUpdatedId(adminname); |
|
|
|
history.setChallon(settlement.getChallon()); |
|
|
|
history.setDddate(settlement.getDddate()); |
|
|
|
history.setDdnumber(settlement.getDdnumber()); |
|
|
|
history.setBookingDetails(settlement.getBookingDetails()); |
|
|
|
history.setCollectionPending(settlement.getCollectionPending()); |
|
|
|
history.setDdamount(settlement.getDdamount()); |
|
|
|
history.setChallonnumber(settlement.getChallonnumber()); |
|
|
|
history.setCollectionStatus(settlement.getCollectionStatus()); |
|
|
|
history.setChallonamount(settlement.getChallonamount()); |
|
|
|
history.setApprovedFlag(settlement.getApprovedFlag()); |
|
|
|
history.setApprovedFlagDate(settlement.getApprovedFlagDate()); |
|
|
|
history.setShDate(new Date()); |
|
|
|
|
|
|
|
settlementHistoryRepository.save(history); |
|
|
|
System.out.println("✅ Record inserted into SettlementHistory for Settlement ID: " + settlementId); |
|
|
|
} |
|
|
|
|
|
|
|
settlement.setApprovedFlag(0); |
|
|
|
settlement.setApprovedFlagDate(null); |
|
|
|
settlementRepository.save(settlement); |
|
|
|
System.out.println("✅ Approved flag reset after 3 days for Settlement ID: " + settlement.getSettlementId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
System.out.println("⚠️ No settlement found for booking ID: " + bookingDetails.getBookingId()); |
|
|
|
} |
|
|
|
|
|
|
|
// ✅ Return same object (your original logic) |
|
|
|
return bookingDetails; |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public BookingDetails saveebdetails(int bookingId, double startingReading, |
|
|
|
MultipartFile startingReadingimage) { |
|
|
|
|