added store column to desktop and display only logged in data

This commit is contained in:
Alex
2026-04-13 15:06:04 -06:00
parent d9c34abcf8
commit facf1d588b
24 changed files with 131 additions and 31 deletions

View File

@@ -21,6 +21,7 @@ public class AppointmentDTO {
private SimpleStringProperty appointmentDate; private SimpleStringProperty appointmentDate;
private SimpleStringProperty appointmentTime; private SimpleStringProperty appointmentTime;
private SimpleStringProperty appointmentStatus; private SimpleStringProperty appointmentStatus;
private SimpleStringProperty storeName;
public AppointmentDTO(int appointmentId, public AppointmentDTO(int appointmentId,
int customerId, String customerName, int customerId, String customerName,
@@ -30,7 +31,8 @@ public class AppointmentDTO {
String employeeName, String employeeName,
String appointmentDate, String appointmentDate,
String appointmentTime, String appointmentTime,
String appointmentStatus) { String appointmentStatus,
String storeName) {
this.appointmentId = new SimpleIntegerProperty(appointmentId); this.appointmentId = new SimpleIntegerProperty(appointmentId);
this.customerId = new SimpleIntegerProperty(customerId); this.customerId = new SimpleIntegerProperty(customerId);
@@ -44,6 +46,7 @@ public class AppointmentDTO {
this.appointmentDate = new SimpleStringProperty(appointmentDate); this.appointmentDate = new SimpleStringProperty(appointmentDate);
this.appointmentTime = new SimpleStringProperty(appointmentTime); this.appointmentTime = new SimpleStringProperty(appointmentTime);
this.appointmentStatus = new SimpleStringProperty(appointmentStatus); this.appointmentStatus = new SimpleStringProperty(appointmentStatus);
this.storeName = new SimpleStringProperty(storeName != null ? storeName : "");
} }
public int getAppointmentId() { return appointmentId.get(); } public int getAppointmentId() { return appointmentId.get(); }
@@ -62,4 +65,5 @@ public class AppointmentDTO {
public String getAppointmentDate() { return appointmentDate.get(); } public String getAppointmentDate() { return appointmentDate.get(); }
public String getAppointmentTime() { return appointmentTime.get(); } public String getAppointmentTime() { return appointmentTime.get(); }
public String getAppointmentStatus() { return appointmentStatus.get(); } public String getAppointmentStatus() { return appointmentStatus.get(); }
public String getStoreName() { return storeName.get(); }
} }

View File

@@ -8,18 +8,21 @@ public class PurchaseOrderDTO {
private StringProperty supplierName; private StringProperty supplierName;
private StringProperty orderDate; private StringProperty orderDate;
private StringProperty status; private StringProperty status;
private StringProperty storeName;
public PurchaseOrderDTO(long id, String supplierName, public PurchaseOrderDTO(long id, String supplierName,
String orderDate, String status) { String orderDate, String status, String storeName) {
this.purchaseOrderId = new SimpleLongProperty(id); this.purchaseOrderId = new SimpleLongProperty(id);
this.supplierName = new SimpleStringProperty(supplierName); this.supplierName = new SimpleStringProperty(supplierName);
this.orderDate = new SimpleStringProperty(orderDate); this.orderDate = new SimpleStringProperty(orderDate);
this.status = new SimpleStringProperty(status); this.status = new SimpleStringProperty(status);
this.storeName = new SimpleStringProperty(storeName != null ? storeName : "");
} }
public long getPurchaseOrderId() { return purchaseOrderId.get(); } public long getPurchaseOrderId() { return purchaseOrderId.get(); }
public String getSupplierName() { return supplierName.get(); } public String getSupplierName() { return supplierName.get(); }
public String getOrderDate() { return orderDate.get(); } public String getOrderDate() { return orderDate.get(); }
public String getStatus() { return status.get(); } public String getStatus() { return status.get(); }
public String getStoreName() { return storeName.get(); }
} }

View File

@@ -13,6 +13,7 @@ public class AdoptionResponse {
private LocalDate adoptionDate; private LocalDate adoptionDate;
private java.math.BigDecimal adoptionFee; private java.math.BigDecimal adoptionFee;
private String adoptionStatus; private String adoptionStatus;
private String sourceStoreName;
public AdoptionResponse() { public AdoptionResponse() {
} }
@@ -96,4 +97,12 @@ public class AdoptionResponse {
public void setAdoptionStatus(String adoptionStatus) { public void setAdoptionStatus(String adoptionStatus) {
this.adoptionStatus = adoptionStatus; this.adoptionStatus = adoptionStatus;
} }
public String getSourceStoreName() {
return sourceStoreName;
}
public void setSourceStoreName(String sourceStoreName) {
this.sourceStoreName = sourceStoreName;
}
} }

View File

@@ -6,6 +6,7 @@ import java.time.LocalDate;
public class PurchaseOrderResponse { public class PurchaseOrderResponse {
private Long purchaseOrderId; private Long purchaseOrderId;
private String supplierName; private String supplierName;
private String storeName;
private LocalDate orderDate; private LocalDate orderDate;
private LocalDate expectedDeliveryDate; private LocalDate expectedDeliveryDate;
private String orderStatus; private String orderStatus;
@@ -30,6 +31,14 @@ public class PurchaseOrderResponse {
this.supplierName = supplierName; this.supplierName = supplierName;
} }
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public LocalDate getOrderDate() { public LocalDate getOrderDate() {
return orderDate; return orderDate;
} }

View File

@@ -23,11 +23,14 @@ public class AdoptionApi {
return INSTANCE; return INSTANCE;
} }
public List<AdoptionResponse> listAdoptions(String query) throws Exception { public List<AdoptionResponse> listAdoptions(String query, Long storeId) throws Exception {
String path = "/api/v1/adoptions?page=0&size=1000"; String path = "/api/v1/adoptions?page=0&size=1000";
if (query != null && !query.isEmpty()) { if (query != null && !query.isEmpty()) {
path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8); path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8);
} }
if (storeId != null) {
path += "&storeId=" + storeId;
}
String response = apiClient.getRawResponse(path); String response = apiClient.getRawResponse(path);
PageResponse<AdoptionResponse> pageResponse = apiClient.getObjectMapper().readValue( PageResponse<AdoptionResponse> pageResponse = apiClient.getObjectMapper().readValue(
response, response,

View File

@@ -23,11 +23,14 @@ public class AppointmentApi {
return INSTANCE; return INSTANCE;
} }
public List<AppointmentResponse> listAppointments(String query) throws Exception { public List<AppointmentResponse> listAppointments(String query, Long storeId) throws Exception {
String path = "/api/v1/appointments?page=0&size=1000"; String path = "/api/v1/appointments?page=0&size=1000";
if (query != null && !query.isEmpty()) { if (query != null && !query.isEmpty()) {
path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8); path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8);
} }
if (storeId != null) {
path += "&storeId=" + storeId;
}
String response = apiClient.getRawResponse(path); String response = apiClient.getRawResponse(path);
PageResponse<AppointmentResponse> pageResponse = apiClient.getObjectMapper().readValue( PageResponse<AppointmentResponse> pageResponse = apiClient.getObjectMapper().readValue(
response, response,

View File

@@ -22,11 +22,14 @@ public class InventoryApi {
return INSTANCE; return INSTANCE;
} }
public List<InventoryResponse> listInventory(String query) throws Exception { public List<InventoryResponse> listInventory(String query, Long storeId) throws Exception {
String path = "/api/v1/inventory?page=0&size=1000"; String path = "/api/v1/inventory?page=0&size=1000";
if (query != null && !query.isEmpty()) { if (query != null && !query.isEmpty()) {
path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8); path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8);
} }
if (storeId != null) {
path += "&storeId=" + storeId;
}
String response = apiClient.getRawResponse(path); String response = apiClient.getRawResponse(path);
PageResponse<InventoryResponse> pageResponse = apiClient.getObjectMapper().readValue( PageResponse<InventoryResponse> pageResponse = apiClient.getObjectMapper().readValue(
response, response,

View File

@@ -21,11 +21,14 @@ public class PurchaseOrderApi {
return INSTANCE; return INSTANCE;
} }
public List<PurchaseOrderResponse> listPurchaseOrders(String query) throws Exception { public List<PurchaseOrderResponse> listPurchaseOrders(String query, Long storeId) throws Exception {
String path = "/api/v1/purchase-orders?page=0&size=1000"; String path = "/api/v1/purchase-orders?page=0&size=1000";
if (query != null && !query.isEmpty()) { if (query != null && !query.isEmpty()) {
path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8); path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8);
} }
if (storeId != null) {
path += "&storeId=" + storeId;
}
String response = apiClient.getRawResponse(path); String response = apiClient.getRawResponse(path);
PageResponse<PurchaseOrderResponse> pageResponse = apiClient.getObjectMapper().readValue( PageResponse<PurchaseOrderResponse> pageResponse = apiClient.getObjectMapper().readValue(
response, response,

View File

@@ -22,11 +22,14 @@ public class SaleApi {
return INSTANCE; return INSTANCE;
} }
public List<SaleResponse> listSales(int page, int size, String query) throws Exception { public List<SaleResponse> listSales(int page, int size, String query, Long storeId) throws Exception {
String path = "/api/v1/sales?page=" + page + "&size=" + size; String path = "/api/v1/sales?page=" + page + "&size=" + size;
if (query != null && !query.isEmpty()) { if (query != null && !query.isEmpty()) {
path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8); path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8);
} }
if (storeId != null) {
path += "&storeId=" + storeId;
}
String response = apiClient.getRawResponse(path); String response = apiClient.getRawResponse(path);
PageResponse<SaleResponse> pageResponse = apiClient.getObjectMapper().readValue( PageResponse<SaleResponse> pageResponse = apiClient.getObjectMapper().readValue(
response, response,
@@ -38,7 +41,7 @@ public class SaleApi {
return pageResponse.getContent(); return pageResponse.getContent();
} }
public List<SaleResponse> listAllSales(String query) throws Exception { public List<SaleResponse> listAllSales(String query, Long storeId) throws Exception {
int page = 0; int page = 0;
int size = 250; int size = 250;
List<SaleResponse> allSales = new java.util.ArrayList<>(); List<SaleResponse> allSales = new java.util.ArrayList<>();
@@ -48,6 +51,9 @@ public class SaleApi {
if (query != null && !query.isEmpty()) { if (query != null && !query.isEmpty()) {
path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8); path += "&q=" + URLEncoder.encode(query, StandardCharsets.UTF_8);
} }
if (storeId != null) {
path += "&storeId=" + storeId;
}
String response = apiClient.getRawResponse(path); String response = apiClient.getRawResponse(path);
PageResponse<SaleResponse> pageResponse = apiClient.getObjectMapper().readValue( PageResponse<SaleResponse> pageResponse = apiClient.getObjectMapper().readValue(

View File

@@ -1,6 +1,7 @@
package org.example.petshopdesktop.controllers; package org.example.petshopdesktop.controllers;
import javafx.application.Platform; import javafx.application.Platform;
import org.example.petshopdesktop.auth.UserSession;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
@@ -62,6 +63,9 @@ public class AdoptionController {
@FXML @FXML
private TableColumn<Adoption, String> colAdoptionStatus; private TableColumn<Adoption, String> colAdoptionStatus;
@FXML
private TableColumn<Adoption, String> colStoreName;
@FXML @FXML
private TableView<Adoption> tvAdoptions; private TableView<Adoption> tvAdoptions;
@@ -85,6 +89,7 @@ public class AdoptionController {
colAdoptionDate.setCellValueFactory(new PropertyValueFactory<>("adoptionDate")); colAdoptionDate.setCellValueFactory(new PropertyValueFactory<>("adoptionDate"));
colAdoptionFee.setCellValueFactory(new PropertyValueFactory<>("adoptionFee")); colAdoptionFee.setCellValueFactory(new PropertyValueFactory<>("adoptionFee"));
colAdoptionStatus.setCellValueFactory(new PropertyValueFactory<>("adoptionStatus")); colAdoptionStatus.setCellValueFactory(new PropertyValueFactory<>("adoptionStatus"));
colStoreName.setCellValueFactory(new PropertyValueFactory<>("storeName"));
TableViewSupport.applyCurrencyColumn(colAdoptionFee); TableViewSupport.applyCurrencyColumn(colAdoptionFee);
displayAdoptions(); displayAdoptions();
@@ -184,7 +189,8 @@ public class AdoptionController {
} else { } else {
new Thread(() -> { new Thread(() -> {
try { try {
List<AdoptionResponse> adoptions = AdoptionApi.getInstance().listAdoptions(filter); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<AdoptionResponse> adoptions = AdoptionApi.getInstance().listAdoptions(filter, storeId);
List<Adoption> adoptionList = adoptions.stream() List<Adoption> adoptionList = adoptions.stream()
.map(this::mapToAdoption) .map(this::mapToAdoption)
.sorted(Comparator.comparing(Adoption::getAdoptionDate).reversed()) .sorted(Comparator.comparing(Adoption::getAdoptionDate).reversed())
@@ -210,7 +216,8 @@ public class AdoptionController {
private void displayAdoptions() { private void displayAdoptions() {
new Thread(() -> { new Thread(() -> {
try { try {
List<AdoptionResponse> adoptions = AdoptionApi.getInstance().listAdoptions(null); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<AdoptionResponse> adoptions = AdoptionApi.getInstance().listAdoptions(null, storeId);
List<Adoption> adoptionList = adoptions.stream() List<Adoption> adoptionList = adoptions.stream()
.map(this::mapToAdoption) .map(this::mapToAdoption)
.sorted(Comparator.comparing(Adoption::getAdoptionDate).reversed()) .sorted(Comparator.comparing(Adoption::getAdoptionDate).reversed())
@@ -276,7 +283,8 @@ public class AdoptionController {
response.getEmployeeName(), response.getEmployeeName(),
response.getAdoptionDate() != null ? response.getAdoptionDate().toString() : "", response.getAdoptionDate() != null ? response.getAdoptionDate().toString() : "",
response.getAdoptionFee() != null ? response.getAdoptionFee().doubleValue() : 0.0, response.getAdoptionFee() != null ? response.getAdoptionFee().doubleValue() : 0.0,
response.getAdoptionStatus() response.getAdoptionStatus(),
response.getSourceStoreName()
); );
} }
} }

View File

@@ -327,7 +327,8 @@ public class AnalyticsController {
} }
private DashboardResponse buildStaffFallbackDashboard() throws Exception { private DashboardResponse buildStaffFallbackDashboard() throws Exception {
List<SaleResponse> sales = SaleApi.getInstance().listSales(0, Integer.MAX_VALUE, null); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<SaleResponse> sales = SaleApi.getInstance().listSales(0, Integer.MAX_VALUE, null, storeId);
String employeeName = UserSession.getInstance().getEmployeeName(); String employeeName = UserSession.getInstance().getEmployeeName();
if (employeeName == null || employeeName.isBlank()) { if (employeeName == null || employeeName.isBlank()) {
employeeName = UserSession.getInstance().getUsername(); employeeName = UserSession.getInstance().getUsername();

View File

@@ -1,6 +1,7 @@
package org.example.petshopdesktop.controllers; package org.example.petshopdesktop.controllers;
import javafx.application.Platform; import javafx.application.Platform;
import org.example.petshopdesktop.auth.UserSession;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.FilteredList;
@@ -36,6 +37,7 @@ public class AppointmentController {
@FXML private TableColumn<AppointmentDTO,String> colCustomerName; @FXML private TableColumn<AppointmentDTO,String> colCustomerName;
@FXML private TableColumn<AppointmentDTO,String> colEmployeeName; @FXML private TableColumn<AppointmentDTO,String> colEmployeeName;
@FXML private TableColumn<AppointmentDTO,String> colAppointmentStatus; @FXML private TableColumn<AppointmentDTO,String> colAppointmentStatus;
@FXML private TableColumn<AppointmentDTO,String> colStoreName;
@FXML private Button btnAdd; @FXML private Button btnAdd;
@FXML private Button btnEdit; @FXML private Button btnEdit;
@@ -63,6 +65,7 @@ public class AppointmentController {
colCustomerName.setCellValueFactory(new PropertyValueFactory<>("customerName")); colCustomerName.setCellValueFactory(new PropertyValueFactory<>("customerName"));
colEmployeeName.setCellValueFactory(new PropertyValueFactory<>("employeeName")); colEmployeeName.setCellValueFactory(new PropertyValueFactory<>("employeeName"));
colAppointmentStatus.setCellValueFactory(new PropertyValueFactory<>("appointmentStatus")); colAppointmentStatus.setCellValueFactory(new PropertyValueFactory<>("appointmentStatus"));
colStoreName.setCellValueFactory(new PropertyValueFactory<>("storeName"));
filtered = new FilteredList<>(appointments, a -> true); filtered = new FilteredList<>(appointments, a -> true);
TableViewSupport.bindSortedItems(tvAppointments, filtered); TableViewSupport.bindSortedItems(tvAppointments, filtered);
@@ -92,7 +95,8 @@ public class AppointmentController {
private void loadAppointments(){ private void loadAppointments(){
new Thread(() -> { new Thread(() -> {
try{ try{
List<AppointmentResponse> responses = AppointmentApi.getInstance().listAppointments(null); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<AppointmentResponse> responses = AppointmentApi.getInstance().listAppointments(null, storeId);
List<AppointmentDTO> appointmentDTOs = responses.stream() List<AppointmentDTO> appointmentDTOs = responses.stream()
.map(this::mapToAppointmentDTO) .map(this::mapToAppointmentDTO)
.sorted(Comparator.comparing((AppointmentDTO a) -> a.getAppointmentDate() + "T" + a.getAppointmentTime()).reversed()) .sorted(Comparator.comparing((AppointmentDTO a) -> a.getAppointmentDate() + "T" + a.getAppointmentTime()).reversed())
@@ -117,7 +121,8 @@ public class AppointmentController {
String query = text == null || text.trim().isEmpty() ? null : text.trim(); String query = text == null || text.trim().isEmpty() ? null : text.trim();
new Thread(() -> { new Thread(() -> {
try { try {
List<AppointmentResponse> responses = AppointmentApi.getInstance().listAppointments(query); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<AppointmentResponse> responses = AppointmentApi.getInstance().listAppointments(query, storeId);
List<AppointmentDTO> appointmentDTOs = responses.stream() List<AppointmentDTO> appointmentDTOs = responses.stream()
.map(this::mapToAppointmentDTO) .map(this::mapToAppointmentDTO)
.sorted(Comparator.comparing((AppointmentDTO a) -> a.getAppointmentDate() + "T" + a.getAppointmentTime()).reversed()) .sorted(Comparator.comparing((AppointmentDTO a) -> a.getAppointmentDate() + "T" + a.getAppointmentTime()).reversed())
@@ -263,7 +268,8 @@ public class AppointmentController {
response.getEmployeeName() != null ? response.getEmployeeName() : "", response.getEmployeeName() != null ? response.getEmployeeName() : "",
response.getAppointmentDate() != null ? response.getAppointmentDate().toString() : "", response.getAppointmentDate() != null ? response.getAppointmentDate().toString() : "",
response.getAppointmentTime() != null ? response.getAppointmentTime().toString() : "", response.getAppointmentTime() != null ? response.getAppointmentTime().toString() : "",
normalizeAppointmentStatus(response.getAppointmentStatus()) normalizeAppointmentStatus(response.getAppointmentStatus()),
response.getStoreName()
); );
} }

View File

@@ -10,6 +10,7 @@ import javafx.scene.Scene;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Modality; import javafx.stage.Modality;
import org.example.petshopdesktop.auth.UserSession;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.example.petshopdesktop.api.dto.inventory.InventoryResponse; import org.example.petshopdesktop.api.dto.inventory.InventoryResponse;
import org.example.petshopdesktop.api.endpoints.InventoryApi; import org.example.petshopdesktop.api.endpoints.InventoryApi;
@@ -53,6 +54,9 @@ public class InventoryController {
@FXML @FXML
private TableColumn<Inventory, Integer> colQuantity; private TableColumn<Inventory, Integer> colQuantity;
@FXML
private TableColumn<Inventory, String> colStoreName;
@FXML @FXML
private TableView<Inventory> tvInventory; private TableView<Inventory> tvInventory;
@@ -75,6 +79,7 @@ public class InventoryController {
colProductId.setCellValueFactory(new PropertyValueFactory<>("prodId")); colProductId.setCellValueFactory(new PropertyValueFactory<>("prodId"));
colProductName.setCellValueFactory(new PropertyValueFactory<>("prodName")); colProductName.setCellValueFactory(new PropertyValueFactory<>("prodName"));
colQuantity.setCellValueFactory(new PropertyValueFactory<>("quantity")); colQuantity.setCellValueFactory(new PropertyValueFactory<>("quantity"));
colStoreName.setCellValueFactory(new PropertyValueFactory<>("storeName"));
displayInventory(); displayInventory();
TableViewSupport.installDoubleClickAction(tvInventory, selected -> openDialog(selected, "Edit")); TableViewSupport.installDoubleClickAction(tvInventory, selected -> openDialog(selected, "Edit"));
@@ -167,7 +172,8 @@ public class InventoryController {
} else { } else {
new Thread(() -> { new Thread(() -> {
try { try {
List<InventoryResponse> inventories = InventoryApi.getInstance().listInventory(filter); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<InventoryResponse> inventories = InventoryApi.getInstance().listInventory(filter, storeId);
List<Inventory> inventoryList = inventories.stream() List<Inventory> inventoryList = inventories.stream()
.map(this::mapToInventory) .map(this::mapToInventory)
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -192,7 +198,8 @@ public class InventoryController {
private void displayInventory() { private void displayInventory() {
new Thread(() -> { new Thread(() -> {
try { try {
List<InventoryResponse> inventories = InventoryApi.getInstance().listInventory(null); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<InventoryResponse> inventories = InventoryApi.getInstance().listInventory(null, storeId);
List<Inventory> inventoryList = inventories.stream() List<Inventory> inventoryList = inventories.stream()
.map(this::mapToInventory) .map(this::mapToInventory)
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@@ -1,6 +1,7 @@
package org.example.petshopdesktop.controllers; package org.example.petshopdesktop.controllers;
import javafx.application.Platform; import javafx.application.Platform;
import org.example.petshopdesktop.auth.UserSession;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
@@ -228,7 +229,8 @@ public class PetController {
} else { } else {
new Thread(() -> { new Thread(() -> {
try { try {
List<PetResponse> pets = PetApi.getInstance().listPets(filter, species, status); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<PetResponse> pets = PetApi.getInstance().listPets(filter, species, status, storeId);
List<Pet> petList = pets.stream() List<Pet> petList = pets.stream()
.map(this::mapToPet) .map(this::mapToPet)
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -253,7 +255,8 @@ public class PetController {
private void displayPets() { private void displayPets() {
new Thread(() -> { new Thread(() -> {
try { try {
List<PetResponse> pets = PetApi.getInstance().listPets(null, selectedSpecies(), selectedStatus()); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<PetResponse> pets = PetApi.getInstance().listPets(null, selectedSpecies(), selectedStatus(), storeId);
List<Pet> petList = pets.stream() List<Pet> petList = pets.stream()
.map(this::mapToPet) .map(this::mapToPet)
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@@ -10,6 +10,7 @@ import javafx.scene.Scene;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import org.example.petshopdesktop.DTOs.PurchaseOrderDTO; import org.example.petshopdesktop.DTOs.PurchaseOrderDTO;
import org.example.petshopdesktop.auth.UserSession;
import org.example.petshopdesktop.api.dto.purchaseorder.PurchaseOrderResponse; import org.example.petshopdesktop.api.dto.purchaseorder.PurchaseOrderResponse;
import org.example.petshopdesktop.api.endpoints.PurchaseOrderApi; import org.example.petshopdesktop.api.endpoints.PurchaseOrderApi;
import org.example.petshopdesktop.controllers.dialogcontrollers.PurchaseOrderDetailsDialogController; import org.example.petshopdesktop.controllers.dialogcontrollers.PurchaseOrderDetailsDialogController;
@@ -39,6 +40,7 @@ public class PurchaseOrderController {
@FXML private TableColumn<PurchaseOrderDTO,String> colSupplier; @FXML private TableColumn<PurchaseOrderDTO,String> colSupplier;
@FXML private TableColumn<PurchaseOrderDTO,String> colOrderDate; @FXML private TableColumn<PurchaseOrderDTO,String> colOrderDate;
@FXML private TableColumn<PurchaseOrderDTO,String> colStatus; @FXML private TableColumn<PurchaseOrderDTO,String> colStatus;
@FXML private TableColumn<PurchaseOrderDTO,String> colStoreName;
private final ObservableList<PurchaseOrderDTO> purchaseOrders = FXCollections.observableArrayList(); private final ObservableList<PurchaseOrderDTO> purchaseOrders = FXCollections.observableArrayList();
private FilteredList<PurchaseOrderDTO> filtered; private FilteredList<PurchaseOrderDTO> filtered;
@@ -55,6 +57,7 @@ public class PurchaseOrderController {
colOrderDate.setCellValueFactory( colOrderDate.setCellValueFactory(
new PropertyValueFactory<>("orderDate")); new PropertyValueFactory<>("orderDate"));
colStoreName.setCellValueFactory(new javafx.scene.control.cell.PropertyValueFactory<>("storeName"));
colStatus.setCellValueFactory( colStatus.setCellValueFactory(
new PropertyValueFactory<>("status")); new PropertyValueFactory<>("status"));
@@ -72,7 +75,8 @@ public class PurchaseOrderController {
private void loadPurchaseOrders() { private void loadPurchaseOrders() {
new Thread(() -> { new Thread(() -> {
try { try {
List<PurchaseOrderResponse> responses = PurchaseOrderApi.getInstance().listPurchaseOrders(null); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<PurchaseOrderResponse> responses = PurchaseOrderApi.getInstance().listPurchaseOrders(null, storeId);
List<PurchaseOrderDTO> dtos = responses.stream() List<PurchaseOrderDTO> dtos = responses.stream()
.map(this::mapToPurchaseOrderDTO) .map(this::mapToPurchaseOrderDTO)
.sorted(Comparator.comparing(PurchaseOrderDTO::getOrderDate).reversed()) .sorted(Comparator.comparing(PurchaseOrderDTO::getOrderDate).reversed())
@@ -154,7 +158,8 @@ public class PurchaseOrderController {
response.getPurchaseOrderId(), response.getPurchaseOrderId(),
response.getSupplierName(), response.getSupplierName(),
response.getOrderDate() != null ? response.getOrderDate().toString() : "", response.getOrderDate() != null ? response.getOrderDate().toString() : "",
response.getOrderStatus() response.getOrderStatus(),
response.getStoreName()
); );
} }
} }

View File

@@ -126,6 +126,9 @@ public class SaleController {
@FXML @FXML
private TableColumn<SaleLineItem, String> colSalePaymentType; private TableColumn<SaleLineItem, String> colSalePaymentType;
@FXML
private TableColumn<SaleLineItem, String> colStoreName;
@FXML @FXML
private TableView<SaleLineItem> tvSales; private TableView<SaleLineItem> tvSales;
@@ -175,6 +178,7 @@ public class SaleController {
colSaleUnitPrice.setCellValueFactory(new PropertyValueFactory<>("unitPrice")); colSaleUnitPrice.setCellValueFactory(new PropertyValueFactory<>("unitPrice"));
colSaleTotal.setCellValueFactory(new PropertyValueFactory<>("total")); colSaleTotal.setCellValueFactory(new PropertyValueFactory<>("total"));
colSalePaymentType.setCellValueFactory(new PropertyValueFactory<>("paymentMethod")); colSalePaymentType.setCellValueFactory(new PropertyValueFactory<>("paymentMethod"));
colStoreName.setCellValueFactory(new PropertyValueFactory<>("storeName"));
colSaleId.setMinWidth(50); colSaleId.setMinWidth(50);
colSaleDate.setMinWidth(150); colSaleDate.setMinWidth(150);
colEmployeeName.setMinWidth(150); colEmployeeName.setMinWidth(150);
@@ -263,7 +267,8 @@ public class SaleController {
Task<List<SaleLineItem>> task = new Task<List<SaleLineItem>>() { Task<List<SaleLineItem>> task = new Task<List<SaleLineItem>>() {
@Override @Override
protected List<SaleLineItem> call() throws Exception { protected List<SaleLineItem> call() throws Exception {
List<SaleResponse> sales = SaleApi.getInstance().listAllSales(null); Long storeId = UserSession.getInstance().isAdmin() ? null : UserSession.getInstance().getStoreId();
List<SaleResponse> sales = SaleApi.getInstance().listAllSales(null, storeId);
sales.sort(Comparator.comparing(SaleResponse::getSaleDate, Comparator.nullsLast(Comparator.reverseOrder())) sales.sort(Comparator.comparing(SaleResponse::getSaleDate, Comparator.nullsLast(Comparator.reverseOrder()))
.thenComparing(SaleResponse::getSaleId, Comparator.nullsLast(Comparator.reverseOrder()))); .thenComparing(SaleResponse::getSaleId, Comparator.nullsLast(Comparator.reverseOrder())));
List<SaleLineItem> lineItems = new ArrayList<>(); List<SaleLineItem> lineItems = new ArrayList<>();
@@ -291,7 +296,8 @@ public class SaleController {
unitPrice, unitPrice,
lineTotal, lineTotal,
sale.getPaymentMethod(), sale.getPaymentMethod(),
isRefund isRefund,
sale.getStoreName()
)); ));
} }
} }
@@ -563,7 +569,7 @@ public class SaleController {
private void updateSalesColumnWidths(double tableWidth) { private void updateSalesColumnWidths(double tableWidth) {
double available = Math.max(tableWidth - 28.0, 0.0); double available = Math.max(tableWidth - 28.0, 0.0);
double baseWidth = 1125.0; double baseWidth = 1255.0;
if (available <= 0) { if (available <= 0) {
return; return;
} }
@@ -577,18 +583,20 @@ public class SaleController {
colSaleUnitPrice.setPrefWidth(115.0); colSaleUnitPrice.setPrefWidth(115.0);
colSaleTotal.setPrefWidth(120.0); colSaleTotal.setPrefWidth(120.0);
colSalePaymentType.setPrefWidth(110.0); colSalePaymentType.setPrefWidth(110.0);
colStoreName.setPrefWidth(130.0);
return; return;
} }
double extra = available - baseWidth; double extra = available - baseWidth;
colSaleId.setPrefWidth(60.0); colSaleId.setPrefWidth(60.0);
colSaleDate.setPrefWidth(170.0 + extra * 0.18); colSaleDate.setPrefWidth(170.0 + extra * 0.16);
colEmployeeName.setPrefWidth(160.0 + extra * 0.18); colEmployeeName.setPrefWidth(160.0 + extra * 0.16);
colServiceProduct.setPrefWidth(320.0 + extra * 0.42); colServiceProduct.setPrefWidth(320.0 + extra * 0.38);
colSaleQuantity.setPrefWidth(70.0); colSaleQuantity.setPrefWidth(70.0);
colSaleUnitPrice.setPrefWidth(115.0 + extra * 0.08); colSaleUnitPrice.setPrefWidth(115.0 + extra * 0.08);
colSaleTotal.setPrefWidth(120.0 + extra * 0.08); colSaleTotal.setPrefWidth(120.0 + extra * 0.08);
colSalePaymentType.setPrefWidth(110.0 + extra * 0.06); colSalePaymentType.setPrefWidth(110.0 + extra * 0.06);
colStoreName.setPrefWidth(130.0 + extra * 0.08);
} }
private void updateCartColumnWidths(double tableWidth) { private void updateCartColumnWidths(double tableWidth) {

View File

@@ -158,7 +158,7 @@ public class RefundDialogController {
Task<LoadedSaleData> task = new Task<>() { Task<LoadedSaleData> task = new Task<>() {
@Override @Override
protected LoadedSaleData call() throws Exception { protected LoadedSaleData call() throws Exception {
List<SaleResponse> allSales = SaleApi.getInstance().listAllSales(null); List<SaleResponse> allSales = SaleApi.getInstance().listAllSales(null, null);
SaleResponse sale = SaleApi.getInstance().getSale(saleId); SaleResponse sale = SaleApi.getInstance().getSale(saleId);
if (Boolean.TRUE.equals(sale.getIsRefund())) { if (Boolean.TRUE.equals(sale.getIsRefund())) {
throw new IllegalStateException("Select an original sale, not a refund record."); throw new IllegalStateException("Select an original sale, not a refund record.");

View File

@@ -15,8 +15,9 @@ public class Adoption {
private SimpleStringProperty adoptionDate; private SimpleStringProperty adoptionDate;
private SimpleDoubleProperty adoptionFee; private SimpleDoubleProperty adoptionFee;
private SimpleStringProperty adoptionStatus; private SimpleStringProperty adoptionStatus;
private SimpleStringProperty storeName;
public Adoption(int adoptionId, int petId, int customerId, int employeeId, String petName, String customerName, String employeeName, String adoptionDate, double adoptionFee, String adoptionStatus) { public Adoption(int adoptionId, int petId, int customerId, int employeeId, String petName, String customerName, String employeeName, String adoptionDate, double adoptionFee, String adoptionStatus, String storeName) {
this.adoptionId = new SimpleIntegerProperty(adoptionId); this.adoptionId = new SimpleIntegerProperty(adoptionId);
this.petId = new SimpleIntegerProperty(petId); this.petId = new SimpleIntegerProperty(petId);
this.customerId = new SimpleIntegerProperty(customerId); this.customerId = new SimpleIntegerProperty(customerId);
@@ -27,6 +28,7 @@ public class Adoption {
this.adoptionDate = new SimpleStringProperty(adoptionDate); this.adoptionDate = new SimpleStringProperty(adoptionDate);
this.adoptionFee = new SimpleDoubleProperty(adoptionFee); this.adoptionFee = new SimpleDoubleProperty(adoptionFee);
this.adoptionStatus = new SimpleStringProperty(adoptionStatus); this.adoptionStatus = new SimpleStringProperty(adoptionStatus);
this.storeName = new SimpleStringProperty(storeName != null ? storeName : "");
} }
public int getAdoptionId() { return adoptionId.get(); } public int getAdoptionId() { return adoptionId.get(); }
@@ -88,4 +90,10 @@ public class Adoption {
public void setAdoptionStatus(String adoptionStatus) { this.adoptionStatus.set(adoptionStatus); } public void setAdoptionStatus(String adoptionStatus) { this.adoptionStatus.set(adoptionStatus); }
public SimpleStringProperty adoptionStatusProperty() { return adoptionStatus; } public SimpleStringProperty adoptionStatusProperty() { return adoptionStatus; }
public String getStoreName() { return storeName.get(); }
public void setStoreName(String storeName) { this.storeName.set(storeName); }
public SimpleStringProperty storeNameProperty() { return storeName; }
} }

View File

@@ -10,8 +10,9 @@ public class SaleLineItem {
private final double total; private final double total;
private final String paymentMethod; private final String paymentMethod;
private final boolean isRefund; private final boolean isRefund;
private final String storeName;
public SaleLineItem(int saleId, String saleDate, String employeeName, String itemName, int quantity, double unitPrice, double total, String paymentMethod, boolean isRefund) { public SaleLineItem(int saleId, String saleDate, String employeeName, String itemName, int quantity, double unitPrice, double total, String paymentMethod, boolean isRefund, String storeName) {
this.saleId = saleId; this.saleId = saleId;
this.saleDate = saleDate; this.saleDate = saleDate;
this.employeeName = employeeName; this.employeeName = employeeName;
@@ -21,6 +22,7 @@ public class SaleLineItem {
this.total = total; this.total = total;
this.paymentMethod = paymentMethod; this.paymentMethod = paymentMethod;
this.isRefund = isRefund; this.isRefund = isRefund;
this.storeName = storeName != null ? storeName : "";
} }
public int getSaleId() { public int getSaleId() {
@@ -58,4 +60,8 @@ public class SaleLineItem {
public boolean isRefund() { public boolean isRefund() {
return isRefund; return isRefund;
} }
public String getStoreName() {
return storeName;
}
} }

View File

@@ -88,6 +88,7 @@
<TableColumn fx:id="colAdoptionDate" prefWidth="190.85711669921875" text="Adoption Date" /> <TableColumn fx:id="colAdoptionDate" prefWidth="190.85711669921875" text="Adoption Date" />
<TableColumn fx:id="colAdoptionFee" prefWidth="91.4285888671875" text="Fee" /> <TableColumn fx:id="colAdoptionFee" prefWidth="91.4285888671875" text="Fee" />
<TableColumn fx:id="colAdoptionStatus" prefWidth="120.0" text="Status" /> <TableColumn fx:id="colAdoptionStatus" prefWidth="120.0" text="Status" />
<TableColumn fx:id="colStoreName" prefWidth="130.0" text="Store" />
</columns> </columns>
</TableView> </TableView>
</children> </children>

View File

@@ -89,6 +89,7 @@
<TableColumn fx:id="colAppointmentTime" prefWidth="89.7142333984375" text="Time" /> <TableColumn fx:id="colAppointmentTime" prefWidth="89.7142333984375" text="Time" />
<TableColumn fx:id="colCustomerName" prefWidth="140.0" text="Customer" /> <TableColumn fx:id="colCustomerName" prefWidth="140.0" text="Customer" />
<TableColumn fx:id="colAppointmentStatus" prefWidth="98.28570556640625" text="Status" /> <TableColumn fx:id="colAppointmentStatus" prefWidth="98.28570556640625" text="Status" />
<TableColumn fx:id="colStoreName" prefWidth="130.0" text="Store" />
</columns> </columns>
</TableView> </TableView>
</children> </children>

View File

@@ -85,6 +85,7 @@
<TableColumn fx:id="colProductId" prefWidth="153.14285278320312" text="Product ID" /> <TableColumn fx:id="colProductId" prefWidth="153.14285278320312" text="Product ID" />
<TableColumn fx:id="colProductName" prefWidth="325.14288330078125" text="Product Name" /> <TableColumn fx:id="colProductName" prefWidth="325.14288330078125" text="Product Name" />
<TableColumn fx:id="colQuantity" prefWidth="179.42852783203125" text="Quantity" /> <TableColumn fx:id="colQuantity" prefWidth="179.42852783203125" text="Quantity" />
<TableColumn fx:id="colStoreName" prefWidth="130.0" text="Store" />
</columns> </columns>
</TableView> </TableView>
</children> </children>

View File

@@ -70,6 +70,7 @@
<TableColumn fx:id="colSupplier" text="Supplier" prefWidth="200"/> <TableColumn fx:id="colSupplier" text="Supplier" prefWidth="200"/>
<TableColumn fx:id="colOrderDate" text="Order Date" prefWidth="150"/> <TableColumn fx:id="colOrderDate" text="Order Date" prefWidth="150"/>
<TableColumn fx:id="colStatus" text="Status" prefWidth="120"/> <TableColumn fx:id="colStatus" text="Status" prefWidth="120"/>
<TableColumn fx:id="colStoreName" text="Store" prefWidth="130"/>
</columns> </columns>
</TableView> </TableView>

View File

@@ -186,6 +186,7 @@
<TableColumn fx:id="colSaleUnitPrice" minWidth="100.0" prefWidth="115.0" text="Unit Price" /> <TableColumn fx:id="colSaleUnitPrice" minWidth="100.0" prefWidth="115.0" text="Unit Price" />
<TableColumn fx:id="colSaleTotal" minWidth="100.0" prefWidth="120.0" text="Total" /> <TableColumn fx:id="colSaleTotal" minWidth="100.0" prefWidth="120.0" text="Total" />
<TableColumn fx:id="colSalePaymentType" minWidth="95.0" prefWidth="110.0" text="Payment" /> <TableColumn fx:id="colSalePaymentType" minWidth="95.0" prefWidth="110.0" text="Payment" />
<TableColumn fx:id="colStoreName" minWidth="100.0" prefWidth="130.0" text="Store" />
</columns> </columns>
</TableView> </TableView>
</children> </children>