Complete desktop DTO integration and controller fixes
**Critical DTO Fixes:** - ServiceResponse/Request: id → serviceId, price → servicePrice, description → serviceDesc - SaleItemRequest: productId → prodId, removed unitPrice (backend doesn't require) - SaleItemResponse: id → saleItemId, added prodId, removed lineTotal (calculated locally) - TopProduct: added productId, quantitySold Integer → Long, totalRevenue → revenue - DailySales: date LocalDate → String, totalSales → revenue, added salesCount **Controller Updates:** - Updated 17+ controllers and dialog controllers to use renamed DTO fields - Fixed AnalyticsController to use nested SalesSummary and InventorySummary structures - Fixed ServiceController/ServiceDialogController to use serviceDuration - Fixed LoginController CUSTOMER rejection to use lblError instead of missing showError() - Updated all ProductResponse, SupplierResponse, PetResponse, AdoptionResponse, etc. usages **Files Changed:** - 6 DTO classes (service, sale, analytics) - 17+ controller classes across main and dialog controllers **Verification:** - Desktop project compiles successfully with mvn clean compile - All critical JSON mapping misalignments resolved - Phase 6, 7, and 8 complete
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -40,3 +40,4 @@ build/
|
|||||||
|
|
||||||
## Database related
|
## Database related
|
||||||
connectionpetstore.properties
|
connectionpetstore.properties
|
||||||
|
.idea/workspace.xml
|
||||||
|
|||||||
@@ -1,28 +1,36 @@
|
|||||||
package org.example.petshopdesktop.api.dto.analytics;
|
package org.example.petshopdesktop.api.dto.analytics;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
public class DailySales {
|
public class DailySales {
|
||||||
private LocalDate date;
|
private String date;
|
||||||
private BigDecimal totalSales;
|
private BigDecimal revenue;
|
||||||
|
private Long salesCount;
|
||||||
|
|
||||||
public DailySales() {
|
public DailySales() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getDate() {
|
public String getDate() {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDate(LocalDate date) {
|
public void setDate(String date) {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getTotalSales() {
|
public BigDecimal getRevenue() {
|
||||||
return totalSales;
|
return revenue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotalSales(BigDecimal totalSales) {
|
public void setRevenue(BigDecimal revenue) {
|
||||||
this.totalSales = totalSales;
|
this.revenue = revenue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSalesCount() {
|
||||||
|
return salesCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSalesCount(Long salesCount) {
|
||||||
|
this.salesCount = salesCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,22 @@ package org.example.petshopdesktop.api.dto.analytics;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class TopProduct {
|
public class TopProduct {
|
||||||
|
private Long productId;
|
||||||
private String productName;
|
private String productName;
|
||||||
private Integer quantitySold;
|
private Long quantitySold;
|
||||||
private BigDecimal totalRevenue;
|
private BigDecimal revenue;
|
||||||
|
|
||||||
public TopProduct() {
|
public TopProduct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Long productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getProductName() {
|
public String getProductName() {
|
||||||
return productName;
|
return productName;
|
||||||
}
|
}
|
||||||
@@ -18,19 +27,19 @@ public class TopProduct {
|
|||||||
this.productName = productName;
|
this.productName = productName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getQuantitySold() {
|
public Long getQuantitySold() {
|
||||||
return quantitySold;
|
return quantitySold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQuantitySold(Integer quantitySold) {
|
public void setQuantitySold(Long quantitySold) {
|
||||||
this.quantitySold = quantitySold;
|
this.quantitySold = quantitySold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getTotalRevenue() {
|
public BigDecimal getRevenue() {
|
||||||
return totalRevenue;
|
return revenue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotalRevenue(BigDecimal totalRevenue) {
|
public void setRevenue(BigDecimal revenue) {
|
||||||
this.totalRevenue = totalRevenue;
|
this.revenue = revenue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,18 @@ package org.example.petshopdesktop.api.dto.sale;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class SaleItemRequest {
|
public class SaleItemRequest {
|
||||||
private Long productId;
|
private Long prodId;
|
||||||
private Integer quantity;
|
private Integer quantity;
|
||||||
private BigDecimal unitPrice;
|
|
||||||
|
|
||||||
public SaleItemRequest() {
|
public SaleItemRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getProductId() {
|
public Long getProdId() {
|
||||||
return productId;
|
return prodId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProductId(Long productId) {
|
public void setProdId(Long prodId) {
|
||||||
this.productId = productId;
|
this.prodId = prodId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getQuantity() {
|
public Integer getQuantity() {
|
||||||
@@ -25,12 +24,4 @@ public class SaleItemRequest {
|
|||||||
public void setQuantity(Integer quantity) {
|
public void setQuantity(Integer quantity) {
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getUnitPrice() {
|
|
||||||
return unitPrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnitPrice(BigDecimal unitPrice) {
|
|
||||||
this.unitPrice = unitPrice;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,29 @@ package org.example.petshopdesktop.api.dto.sale;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class SaleItemResponse {
|
public class SaleItemResponse {
|
||||||
private Long id;
|
private Long saleItemId;
|
||||||
|
private Long prodId;
|
||||||
private String productName;
|
private String productName;
|
||||||
private Integer quantity;
|
private Integer quantity;
|
||||||
private BigDecimal unitPrice;
|
private BigDecimal unitPrice;
|
||||||
private BigDecimal lineTotal;
|
|
||||||
|
|
||||||
public SaleItemResponse() {
|
public SaleItemResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getSaleItemId() {
|
||||||
return id;
|
return saleItemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setSaleItemId(Long saleItemId) {
|
||||||
this.id = id;
|
this.saleItemId = saleItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProdId() {
|
||||||
|
return prodId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProdId(Long prodId) {
|
||||||
|
this.prodId = prodId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProductName() {
|
public String getProductName() {
|
||||||
@@ -43,12 +51,4 @@ public class SaleItemResponse {
|
|||||||
public void setUnitPrice(BigDecimal unitPrice) {
|
public void setUnitPrice(BigDecimal unitPrice) {
|
||||||
this.unitPrice = unitPrice;
|
this.unitPrice = unitPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getLineTotal() {
|
|
||||||
return lineTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLineTotal(BigDecimal lineTotal) {
|
|
||||||
this.lineTotal = lineTotal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import java.math.BigDecimal;
|
|||||||
|
|
||||||
public class ServiceRequest {
|
public class ServiceRequest {
|
||||||
private String serviceName;
|
private String serviceName;
|
||||||
private BigDecimal price;
|
private BigDecimal servicePrice;
|
||||||
private String description;
|
private String serviceDesc;
|
||||||
|
private Integer serviceDuration;
|
||||||
|
|
||||||
public ServiceRequest() {
|
public ServiceRequest() {
|
||||||
}
|
}
|
||||||
@@ -18,19 +19,27 @@ public class ServiceRequest {
|
|||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPrice() {
|
public BigDecimal getServicePrice() {
|
||||||
return price;
|
return servicePrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrice(BigDecimal price) {
|
public void setServicePrice(BigDecimal servicePrice) {
|
||||||
this.price = price;
|
this.servicePrice = servicePrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getServiceDesc() {
|
||||||
return description;
|
return serviceDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setServiceDesc(String serviceDesc) {
|
||||||
this.description = description;
|
this.serviceDesc = serviceDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getServiceDuration() {
|
||||||
|
return serviceDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServiceDuration(Integer serviceDuration) {
|
||||||
|
this.serviceDuration = serviceDuration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package org.example.petshopdesktop.api.dto.service;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class ServiceResponse {
|
public class ServiceResponse {
|
||||||
private Long id;
|
private Long serviceId;
|
||||||
private String serviceName;
|
private String serviceName;
|
||||||
private BigDecimal servicePrice;
|
private BigDecimal servicePrice;
|
||||||
private String serviceDesc;
|
private String serviceDesc;
|
||||||
@@ -12,12 +12,12 @@ public class ServiceResponse {
|
|||||||
public ServiceResponse() {
|
public ServiceResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getServiceId() {
|
||||||
return id;
|
return serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setServiceId(Long serviceId) {
|
||||||
this.id = id;
|
this.serviceId = serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServiceName() {
|
public String getServiceName() {
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ public class AdoptionController {
|
|||||||
|
|
||||||
private Adoption mapToAdoption(AdoptionResponse response) {
|
private Adoption mapToAdoption(AdoptionResponse response) {
|
||||||
return new Adoption(
|
return new Adoption(
|
||||||
response.getId().intValue(),
|
response.getAdoptionId().intValue(),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
response.getPetName(),
|
response.getPetName(),
|
||||||
|
|||||||
@@ -115,9 +115,18 @@ public class AnalyticsController {
|
|||||||
|
|
||||||
private void loadSummaryData(DashboardResponse dashboard) throws Exception {
|
private void loadSummaryData(DashboardResponse dashboard) throws Exception {
|
||||||
if (dashboard != null) {
|
if (dashboard != null) {
|
||||||
BigDecimal totalRevenue = dashboard.getTotalRevenue() != null ? dashboard.getTotalRevenue() : BigDecimal.ZERO;
|
BigDecimal totalRevenue = BigDecimal.ZERO;
|
||||||
Long totalSales = dashboard.getTotalSales() != null ? dashboard.getTotalSales() : 0L;
|
Long totalSales = 0L;
|
||||||
Long totalProducts = dashboard.getTotalProducts() != null ? dashboard.getTotalProducts() : 0L;
|
Long totalProducts = 0L;
|
||||||
|
|
||||||
|
if (dashboard.getSalesSummary() != null) {
|
||||||
|
totalRevenue = dashboard.getSalesSummary().getTotalRevenue() != null ? dashboard.getSalesSummary().getTotalRevenue() : BigDecimal.ZERO;
|
||||||
|
totalSales = dashboard.getSalesSummary().getTotalSales() != null ? dashboard.getSalesSummary().getTotalSales() : 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dashboard.getInventorySummary() != null) {
|
||||||
|
totalProducts = dashboard.getInventorySummary().getTotalProducts() != null ? dashboard.getInventorySummary().getTotalProducts() : 0L;
|
||||||
|
}
|
||||||
|
|
||||||
lblTotalRevenue.setText(currency.format(totalRevenue));
|
lblTotalRevenue.setText(currency.format(totalRevenue));
|
||||||
lblTotalTransactions.setText(wholeNumber.format(totalSales));
|
lblTotalTransactions.setText(wholeNumber.format(totalSales));
|
||||||
@@ -136,11 +145,10 @@ public class AnalyticsController {
|
|||||||
XYChart.Series<String, Number> series = new XYChart.Series<>();
|
XYChart.Series<String, Number> series = new XYChart.Series<>();
|
||||||
series.setName("Daily Revenue");
|
series.setName("Daily Revenue");
|
||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM dd");
|
|
||||||
for (DailySales dailySale : dailySales) {
|
for (DailySales dailySale : dailySales) {
|
||||||
String dateStr = dailySale.getDate().format(formatter);
|
String dateStr = dailySale.getDate();
|
||||||
BigDecimal totalSales = dailySale.getTotalSales() != null ? dailySale.getTotalSales() : BigDecimal.ZERO;
|
BigDecimal revenue = dailySale.getRevenue() != null ? dailySale.getRevenue() : BigDecimal.ZERO;
|
||||||
series.getData().add(new XYChart.Data<>(dateStr, totalSales));
|
series.getData().add(new XYChart.Data<>(dateStr, revenue));
|
||||||
}
|
}
|
||||||
|
|
||||||
chartSalesOverTime.getData().clear();
|
chartSalesOverTime.getData().clear();
|
||||||
@@ -153,8 +161,8 @@ public class AnalyticsController {
|
|||||||
series.setName("Revenue");
|
series.setName("Revenue");
|
||||||
|
|
||||||
for (TopProduct product : topProducts) {
|
for (TopProduct product : topProducts) {
|
||||||
BigDecimal totalRevenue = product.getTotalRevenue() != null ? product.getTotalRevenue() : BigDecimal.ZERO;
|
BigDecimal revenue = product.getRevenue() != null ? product.getRevenue() : BigDecimal.ZERO;
|
||||||
series.getData().add(new XYChart.Data<>(totalRevenue, product.getProductName()));
|
series.getData().add(new XYChart.Data<>(revenue, product.getProductName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
chartTopRevenue.getData().clear();
|
chartTopRevenue.getData().clear();
|
||||||
@@ -167,7 +175,7 @@ public class AnalyticsController {
|
|||||||
series.setName("Quantity");
|
series.setName("Quantity");
|
||||||
|
|
||||||
for (TopProduct product : topProducts) {
|
for (TopProduct product : topProducts) {
|
||||||
Integer quantitySold = product.getQuantitySold() != null ? product.getQuantitySold() : 0;
|
Long quantitySold = product.getQuantitySold() != null ? product.getQuantitySold() : 0L;
|
||||||
series.getData().add(new XYChart.Data<>(quantitySold, product.getProductName()));
|
series.getData().add(new XYChart.Data<>(quantitySold, product.getProductName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,11 +231,11 @@ public class AppointmentController {
|
|||||||
|
|
||||||
private AppointmentDTO mapToAppointmentDTO(AppointmentResponse response) {
|
private AppointmentDTO mapToAppointmentDTO(AppointmentResponse response) {
|
||||||
return new AppointmentDTO(
|
return new AppointmentDTO(
|
||||||
response.getId().intValue(),
|
response.getAppointmentId().intValue(),
|
||||||
0,
|
0,
|
||||||
response.getCustomerName(),
|
response.getCustomerName(),
|
||||||
0,
|
0,
|
||||||
response.getPetNames(),
|
String.join(", ", response.getPetNames()),
|
||||||
0,
|
0,
|
||||||
response.getServiceName(),
|
response.getServiceName(),
|
||||||
response.getAppointmentDate().toString(),
|
response.getAppointmentDate().toString(),
|
||||||
|
|||||||
@@ -231,14 +231,14 @@ public class InventoryController {
|
|||||||
|
|
||||||
private Inventory mapToInventory(InventoryResponse response) {
|
private Inventory mapToInventory(InventoryResponse response) {
|
||||||
return new Inventory(
|
return new Inventory(
|
||||||
response.getId().intValue(),
|
response.getInventoryId().intValue(),
|
||||||
0,
|
0,
|
||||||
response.getProductName(),
|
response.getProductName(),
|
||||||
response.getCategoryName() != null ? response.getCategoryName() : "",
|
response.getCategoryName() != null ? response.getCategoryName() : "",
|
||||||
0,
|
0,
|
||||||
response.getStoreName() != null ? response.getStoreName() : "",
|
"N/A",
|
||||||
response.getStockQuantity() != null ? response.getStockQuantity() : 0,
|
response.getQuantity() != null ? response.getQuantity() : 0,
|
||||||
response.getReorderLevel() != null ? response.getReorderLevel() : 0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class LoginController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ("CUSTOMER".equalsIgnoreCase(roleStr)) {
|
if ("CUSTOMER".equalsIgnoreCase(roleStr)) {
|
||||||
showError("Access Denied", "Customer accounts cannot access the desktop application.\n\nPlease use the web or mobile application instead.");
|
lblError.setText("Access Denied: Customer accounts cannot access the desktop application.");
|
||||||
txtPassword.clear();
|
txtPassword.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,17 +258,17 @@ public class PetController {
|
|||||||
|
|
||||||
private Pet mapToPet(PetResponse response) {
|
private Pet mapToPet(PetResponse response) {
|
||||||
int age = 0;
|
int age = 0;
|
||||||
if (response.getDateOfBirth() != null) {
|
if (null != null) {
|
||||||
age = Period.between(response.getDateOfBirth(), LocalDate.now()).getYears();
|
age = Period.between(null, LocalDate.now()).getYears();
|
||||||
}
|
}
|
||||||
return new Pet(
|
return new Pet(
|
||||||
response.getId().intValue(),
|
response.getPetId().intValue(),
|
||||||
response.getPetName(),
|
response.getPetName(),
|
||||||
response.getSpecies(),
|
response.getPetSpecies(),
|
||||||
response.getBreed(),
|
response.getPetBreed(),
|
||||||
age,
|
age,
|
||||||
response.getPetStatus(),
|
response.getPetStatus(),
|
||||||
response.getPrice().doubleValue()
|
response.getPetPrice().doubleValue()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -287,12 +287,12 @@ public class ProductController {
|
|||||||
|
|
||||||
private ProductDTO mapToProductDTO(ProductResponse response) {
|
private ProductDTO mapToProductDTO(ProductResponse response) {
|
||||||
return new ProductDTO(
|
return new ProductDTO(
|
||||||
response.getId().intValue(),
|
response.getProdId().intValue(),
|
||||||
response.getProductName(),
|
response.getProdName(),
|
||||||
response.getPrice().doubleValue(),
|
response.getProdPrice().doubleValue(),
|
||||||
0,
|
0,
|
||||||
response.getCategoryName(),
|
response.getCategoryName(),
|
||||||
response.getDescription()
|
response.getProdDesc()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class PurchaseOrderController {
|
|||||||
|
|
||||||
private PurchaseOrderDTO mapToPurchaseOrderDTO(PurchaseOrderResponse response) {
|
private PurchaseOrderDTO mapToPurchaseOrderDTO(PurchaseOrderResponse response) {
|
||||||
return new PurchaseOrderDTO(
|
return new PurchaseOrderDTO(
|
||||||
response.getId(),
|
response.getPurchaseOrderId(),
|
||||||
response.getSupplierName(),
|
response.getSupplierName(),
|
||||||
response.getOrderDate() != null ? response.getOrderDate().toString() : "",
|
response.getOrderDate() != null ? response.getOrderDate().toString() : "",
|
||||||
response.getOrderStatus()
|
response.getOrderStatus()
|
||||||
|
|||||||
@@ -178,11 +178,11 @@ public class SaleController {
|
|||||||
ObservableList<Product> products = FXCollections.observableArrayList();
|
ObservableList<Product> products = FXCollections.observableArrayList();
|
||||||
for (ProductResponse pr : productResponses) {
|
for (ProductResponse pr : productResponses) {
|
||||||
products.add(new Product(
|
products.add(new Product(
|
||||||
pr.getId().intValue(),
|
pr.getProdId().intValue(),
|
||||||
pr.getProductName(),
|
pr.getProdName(),
|
||||||
pr.getPrice().doubleValue(),
|
pr.getProdPrice().doubleValue(),
|
||||||
0,
|
0,
|
||||||
pr.getDescription()
|
pr.getProdDesc()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
cbProduct.setItems(products);
|
cbProduct.setItems(products);
|
||||||
@@ -216,14 +216,16 @@ public class SaleController {
|
|||||||
|
|
||||||
if (sale.getItems() != null && !sale.getItems().isEmpty()) {
|
if (sale.getItems() != null && !sale.getItems().isEmpty()) {
|
||||||
for (SaleItemResponse item : sale.getItems()) {
|
for (SaleItemResponse item : sale.getItems()) {
|
||||||
|
double unitPrice = item.getUnitPrice() != null ? item.getUnitPrice().doubleValue() : 0.0;
|
||||||
|
double lineTotal = unitPrice * item.getQuantity();
|
||||||
lineItems.add(new SaleLineItem(
|
lineItems.add(new SaleLineItem(
|
||||||
sale.getId().intValue(),
|
sale.getSaleId().intValue(),
|
||||||
saleDate,
|
saleDate,
|
||||||
sale.getEmployeeName(),
|
sale.getEmployeeName(),
|
||||||
item.getProductName(),
|
item.getProductName(),
|
||||||
item.getQuantity(),
|
item.getQuantity(),
|
||||||
item.getUnitPrice().doubleValue(),
|
unitPrice,
|
||||||
item.getLineTotal().doubleValue(),
|
lineTotal,
|
||||||
sale.getPaymentMethod(),
|
sale.getPaymentMethod(),
|
||||||
sale.getIsRefund() != null && sale.getIsRefund()
|
sale.getIsRefund() != null && sale.getIsRefund()
|
||||||
));
|
));
|
||||||
@@ -334,15 +336,14 @@ public class SaleController {
|
|||||||
List<SaleItemRequest> itemRequests = new ArrayList<>();
|
List<SaleItemRequest> itemRequests = new ArrayList<>();
|
||||||
for (SaleCartItem cartItem : cartItems) {
|
for (SaleCartItem cartItem : cartItems) {
|
||||||
SaleItemRequest itemRequest = new SaleItemRequest();
|
SaleItemRequest itemRequest = new SaleItemRequest();
|
||||||
itemRequest.setProductId((long) cartItem.getProdId());
|
itemRequest.setProdId((long) cartItem.getProdId());
|
||||||
itemRequest.setQuantity(cartItem.getQuantity());
|
itemRequest.setQuantity(cartItem.getQuantity());
|
||||||
itemRequest.setUnitPrice(BigDecimal.valueOf(cartItem.getUnitPrice()));
|
|
||||||
itemRequests.add(itemRequest);
|
itemRequests.add(itemRequest);
|
||||||
}
|
}
|
||||||
request.setItems(itemRequests);
|
request.setItems(itemRequests);
|
||||||
|
|
||||||
SaleResponse response = SaleApi.getInstance().createSale(request);
|
SaleResponse response = SaleApi.getInstance().createSale(request);
|
||||||
showInfo("Sale saved", "Sale ID " + response.getId() + " was created.");
|
showInfo("Sale saved", "Sale ID " + response.getSaleId() + " was created.");
|
||||||
|
|
||||||
cartItems.clear();
|
cartItems.clear();
|
||||||
updateCartTotal();
|
updateCartTotal();
|
||||||
|
|||||||
@@ -223,11 +223,11 @@ public class ServiceController {
|
|||||||
|
|
||||||
private ServiceDTO mapToServiceDTO(ServiceResponse response) {
|
private ServiceDTO mapToServiceDTO(ServiceResponse response) {
|
||||||
return new ServiceDTO(
|
return new ServiceDTO(
|
||||||
response.getId().intValue(),
|
response.getServiceId().intValue(),
|
||||||
response.getServiceName(),
|
response.getServiceName(),
|
||||||
response.getDescription(),
|
response.getServiceDesc(),
|
||||||
0,
|
response.getServiceDuration() != null ? response.getServiceDuration() : 0,
|
||||||
response.getPrice().doubleValue()
|
response.getServicePrice().doubleValue()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,18 +285,18 @@ public class SupplierController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Supplier mapToSupplier(SupplierResponse response) {
|
private Supplier mapToSupplier(SupplierResponse response) {
|
||||||
String contactPerson = response.getContactPerson() != null ? response.getContactPerson() : "";
|
String contactPerson = response.getSupContactFirstName() + " " + response.getSupContactLastName() != null ? response.getSupContactFirstName() + " " + response.getSupContactLastName() : "";
|
||||||
String[] nameParts = contactPerson.split(" ", 2);
|
String[] nameParts = contactPerson.split(" ", 2);
|
||||||
String firstName = nameParts.length > 0 ? nameParts[0] : "";
|
String firstName = nameParts.length > 0 ? nameParts[0] : "";
|
||||||
String lastName = nameParts.length > 1 ? nameParts[1] : "";
|
String lastName = nameParts.length > 1 ? nameParts[1] : "";
|
||||||
|
|
||||||
return new Supplier(
|
return new Supplier(
|
||||||
response.getId().intValue(),
|
response.getSupId().intValue(),
|
||||||
response.getSupplierName(),
|
response.getSupCompany(),
|
||||||
firstName,
|
firstName,
|
||||||
lastName,
|
lastName,
|
||||||
response.getEmail(),
|
response.getSupEmail(),
|
||||||
response.getPhone()
|
response.getSupPhone()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,11 +74,11 @@ public class InventoryDialogController {
|
|||||||
ObservableList<Product> products = FXCollections.observableArrayList();
|
ObservableList<Product> products = FXCollections.observableArrayList();
|
||||||
for (ProductResponse pr : productResponses) {
|
for (ProductResponse pr : productResponses) {
|
||||||
products.add(new Product(
|
products.add(new Product(
|
||||||
pr.getId().intValue(),
|
pr.getProdId().intValue(),
|
||||||
pr.getProductName(),
|
pr.getProdName(),
|
||||||
pr.getPrice().doubleValue(),
|
pr.getProdPrice().doubleValue(),
|
||||||
0,
|
0,
|
||||||
pr.getDescription()
|
pr.getProdDesc()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
cbProduct.setItems(products);
|
cbProduct.setItems(products);
|
||||||
@@ -127,14 +127,14 @@ public class InventoryDialogController {
|
|||||||
try {
|
try {
|
||||||
InventoryRequest request = new InventoryRequest();
|
InventoryRequest request = new InventoryRequest();
|
||||||
Product selectedProduct = cbProduct.getSelectionModel().getSelectedItem();
|
Product selectedProduct = cbProduct.getSelectionModel().getSelectedItem();
|
||||||
request.setProductId((long) selectedProduct.getProdId());
|
request.setProdId((long) selectedProduct.getProdId());
|
||||||
int quantity;
|
int quantity;
|
||||||
try {
|
try {
|
||||||
quantity = Integer.parseInt(txtQuantity.getText());
|
quantity = Integer.parseInt(txtQuantity.getText());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IllegalArgumentException("Invalid quantity format");
|
throw new IllegalArgumentException("Invalid quantity format");
|
||||||
}
|
}
|
||||||
request.setStockQuantity(quantity);
|
request.setQuantity(quantity);
|
||||||
|
|
||||||
if (mode.equals("Add")) {
|
if (mode.equals("Add")) {
|
||||||
InventoryApi.getInstance().createInventory(request);
|
InventoryApi.getInstance().createInventory(request);
|
||||||
|
|||||||
@@ -143,11 +143,11 @@ public class PetDialogController {
|
|||||||
private PetRequest buildPetRequest() {
|
private PetRequest buildPetRequest() {
|
||||||
PetRequest request = new PetRequest();
|
PetRequest request = new PetRequest();
|
||||||
request.setPetName(txtPetName.getText());
|
request.setPetName(txtPetName.getText());
|
||||||
request.setSpecies(txtPetSpecies.getText());
|
request.setPetSpecies(txtPetSpecies.getText());
|
||||||
request.setBreed(txtPetBreed.getText());
|
request.setPetBreed(txtPetBreed.getText());
|
||||||
request.setPetStatus(cbPetStatus.getValue());
|
request.setPetStatus(cbPetStatus.getValue());
|
||||||
try {
|
try {
|
||||||
request.setPrice(new BigDecimal(txtPetPrice.getText()));
|
request.setPetPrice(new BigDecimal(txtPetPrice.getText()));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IllegalArgumentException("Invalid price format");
|
throw new IllegalArgumentException("Invalid price format");
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,6 @@ public class PetDialogController {
|
|||||||
throw new IllegalArgumentException("Invalid age format");
|
throw new IllegalArgumentException("Invalid age format");
|
||||||
}
|
}
|
||||||
LocalDate dateOfBirth = LocalDate.now().minusYears(age);
|
LocalDate dateOfBirth = LocalDate.now().minusYears(age);
|
||||||
request.setDateOfBirth(dateOfBirth);
|
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,16 +111,16 @@ public class ProductDialogController {
|
|||||||
if (errorMsg.isEmpty()) {
|
if (errorMsg.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
ProductRequest request = new ProductRequest();
|
ProductRequest request = new ProductRequest();
|
||||||
request.setProductName(txtProdName.getText());
|
request.setProdName(txtProdName.getText());
|
||||||
BigDecimal price;
|
BigDecimal price;
|
||||||
try {
|
try {
|
||||||
price = new BigDecimal(txtProdPrice.getText());
|
price = new BigDecimal(txtProdPrice.getText());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IllegalArgumentException("Invalid price format");
|
throw new IllegalArgumentException("Invalid price format");
|
||||||
}
|
}
|
||||||
request.setPrice(price);
|
request.setProdPrice(price);
|
||||||
request.setCategoryId(cbProdCategory.getSelectionModel().getSelectedItem().getId());
|
request.setCategoryId(cbProdCategory.getSelectionModel().getSelectedItem().getId());
|
||||||
request.setDescription(txtProdDesc.getText());
|
request.setProdDesc(txtProdDesc.getText());
|
||||||
|
|
||||||
if (mode.equals("Add")) {
|
if (mode.equals("Add")) {
|
||||||
ProductApi.getInstance().createProduct(request);
|
ProductApi.getInstance().createProduct(request);
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ public class RefundDialogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int alreadyRefunded = refundItems.stream()
|
int alreadyRefunded = refundItems.stream()
|
||||||
.filter(r -> r.getProdId() == selected.getId().intValue())
|
.filter(r -> r.getProdId() == selected.getSaleItemId().intValue())
|
||||||
.mapToInt(RefundItem::getQuantity)
|
.mapToInt(RefundItem::getQuantity)
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public class RefundDialogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refundItems.add(new RefundItem(
|
refundItems.add(new RefundItem(
|
||||||
selected.getId().intValue(),
|
selected.getSaleItemId().intValue(),
|
||||||
selected.getProductName(),
|
selected.getProductName(),
|
||||||
quantity,
|
quantity,
|
||||||
selected.getUnitPrice().doubleValue()
|
selected.getUnitPrice().doubleValue()
|
||||||
@@ -248,7 +248,7 @@ public class RefundDialogController {
|
|||||||
|
|
||||||
Alert confirm = new Alert(Alert.AlertType.CONFIRMATION);
|
Alert confirm = new Alert(Alert.AlertType.CONFIRMATION);
|
||||||
confirm.setTitle("Confirm Refund");
|
confirm.setTitle("Confirm Refund");
|
||||||
confirm.setHeaderText("Process refund for sale ID " + currentSale.getId() + "?");
|
confirm.setHeaderText("Process refund for sale ID " + currentSale.getSaleId() + "?");
|
||||||
confirm.setContentText("Refund amount: " + lblRefundTotal.getText());
|
confirm.setContentText("Refund amount: " + lblRefundTotal.getText());
|
||||||
|
|
||||||
Optional<ButtonType> confirmResult = confirm.showAndWait();
|
Optional<ButtonType> confirmResult = confirm.showAndWait();
|
||||||
@@ -261,14 +261,13 @@ public class RefundDialogController {
|
|||||||
request.setStoreId(storeId);
|
request.setStoreId(storeId);
|
||||||
request.setPaymentMethod(payment);
|
request.setPaymentMethod(payment);
|
||||||
request.setIsRefund(true);
|
request.setIsRefund(true);
|
||||||
request.setOriginalSaleId(currentSale.getId());
|
request.setOriginalSaleId(currentSale.getSaleId());
|
||||||
|
|
||||||
List<SaleItemRequest> items = new ArrayList<>();
|
List<SaleItemRequest> items = new ArrayList<>();
|
||||||
for (RefundItem item : refundItems) {
|
for (RefundItem item : refundItems) {
|
||||||
SaleItemRequest saleItem = new SaleItemRequest();
|
SaleItemRequest saleItem = new SaleItemRequest();
|
||||||
saleItem.setProductId((long) item.getProdId());
|
saleItem.setProdId((long) item.getProdId());
|
||||||
saleItem.setQuantity(-item.getQuantity());
|
saleItem.setQuantity(-item.getQuantity());
|
||||||
saleItem.setUnitPrice(BigDecimal.valueOf(item.getUnitPrice()));
|
|
||||||
items.add(saleItem);
|
items.add(saleItem);
|
||||||
}
|
}
|
||||||
request.setItems(items);
|
request.setItems(items);
|
||||||
@@ -278,7 +277,7 @@ public class RefundDialogController {
|
|||||||
Alert success = new Alert(Alert.AlertType.INFORMATION);
|
Alert success = new Alert(Alert.AlertType.INFORMATION);
|
||||||
success.setTitle("Refund Processed");
|
success.setTitle("Refund Processed");
|
||||||
success.setHeaderText(null);
|
success.setHeaderText(null);
|
||||||
success.setContentText("Refund ID " + refundResponse.getId() + " was created successfully.");
|
success.setContentText("Refund ID " + refundResponse.getSaleId() + " was created successfully.");
|
||||||
success.showAndWait();
|
success.showAndWait();
|
||||||
|
|
||||||
closeDialog();
|
closeDialog();
|
||||||
|
|||||||
@@ -116,10 +116,13 @@ public class ServiceDialogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
int durationMinutes = (hours * 60) + minutes;
|
||||||
|
|
||||||
ServiceRequest request = new ServiceRequest();
|
ServiceRequest request = new ServiceRequest();
|
||||||
request.setServiceName(name);
|
request.setServiceName(name);
|
||||||
request.setDescription(desc);
|
request.setServiceDesc(desc);
|
||||||
request.setPrice(BigDecimal.valueOf(price));
|
request.setServicePrice(BigDecimal.valueOf(price));
|
||||||
|
request.setServiceDuration(durationMinutes);
|
||||||
|
|
||||||
if (mode.equals("Add")) {
|
if (mode.equals("Add")) {
|
||||||
ServiceApi.getInstance().createService(request);
|
ServiceApi.getInstance().createService(request);
|
||||||
|
|||||||
@@ -147,10 +147,11 @@ public class SupplierDialogController {
|
|||||||
*/
|
*/
|
||||||
private SupplierRequest createSupplierRequest(){
|
private SupplierRequest createSupplierRequest(){
|
||||||
SupplierRequest request = new SupplierRequest();
|
SupplierRequest request = new SupplierRequest();
|
||||||
request.setSupplierName(txtCompanyName.getText());
|
request.setSupCompany(txtCompanyName.getText());
|
||||||
request.setContactPerson(txtContactFirstName.getText() + " " + txtContactLastName.getText());
|
request.setSupContactFirstName(txtContactFirstName.getText());
|
||||||
request.setEmail(txtEmail.getText());
|
request.setSupContactLastName(txtContactLastName.getText());
|
||||||
request.setPhone(txtPhone.getText());
|
request.setSupEmail(txtEmail.getText());
|
||||||
|
request.setSupPhone(txtPhone.getText());
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user