Fix Service Booking Creation Is Not Synchronized Between Processes

Changes:

- Updated ServiceManagementService::purchaseService() to persist service
  bookings immediately after creation using m_dataStore.saveServiceBookings().
- Updated ServiceManagementService::purchaseComboPackage() to persist
  combo package bookings immediately after creation using
  m_dataStore.saveServiceBookings().
- Changed DataStore::getJobCards() to use a reference for tracked bookings
  to ensure consistent linkage and prevent overwriting.

Fixes #2074
This commit is contained in:
Jissin Mathew
2026-06-17 14:47:37 +05:30
parent 528075e0cd
commit 974d4efe02
2 changed files with 3 additions and 1 deletions
@@ -415,7 +415,7 @@ util::Map<std::string, TrackedRecord<JobCard>>& DataStore::getJobCards()
{
throw std::runtime_error("Invalid booking ID: " + bookingId);
}
auto trackedBooking = serviceBookings.getValueAt(bookingIndex);
auto& trackedBooking = serviceBookings.getValueAt(bookingIndex);
jobCard->setBooking(trackedBooking.data);
const std::string& serviceId = jobCard->getServiceId();
int serviceIndex = services.find(serviceId);
@@ -72,6 +72,7 @@ void ServiceManagementService::purchaseService(const util::Vector<std::string>&
std::string title = "Service Booking succeeded";
std::string message = "Your service booking has been successfully placed with ID " + serviceBooking->getId();
sendNotification(authenticatedUser, title, message);
m_dataStore.saveServiceBookings();
}
/*
@@ -112,6 +113,7 @@ void ServiceManagementService::purchaseComboPackage(const std::string& comboPack
std::string title = "Combo Package Service Booking succeeded";
std::string message = "Your service booking for the combo package has been successfully placed with ID " + serviceBooking->getId();
sendNotification(authenticatedUser, title, message);
m_dataStore.saveServiceBookings();
}
util::Map<std::string, User*> ServiceManagementService::m_observers{};