Align backend schema with desktop application
This commit is contained in:
@@ -23,10 +23,7 @@ public class DataInitializer implements CommandLineRunner {
|
||||
User admin = new User();
|
||||
admin.setUsername("admin");
|
||||
admin.setPassword(passwordEncoder.encode("admin123"));
|
||||
admin.setFullName("Admin User");
|
||||
admin.setEmail("admin@petshop.com");
|
||||
admin.setRole(User.Role.ADMIN);
|
||||
admin.setActive(true);
|
||||
userRepository.save(admin);
|
||||
}
|
||||
|
||||
@@ -34,10 +31,7 @@ public class DataInitializer implements CommandLineRunner {
|
||||
User staff = new User();
|
||||
staff.setUsername("staff");
|
||||
staff.setPassword(passwordEncoder.encode("staff123"));
|
||||
staff.setFullName("Staff User");
|
||||
staff.setEmail("staff@petshop.com");
|
||||
staff.setRole(User.Role.STAFF);
|
||||
staff.setActive(true);
|
||||
userRepository.save(staff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ public class AuthController {
|
||||
return ResponseEntity.ok(new LoginResponse(
|
||||
token,
|
||||
user.getUsername(),
|
||||
user.getFullName(),
|
||||
user.getRole().name()
|
||||
));
|
||||
|
||||
@@ -81,8 +80,6 @@ public class AuthController {
|
||||
return ResponseEntity.ok(new UserInfoResponse(
|
||||
user.getId(),
|
||||
user.getUsername(),
|
||||
user.getFullName(),
|
||||
user.getEmail(),
|
||||
user.getRole().name()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DropdownController {
|
||||
public ResponseEntity<List<DropdownOption>> getPets() {
|
||||
return ResponseEntity.ok(
|
||||
petRepository.findAll().stream()
|
||||
.map(p -> new DropdownOption(p.getId(), p.getPetName()))
|
||||
.map(p -> new DropdownOption(p.getPetId(), p.getPetName()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class DropdownController {
|
||||
public ResponseEntity<List<DropdownOption>> getCustomers() {
|
||||
return ResponseEntity.ok(
|
||||
customerRepository.findAll().stream()
|
||||
.map(c -> new DropdownOption(c.getId(), c.getCustomerName()))
|
||||
.map(c -> new DropdownOption(c.getCustomerId(), c.getFirstName() + " " + c.getLastName()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class DropdownController {
|
||||
public ResponseEntity<List<DropdownOption>> getServices() {
|
||||
return ResponseEntity.ok(
|
||||
serviceRepository.findAll().stream()
|
||||
.map(s -> new DropdownOption(s.getId(), s.getServiceName()))
|
||||
.map(s -> new DropdownOption(s.getServiceId(), s.getServiceName()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class DropdownController {
|
||||
public ResponseEntity<List<DropdownOption>> getProducts() {
|
||||
return ResponseEntity.ok(
|
||||
productRepository.findAll().stream()
|
||||
.map(p -> new DropdownOption(p.getId(), p.getProductName()))
|
||||
.map(p -> new DropdownOption(p.getProdId(), p.getProdName()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class DropdownController {
|
||||
public ResponseEntity<List<DropdownOption>> getCategories() {
|
||||
return ResponseEntity.ok(
|
||||
categoryRepository.findAll().stream()
|
||||
.map(c -> new DropdownOption(c.getId(), c.getCategoryName()))
|
||||
.map(c -> new DropdownOption(c.getCategoryId(), c.getCategoryName()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class DropdownController {
|
||||
public ResponseEntity<List<DropdownOption>> getStores() {
|
||||
return ResponseEntity.ok(
|
||||
storeRepository.findAll().stream()
|
||||
.map(s -> new DropdownOption(s.getId(), s.getStoreName()))
|
||||
.map(s -> new DropdownOption(s.getStoreId(), s.getStoreName()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class DropdownController {
|
||||
public ResponseEntity<List<DropdownOption>> getSuppliers() {
|
||||
return ResponseEntity.ok(
|
||||
supplierRepository.findAll().stream()
|
||||
.map(s -> new DropdownOption(s.getId(), s.getSupplierName()))
|
||||
.map(s -> new DropdownOption(s.getSupId(), s.getSupCompany()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.petshop.backend.dto.adoption;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -16,11 +15,8 @@ public class AdoptionRequest {
|
||||
@NotNull(message = "Adoption date is required")
|
||||
private LocalDate adoptionDate;
|
||||
|
||||
@NotNull(message = "Adoption fee is required")
|
||||
@Positive(message = "Adoption fee must be positive")
|
||||
private BigDecimal adoptionFee;
|
||||
|
||||
private String notes;
|
||||
@NotBlank(message = "Adoption status is required")
|
||||
private String adoptionStatus;
|
||||
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
@@ -46,20 +42,12 @@ public class AdoptionRequest {
|
||||
this.adoptionDate = adoptionDate;
|
||||
}
|
||||
|
||||
public BigDecimal getAdoptionFee() {
|
||||
return adoptionFee;
|
||||
public String getAdoptionStatus() {
|
||||
return adoptionStatus;
|
||||
}
|
||||
|
||||
public void setAdoptionFee(BigDecimal adoptionFee) {
|
||||
this.adoptionFee = adoptionFee;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
public void setAdoptionStatus(String adoptionStatus) {
|
||||
this.adoptionStatus = adoptionStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,13 +58,12 @@ public class AdoptionRequest {
|
||||
return Objects.equals(petId, that.petId) &&
|
||||
Objects.equals(customerId, that.customerId) &&
|
||||
Objects.equals(adoptionDate, that.adoptionDate) &&
|
||||
Objects.equals(adoptionFee, that.adoptionFee) &&
|
||||
Objects.equals(notes, that.notes);
|
||||
Objects.equals(adoptionStatus, that.adoptionStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(petId, customerId, adoptionDate, adoptionFee, notes);
|
||||
return Objects.hash(petId, customerId, adoptionDate, adoptionStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,8 +72,7 @@ public class AdoptionRequest {
|
||||
"petId=" + petId +
|
||||
", customerId=" + customerId +
|
||||
", adoptionDate=" + adoptionDate +
|
||||
", adoptionFee=" + adoptionFee +
|
||||
", notes='" + notes + '\'' +
|
||||
", adoptionStatus='" + adoptionStatus + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,41 @@
|
||||
package com.petshop.backend.dto.adoption;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AdoptionResponse {
|
||||
private Long id;
|
||||
private Long adoptionId;
|
||||
private Long petId;
|
||||
private String petName;
|
||||
private Long customerId;
|
||||
private String customerName;
|
||||
private LocalDate adoptionDate;
|
||||
private BigDecimal adoptionFee;
|
||||
private String notes;
|
||||
private String adoptionStatus;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public AdoptionResponse() {
|
||||
}
|
||||
|
||||
public AdoptionResponse(Long id, Long petId, String petName, Long customerId, String customerName, LocalDate adoptionDate, BigDecimal adoptionFee, String notes, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
public AdoptionResponse(Long adoptionId, Long petId, String petName, Long customerId, String customerName, LocalDate adoptionDate, String adoptionStatus, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.adoptionId = adoptionId;
|
||||
this.petId = petId;
|
||||
this.petName = petName;
|
||||
this.customerId = customerId;
|
||||
this.customerName = customerName;
|
||||
this.adoptionDate = adoptionDate;
|
||||
this.adoptionFee = adoptionFee;
|
||||
this.notes = notes;
|
||||
this.adoptionStatus = adoptionStatus;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getAdoptionId() {
|
||||
return adoptionId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setAdoptionId(Long adoptionId) {
|
||||
this.adoptionId = adoptionId;
|
||||
}
|
||||
|
||||
public Long getPetId() {
|
||||
@@ -81,20 +78,12 @@ public class AdoptionResponse {
|
||||
this.adoptionDate = adoptionDate;
|
||||
}
|
||||
|
||||
public BigDecimal getAdoptionFee() {
|
||||
return adoptionFee;
|
||||
public String getAdoptionStatus() {
|
||||
return adoptionStatus;
|
||||
}
|
||||
|
||||
public void setAdoptionFee(BigDecimal adoptionFee) {
|
||||
this.adoptionFee = adoptionFee;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
public void setAdoptionStatus(String adoptionStatus) {
|
||||
this.adoptionStatus = adoptionStatus;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
@@ -118,25 +107,24 @@ public class AdoptionResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AdoptionResponse that = (AdoptionResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(petId, that.petId) && Objects.equals(petName, that.petName) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(adoptionDate, that.adoptionDate) && Objects.equals(adoptionFee, that.adoptionFee) && Objects.equals(notes, that.notes) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(adoptionId, that.adoptionId) && Objects.equals(petId, that.petId) && Objects.equals(petName, that.petName) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(adoptionDate, that.adoptionDate) && Objects.equals(adoptionStatus, that.adoptionStatus) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, petId, petName, customerId, customerName, adoptionDate, adoptionFee, notes, createdAt, updatedAt);
|
||||
return Objects.hash(adoptionId, petId, petName, customerId, customerName, adoptionDate, adoptionStatus, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AdoptionResponse{" +
|
||||
"id=" + id +
|
||||
"adoptionId=" + adoptionId +
|
||||
", petId=" + petId +
|
||||
", petName='" + petName + '\'' +
|
||||
", customerId=" + customerId +
|
||||
", customerName='" + customerName + '\'' +
|
||||
", adoptionDate=" + adoptionDate +
|
||||
", adoptionFee=" + adoptionFee +
|
||||
", notes='" + notes + '\'' +
|
||||
", adoptionStatus='" + adoptionStatus + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.petshop.backend.dto.appointment;
|
||||
|
||||
import com.petshop.backend.entity.Appointment;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDate;
|
||||
@@ -21,14 +20,12 @@ public class AppointmentRequest {
|
||||
@NotNull(message = "Appointment time is required")
|
||||
private LocalTime appointmentTime;
|
||||
|
||||
@NotNull(message = "Status is required")
|
||||
private Appointment.AppointmentStatus status;
|
||||
@NotNull(message = "Appointment status is required")
|
||||
private String appointmentStatus;
|
||||
|
||||
@NotEmpty(message = "At least one pet must be specified")
|
||||
private List<Long> petIds;
|
||||
|
||||
private String notes;
|
||||
|
||||
public Long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
@@ -61,12 +58,12 @@ public class AppointmentRequest {
|
||||
this.appointmentTime = appointmentTime;
|
||||
}
|
||||
|
||||
public Appointment.AppointmentStatus getStatus() {
|
||||
return status;
|
||||
public String getAppointmentStatus() {
|
||||
return appointmentStatus;
|
||||
}
|
||||
|
||||
public void setStatus(Appointment.AppointmentStatus status) {
|
||||
this.status = status;
|
||||
public void setAppointmentStatus(String appointmentStatus) {
|
||||
this.appointmentStatus = appointmentStatus;
|
||||
}
|
||||
|
||||
public List<Long> getPetIds() {
|
||||
@@ -77,14 +74,6 @@ public class AppointmentRequest {
|
||||
this.petIds = petIds;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -94,14 +83,13 @@ public class AppointmentRequest {
|
||||
Objects.equals(serviceId, that.serviceId) &&
|
||||
Objects.equals(appointmentDate, that.appointmentDate) &&
|
||||
Objects.equals(appointmentTime, that.appointmentTime) &&
|
||||
status == that.status &&
|
||||
Objects.equals(petIds, that.petIds) &&
|
||||
Objects.equals(notes, that.notes);
|
||||
Objects.equals(appointmentStatus, that.appointmentStatus) &&
|
||||
Objects.equals(petIds, that.petIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(customerId, serviceId, appointmentDate, appointmentTime, status, petIds, notes);
|
||||
return Objects.hash(customerId, serviceId, appointmentDate, appointmentTime, appointmentStatus, petIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,9 +99,8 @@ public class AppointmentRequest {
|
||||
", serviceId=" + serviceId +
|
||||
", appointmentDate=" + appointmentDate +
|
||||
", appointmentTime=" + appointmentTime +
|
||||
", status=" + status +
|
||||
", appointmentStatus='" + appointmentStatus + '\'' +
|
||||
", petIds=" + petIds +
|
||||
", notes='" + notes + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,45 +7,43 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AppointmentResponse {
|
||||
private Long id;
|
||||
private Long appointmentId;
|
||||
private Long customerId;
|
||||
private String customerName;
|
||||
private Long serviceId;
|
||||
private String serviceName;
|
||||
private LocalDate appointmentDate;
|
||||
private LocalTime appointmentTime;
|
||||
private String status;
|
||||
private String appointmentStatus;
|
||||
private List<String> petNames;
|
||||
private List<Long> petIds;
|
||||
private String notes;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public AppointmentResponse() {
|
||||
}
|
||||
|
||||
public AppointmentResponse(Long id, Long customerId, String customerName, Long serviceId, String serviceName, LocalDate appointmentDate, LocalTime appointmentTime, String status, List<String> petNames, List<Long> petIds, String notes, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
public AppointmentResponse(Long appointmentId, Long customerId, String customerName, Long serviceId, String serviceName, LocalDate appointmentDate, LocalTime appointmentTime, String appointmentStatus, List<String> petNames, List<Long> petIds, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.appointmentId = appointmentId;
|
||||
this.customerId = customerId;
|
||||
this.customerName = customerName;
|
||||
this.serviceId = serviceId;
|
||||
this.serviceName = serviceName;
|
||||
this.appointmentDate = appointmentDate;
|
||||
this.appointmentTime = appointmentTime;
|
||||
this.status = status;
|
||||
this.appointmentStatus = appointmentStatus;
|
||||
this.petNames = petNames;
|
||||
this.petIds = petIds;
|
||||
this.notes = notes;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getAppointmentId() {
|
||||
return appointmentId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setAppointmentId(Long appointmentId) {
|
||||
this.appointmentId = appointmentId;
|
||||
}
|
||||
|
||||
public Long getCustomerId() {
|
||||
@@ -96,12 +94,12 @@ public class AppointmentResponse {
|
||||
this.appointmentTime = appointmentTime;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
public String getAppointmentStatus() {
|
||||
return appointmentStatus;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
public void setAppointmentStatus(String appointmentStatus) {
|
||||
this.appointmentStatus = appointmentStatus;
|
||||
}
|
||||
|
||||
public List<String> getPetNames() {
|
||||
@@ -120,14 +118,6 @@ public class AppointmentResponse {
|
||||
this.petIds = petIds;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
@@ -149,28 +139,27 @@ public class AppointmentResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AppointmentResponse that = (AppointmentResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(serviceId, that.serviceId) && Objects.equals(serviceName, that.serviceName) && Objects.equals(appointmentDate, that.appointmentDate) && Objects.equals(appointmentTime, that.appointmentTime) && Objects.equals(status, that.status) && Objects.equals(petNames, that.petNames) && Objects.equals(petIds, that.petIds) && Objects.equals(notes, that.notes) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(appointmentId, that.appointmentId) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(serviceId, that.serviceId) && Objects.equals(serviceName, that.serviceName) && Objects.equals(appointmentDate, that.appointmentDate) && Objects.equals(appointmentTime, that.appointmentTime) && Objects.equals(appointmentStatus, that.appointmentStatus) && Objects.equals(petNames, that.petNames) && Objects.equals(petIds, that.petIds) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, customerId, customerName, serviceId, serviceName, appointmentDate, appointmentTime, status, petNames, petIds, notes, createdAt, updatedAt);
|
||||
return Objects.hash(appointmentId, customerId, customerName, serviceId, serviceName, appointmentDate, appointmentTime, appointmentStatus, petNames, petIds, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AppointmentResponse{" +
|
||||
"id=" + id +
|
||||
"appointmentId=" + appointmentId +
|
||||
", customerId=" + customerId +
|
||||
", customerName='" + customerName + '\'' +
|
||||
", serviceId=" + serviceId +
|
||||
", serviceName='" + serviceName + '\'' +
|
||||
", appointmentDate=" + appointmentDate +
|
||||
", appointmentTime=" + appointmentTime +
|
||||
", status='" + status + '\'' +
|
||||
", appointmentStatus='" + appointmentStatus + '\'' +
|
||||
", petNames=" + petNames +
|
||||
", petIds=" + petIds +
|
||||
", notes='" + notes + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -5,16 +5,14 @@ import java.util.Objects;
|
||||
public class LoginResponse {
|
||||
private String token;
|
||||
private String username;
|
||||
private String fullName;
|
||||
private String role;
|
||||
|
||||
public LoginResponse() {
|
||||
}
|
||||
|
||||
public LoginResponse(String token, String username, String fullName, String role) {
|
||||
public LoginResponse(String token, String username, String role) {
|
||||
this.token = token;
|
||||
this.username = username;
|
||||
this.fullName = fullName;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
@@ -34,14 +32,6 @@ public class LoginResponse {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
@@ -55,12 +45,12 @@ public class LoginResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
LoginResponse that = (LoginResponse) o;
|
||||
return Objects.equals(token, that.token) && Objects.equals(username, that.username) && Objects.equals(fullName, that.fullName) && Objects.equals(role, that.role);
|
||||
return Objects.equals(token, that.token) && Objects.equals(username, that.username) && Objects.equals(role, that.role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(token, username, fullName, role);
|
||||
return Objects.hash(token, username, role);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,7 +58,6 @@ public class LoginResponse {
|
||||
return "LoginResponse{" +
|
||||
"token='" + token + '\'' +
|
||||
", username='" + username + '\'' +
|
||||
", fullName='" + fullName + '\'' +
|
||||
", role='" + role + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@@ -5,18 +5,14 @@ import java.util.Objects;
|
||||
public class UserInfoResponse {
|
||||
private Long id;
|
||||
private String username;
|
||||
private String fullName;
|
||||
private String email;
|
||||
private String role;
|
||||
|
||||
public UserInfoResponse() {
|
||||
}
|
||||
|
||||
public UserInfoResponse(Long id, String username, String fullName, String email, String role) {
|
||||
public UserInfoResponse(Long id, String username, String role) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.fullName = fullName;
|
||||
this.email = email;
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
@@ -36,22 +32,6 @@ public class UserInfoResponse {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
@@ -65,12 +45,12 @@ public class UserInfoResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
UserInfoResponse that = (UserInfoResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(username, that.username) && Objects.equals(fullName, that.fullName) && Objects.equals(email, that.email) && Objects.equals(role, that.role);
|
||||
return Objects.equals(id, that.id) && Objects.equals(username, that.username) && Objects.equals(role, that.role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username, fullName, email, role);
|
||||
return Objects.hash(id, username, role);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,8 +58,6 @@ public class UserInfoResponse {
|
||||
return "UserInfoResponse{" +
|
||||
"id=" + id +
|
||||
", username='" + username + '\'' +
|
||||
", fullName='" + fullName + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", role='" + role + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public class CategoryRequest {
|
||||
@NotBlank(message = "Category name is required")
|
||||
private String categoryName;
|
||||
|
||||
private String categoryDescription;
|
||||
private String categoryType;
|
||||
|
||||
public String getCategoryName() {
|
||||
return categoryName;
|
||||
@@ -17,12 +17,12 @@ public class CategoryRequest {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getCategoryDescription() {
|
||||
return categoryDescription;
|
||||
public String getCategoryType() {
|
||||
return categoryType;
|
||||
}
|
||||
|
||||
public void setCategoryDescription(String categoryDescription) {
|
||||
this.categoryDescription = categoryDescription;
|
||||
public void setCategoryType(String categoryType) {
|
||||
this.categoryType = categoryType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,19 +31,19 @@ public class CategoryRequest {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CategoryRequest that = (CategoryRequest) o;
|
||||
return Objects.equals(categoryName, that.categoryName) &&
|
||||
Objects.equals(categoryDescription, that.categoryDescription);
|
||||
Objects.equals(categoryType, that.categoryType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(categoryName, categoryDescription);
|
||||
return Objects.hash(categoryName, categoryType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CategoryRequest{" +
|
||||
"categoryName='" + categoryName + '\'' +
|
||||
", categoryDescription='" + categoryDescription + '\'' +
|
||||
", categoryType='" + categoryType + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,29 +4,29 @@ import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CategoryResponse {
|
||||
private Long id;
|
||||
private Long categoryId;
|
||||
private String categoryName;
|
||||
private String categoryDescription;
|
||||
private String categoryType;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public CategoryResponse() {
|
||||
}
|
||||
|
||||
public CategoryResponse(Long id, String categoryName, String categoryDescription, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
public CategoryResponse(Long categoryId, String categoryName, String categoryType, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.categoryId = categoryId;
|
||||
this.categoryName = categoryName;
|
||||
this.categoryDescription = categoryDescription;
|
||||
this.categoryType = categoryType;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setCategoryId(Long categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public String getCategoryName() {
|
||||
@@ -37,12 +37,12 @@ public class CategoryResponse {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getCategoryDescription() {
|
||||
return categoryDescription;
|
||||
public String getCategoryType() {
|
||||
return categoryType;
|
||||
}
|
||||
|
||||
public void setCategoryDescription(String categoryDescription) {
|
||||
this.categoryDescription = categoryDescription;
|
||||
public void setCategoryType(String categoryType) {
|
||||
this.categoryType = categoryType;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
@@ -66,20 +66,20 @@ public class CategoryResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CategoryResponse that = (CategoryResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(categoryName, that.categoryName) && Objects.equals(categoryDescription, that.categoryDescription) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(categoryId, that.categoryId) && Objects.equals(categoryName, that.categoryName) && Objects.equals(categoryType, that.categoryType) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, categoryName, categoryDescription, createdAt, updatedAt);
|
||||
return Objects.hash(categoryId, categoryName, categoryType, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CategoryResponse{" +
|
||||
"id=" + id +
|
||||
"categoryId=" + categoryId +
|
||||
", categoryName='" + categoryName + '\'' +
|
||||
", categoryDescription='" + categoryDescription + '\'' +
|
||||
", categoryType='" + categoryType + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -5,45 +5,47 @@ import jakarta.validation.constraints.NotBlank;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CustomerRequest {
|
||||
@NotBlank(message = "Customer name is required")
|
||||
private String customerName;
|
||||
@NotBlank(message = "First name is required")
|
||||
private String firstName;
|
||||
|
||||
@NotBlank(message = "Last name is required")
|
||||
private String lastName;
|
||||
|
||||
@Email(message = "Invalid email format")
|
||||
private String customerEmail;
|
||||
private String email;
|
||||
|
||||
private String customerPhone;
|
||||
private String customerAddress;
|
||||
private String phone;
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getCustomerEmail() {
|
||||
return customerEmail;
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setCustomerEmail(String customerEmail) {
|
||||
this.customerEmail = customerEmail;
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getCustomerPhone() {
|
||||
return customerPhone;
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setCustomerPhone(String customerPhone) {
|
||||
this.customerPhone = customerPhone;
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getCustomerAddress() {
|
||||
return customerAddress;
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setCustomerAddress(String customerAddress) {
|
||||
this.customerAddress = customerAddress;
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,24 +53,24 @@ public class CustomerRequest {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CustomerRequest that = (CustomerRequest) o;
|
||||
return Objects.equals(customerName, that.customerName) &&
|
||||
Objects.equals(customerEmail, that.customerEmail) &&
|
||||
Objects.equals(customerPhone, that.customerPhone) &&
|
||||
Objects.equals(customerAddress, that.customerAddress);
|
||||
return Objects.equals(firstName, that.firstName) &&
|
||||
Objects.equals(lastName, that.lastName) &&
|
||||
Objects.equals(email, that.email) &&
|
||||
Objects.equals(phone, that.phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(customerName, customerEmail, customerPhone, customerAddress);
|
||||
return Objects.hash(firstName, lastName, email, phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CustomerRequest{" +
|
||||
"customerName='" + customerName + '\'' +
|
||||
", customerEmail='" + customerEmail + '\'' +
|
||||
", customerPhone='" + customerPhone + '\'' +
|
||||
", customerAddress='" + customerAddress + '\'' +
|
||||
"firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", phone='" + phone + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,65 +4,65 @@ import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CustomerResponse {
|
||||
private Long id;
|
||||
private String customerName;
|
||||
private String customerEmail;
|
||||
private String customerPhone;
|
||||
private String customerAddress;
|
||||
private Long customerId;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
private String phone;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public CustomerResponse() {
|
||||
}
|
||||
|
||||
public CustomerResponse(Long id, String customerName, String customerEmail, String customerPhone, String customerAddress, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
this.customerName = customerName;
|
||||
this.customerEmail = customerEmail;
|
||||
this.customerPhone = customerPhone;
|
||||
this.customerAddress = customerAddress;
|
||||
public CustomerResponse(Long customerId, String firstName, String lastName, String email, String phone, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.customerId = customerId;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.email = email;
|
||||
this.phone = phone;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setCustomerId(Long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getCustomerEmail() {
|
||||
return customerEmail;
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setCustomerEmail(String customerEmail) {
|
||||
this.customerEmail = customerEmail;
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getCustomerPhone() {
|
||||
return customerPhone;
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setCustomerPhone(String customerPhone) {
|
||||
this.customerPhone = customerPhone;
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getCustomerAddress() {
|
||||
return customerAddress;
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setCustomerAddress(String customerAddress) {
|
||||
this.customerAddress = customerAddress;
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
@@ -86,22 +86,22 @@ public class CustomerResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CustomerResponse that = (CustomerResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(customerName, that.customerName) && Objects.equals(customerEmail, that.customerEmail) && Objects.equals(customerPhone, that.customerPhone) && Objects.equals(customerAddress, that.customerAddress) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(customerId, that.customerId) && Objects.equals(firstName, that.firstName) && Objects.equals(lastName, that.lastName) && Objects.equals(email, that.email) && Objects.equals(phone, that.phone) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, customerName, customerEmail, customerPhone, customerAddress, createdAt, updatedAt);
|
||||
return Objects.hash(customerId, firstName, lastName, email, phone, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CustomerResponse{" +
|
||||
"id=" + id +
|
||||
", customerName='" + customerName + '\'' +
|
||||
", customerEmail='" + customerEmail + '\'' +
|
||||
", customerPhone='" + customerPhone + '\'' +
|
||||
", customerAddress='" + customerAddress + '\'' +
|
||||
"customerId=" + customerId +
|
||||
", firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", phone='" + phone + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -8,15 +8,10 @@ public class InventoryRequest {
|
||||
@NotNull(message = "Product ID is required")
|
||||
private Long prodId;
|
||||
|
||||
private Long storeId;
|
||||
|
||||
@NotNull(message = "Quantity is required")
|
||||
@PositiveOrZero(message = "Quantity must be zero or positive")
|
||||
private Integer quantity;
|
||||
|
||||
@PositiveOrZero(message = "Reorder level must be zero or positive")
|
||||
private Integer reorderLevel = 10;
|
||||
|
||||
public Long getProdId() {
|
||||
return prodId;
|
||||
}
|
||||
@@ -25,14 +20,6 @@ public class InventoryRequest {
|
||||
this.prodId = prodId;
|
||||
}
|
||||
|
||||
public Long getStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
|
||||
public void setStoreId(Long storeId) {
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
@@ -41,37 +28,25 @@ public class InventoryRequest {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public Integer getReorderLevel() {
|
||||
return reorderLevel;
|
||||
}
|
||||
|
||||
public void setReorderLevel(Integer reorderLevel) {
|
||||
this.reorderLevel = reorderLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
InventoryRequest that = (InventoryRequest) o;
|
||||
return Objects.equals(prodId, that.prodId) &&
|
||||
Objects.equals(storeId, that.storeId) &&
|
||||
Objects.equals(quantity, that.quantity) &&
|
||||
Objects.equals(reorderLevel, that.reorderLevel);
|
||||
Objects.equals(quantity, that.quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(prodId, storeId, quantity, reorderLevel);
|
||||
return Objects.hash(prodId, quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InventoryRequest{" +
|
||||
"prodId=" + prodId +
|
||||
", storeId=" + storeId +
|
||||
", quantity=" + quantity +
|
||||
", reorderLevel=" + reorderLevel +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,49 +4,41 @@ import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class InventoryResponse {
|
||||
private Long id;
|
||||
private Long productId;
|
||||
private Long inventoryId;
|
||||
private Long prodId;
|
||||
private String productName;
|
||||
private String categoryName;
|
||||
private Long storeId;
|
||||
private String storeName;
|
||||
private Integer quantity;
|
||||
private Integer reorderLevel;
|
||||
private LocalDateTime lastRestocked;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public InventoryResponse() {
|
||||
}
|
||||
|
||||
public InventoryResponse(Long id, Long productId, String productName, String categoryName, Long storeId, String storeName, Integer quantity, Integer reorderLevel, LocalDateTime lastRestocked, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
this.productId = productId;
|
||||
public InventoryResponse(Long inventoryId, Long prodId, String productName, String categoryName, Integer quantity, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.inventoryId = inventoryId;
|
||||
this.prodId = prodId;
|
||||
this.productName = productName;
|
||||
this.categoryName = categoryName;
|
||||
this.storeId = storeId;
|
||||
this.storeName = storeName;
|
||||
this.quantity = quantity;
|
||||
this.reorderLevel = reorderLevel;
|
||||
this.lastRestocked = lastRestocked;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getInventoryId() {
|
||||
return inventoryId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setInventoryId(Long inventoryId) {
|
||||
this.inventoryId = inventoryId;
|
||||
}
|
||||
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
public Long getProdId() {
|
||||
return prodId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId) {
|
||||
this.productId = productId;
|
||||
public void setProdId(Long prodId) {
|
||||
this.prodId = prodId;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
@@ -65,22 +57,6 @@ public class InventoryResponse {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public Long getStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
|
||||
public void setStoreId(Long storeId) {
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
@@ -89,22 +65,6 @@ public class InventoryResponse {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public Integer getReorderLevel() {
|
||||
return reorderLevel;
|
||||
}
|
||||
|
||||
public void setReorderLevel(Integer reorderLevel) {
|
||||
this.reorderLevel = reorderLevel;
|
||||
}
|
||||
|
||||
public LocalDateTime getLastRestocked() {
|
||||
return lastRestocked;
|
||||
}
|
||||
|
||||
public void setLastRestocked(LocalDateTime lastRestocked) {
|
||||
this.lastRestocked = lastRestocked;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
@@ -126,26 +86,22 @@ public class InventoryResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
InventoryResponse that = (InventoryResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(categoryName, that.categoryName) && Objects.equals(storeId, that.storeId) && Objects.equals(storeName, that.storeName) && Objects.equals(quantity, that.quantity) && Objects.equals(reorderLevel, that.reorderLevel) && Objects.equals(lastRestocked, that.lastRestocked) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(inventoryId, that.inventoryId) && Objects.equals(prodId, that.prodId) && Objects.equals(productName, that.productName) && Objects.equals(categoryName, that.categoryName) && Objects.equals(quantity, that.quantity) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, productId, productName, categoryName, storeId, storeName, quantity, reorderLevel, lastRestocked, createdAt, updatedAt);
|
||||
return Objects.hash(inventoryId, prodId, productName, categoryName, quantity, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InventoryResponse{" +
|
||||
"id=" + id +
|
||||
", productId=" + productId +
|
||||
"inventoryId=" + inventoryId +
|
||||
", prodId=" + prodId +
|
||||
", productName='" + productName + '\'' +
|
||||
", categoryName='" + categoryName + '\'' +
|
||||
", storeId=" + storeId +
|
||||
", storeName='" + storeName + '\'' +
|
||||
", quantity=" + quantity +
|
||||
", reorderLevel=" + reorderLevel +
|
||||
", lastRestocked=" + lastRestocked +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -19,8 +19,6 @@ public class ProductRequest {
|
||||
@Positive(message = "Price must be positive")
|
||||
private BigDecimal prodPrice;
|
||||
|
||||
private Boolean active = true;
|
||||
|
||||
public String getProdName() {
|
||||
return prodName;
|
||||
}
|
||||
@@ -53,14 +51,6 @@ public class ProductRequest {
|
||||
this.prodPrice = prodPrice;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -69,13 +59,12 @@ public class ProductRequest {
|
||||
return Objects.equals(prodName, that.prodName) &&
|
||||
Objects.equals(categoryId, that.categoryId) &&
|
||||
Objects.equals(prodDesc, that.prodDesc) &&
|
||||
Objects.equals(prodPrice, that.prodPrice) &&
|
||||
Objects.equals(active, that.active);
|
||||
Objects.equals(prodPrice, that.prodPrice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(prodName, categoryId, prodDesc, prodPrice, active);
|
||||
return Objects.hash(prodName, categoryId, prodDesc, prodPrice);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +74,6 @@ public class ProductRequest {
|
||||
", categoryId=" + categoryId +
|
||||
", prodDesc='" + prodDesc + '\'' +
|
||||
", prodPrice=" + prodPrice +
|
||||
", active=" + active +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,45 +5,43 @@ import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ProductResponse {
|
||||
private Long id;
|
||||
private String productName;
|
||||
private Long prodId;
|
||||
private String prodName;
|
||||
private Long categoryId;
|
||||
private String categoryName;
|
||||
private String productDescription;
|
||||
private BigDecimal productPrice;
|
||||
private Boolean active;
|
||||
private String prodDesc;
|
||||
private BigDecimal prodPrice;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public ProductResponse() {
|
||||
}
|
||||
|
||||
public ProductResponse(Long id, String productName, Long categoryId, String categoryName, String productDescription, BigDecimal productPrice, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
this.productName = productName;
|
||||
public ProductResponse(Long prodId, String prodName, Long categoryId, String categoryName, String prodDesc, BigDecimal prodPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.prodId = prodId;
|
||||
this.prodName = prodName;
|
||||
this.categoryId = categoryId;
|
||||
this.categoryName = categoryName;
|
||||
this.productDescription = productDescription;
|
||||
this.productPrice = productPrice;
|
||||
this.active = active;
|
||||
this.prodDesc = prodDesc;
|
||||
this.prodPrice = prodPrice;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getProdId() {
|
||||
return prodId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setProdId(Long prodId) {
|
||||
this.prodId = prodId;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
public String getProdName() {
|
||||
return prodName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
public void setProdName(String prodName) {
|
||||
this.prodName = prodName;
|
||||
}
|
||||
|
||||
public Long getCategoryId() {
|
||||
@@ -62,28 +60,20 @@ public class ProductResponse {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getProductDescription() {
|
||||
return productDescription;
|
||||
public String getProdDesc() {
|
||||
return prodDesc;
|
||||
}
|
||||
|
||||
public void setProductDescription(String productDescription) {
|
||||
this.productDescription = productDescription;
|
||||
public void setProdDesc(String prodDesc) {
|
||||
this.prodDesc = prodDesc;
|
||||
}
|
||||
|
||||
public BigDecimal getProductPrice() {
|
||||
return productPrice;
|
||||
public BigDecimal getProdPrice() {
|
||||
return prodPrice;
|
||||
}
|
||||
|
||||
public void setProductPrice(BigDecimal productPrice) {
|
||||
this.productPrice = productPrice;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
public void setProdPrice(BigDecimal prodPrice) {
|
||||
this.prodPrice = prodPrice;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
@@ -107,24 +97,23 @@ public class ProductResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ProductResponse that = (ProductResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(productName, that.productName) && Objects.equals(categoryId, that.categoryId) && Objects.equals(categoryName, that.categoryName) && Objects.equals(productDescription, that.productDescription) && Objects.equals(productPrice, that.productPrice) && Objects.equals(active, that.active) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(prodId, that.prodId) && Objects.equals(prodName, that.prodName) && Objects.equals(categoryId, that.categoryId) && Objects.equals(categoryName, that.categoryName) && Objects.equals(prodDesc, that.prodDesc) && Objects.equals(prodPrice, that.prodPrice) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, productName, categoryId, categoryName, productDescription, productPrice, active, createdAt, updatedAt);
|
||||
return Objects.hash(prodId, prodName, categoryId, categoryName, prodDesc, prodPrice, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProductResponse{" +
|
||||
"id=" + id +
|
||||
", productName='" + productName + '\'' +
|
||||
"prodId=" + prodId +
|
||||
", prodName='" + prodName + '\'' +
|
||||
", categoryId=" + categoryId +
|
||||
", categoryName='" + categoryName + '\'' +
|
||||
", productDescription='" + productDescription + '\'' +
|
||||
", productPrice=" + productPrice +
|
||||
", active=" + active +
|
||||
", prodDesc='" + prodDesc + '\'' +
|
||||
", prodPrice=" + prodPrice +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.petshop.backend.dto.productsupplier;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import jakarta.validation.constraints.PositiveOrZero;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -13,14 +12,9 @@ public class ProductSupplierRequest {
|
||||
@NotNull(message = "Supplier ID is required")
|
||||
private Long supplierId;
|
||||
|
||||
@NotNull(message = "Cost price is required")
|
||||
@Positive(message = "Cost price must be positive")
|
||||
private BigDecimal costPrice;
|
||||
|
||||
@PositiveOrZero(message = "Lead time must be zero or positive")
|
||||
private Integer leadTimeDays;
|
||||
|
||||
private Boolean isPreferred = false;
|
||||
@NotNull(message = "Cost is required")
|
||||
@Positive(message = "Cost must be positive")
|
||||
private BigDecimal cost;
|
||||
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
@@ -38,28 +32,12 @@ public class ProductSupplierRequest {
|
||||
this.supplierId = supplierId;
|
||||
}
|
||||
|
||||
public BigDecimal getCostPrice() {
|
||||
return costPrice;
|
||||
public BigDecimal getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
public void setCostPrice(BigDecimal costPrice) {
|
||||
this.costPrice = costPrice;
|
||||
}
|
||||
|
||||
public Integer getLeadTimeDays() {
|
||||
return leadTimeDays;
|
||||
}
|
||||
|
||||
public void setLeadTimeDays(Integer leadTimeDays) {
|
||||
this.leadTimeDays = leadTimeDays;
|
||||
}
|
||||
|
||||
public Boolean getIsPreferred() {
|
||||
return isPreferred;
|
||||
}
|
||||
|
||||
public void setIsPreferred(Boolean isPreferred) {
|
||||
this.isPreferred = isPreferred;
|
||||
public void setCost(BigDecimal cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,14 +47,12 @@ public class ProductSupplierRequest {
|
||||
ProductSupplierRequest that = (ProductSupplierRequest) o;
|
||||
return Objects.equals(productId, that.productId) &&
|
||||
Objects.equals(supplierId, that.supplierId) &&
|
||||
Objects.equals(costPrice, that.costPrice) &&
|
||||
Objects.equals(leadTimeDays, that.leadTimeDays) &&
|
||||
Objects.equals(isPreferred, that.isPreferred);
|
||||
Objects.equals(cost, that.cost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(productId, supplierId, costPrice, leadTimeDays, isPreferred);
|
||||
return Objects.hash(productId, supplierId, cost);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,9 +60,7 @@ public class ProductSupplierRequest {
|
||||
return "ProductSupplierRequest{" +
|
||||
"productId=" + productId +
|
||||
", supplierId=" + supplierId +
|
||||
", costPrice=" + costPrice +
|
||||
", leadTimeDays=" + leadTimeDays +
|
||||
", isPreferred=" + isPreferred +
|
||||
", cost=" + cost +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,23 +9,19 @@ public class ProductSupplierResponse {
|
||||
private String productName;
|
||||
private Long supplierId;
|
||||
private String supplierName;
|
||||
private BigDecimal costPrice;
|
||||
private Integer leadTimeDays;
|
||||
private Boolean isPreferred;
|
||||
private BigDecimal cost;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public ProductSupplierResponse() {
|
||||
}
|
||||
|
||||
public ProductSupplierResponse(Long productId, String productName, Long supplierId, String supplierName, BigDecimal costPrice, Integer leadTimeDays, Boolean isPreferred, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
public ProductSupplierResponse(Long productId, String productName, Long supplierId, String supplierName, BigDecimal cost, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.productId = productId;
|
||||
this.productName = productName;
|
||||
this.supplierId = supplierId;
|
||||
this.supplierName = supplierName;
|
||||
this.costPrice = costPrice;
|
||||
this.leadTimeDays = leadTimeDays;
|
||||
this.isPreferred = isPreferred;
|
||||
this.cost = cost;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
@@ -62,28 +58,12 @@ public class ProductSupplierResponse {
|
||||
this.supplierName = supplierName;
|
||||
}
|
||||
|
||||
public BigDecimal getCostPrice() {
|
||||
return costPrice;
|
||||
public BigDecimal getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
public void setCostPrice(BigDecimal costPrice) {
|
||||
this.costPrice = costPrice;
|
||||
}
|
||||
|
||||
public Integer getLeadTimeDays() {
|
||||
return leadTimeDays;
|
||||
}
|
||||
|
||||
public void setLeadTimeDays(Integer leadTimeDays) {
|
||||
this.leadTimeDays = leadTimeDays;
|
||||
}
|
||||
|
||||
public Boolean getIsPreferred() {
|
||||
return isPreferred;
|
||||
}
|
||||
|
||||
public void setIsPreferred(Boolean isPreferred) {
|
||||
this.isPreferred = isPreferred;
|
||||
public void setCost(BigDecimal cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
@@ -107,12 +87,12 @@ public class ProductSupplierResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ProductSupplierResponse that = (ProductSupplierResponse) o;
|
||||
return Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(supplierId, that.supplierId) && Objects.equals(supplierName, that.supplierName) && Objects.equals(costPrice, that.costPrice) && Objects.equals(leadTimeDays, that.leadTimeDays) && Objects.equals(isPreferred, that.isPreferred) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(supplierId, that.supplierId) && Objects.equals(supplierName, that.supplierName) && Objects.equals(cost, that.cost) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(productId, productName, supplierId, supplierName, costPrice, leadTimeDays, isPreferred, createdAt, updatedAt);
|
||||
return Objects.hash(productId, productName, supplierId, supplierName, cost, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,9 +102,7 @@ public class ProductSupplierResponse {
|
||||
", productName='" + productName + '\'' +
|
||||
", supplierId=" + supplierId +
|
||||
", supplierName='" + supplierName + '\'' +
|
||||
", costPrice=" + costPrice +
|
||||
", leadTimeDays=" + leadTimeDays +
|
||||
", isPreferred=" + isPreferred +
|
||||
", cost=" + cost +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -1,55 +1,45 @@
|
||||
package com.petshop.backend.dto.purchaseorder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PurchaseOrderResponse {
|
||||
private Long id;
|
||||
private Long supplierId;
|
||||
private Long purchaseOrderId;
|
||||
private Long supId;
|
||||
private String supplierName;
|
||||
private LocalDate orderDate;
|
||||
private LocalDate expectedDelivery;
|
||||
private String status;
|
||||
private BigDecimal totalAmount;
|
||||
private String notes;
|
||||
private List<PurchaseOrderItemResponse> items;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public PurchaseOrderResponse() {
|
||||
}
|
||||
|
||||
public PurchaseOrderResponse(Long id, Long supplierId, String supplierName, LocalDate orderDate, LocalDate expectedDelivery, String status, BigDecimal totalAmount, String notes, List<PurchaseOrderItemResponse> items, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
this.supplierId = supplierId;
|
||||
public PurchaseOrderResponse(Long purchaseOrderId, Long supId, String supplierName, LocalDate orderDate, String status, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.purchaseOrderId = purchaseOrderId;
|
||||
this.supId = supId;
|
||||
this.supplierName = supplierName;
|
||||
this.orderDate = orderDate;
|
||||
this.expectedDelivery = expectedDelivery;
|
||||
this.status = status;
|
||||
this.totalAmount = totalAmount;
|
||||
this.notes = notes;
|
||||
this.items = items;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getPurchaseOrderId() {
|
||||
return purchaseOrderId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setPurchaseOrderId(Long purchaseOrderId) {
|
||||
this.purchaseOrderId = purchaseOrderId;
|
||||
}
|
||||
|
||||
public Long getSupplierId() {
|
||||
return supplierId;
|
||||
public Long getSupId() {
|
||||
return supId;
|
||||
}
|
||||
|
||||
public void setSupplierId(Long supplierId) {
|
||||
this.supplierId = supplierId;
|
||||
public void setSupId(Long supId) {
|
||||
this.supId = supId;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
@@ -68,14 +58,6 @@ public class PurchaseOrderResponse {
|
||||
this.orderDate = orderDate;
|
||||
}
|
||||
|
||||
public LocalDate getExpectedDelivery() {
|
||||
return expectedDelivery;
|
||||
}
|
||||
|
||||
public void setExpectedDelivery(LocalDate expectedDelivery) {
|
||||
this.expectedDelivery = expectedDelivery;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
@@ -84,30 +66,6 @@ public class PurchaseOrderResponse {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public void setTotalAmount(BigDecimal totalAmount) {
|
||||
this.totalAmount = totalAmount;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public List<PurchaseOrderItemResponse> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<PurchaseOrderItemResponse> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
@@ -129,122 +87,24 @@ public class PurchaseOrderResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PurchaseOrderResponse that = (PurchaseOrderResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(supplierId, that.supplierId) && Objects.equals(supplierName, that.supplierName) && Objects.equals(orderDate, that.orderDate) && Objects.equals(expectedDelivery, that.expectedDelivery) && Objects.equals(status, that.status) && Objects.equals(totalAmount, that.totalAmount) && Objects.equals(notes, that.notes) && Objects.equals(items, that.items) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(purchaseOrderId, that.purchaseOrderId) && Objects.equals(supId, that.supId) && Objects.equals(supplierName, that.supplierName) && Objects.equals(orderDate, that.orderDate) && Objects.equals(status, that.status) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, supplierId, supplierName, orderDate, expectedDelivery, status, totalAmount, notes, items, createdAt, updatedAt);
|
||||
return Objects.hash(purchaseOrderId, supId, supplierName, orderDate, status, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PurchaseOrderResponse{" +
|
||||
"id=" + id +
|
||||
", supplierId=" + supplierId +
|
||||
"purchaseOrderId=" + purchaseOrderId +
|
||||
", supId=" + supId +
|
||||
", supplierName='" + supplierName + '\'' +
|
||||
", orderDate=" + orderDate +
|
||||
", expectedDelivery=" + expectedDelivery +
|
||||
", status='" + status + '\'' +
|
||||
", totalAmount=" + totalAmount +
|
||||
", notes='" + notes + '\'' +
|
||||
", items=" + items +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class PurchaseOrderItemResponse {
|
||||
private Long id;
|
||||
private Long productId;
|
||||
private String productName;
|
||||
private Integer quantity;
|
||||
private BigDecimal unitCost;
|
||||
private BigDecimal subtotal;
|
||||
|
||||
public PurchaseOrderItemResponse() {
|
||||
}
|
||||
|
||||
public PurchaseOrderItemResponse(Long id, Long productId, String productName, Integer quantity, BigDecimal unitCost, BigDecimal subtotal) {
|
||||
this.id = id;
|
||||
this.productId = productId;
|
||||
this.productName = productName;
|
||||
this.quantity = quantity;
|
||||
this.unitCost = unitCost;
|
||||
this.subtotal = subtotal;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public BigDecimal getUnitCost() {
|
||||
return unitCost;
|
||||
}
|
||||
|
||||
public void setUnitCost(BigDecimal unitCost) {
|
||||
this.unitCost = unitCost;
|
||||
}
|
||||
|
||||
public BigDecimal getSubtotal() {
|
||||
return subtotal;
|
||||
}
|
||||
|
||||
public void setSubtotal(BigDecimal subtotal) {
|
||||
this.subtotal = subtotal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PurchaseOrderItemResponse that = (PurchaseOrderItemResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(quantity, that.quantity) && Objects.equals(unitCost, that.unitCost) && Objects.equals(subtotal, that.subtotal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, productId, productName, quantity, unitCost, subtotal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PurchaseOrderItemResponse{" +
|
||||
"id=" + id +
|
||||
", productId=" + productId +
|
||||
", productName='" + productName + '\'' +
|
||||
", quantity=" + quantity +
|
||||
", unitCost=" + unitCost +
|
||||
", subtotal=" + subtotal +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,18 +6,17 @@ import java.util.Objects;
|
||||
|
||||
public class SaleItemRequest {
|
||||
@NotNull(message = "Product ID is required")
|
||||
private Long productId;
|
||||
private Long prodId;
|
||||
|
||||
@NotNull(message = "Quantity is required")
|
||||
@Positive(message = "Quantity must be positive")
|
||||
private Integer quantity;
|
||||
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
public Long getProdId() {
|
||||
return prodId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId) {
|
||||
this.productId = productId;
|
||||
public void setProdId(Long prodId) {
|
||||
this.prodId = prodId;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
@@ -33,19 +32,19 @@ public class SaleItemRequest {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SaleItemRequest that = (SaleItemRequest) o;
|
||||
return Objects.equals(productId, that.productId) &&
|
||||
return Objects.equals(prodId, that.prodId) &&
|
||||
Objects.equals(quantity, that.quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(productId, quantity);
|
||||
return Objects.hash(prodId, quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SaleItemRequest{" +
|
||||
"productId=" + productId +
|
||||
"prodId=" + prodId +
|
||||
", quantity=" + quantity +
|
||||
'}';
|
||||
}
|
||||
|
||||
@@ -3,33 +3,22 @@ package com.petshop.backend.dto.sale;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SaleRequest {
|
||||
private Long customerId;
|
||||
|
||||
@NotNull(message = "Store ID is required")
|
||||
private Long storeId;
|
||||
|
||||
private String paymentMethod;
|
||||
|
||||
private BigDecimal tax = BigDecimal.ZERO;
|
||||
|
||||
@NotEmpty(message = "At least one item is required")
|
||||
@Valid
|
||||
private List<SaleItemRequest> items;
|
||||
|
||||
private String notes;
|
||||
private Boolean isRefund = false;
|
||||
|
||||
public Long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(Long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
private Long originalSaleId;
|
||||
|
||||
public Long getStoreId() {
|
||||
return storeId;
|
||||
@@ -47,14 +36,6 @@ public class SaleRequest {
|
||||
this.paymentMethod = paymentMethod;
|
||||
}
|
||||
|
||||
public BigDecimal getTax() {
|
||||
return tax;
|
||||
}
|
||||
|
||||
public void setTax(BigDecimal tax) {
|
||||
this.tax = tax;
|
||||
}
|
||||
|
||||
public List<SaleItemRequest> getItems() {
|
||||
return items;
|
||||
}
|
||||
@@ -63,12 +44,20 @@ public class SaleRequest {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
public Boolean getIsRefund() {
|
||||
return isRefund;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
public void setIsRefund(Boolean isRefund) {
|
||||
this.isRefund = isRefund;
|
||||
}
|
||||
|
||||
public Long getOriginalSaleId() {
|
||||
return originalSaleId;
|
||||
}
|
||||
|
||||
public void setOriginalSaleId(Long originalSaleId) {
|
||||
this.originalSaleId = originalSaleId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,28 +65,26 @@ public class SaleRequest {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SaleRequest that = (SaleRequest) o;
|
||||
return Objects.equals(customerId, that.customerId) &&
|
||||
Objects.equals(storeId, that.storeId) &&
|
||||
return Objects.equals(storeId, that.storeId) &&
|
||||
Objects.equals(paymentMethod, that.paymentMethod) &&
|
||||
Objects.equals(tax, that.tax) &&
|
||||
Objects.equals(items, that.items) &&
|
||||
Objects.equals(notes, that.notes);
|
||||
Objects.equals(isRefund, that.isRefund) &&
|
||||
Objects.equals(originalSaleId, that.originalSaleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(customerId, storeId, paymentMethod, tax, items, notes);
|
||||
return Objects.hash(storeId, paymentMethod, items, isRefund, originalSaleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SaleRequest{" +
|
||||
"customerId=" + customerId +
|
||||
", storeId=" + storeId +
|
||||
"storeId=" + storeId +
|
||||
", paymentMethod='" + paymentMethod + '\'' +
|
||||
", tax=" + tax +
|
||||
", items=" + items +
|
||||
", notes='" + notes + '\'' +
|
||||
", isRefund=" + isRefund +
|
||||
", originalSaleId=" + originalSaleId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,49 +6,43 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SaleResponse {
|
||||
private Long id;
|
||||
private Long saleId;
|
||||
private LocalDateTime saleDate;
|
||||
private Long employeeId;
|
||||
private String employeeName;
|
||||
private Long customerId;
|
||||
private String customerName;
|
||||
private Long storeId;
|
||||
private String storeName;
|
||||
private BigDecimal subtotal;
|
||||
private BigDecimal tax;
|
||||
private BigDecimal total;
|
||||
private BigDecimal totalAmount;
|
||||
private String paymentMethod;
|
||||
private String notes;
|
||||
private Boolean isRefund;
|
||||
private Long originalSaleId;
|
||||
private List<SaleItemResponse> items;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public SaleResponse() {
|
||||
}
|
||||
|
||||
public SaleResponse(Long id, LocalDateTime saleDate, Long employeeId, String employeeName, Long customerId, String customerName, Long storeId, String storeName, BigDecimal subtotal, BigDecimal tax, BigDecimal total, String paymentMethod, String notes, List<SaleItemResponse> items, LocalDateTime createdAt) {
|
||||
this.id = id;
|
||||
public SaleResponse(Long saleId, LocalDateTime saleDate, Long employeeId, String employeeName, Long storeId, String storeName, BigDecimal totalAmount, String paymentMethod, Boolean isRefund, Long originalSaleId, List<SaleItemResponse> items, LocalDateTime createdAt) {
|
||||
this.saleId = saleId;
|
||||
this.saleDate = saleDate;
|
||||
this.employeeId = employeeId;
|
||||
this.employeeName = employeeName;
|
||||
this.customerId = customerId;
|
||||
this.customerName = customerName;
|
||||
this.storeId = storeId;
|
||||
this.storeName = storeName;
|
||||
this.subtotal = subtotal;
|
||||
this.tax = tax;
|
||||
this.total = total;
|
||||
this.totalAmount = totalAmount;
|
||||
this.paymentMethod = paymentMethod;
|
||||
this.notes = notes;
|
||||
this.isRefund = isRefund;
|
||||
this.originalSaleId = originalSaleId;
|
||||
this.items = items;
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getSaleId() {
|
||||
return saleId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setSaleId(Long saleId) {
|
||||
this.saleId = saleId;
|
||||
}
|
||||
|
||||
public LocalDateTime getSaleDate() {
|
||||
@@ -75,22 +69,6 @@ public class SaleResponse {
|
||||
this.employeeName = employeeName;
|
||||
}
|
||||
|
||||
public Long getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(Long customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public Long getStoreId() {
|
||||
return storeId;
|
||||
}
|
||||
@@ -107,28 +85,12 @@ public class SaleResponse {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public BigDecimal getSubtotal() {
|
||||
return subtotal;
|
||||
public BigDecimal getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public void setSubtotal(BigDecimal subtotal) {
|
||||
this.subtotal = subtotal;
|
||||
}
|
||||
|
||||
public BigDecimal getTax() {
|
||||
return tax;
|
||||
}
|
||||
|
||||
public void setTax(BigDecimal tax) {
|
||||
this.tax = tax;
|
||||
}
|
||||
|
||||
public BigDecimal getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(BigDecimal total) {
|
||||
this.total = total;
|
||||
public void setTotalAmount(BigDecimal totalAmount) {
|
||||
this.totalAmount = totalAmount;
|
||||
}
|
||||
|
||||
public String getPaymentMethod() {
|
||||
@@ -139,12 +101,20 @@ public class SaleResponse {
|
||||
this.paymentMethod = paymentMethod;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
public Boolean getIsRefund() {
|
||||
return isRefund;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
public void setIsRefund(Boolean isRefund) {
|
||||
this.isRefund = isRefund;
|
||||
}
|
||||
|
||||
public Long getOriginalSaleId() {
|
||||
return originalSaleId;
|
||||
}
|
||||
|
||||
public void setOriginalSaleId(Long originalSaleId) {
|
||||
this.originalSaleId = originalSaleId;
|
||||
}
|
||||
|
||||
public List<SaleItemResponse> getItems() {
|
||||
@@ -168,69 +138,64 @@ public class SaleResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SaleResponse that = (SaleResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(saleDate, that.saleDate) && Objects.equals(employeeId, that.employeeId) && Objects.equals(employeeName, that.employeeName) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(storeId, that.storeId) && Objects.equals(storeName, that.storeName) && Objects.equals(subtotal, that.subtotal) && Objects.equals(tax, that.tax) && Objects.equals(total, that.total) && Objects.equals(paymentMethod, that.paymentMethod) && Objects.equals(notes, that.notes) && Objects.equals(items, that.items) && Objects.equals(createdAt, that.createdAt);
|
||||
return Objects.equals(saleId, that.saleId) && Objects.equals(saleDate, that.saleDate) && Objects.equals(employeeId, that.employeeId) && Objects.equals(employeeName, that.employeeName) && Objects.equals(storeId, that.storeId) && Objects.equals(storeName, that.storeName) && Objects.equals(totalAmount, that.totalAmount) && Objects.equals(paymentMethod, that.paymentMethod) && Objects.equals(isRefund, that.isRefund) && Objects.equals(originalSaleId, that.originalSaleId) && Objects.equals(items, that.items) && Objects.equals(createdAt, that.createdAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, saleDate, employeeId, employeeName, customerId, customerName, storeId, storeName, subtotal, tax, total, paymentMethod, notes, items, createdAt);
|
||||
return Objects.hash(saleId, saleDate, employeeId, employeeName, storeId, storeName, totalAmount, paymentMethod, isRefund, originalSaleId, items, createdAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SaleResponse{" +
|
||||
"id=" + id +
|
||||
"saleId=" + saleId +
|
||||
", saleDate=" + saleDate +
|
||||
", employeeId=" + employeeId +
|
||||
", employeeName='" + employeeName + '\'' +
|
||||
", customerId=" + customerId +
|
||||
", customerName='" + customerName + '\'' +
|
||||
", storeId=" + storeId +
|
||||
", storeName='" + storeName + '\'' +
|
||||
", subtotal=" + subtotal +
|
||||
", tax=" + tax +
|
||||
", total=" + total +
|
||||
", totalAmount=" + totalAmount +
|
||||
", paymentMethod='" + paymentMethod + '\'' +
|
||||
", notes='" + notes + '\'' +
|
||||
", isRefund=" + isRefund +
|
||||
", originalSaleId=" + originalSaleId +
|
||||
", items=" + items +
|
||||
", createdAt=" + createdAt +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class SaleItemResponse {
|
||||
private Long id;
|
||||
private Long productId;
|
||||
private Long saleItemId;
|
||||
private Long prodId;
|
||||
private String productName;
|
||||
private Integer quantity;
|
||||
private BigDecimal unitPrice;
|
||||
private BigDecimal subtotal;
|
||||
|
||||
public SaleItemResponse() {
|
||||
}
|
||||
|
||||
public SaleItemResponse(Long id, Long productId, String productName, Integer quantity, BigDecimal unitPrice, BigDecimal subtotal) {
|
||||
this.id = id;
|
||||
this.productId = productId;
|
||||
public SaleItemResponse(Long saleItemId, Long prodId, String productName, Integer quantity, BigDecimal unitPrice) {
|
||||
this.saleItemId = saleItemId;
|
||||
this.prodId = prodId;
|
||||
this.productName = productName;
|
||||
this.quantity = quantity;
|
||||
this.unitPrice = unitPrice;
|
||||
this.subtotal = subtotal;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getSaleItemId() {
|
||||
return saleItemId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setSaleItemId(Long saleItemId) {
|
||||
this.saleItemId = saleItemId;
|
||||
}
|
||||
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
public Long getProdId() {
|
||||
return prodId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId) {
|
||||
this.productId = productId;
|
||||
public void setProdId(Long prodId) {
|
||||
this.prodId = prodId;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
@@ -257,36 +222,27 @@ public class SaleResponse {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getSubtotal() {
|
||||
return subtotal;
|
||||
}
|
||||
|
||||
public void setSubtotal(BigDecimal subtotal) {
|
||||
this.subtotal = subtotal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SaleItemResponse that = (SaleItemResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(quantity, that.quantity) && Objects.equals(unitPrice, that.unitPrice) && Objects.equals(subtotal, that.subtotal);
|
||||
return Objects.equals(saleItemId, that.saleItemId) && Objects.equals(prodId, that.prodId) && Objects.equals(productName, that.productName) && Objects.equals(quantity, that.quantity) && Objects.equals(unitPrice, that.unitPrice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, productId, productName, quantity, unitPrice, subtotal);
|
||||
return Objects.hash(saleItemId, prodId, productName, quantity, unitPrice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SaleItemResponse{" +
|
||||
"id=" + id +
|
||||
", productId=" + productId +
|
||||
"saleItemId=" + saleItemId +
|
||||
", prodId=" + prodId +
|
||||
", productName='" + productName + '\'' +
|
||||
", quantity=" + quantity +
|
||||
", unitPrice=" + unitPrice +
|
||||
", subtotal=" + subtotal +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,16 +10,14 @@ public class ServiceRequest {
|
||||
@NotBlank(message = "Service name is required")
|
||||
private String serviceName;
|
||||
|
||||
private String serviceDescription;
|
||||
private String serviceDesc;
|
||||
|
||||
@NotNull(message = "Service price is required")
|
||||
@Positive(message = "Price must be positive")
|
||||
private BigDecimal servicePrice;
|
||||
|
||||
@Positive(message = "Duration must be positive")
|
||||
private Integer serviceDurationMinutes;
|
||||
|
||||
private Boolean active = true;
|
||||
private Integer serviceDuration;
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
@@ -29,12 +27,12 @@ public class ServiceRequest {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public String getServiceDescription() {
|
||||
return serviceDescription;
|
||||
public String getServiceDesc() {
|
||||
return serviceDesc;
|
||||
}
|
||||
|
||||
public void setServiceDescription(String serviceDescription) {
|
||||
this.serviceDescription = serviceDescription;
|
||||
public void setServiceDesc(String serviceDesc) {
|
||||
this.serviceDesc = serviceDesc;
|
||||
}
|
||||
|
||||
public BigDecimal getServicePrice() {
|
||||
@@ -45,20 +43,12 @@ public class ServiceRequest {
|
||||
this.servicePrice = servicePrice;
|
||||
}
|
||||
|
||||
public Integer getServiceDurationMinutes() {
|
||||
return serviceDurationMinutes;
|
||||
public Integer getServiceDuration() {
|
||||
return serviceDuration;
|
||||
}
|
||||
|
||||
public void setServiceDurationMinutes(Integer serviceDurationMinutes) {
|
||||
this.serviceDurationMinutes = serviceDurationMinutes;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
public void setServiceDuration(Integer serviceDuration) {
|
||||
this.serviceDuration = serviceDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,25 +57,23 @@ public class ServiceRequest {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ServiceRequest that = (ServiceRequest) o;
|
||||
return Objects.equals(serviceName, that.serviceName) &&
|
||||
Objects.equals(serviceDescription, that.serviceDescription) &&
|
||||
Objects.equals(serviceDesc, that.serviceDesc) &&
|
||||
Objects.equals(servicePrice, that.servicePrice) &&
|
||||
Objects.equals(serviceDurationMinutes, that.serviceDurationMinutes) &&
|
||||
Objects.equals(active, that.active);
|
||||
Objects.equals(serviceDuration, that.serviceDuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(serviceName, serviceDescription, servicePrice, serviceDurationMinutes, active);
|
||||
return Objects.hash(serviceName, serviceDesc, servicePrice, serviceDuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServiceRequest{" +
|
||||
"serviceName='" + serviceName + '\'' +
|
||||
", serviceDescription='" + serviceDescription + '\'' +
|
||||
", serviceDesc='" + serviceDesc + '\'' +
|
||||
", servicePrice=" + servicePrice +
|
||||
", serviceDurationMinutes=" + serviceDurationMinutes +
|
||||
", active=" + active +
|
||||
", serviceDuration=" + serviceDuration +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,35 +5,33 @@ import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ServiceResponse {
|
||||
private Long id;
|
||||
private Long serviceId;
|
||||
private String serviceName;
|
||||
private String serviceDescription;
|
||||
private String serviceDesc;
|
||||
private BigDecimal servicePrice;
|
||||
private Integer serviceDurationMinutes;
|
||||
private Boolean active;
|
||||
private Integer serviceDuration;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public ServiceResponse() {
|
||||
}
|
||||
|
||||
public ServiceResponse(Long id, String serviceName, String serviceDescription, BigDecimal servicePrice, Integer serviceDurationMinutes, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
public ServiceResponse(Long serviceId, String serviceName, String serviceDesc, BigDecimal servicePrice, Integer serviceDuration, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.serviceId = serviceId;
|
||||
this.serviceName = serviceName;
|
||||
this.serviceDescription = serviceDescription;
|
||||
this.serviceDesc = serviceDesc;
|
||||
this.servicePrice = servicePrice;
|
||||
this.serviceDurationMinutes = serviceDurationMinutes;
|
||||
this.active = active;
|
||||
this.serviceDuration = serviceDuration;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getServiceId() {
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setServiceId(Long serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
@@ -44,12 +42,12 @@ public class ServiceResponse {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public String getServiceDescription() {
|
||||
return serviceDescription;
|
||||
public String getServiceDesc() {
|
||||
return serviceDesc;
|
||||
}
|
||||
|
||||
public void setServiceDescription(String serviceDescription) {
|
||||
this.serviceDescription = serviceDescription;
|
||||
public void setServiceDesc(String serviceDesc) {
|
||||
this.serviceDesc = serviceDesc;
|
||||
}
|
||||
|
||||
public BigDecimal getServicePrice() {
|
||||
@@ -60,20 +58,12 @@ public class ServiceResponse {
|
||||
this.servicePrice = servicePrice;
|
||||
}
|
||||
|
||||
public Integer getServiceDurationMinutes() {
|
||||
return serviceDurationMinutes;
|
||||
public Integer getServiceDuration() {
|
||||
return serviceDuration;
|
||||
}
|
||||
|
||||
public void setServiceDurationMinutes(Integer serviceDurationMinutes) {
|
||||
this.serviceDurationMinutes = serviceDurationMinutes;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
public void setServiceDuration(Integer serviceDuration) {
|
||||
this.serviceDuration = serviceDuration;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
@@ -97,23 +87,22 @@ public class ServiceResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ServiceResponse that = (ServiceResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(serviceName, that.serviceName) && Objects.equals(serviceDescription, that.serviceDescription) && Objects.equals(servicePrice, that.servicePrice) && Objects.equals(serviceDurationMinutes, that.serviceDurationMinutes) && Objects.equals(active, that.active) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(serviceId, that.serviceId) && Objects.equals(serviceName, that.serviceName) && Objects.equals(serviceDesc, that.serviceDesc) && Objects.equals(servicePrice, that.servicePrice) && Objects.equals(serviceDuration, that.serviceDuration) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, serviceName, serviceDescription, servicePrice, serviceDurationMinutes, active, createdAt, updatedAt);
|
||||
return Objects.hash(serviceId, serviceName, serviceDesc, servicePrice, serviceDuration, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServiceResponse{" +
|
||||
"id=" + id +
|
||||
"serviceId=" + serviceId +
|
||||
", serviceName='" + serviceName + '\'' +
|
||||
", serviceDescription='" + serviceDescription + '\'' +
|
||||
", serviceDesc='" + serviceDesc + '\'' +
|
||||
", servicePrice=" + servicePrice +
|
||||
", serviceDurationMinutes=" + serviceDurationMinutes +
|
||||
", active=" + active +
|
||||
", serviceDuration=" + serviceDuration +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -5,32 +5,40 @@ import jakarta.validation.constraints.NotBlank;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SupplierRequest {
|
||||
@NotBlank(message = "Supplier name is required")
|
||||
private String supName;
|
||||
@NotBlank(message = "Supplier company is required")
|
||||
private String supCompany;
|
||||
|
||||
private String supContact;
|
||||
private String supContactFirstName;
|
||||
|
||||
private String supContactLastName;
|
||||
|
||||
@Email(message = "Invalid email format")
|
||||
private String supEmail;
|
||||
|
||||
private String supPhone;
|
||||
private String supAddress;
|
||||
private Boolean active = true;
|
||||
|
||||
public String getSupName() {
|
||||
return supName;
|
||||
public String getSupCompany() {
|
||||
return supCompany;
|
||||
}
|
||||
|
||||
public void setSupName(String supName) {
|
||||
this.supName = supName;
|
||||
public void setSupCompany(String supCompany) {
|
||||
this.supCompany = supCompany;
|
||||
}
|
||||
|
||||
public String getSupContact() {
|
||||
return supContact;
|
||||
public String getSupContactFirstName() {
|
||||
return supContactFirstName;
|
||||
}
|
||||
|
||||
public void setSupContact(String supContact) {
|
||||
this.supContact = supContact;
|
||||
public void setSupContactFirstName(String supContactFirstName) {
|
||||
this.supContactFirstName = supContactFirstName;
|
||||
}
|
||||
|
||||
public String getSupContactLastName() {
|
||||
return supContactLastName;
|
||||
}
|
||||
|
||||
public void setSupContactLastName(String supContactLastName) {
|
||||
this.supContactLastName = supContactLastName;
|
||||
}
|
||||
|
||||
public String getSupEmail() {
|
||||
@@ -49,49 +57,31 @@ public class SupplierRequest {
|
||||
this.supPhone = supPhone;
|
||||
}
|
||||
|
||||
public String getSupAddress() {
|
||||
return supAddress;
|
||||
}
|
||||
|
||||
public void setSupAddress(String supAddress) {
|
||||
this.supAddress = supAddress;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SupplierRequest that = (SupplierRequest) o;
|
||||
return Objects.equals(supName, that.supName) &&
|
||||
Objects.equals(supContact, that.supContact) &&
|
||||
return Objects.equals(supCompany, that.supCompany) &&
|
||||
Objects.equals(supContactFirstName, that.supContactFirstName) &&
|
||||
Objects.equals(supContactLastName, that.supContactLastName) &&
|
||||
Objects.equals(supEmail, that.supEmail) &&
|
||||
Objects.equals(supPhone, that.supPhone) &&
|
||||
Objects.equals(supAddress, that.supAddress) &&
|
||||
Objects.equals(active, that.active);
|
||||
Objects.equals(supPhone, that.supPhone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(supName, supContact, supEmail, supPhone, supAddress, active);
|
||||
return Objects.hash(supCompany, supContactFirstName, supContactLastName, supEmail, supPhone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SupplierRequest{" +
|
||||
"supName='" + supName + '\'' +
|
||||
", supContact='" + supContact + '\'' +
|
||||
"supCompany='" + supCompany + '\'' +
|
||||
", supContactFirstName='" + supContactFirstName + '\'' +
|
||||
", supContactLastName='" + supContactLastName + '\'' +
|
||||
", supEmail='" + supEmail + '\'' +
|
||||
", supPhone='" + supPhone + '\'' +
|
||||
", supAddress='" + supAddress + '\'' +
|
||||
", active=" + active +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,85 +4,75 @@ import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SupplierResponse {
|
||||
private Long id;
|
||||
private String supplierName;
|
||||
private String supplierContact;
|
||||
private String supplierEmail;
|
||||
private String supplierPhone;
|
||||
private String supplierAddress;
|
||||
private Boolean active;
|
||||
private Long supId;
|
||||
private String supCompany;
|
||||
private String supContactFirstName;
|
||||
private String supContactLastName;
|
||||
private String supEmail;
|
||||
private String supPhone;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public SupplierResponse() {
|
||||
}
|
||||
|
||||
public SupplierResponse(Long id, String supplierName, String supplierContact, String supplierEmail, String supplierPhone, String supplierAddress, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
this.supplierName = supplierName;
|
||||
this.supplierContact = supplierContact;
|
||||
this.supplierEmail = supplierEmail;
|
||||
this.supplierPhone = supplierPhone;
|
||||
this.supplierAddress = supplierAddress;
|
||||
this.active = active;
|
||||
public SupplierResponse(Long supId, String supCompany, String supContactFirstName, String supContactLastName, String supEmail, String supPhone, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.supId = supId;
|
||||
this.supCompany = supCompany;
|
||||
this.supContactFirstName = supContactFirstName;
|
||||
this.supContactLastName = supContactLastName;
|
||||
this.supEmail = supEmail;
|
||||
this.supPhone = supPhone;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public Long getSupId() {
|
||||
return supId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setSupId(Long supId) {
|
||||
this.supId = supId;
|
||||
}
|
||||
|
||||
public String getSupplierName() {
|
||||
return supplierName;
|
||||
public String getSupCompany() {
|
||||
return supCompany;
|
||||
}
|
||||
|
||||
public void setSupplierName(String supplierName) {
|
||||
this.supplierName = supplierName;
|
||||
public void setSupCompany(String supCompany) {
|
||||
this.supCompany = supCompany;
|
||||
}
|
||||
|
||||
public String getSupplierContact() {
|
||||
return supplierContact;
|
||||
public String getSupContactFirstName() {
|
||||
return supContactFirstName;
|
||||
}
|
||||
|
||||
public void setSupplierContact(String supplierContact) {
|
||||
this.supplierContact = supplierContact;
|
||||
public void setSupContactFirstName(String supContactFirstName) {
|
||||
this.supContactFirstName = supContactFirstName;
|
||||
}
|
||||
|
||||
public String getSupplierEmail() {
|
||||
return supplierEmail;
|
||||
public String getSupContactLastName() {
|
||||
return supContactLastName;
|
||||
}
|
||||
|
||||
public void setSupplierEmail(String supplierEmail) {
|
||||
this.supplierEmail = supplierEmail;
|
||||
public void setSupContactLastName(String supContactLastName) {
|
||||
this.supContactLastName = supContactLastName;
|
||||
}
|
||||
|
||||
public String getSupplierPhone() {
|
||||
return supplierPhone;
|
||||
public String getSupEmail() {
|
||||
return supEmail;
|
||||
}
|
||||
|
||||
public void setSupplierPhone(String supplierPhone) {
|
||||
this.supplierPhone = supplierPhone;
|
||||
public void setSupEmail(String supEmail) {
|
||||
this.supEmail = supEmail;
|
||||
}
|
||||
|
||||
public String getSupplierAddress() {
|
||||
return supplierAddress;
|
||||
public String getSupPhone() {
|
||||
return supPhone;
|
||||
}
|
||||
|
||||
public void setSupplierAddress(String supplierAddress) {
|
||||
this.supplierAddress = supplierAddress;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
public void setSupPhone(String supPhone) {
|
||||
this.supPhone = supPhone;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
@@ -106,24 +96,23 @@ public class SupplierResponse {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SupplierResponse that = (SupplierResponse) o;
|
||||
return Objects.equals(id, that.id) && Objects.equals(supplierName, that.supplierName) && Objects.equals(supplierContact, that.supplierContact) && Objects.equals(supplierEmail, that.supplierEmail) && Objects.equals(supplierPhone, that.supplierPhone) && Objects.equals(supplierAddress, that.supplierAddress) && Objects.equals(active, that.active) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
return Objects.equals(supId, that.supId) && Objects.equals(supCompany, that.supCompany) && Objects.equals(supContactFirstName, that.supContactFirstName) && Objects.equals(supContactLastName, that.supContactLastName) && Objects.equals(supEmail, that.supEmail) && Objects.equals(supPhone, that.supPhone) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, supplierName, supplierContact, supplierEmail, supplierPhone, supplierAddress, active, createdAt, updatedAt);
|
||||
return Objects.hash(supId, supCompany, supContactFirstName, supContactLastName, supEmail, supPhone, createdAt, updatedAt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SupplierResponse{" +
|
||||
"id=" + id +
|
||||
", supplierName='" + supplierName + '\'' +
|
||||
", supplierContact='" + supplierContact + '\'' +
|
||||
", supplierEmail='" + supplierEmail + '\'' +
|
||||
", supplierPhone='" + supplierPhone + '\'' +
|
||||
", supplierAddress='" + supplierAddress + '\'' +
|
||||
", active=" + active +
|
||||
"supId=" + supId +
|
||||
", supCompany='" + supCompany + '\'' +
|
||||
", supContactFirstName='" + supContactFirstName + '\'' +
|
||||
", supContactLastName='" + supContactLastName + '\'' +
|
||||
", supEmail='" + supEmail + '\'' +
|
||||
", supPhone='" + supPhone + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.petshop.backend.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@@ -23,22 +20,12 @@ public class EmployeeStore {
|
||||
@JoinColumn(name = "storeId", nullable = false)
|
||||
private StoreLocation store;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(name = "created_at", updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@UpdateTimestamp
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public EmployeeStore() {
|
||||
}
|
||||
|
||||
public EmployeeStore(Employee employee, StoreLocation store, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
public EmployeeStore(Employee employee, StoreLocation store) {
|
||||
this.employee = employee;
|
||||
this.store = store;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Employee getEmployee() {
|
||||
@@ -57,22 +44,6 @@ public class EmployeeStore {
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -91,8 +62,6 @@ public class EmployeeStore {
|
||||
return "EmployeeStore{" +
|
||||
"employee=" + employee +
|
||||
", store=" + store +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
package com.petshop.backend.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "purchase_order_items")
|
||||
public class PurchaseOrderItem {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "purchase_order_id", nullable = false)
|
||||
private PurchaseOrder purchaseOrder;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "product_id", nullable = false)
|
||||
private Product product;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer quantity;
|
||||
|
||||
@Column(name = "unit_cost", nullable = false, precision = 10, scale = 2)
|
||||
private BigDecimal unitCost;
|
||||
|
||||
@Column(nullable = false, precision = 10, scale = 2)
|
||||
private BigDecimal subtotal;
|
||||
|
||||
public PurchaseOrderItem() {
|
||||
}
|
||||
|
||||
public PurchaseOrderItem(Long id, PurchaseOrder purchaseOrder, Product product, Integer quantity, BigDecimal unitCost, BigDecimal subtotal) {
|
||||
this.id = id;
|
||||
this.purchaseOrder = purchaseOrder;
|
||||
this.product = product;
|
||||
this.quantity = quantity;
|
||||
this.unitCost = unitCost;
|
||||
this.subtotal = subtotal;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public PurchaseOrder getPurchaseOrder() {
|
||||
return purchaseOrder;
|
||||
}
|
||||
|
||||
public void setPurchaseOrder(PurchaseOrder purchaseOrder) {
|
||||
this.purchaseOrder = purchaseOrder;
|
||||
}
|
||||
|
||||
public Product getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
public void setProduct(Product product) {
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public BigDecimal getUnitCost() {
|
||||
return unitCost;
|
||||
}
|
||||
|
||||
public void setUnitCost(BigDecimal unitCost) {
|
||||
this.unitCost = unitCost;
|
||||
}
|
||||
|
||||
public BigDecimal getSubtotal() {
|
||||
return subtotal;
|
||||
}
|
||||
|
||||
public void setSubtotal(BigDecimal subtotal) {
|
||||
this.subtotal = subtotal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PurchaseOrderItem that = (PurchaseOrderItem) o;
|
||||
return Objects.equals(id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PurchaseOrderItem{" +
|
||||
"id=" + id +
|
||||
", purchaseOrder=" + purchaseOrder +
|
||||
", product=" + product +
|
||||
", quantity=" + quantity +
|
||||
", unitCost=" + unitCost +
|
||||
", subtotal=" + subtotal +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.petshop.backend.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -48,10 +49,14 @@ public class Sale {
|
||||
@Column(name = "created_at", updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@UpdateTimestamp
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Sale() {
|
||||
}
|
||||
|
||||
public Sale(Long saleId, LocalDateTime saleDate, Employee employee, StoreLocation store, BigDecimal totalAmount, String paymentMethod, Boolean isRefund, Sale originalSale, List<SaleItem> items, LocalDateTime createdAt) {
|
||||
public Sale(Long saleId, LocalDateTime saleDate, Employee employee, StoreLocation store, BigDecimal totalAmount, String paymentMethod, Boolean isRefund, Sale originalSale, List<SaleItem> items, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.saleId = saleId;
|
||||
this.saleDate = saleDate;
|
||||
this.employee = employee;
|
||||
@@ -62,6 +67,7 @@ public class Sale {
|
||||
this.originalSale = originalSale;
|
||||
this.items = items;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getSaleId() {
|
||||
@@ -144,6 +150,14 @@ public class Sale {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -170,6 +184,7 @@ public class Sale {
|
||||
", originalSale=" + originalSale +
|
||||
", items=" + items +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.petshop.backend.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@@ -27,15 +30,25 @@ public class SaleItem {
|
||||
@Column(nullable = false, precision = 10, scale = 2)
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(name = "created_at", updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@UpdateTimestamp
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public SaleItem() {
|
||||
}
|
||||
|
||||
public SaleItem(Long saleItemId, Sale sale, Product product, Integer quantity, BigDecimal unitPrice) {
|
||||
public SaleItem(Long saleItemId, Sale sale, Product product, Integer quantity, BigDecimal unitPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.saleItemId = saleItemId;
|
||||
this.sale = sale;
|
||||
this.product = product;
|
||||
this.quantity = quantity;
|
||||
this.unitPrice = unitPrice;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getSaleItemId() {
|
||||
@@ -78,6 +91,22 @@ public class SaleItem {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -99,6 +128,8 @@ public class SaleItem {
|
||||
", product=" + product +
|
||||
", quantity=" + quantity +
|
||||
", unitPrice=" + unitPrice +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,19 +21,10 @@ public class User {
|
||||
@Column(nullable = false)
|
||||
private String password;
|
||||
|
||||
@Column(name = "full_name", nullable = false, length = 100)
|
||||
private String fullName;
|
||||
|
||||
@Column(length = 100)
|
||||
private String email;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false)
|
||||
@Column(nullable = false, length = 20, columnDefinition = "VARCHAR(20)")
|
||||
private Role role;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Boolean active = true;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(name = "created_at", updatable = false)
|
||||
private LocalDateTime createdAt;
|
||||
@@ -49,14 +40,11 @@ public class User {
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(Long id, String username, String password, String fullName, String email, Role role, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
public User(Long id, String username, String password, Role role, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.fullName = fullName;
|
||||
this.email = email;
|
||||
this.role = role;
|
||||
this.active = active;
|
||||
this.createdAt = createdAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
@@ -85,22 +73,6 @@ public class User {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Role getRole() {
|
||||
return role;
|
||||
}
|
||||
@@ -109,14 +81,6 @@ public class User {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(Boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
@@ -152,10 +116,7 @@ public class User {
|
||||
"id=" + id +
|
||||
", username='" + username + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", fullName='" + fullName + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", role=" + role +
|
||||
", active=" + active +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
|
||||
@@ -12,7 +12,8 @@ import org.springframework.stereotype.Repository;
|
||||
public interface AdoptionRepository extends JpaRepository<Adoption, Long> {
|
||||
|
||||
@Query("SELECT a FROM Adoption a WHERE " +
|
||||
"LOWER(a.customer.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(a.customer.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(a.customer.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(a.pet.petName) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Adoption> searchAdoptions(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@ public interface AppointmentRepository extends JpaRepository<Appointment, Long>
|
||||
@Query("SELECT a FROM Appointment a WHERE a.appointmentDate = :date AND a.appointmentTime = :time")
|
||||
List<Appointment> findByDateAndTime(@Param("date") LocalDate date, @Param("time") LocalTime time);
|
||||
|
||||
@Query("SELECT a FROM Appointment a WHERE a.service.id = :serviceId AND a.appointmentDate = :date AND a.status != 'Cancelled'")
|
||||
@Query("SELECT a FROM Appointment a WHERE a.service.serviceId = :serviceId AND a.appointmentDate = :date AND a.appointmentStatus != 'Cancelled'")
|
||||
List<Appointment> findByServiceAndDate(@Param("serviceId") Long serviceId, @Param("date") LocalDate date);
|
||||
|
||||
@Query("SELECT DISTINCT a FROM Appointment a LEFT JOIN a.pets p WHERE " +
|
||||
"LOWER(a.customer.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(a.customer.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(a.customer.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(a.service.serviceName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(p.petName) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Appointment> searchAppointments(@Param("q") String query, Pageable pageable);
|
||||
|
||||
@@ -17,6 +17,6 @@ public interface CategoryRepository extends JpaRepository<Category, Long> {
|
||||
|
||||
@Query("SELECT c FROM Category c WHERE " +
|
||||
"LOWER(c.categoryName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(c.categoryDescription) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
"LOWER(c.categoryType) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Category> searchCategories(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,9 @@ import org.springframework.stereotype.Repository;
|
||||
public interface CustomerRepository extends JpaRepository<Customer, Long> {
|
||||
|
||||
@Query("SELECT c FROM Customer c WHERE " +
|
||||
"LOWER(c.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(c.customerEmail) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(c.customerPhone) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
"LOWER(c.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(c.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(c.email) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(c.phone) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Customer> searchCustomers(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ import java.util.Optional;
|
||||
@Repository
|
||||
public interface InventoryRepository extends JpaRepository<Inventory, Long> {
|
||||
|
||||
@Query("SELECT i FROM Inventory i WHERE i.product.id = :productId AND i.store.id = :storeId")
|
||||
Optional<Inventory> findByProductIdAndStoreId(@Param("productId") Long productId, @Param("storeId") Long storeId);
|
||||
@Query("SELECT i FROM Inventory i WHERE i.product.prodId = :productId")
|
||||
Optional<Inventory> findByProductId(@Param("productId") Long productId);
|
||||
|
||||
@Query("SELECT i FROM Inventory i WHERE " +
|
||||
"LOWER(i.product.productName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(i.store.storeName) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
"LOWER(i.product.prodName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(i.product.category.categoryName) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Inventory> searchInventory(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Repository;
|
||||
public interface ProductRepository extends JpaRepository<Product, Long> {
|
||||
|
||||
@Query("SELECT p FROM Product p WHERE " +
|
||||
"LOWER(p.productName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(p.productDescription) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
"LOWER(p.prodName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(p.prodDesc) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Product> searchProducts(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Repository;
|
||||
public interface ProductSupplierRepository extends JpaRepository<ProductSupplier, ProductSupplier.ProductSupplierId> {
|
||||
|
||||
@Query("SELECT ps FROM ProductSupplier ps WHERE " +
|
||||
"LOWER(ps.product.productName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(ps.supplier.supplierName) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
"LOWER(ps.product.prodName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(ps.supplier.supCompany) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<ProductSupplier> searchProductSuppliers(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.springframework.stereotype.Repository;
|
||||
public interface PurchaseOrderRepository extends JpaRepository<PurchaseOrder, Long> {
|
||||
|
||||
@Query("SELECT po FROM PurchaseOrder po WHERE " +
|
||||
"LOWER(po.supplier.supplierName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(po.notes) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
"LOWER(po.supplier.supCompany) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<PurchaseOrder> searchPurchaseOrders(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import org.springframework.stereotype.Repository;
|
||||
public interface SaleRepository extends JpaRepository<Sale, Long> {
|
||||
|
||||
@Query("SELECT s FROM Sale s WHERE " +
|
||||
"LOWER(s.customer.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(s.employee.fullName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(s.employee.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(s.employee.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(s.store.storeName) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Sale> searchSales(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ public interface ServiceRepository extends JpaRepository<Service, Long> {
|
||||
|
||||
@Query("SELECT s FROM Service s WHERE " +
|
||||
"LOWER(s.serviceName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(s.serviceDescription) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
"LOWER(s.serviceDesc) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Service> searchServices(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ import org.springframework.stereotype.Repository;
|
||||
public interface SupplierRepository extends JpaRepository<Supplier, Long> {
|
||||
|
||||
@Query("SELECT s FROM Supplier s WHERE " +
|
||||
"LOWER(s.supplierName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(s.supplierContact) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
"LOWER(s.supCompany) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(s.supContactFirstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(s.supContactLastName) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<Supplier> searchSuppliers(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ public interface UserRepository extends JpaRepository<User, Long> {
|
||||
boolean existsByUsername(String username);
|
||||
|
||||
@Query("SELECT u FROM User u WHERE " +
|
||||
"LOWER(u.username) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(u.fullName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
|
||||
"LOWER(u.email) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
"LOWER(u.username) LIKE LOWER(CONCAT('%', :q, '%'))")
|
||||
Page<User> searchUsers(@Param("q") String query, Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -24,10 +24,6 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
User user = userRepository.findByUsername(username)
|
||||
.orElseThrow(() -> new UsernameNotFoundException("User not found: " + username));
|
||||
|
||||
if (!user.getActive()) {
|
||||
throw new UsernameNotFoundException("User is inactive: " + username);
|
||||
}
|
||||
|
||||
return new org.springframework.security.core.userdetails.User(
|
||||
user.getUsername(),
|
||||
user.getPassword(),
|
||||
|
||||
@@ -56,8 +56,7 @@ public class AdoptionService {
|
||||
adoption.setPet(pet);
|
||||
adoption.setCustomer(customer);
|
||||
adoption.setAdoptionDate(request.getAdoptionDate());
|
||||
adoption.setAdoptionFee(request.getAdoptionFee());
|
||||
adoption.setNotes(request.getNotes());
|
||||
adoption.setAdoptionStatus(request.getAdoptionStatus());
|
||||
|
||||
adoption = adoptionRepository.save(adoption);
|
||||
return mapToResponse(adoption);
|
||||
@@ -77,8 +76,7 @@ public class AdoptionService {
|
||||
adoption.setPet(pet);
|
||||
adoption.setCustomer(customer);
|
||||
adoption.setAdoptionDate(request.getAdoptionDate());
|
||||
adoption.setAdoptionFee(request.getAdoptionFee());
|
||||
adoption.setNotes(request.getNotes());
|
||||
adoption.setAdoptionStatus(request.getAdoptionStatus());
|
||||
|
||||
adoption = adoptionRepository.save(adoption);
|
||||
return mapToResponse(adoption);
|
||||
@@ -99,14 +97,13 @@ public class AdoptionService {
|
||||
|
||||
private AdoptionResponse mapToResponse(Adoption adoption) {
|
||||
return new AdoptionResponse(
|
||||
adoption.getId(),
|
||||
adoption.getPet().getId(),
|
||||
adoption.getAdoptionId(),
|
||||
adoption.getPet().getPetId(),
|
||||
adoption.getPet().getPetName(),
|
||||
adoption.getCustomer().getId(),
|
||||
adoption.getCustomer().getCustomerName(),
|
||||
adoption.getCustomer().getCustomerId(),
|
||||
adoption.getCustomer().getFirstName() + " " + adoption.getCustomer().getLastName(),
|
||||
adoption.getAdoptionDate(),
|
||||
adoption.getAdoptionFee(),
|
||||
adoption.getNotes(),
|
||||
adoption.getAdoptionStatus(),
|
||||
adoption.getCreatedAt(),
|
||||
adoption.getUpdatedAt()
|
||||
);
|
||||
|
||||
@@ -3,11 +3,9 @@ package com.petshop.backend.service;
|
||||
import com.petshop.backend.dto.analytics.DashboardResponse;
|
||||
import com.petshop.backend.entity.Inventory;
|
||||
import com.petshop.backend.entity.Product;
|
||||
import com.petshop.backend.entity.Refund;
|
||||
import com.petshop.backend.entity.Sale;
|
||||
import com.petshop.backend.repository.InventoryRepository;
|
||||
import com.petshop.backend.repository.ProductRepository;
|
||||
import com.petshop.backend.repository.RefundRepository;
|
||||
import com.petshop.backend.repository.SaleRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -22,14 +20,12 @@ import java.util.stream.Collectors;
|
||||
public class AnalyticsService {
|
||||
|
||||
private final SaleRepository saleRepository;
|
||||
private final RefundRepository refundRepository;
|
||||
private final InventoryRepository inventoryRepository;
|
||||
private final ProductRepository productRepository;
|
||||
|
||||
public AnalyticsService(SaleRepository saleRepository, RefundRepository refundRepository,
|
||||
public AnalyticsService(SaleRepository saleRepository,
|
||||
InventoryRepository inventoryRepository, ProductRepository productRepository) {
|
||||
this.saleRepository = saleRepository;
|
||||
this.refundRepository = refundRepository;
|
||||
this.inventoryRepository = inventoryRepository;
|
||||
this.productRepository = productRepository;
|
||||
}
|
||||
@@ -41,11 +37,7 @@ public class AnalyticsService {
|
||||
.filter(sale -> sale.getSaleDate().isAfter(startDate))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Refund> refunds = refundRepository.findAll().stream()
|
||||
.filter(refund -> refund.getRefundDate().isAfter(startDate))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
DashboardResponse.SalesSummary salesSummary = calculateSalesSummary(sales, refunds);
|
||||
DashboardResponse.SalesSummary salesSummary = calculateSalesSummary(sales);
|
||||
DashboardResponse.InventorySummary inventorySummary = calculateInventorySummary();
|
||||
List<DashboardResponse.TopProduct> topProducts = calculateTopProducts(sales, top);
|
||||
List<DashboardResponse.DailySales> dailySales = calculateDailySales(sales, days);
|
||||
@@ -53,18 +45,24 @@ public class AnalyticsService {
|
||||
return new DashboardResponse(salesSummary, inventorySummary, topProducts, dailySales);
|
||||
}
|
||||
|
||||
private DashboardResponse.SalesSummary calculateSalesSummary(List<Sale> sales, List<Refund> refunds) {
|
||||
private DashboardResponse.SalesSummary calculateSalesSummary(List<Sale> sales) {
|
||||
BigDecimal totalRevenue = sales.stream()
|
||||
.map(Sale::getTotal)
|
||||
.filter(sale -> !sale.getIsRefund())
|
||||
.map(Sale::getTotalAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
Long totalSales = (long) sales.size();
|
||||
Long totalSales = sales.stream()
|
||||
.filter(sale -> !sale.getIsRefund())
|
||||
.count();
|
||||
|
||||
BigDecimal totalRefunds = refunds.stream()
|
||||
.map(Refund::getRefundAmount)
|
||||
BigDecimal totalRefunds = sales.stream()
|
||||
.filter(Sale::getIsRefund)
|
||||
.map(Sale::getTotalAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
Long totalRefundCount = (long) refunds.size();
|
||||
Long totalRefundCount = sales.stream()
|
||||
.filter(Sale::getIsRefund)
|
||||
.count();
|
||||
|
||||
return new DashboardResponse.SalesSummary(totalRevenue, totalSales, totalRefunds, totalRefundCount);
|
||||
}
|
||||
@@ -75,14 +73,14 @@ public class AnalyticsService {
|
||||
Long totalProducts = productRepository.count();
|
||||
|
||||
Long lowStockProducts = allInventory.stream()
|
||||
.filter(inv -> inv.getQuantity() > 0 && inv.getQuantity() <= inv.getReorderLevel())
|
||||
.map(inv -> inv.getProduct().getId())
|
||||
.filter(inv -> inv.getQuantity() > 0 && inv.getQuantity() <= 10)
|
||||
.map(inv -> inv.getProduct().getProdId())
|
||||
.distinct()
|
||||
.count();
|
||||
|
||||
Long outOfStockProducts = allInventory.stream()
|
||||
.filter(inv -> inv.getQuantity() == 0)
|
||||
.map(inv -> inv.getProduct().getId())
|
||||
.map(inv -> inv.getProduct().getProdId())
|
||||
.distinct()
|
||||
.count();
|
||||
|
||||
@@ -94,10 +92,10 @@ public class AnalyticsService {
|
||||
|
||||
for (Sale sale : sales) {
|
||||
for (var item : sale.getItems()) {
|
||||
Long productId = item.getProduct().getId();
|
||||
String productName = item.getProduct().getProductName();
|
||||
Long productId = item.getProduct().getProdId();
|
||||
String productName = item.getProduct().getProdName();
|
||||
Long quantitySold = Long.valueOf(item.getQuantity());
|
||||
BigDecimal revenue = item.getSubtotal();
|
||||
BigDecimal revenue = item.getUnitPrice().multiply(BigDecimal.valueOf(item.getQuantity()));
|
||||
|
||||
productSalesMap.compute(productId, (key, existing) -> {
|
||||
if (existing == null) {
|
||||
@@ -131,7 +129,7 @@ public class AnalyticsService {
|
||||
LocalDate saleDate = sale.getSaleDate().toLocalDate();
|
||||
if (dailySalesMap.containsKey(saleDate)) {
|
||||
DashboardResponse.DailySales dailySale = dailySalesMap.get(saleDate);
|
||||
dailySale.setRevenue(dailySale.getRevenue().add(sale.getTotal()));
|
||||
dailySale.setRevenue(dailySale.getRevenue().add(sale.getTotalAmount()));
|
||||
dailySale.setSalesCount(dailySale.getSalesCount() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,9 +70,8 @@ public class AppointmentService {
|
||||
appointment.setService(service);
|
||||
appointment.setAppointmentDate(request.getAppointmentDate());
|
||||
appointment.setAppointmentTime(request.getAppointmentTime());
|
||||
appointment.setStatus(request.getStatus());
|
||||
appointment.setAppointmentStatus(request.getAppointmentStatus());
|
||||
appointment.setPets(pets);
|
||||
appointment.setNotes(request.getNotes());
|
||||
|
||||
appointment = appointmentRepository.save(appointment);
|
||||
return mapToResponse(appointment);
|
||||
@@ -95,9 +94,8 @@ public class AppointmentService {
|
||||
appointment.setService(service);
|
||||
appointment.setAppointmentDate(request.getAppointmentDate());
|
||||
appointment.setAppointmentTime(request.getAppointmentTime());
|
||||
appointment.setStatus(request.getStatus());
|
||||
appointment.setAppointmentStatus(request.getAppointmentStatus());
|
||||
appointment.setPets(pets);
|
||||
appointment.setNotes(request.getNotes());
|
||||
|
||||
appointment = appointmentRepository.save(appointment);
|
||||
return mapToResponse(appointment);
|
||||
@@ -156,21 +154,20 @@ public class AppointmentService {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Long> petIds = appointment.getPets().stream()
|
||||
.map(Pet::getId)
|
||||
.map(Pet::getPetId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new AppointmentResponse(
|
||||
appointment.getId(),
|
||||
appointment.getCustomer().getId(),
|
||||
appointment.getCustomer().getCustomerName(),
|
||||
appointment.getService().getId(),
|
||||
appointment.getAppointmentId(),
|
||||
appointment.getCustomer().getCustomerId(),
|
||||
appointment.getCustomer().getFirstName() + " " + appointment.getCustomer().getLastName(),
|
||||
appointment.getService().getServiceId(),
|
||||
appointment.getService().getServiceName(),
|
||||
appointment.getAppointmentDate(),
|
||||
appointment.getAppointmentTime(),
|
||||
appointment.getStatus() != null ? appointment.getStatus().toString() : null,
|
||||
appointment.getAppointmentStatus(),
|
||||
petNames,
|
||||
petIds,
|
||||
appointment.getNotes(),
|
||||
appointment.getCreatedAt(),
|
||||
appointment.getUpdatedAt()
|
||||
);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class CategoryService {
|
||||
public CategoryResponse createCategory(CategoryRequest request) {
|
||||
Category category = new Category();
|
||||
category.setCategoryName(request.getCategoryName());
|
||||
category.setCategoryDescription(request.getCategoryDescription());
|
||||
category.setCategoryType(request.getCategoryType());
|
||||
|
||||
category = categoryRepository.save(category);
|
||||
return mapToResponse(category);
|
||||
@@ -52,7 +52,7 @@ public class CategoryService {
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + id));
|
||||
|
||||
category.setCategoryName(request.getCategoryName());
|
||||
category.setCategoryDescription(request.getCategoryDescription());
|
||||
category.setCategoryType(request.getCategoryType());
|
||||
|
||||
category = categoryRepository.save(category);
|
||||
return mapToResponse(category);
|
||||
@@ -73,9 +73,9 @@ public class CategoryService {
|
||||
|
||||
private CategoryResponse mapToResponse(Category category) {
|
||||
return new CategoryResponse(
|
||||
category.getId(),
|
||||
category.getCategoryId(),
|
||||
category.getCategoryName(),
|
||||
category.getCategoryDescription(),
|
||||
category.getCategoryType(),
|
||||
category.getCreatedAt(),
|
||||
category.getUpdatedAt()
|
||||
);
|
||||
|
||||
@@ -39,10 +39,10 @@ public class CustomerService {
|
||||
@Transactional
|
||||
public CustomerResponse createCustomer(CustomerRequest request) {
|
||||
Customer customer = new Customer();
|
||||
customer.setCustomerName(request.getCustomerName());
|
||||
customer.setCustomerEmail(request.getCustomerEmail());
|
||||
customer.setCustomerPhone(request.getCustomerPhone());
|
||||
customer.setCustomerAddress(request.getCustomerAddress());
|
||||
customer.setFirstName(request.getFirstName());
|
||||
customer.setLastName(request.getLastName());
|
||||
customer.setEmail(request.getEmail());
|
||||
customer.setPhone(request.getPhone());
|
||||
|
||||
customer = customerRepository.save(customer);
|
||||
return mapToResponse(customer);
|
||||
@@ -53,10 +53,10 @@ public class CustomerService {
|
||||
Customer customer = customerRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Customer not found with id: " + id));
|
||||
|
||||
customer.setCustomerName(request.getCustomerName());
|
||||
customer.setCustomerEmail(request.getCustomerEmail());
|
||||
customer.setCustomerPhone(request.getCustomerPhone());
|
||||
customer.setCustomerAddress(request.getCustomerAddress());
|
||||
customer.setFirstName(request.getFirstName());
|
||||
customer.setLastName(request.getLastName());
|
||||
customer.setEmail(request.getEmail());
|
||||
customer.setPhone(request.getPhone());
|
||||
|
||||
customer = customerRepository.save(customer);
|
||||
return mapToResponse(customer);
|
||||
@@ -77,11 +77,11 @@ public class CustomerService {
|
||||
|
||||
private CustomerResponse mapToResponse(Customer customer) {
|
||||
return new CustomerResponse(
|
||||
customer.getId(),
|
||||
customer.getCustomerName(),
|
||||
customer.getCustomerEmail(),
|
||||
customer.getCustomerPhone(),
|
||||
customer.getCustomerAddress(),
|
||||
customer.getCustomerId(),
|
||||
customer.getFirstName(),
|
||||
customer.getLastName(),
|
||||
customer.getEmail(),
|
||||
customer.getPhone(),
|
||||
customer.getCreatedAt(),
|
||||
customer.getUpdatedAt()
|
||||
);
|
||||
|
||||
@@ -5,29 +5,23 @@ import com.petshop.backend.dto.inventory.InventoryRequest;
|
||||
import com.petshop.backend.dto.inventory.InventoryResponse;
|
||||
import com.petshop.backend.entity.Inventory;
|
||||
import com.petshop.backend.entity.Product;
|
||||
import com.petshop.backend.entity.Store;
|
||||
import com.petshop.backend.exception.ResourceNotFoundException;
|
||||
import com.petshop.backend.repository.InventoryRepository;
|
||||
import com.petshop.backend.repository.ProductRepository;
|
||||
import com.petshop.backend.repository.StoreRepository;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Service
|
||||
public class InventoryService {
|
||||
|
||||
private final InventoryRepository inventoryRepository;
|
||||
private final ProductRepository productRepository;
|
||||
private final StoreRepository storeRepository;
|
||||
|
||||
public InventoryService(InventoryRepository inventoryRepository, ProductRepository productRepository, StoreRepository storeRepository) {
|
||||
public InventoryService(InventoryRepository inventoryRepository, ProductRepository productRepository) {
|
||||
this.inventoryRepository = inventoryRepository;
|
||||
this.productRepository = productRepository;
|
||||
this.storeRepository = storeRepository;
|
||||
}
|
||||
|
||||
public Page<InventoryResponse> getAllInventory(String query, Pageable pageable) {
|
||||
@@ -51,18 +45,9 @@ public class InventoryService {
|
||||
Product product = productRepository.findById(request.getProdId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + request.getProdId()));
|
||||
|
||||
Store store = null;
|
||||
if (request.getStoreId() != null) {
|
||||
store = storeRepository.findById(request.getStoreId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Store not found with id: " + request.getStoreId()));
|
||||
}
|
||||
|
||||
Inventory inventory = new Inventory();
|
||||
inventory.setProduct(product);
|
||||
inventory.setStore(store);
|
||||
inventory.setQuantity(request.getQuantity());
|
||||
inventory.setReorderLevel(request.getReorderLevel());
|
||||
inventory.setLastRestocked(LocalDateTime.now());
|
||||
|
||||
inventory = inventoryRepository.save(inventory);
|
||||
return mapToResponse(inventory);
|
||||
@@ -76,17 +61,8 @@ public class InventoryService {
|
||||
Product product = productRepository.findById(request.getProdId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + request.getProdId()));
|
||||
|
||||
Store store = null;
|
||||
if (request.getStoreId() != null) {
|
||||
store = storeRepository.findById(request.getStoreId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Store not found with id: " + request.getStoreId()));
|
||||
}
|
||||
|
||||
inventory.setProduct(product);
|
||||
inventory.setStore(store);
|
||||
inventory.setQuantity(request.getQuantity());
|
||||
inventory.setReorderLevel(request.getReorderLevel());
|
||||
inventory.setLastRestocked(LocalDateTime.now());
|
||||
|
||||
inventory = inventoryRepository.save(inventory);
|
||||
return mapToResponse(inventory);
|
||||
@@ -107,15 +83,11 @@ public class InventoryService {
|
||||
|
||||
private InventoryResponse mapToResponse(Inventory inventory) {
|
||||
return new InventoryResponse(
|
||||
inventory.getId(),
|
||||
inventory.getProduct().getId(),
|
||||
inventory.getProduct().getProductName(),
|
||||
inventory.getInventoryId(),
|
||||
inventory.getProduct().getProdId(),
|
||||
inventory.getProduct().getProdName(),
|
||||
inventory.getProduct().getCategory().getCategoryName(),
|
||||
inventory.getStore() != null ? inventory.getStore().getId() : null,
|
||||
inventory.getStore() != null ? inventory.getStore().getStoreName() : null,
|
||||
inventory.getQuantity(),
|
||||
inventory.getReorderLevel(),
|
||||
inventory.getLastRestocked(),
|
||||
inventory.getCreatedAt(),
|
||||
inventory.getUpdatedAt()
|
||||
);
|
||||
|
||||
@@ -46,11 +46,10 @@ public class ProductService {
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId()));
|
||||
|
||||
Product product = new Product();
|
||||
product.setProductName(request.getProdName());
|
||||
product.setProdName(request.getProdName());
|
||||
product.setCategory(category);
|
||||
product.setProductDescription(request.getProdDesc());
|
||||
product.setProductPrice(request.getProdPrice());
|
||||
product.setActive(request.getActive() != null ? request.getActive() : true);
|
||||
product.setProdDesc(request.getProdDesc());
|
||||
product.setProdPrice(request.getProdPrice());
|
||||
|
||||
product = productRepository.save(product);
|
||||
return mapToResponse(product);
|
||||
@@ -64,11 +63,10 @@ public class ProductService {
|
||||
Category category = categoryRepository.findById(request.getCategoryId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId()));
|
||||
|
||||
product.setProductName(request.getProdName());
|
||||
product.setProdName(request.getProdName());
|
||||
product.setCategory(category);
|
||||
product.setProductDescription(request.getProdDesc());
|
||||
product.setProductPrice(request.getProdPrice());
|
||||
product.setActive(request.getActive() != null ? request.getActive() : true);
|
||||
product.setProdDesc(request.getProdDesc());
|
||||
product.setProdPrice(request.getProdPrice());
|
||||
|
||||
product = productRepository.save(product);
|
||||
return mapToResponse(product);
|
||||
@@ -89,13 +87,12 @@ public class ProductService {
|
||||
|
||||
private ProductResponse mapToResponse(Product product) {
|
||||
return new ProductResponse(
|
||||
product.getId(),
|
||||
product.getProductName(),
|
||||
product.getCategory().getId(),
|
||||
product.getProdId(),
|
||||
product.getProdName(),
|
||||
product.getCategory().getCategoryId(),
|
||||
product.getCategory().getCategoryName(),
|
||||
product.getProductDescription(),
|
||||
product.getProductPrice(),
|
||||
product.getActive(),
|
||||
product.getProdDesc(),
|
||||
product.getProdPrice(),
|
||||
product.getCreatedAt(),
|
||||
product.getUpdatedAt()
|
||||
);
|
||||
|
||||
@@ -57,9 +57,7 @@ public class ProductSupplierService {
|
||||
ProductSupplier productSupplier = new ProductSupplier();
|
||||
productSupplier.setProduct(product);
|
||||
productSupplier.setSupplier(supplier);
|
||||
productSupplier.setCostPrice(request.getCostPrice());
|
||||
productSupplier.setLeadTimeDays(request.getLeadTimeDays());
|
||||
productSupplier.setIsPreferred(request.getIsPreferred());
|
||||
productSupplier.setCost(request.getCost());
|
||||
|
||||
productSupplier = productSupplierRepository.save(productSupplier);
|
||||
return mapToResponse(productSupplier);
|
||||
@@ -72,9 +70,7 @@ public class ProductSupplierService {
|
||||
.orElseThrow(() -> new ResourceNotFoundException(
|
||||
"ProductSupplier not found with productId: " + productId + " and supplierId: " + supplierId));
|
||||
|
||||
productSupplier.setCostPrice(request.getCostPrice());
|
||||
productSupplier.setLeadTimeDays(request.getLeadTimeDays());
|
||||
productSupplier.setIsPreferred(request.getIsPreferred());
|
||||
productSupplier.setCost(request.getCost());
|
||||
|
||||
productSupplier = productSupplierRepository.save(productSupplier);
|
||||
return mapToResponse(productSupplier);
|
||||
@@ -101,13 +97,11 @@ public class ProductSupplierService {
|
||||
|
||||
private ProductSupplierResponse mapToResponse(ProductSupplier productSupplier) {
|
||||
return new ProductSupplierResponse(
|
||||
productSupplier.getProduct().getId(),
|
||||
productSupplier.getProduct().getProductName(),
|
||||
productSupplier.getSupplier().getId(),
|
||||
productSupplier.getSupplier().getSupplierName(),
|
||||
productSupplier.getCostPrice(),
|
||||
productSupplier.getLeadTimeDays(),
|
||||
productSupplier.getIsPreferred(),
|
||||
productSupplier.getProduct().getProdId(),
|
||||
productSupplier.getProduct().getProdName(),
|
||||
productSupplier.getSupplier().getSupId(),
|
||||
productSupplier.getSupplier().getSupCompany(),
|
||||
productSupplier.getCost(),
|
||||
productSupplier.getCreatedAt(),
|
||||
productSupplier.getUpdatedAt()
|
||||
);
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
package com.petshop.backend.service;
|
||||
|
||||
import com.petshop.backend.dto.purchaseorder.PurchaseOrderResponse;
|
||||
import com.petshop.backend.dto.purchaseorder.PurchaseOrderResponse.PurchaseOrderItemResponse;
|
||||
import com.petshop.backend.entity.PurchaseOrder;
|
||||
import com.petshop.backend.entity.PurchaseOrderItem;
|
||||
import com.petshop.backend.exception.ResourceNotFoundException;
|
||||
import com.petshop.backend.repository.PurchaseOrderRepository;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class PurchaseOrderService {
|
||||
|
||||
@@ -39,33 +34,14 @@ public class PurchaseOrderService {
|
||||
}
|
||||
|
||||
private PurchaseOrderResponse mapToResponse(PurchaseOrder purchaseOrder) {
|
||||
List<PurchaseOrderItemResponse> items = purchaseOrder.getItems().stream()
|
||||
.map(this::mapItemToResponse)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new PurchaseOrderResponse(
|
||||
purchaseOrder.getId(),
|
||||
purchaseOrder.getSupplier().getId(),
|
||||
purchaseOrder.getSupplier().getSupplierName(),
|
||||
purchaseOrder.getPurchaseOrderId(),
|
||||
purchaseOrder.getSupplier().getSupId(),
|
||||
purchaseOrder.getSupplier().getSupCompany(),
|
||||
purchaseOrder.getOrderDate(),
|
||||
purchaseOrder.getExpectedDelivery(),
|
||||
purchaseOrder.getStatus().toString(),
|
||||
purchaseOrder.getTotalAmount(),
|
||||
purchaseOrder.getNotes(),
|
||||
items,
|
||||
purchaseOrder.getStatus(),
|
||||
purchaseOrder.getCreatedAt(),
|
||||
purchaseOrder.getUpdatedAt()
|
||||
);
|
||||
}
|
||||
|
||||
private PurchaseOrderItemResponse mapItemToResponse(PurchaseOrderItem item) {
|
||||
return new PurchaseOrderItemResponse(
|
||||
item.getId(),
|
||||
item.getProduct().getId(),
|
||||
item.getProduct().getProductName(),
|
||||
item.getQuantity(),
|
||||
item.getUnitCost(),
|
||||
item.getSubtotal()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,18 +22,16 @@ public class SaleService {
|
||||
|
||||
private final SaleRepository saleRepository;
|
||||
private final ProductRepository productRepository;
|
||||
private final CustomerRepository customerRepository;
|
||||
private final StoreRepository storeRepository;
|
||||
private final InventoryRepository inventoryRepository;
|
||||
private final UserRepository userRepository;
|
||||
private final EmployeeRepository employeeRepository;
|
||||
|
||||
public SaleService(SaleRepository saleRepository, ProductRepository productRepository, CustomerRepository customerRepository, StoreRepository storeRepository, InventoryRepository inventoryRepository, UserRepository userRepository) {
|
||||
public SaleService(SaleRepository saleRepository, ProductRepository productRepository, StoreRepository storeRepository, InventoryRepository inventoryRepository, EmployeeRepository employeeRepository) {
|
||||
this.saleRepository = saleRepository;
|
||||
this.productRepository = productRepository;
|
||||
this.customerRepository = customerRepository;
|
||||
this.storeRepository = storeRepository;
|
||||
this.inventoryRepository = inventoryRepository;
|
||||
this.userRepository = userRepository;
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
public Page<SaleResponse> getAllSales(String query, Pageable pageable) {
|
||||
@@ -54,62 +52,58 @@ public class SaleService {
|
||||
|
||||
@Transactional
|
||||
public SaleResponse createSale(SaleRequest request) {
|
||||
String username = SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
User employee = userRepository.findByUsername(username)
|
||||
.orElseThrow(() -> new ResourceNotFoundException("User not found: " + username));
|
||||
Employee employee = employeeRepository.findAll().stream()
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new ResourceNotFoundException("No employees found"));
|
||||
|
||||
Store store = storeRepository.findById(request.getStoreId())
|
||||
StoreLocation store = storeRepository.findById(request.getStoreId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Store not found with id: " + request.getStoreId()));
|
||||
|
||||
Customer customer = null;
|
||||
if (request.getCustomerId() != null) {
|
||||
customer = customerRepository.findById(request.getCustomerId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Customer not found with id: " + request.getCustomerId()));
|
||||
}
|
||||
|
||||
Sale sale = new Sale();
|
||||
sale.setSaleDate(LocalDateTime.now());
|
||||
sale.setEmployee(employee);
|
||||
sale.setCustomer(customer);
|
||||
sale.setStore(store);
|
||||
sale.setPaymentMethod(request.getPaymentMethod());
|
||||
sale.setTax(request.getTax());
|
||||
sale.setNotes(request.getNotes());
|
||||
sale.setIsRefund(request.getIsRefund() != null ? request.getIsRefund() : false);
|
||||
|
||||
BigDecimal subtotal = BigDecimal.ZERO;
|
||||
if (sale.getIsRefund() && request.getOriginalSaleId() != null) {
|
||||
Sale originalSale = saleRepository.findById(request.getOriginalSaleId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Original sale not found with id: " + request.getOriginalSaleId()));
|
||||
sale.setOriginalSale(originalSale);
|
||||
}
|
||||
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
List<SaleItem> saleItems = new ArrayList<>();
|
||||
|
||||
for (var itemRequest : request.getItems()) {
|
||||
Product product = productRepository.findById(itemRequest.getProductId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + itemRequest.getProductId()));
|
||||
Product product = productRepository.findById(itemRequest.getProdId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + itemRequest.getProdId()));
|
||||
|
||||
Inventory inventory = inventoryRepository.findByProductIdAndStoreId(itemRequest.getProductId(), request.getStoreId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Inventory not found for product " + itemRequest.getProductId() + " at store " + request.getStoreId()));
|
||||
Inventory inventory = inventoryRepository.findByProductId(itemRequest.getProdId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Inventory not found for product " + itemRequest.getProdId()));
|
||||
|
||||
if (inventory.getQuantity() < itemRequest.getQuantity()) {
|
||||
throw new BusinessException("Insufficient stock for product: " + product.getProductName() +
|
||||
throw new BusinessException("Insufficient stock for product: " + product.getProdName() +
|
||||
". Available: " + inventory.getQuantity() + ", requested: " + itemRequest.getQuantity());
|
||||
}
|
||||
|
||||
inventory.setQuantity(inventory.getQuantity() - itemRequest.getQuantity());
|
||||
inventoryRepository.save(inventory);
|
||||
|
||||
BigDecimal unitPrice = product.getProductPrice();
|
||||
BigDecimal itemSubtotal = unitPrice.multiply(BigDecimal.valueOf(itemRequest.getQuantity()));
|
||||
BigDecimal unitPrice = product.getProdPrice();
|
||||
BigDecimal itemTotal = unitPrice.multiply(BigDecimal.valueOf(itemRequest.getQuantity()));
|
||||
|
||||
SaleItem saleItem = new SaleItem();
|
||||
saleItem.setSale(sale);
|
||||
saleItem.setProduct(product);
|
||||
saleItem.setQuantity(itemRequest.getQuantity());
|
||||
saleItem.setUnitPrice(unitPrice);
|
||||
saleItem.setSubtotal(itemSubtotal);
|
||||
|
||||
saleItems.add(saleItem);
|
||||
subtotal = subtotal.add(itemSubtotal);
|
||||
totalAmount = totalAmount.add(itemTotal);
|
||||
}
|
||||
|
||||
sale.setSubtotal(subtotal);
|
||||
sale.setTotal(subtotal.add(sale.getTax()));
|
||||
sale.setTotalAmount(totalAmount);
|
||||
sale.setItems(saleItems);
|
||||
|
||||
Sale savedSale = saleRepository.save(sale);
|
||||
@@ -118,37 +112,32 @@ public class SaleService {
|
||||
|
||||
private SaleResponse mapToResponse(Sale sale) {
|
||||
SaleResponse response = new SaleResponse();
|
||||
response.setId(sale.getId());
|
||||
response.setSaleId(sale.getSaleId());
|
||||
response.setSaleDate(sale.getSaleDate());
|
||||
response.setEmployeeId(sale.getEmployee().getId());
|
||||
response.setEmployeeName(sale.getEmployee().getFullName());
|
||||
|
||||
if (sale.getCustomer() != null) {
|
||||
response.setCustomerId(sale.getCustomer().getId());
|
||||
response.setCustomerName(sale.getCustomer().getCustomerName());
|
||||
}
|
||||
response.setEmployeeId(sale.getEmployee().getEmployeeId());
|
||||
response.setEmployeeName(sale.getEmployee().getFirstName() + " " + sale.getEmployee().getLastName());
|
||||
|
||||
if (sale.getStore() != null) {
|
||||
response.setStoreId(sale.getStore().getId());
|
||||
response.setStoreId(sale.getStore().getStoreId());
|
||||
response.setStoreName(sale.getStore().getStoreName());
|
||||
}
|
||||
|
||||
response.setSubtotal(sale.getSubtotal());
|
||||
response.setTax(sale.getTax());
|
||||
response.setTotal(sale.getTotal());
|
||||
response.setTotalAmount(sale.getTotalAmount());
|
||||
response.setPaymentMethod(sale.getPaymentMethod());
|
||||
response.setNotes(sale.getNotes());
|
||||
response.setIsRefund(sale.getIsRefund());
|
||||
if (sale.getOriginalSale() != null) {
|
||||
response.setOriginalSaleId(sale.getOriginalSale().getSaleId());
|
||||
}
|
||||
response.setCreatedAt(sale.getCreatedAt());
|
||||
|
||||
List<SaleResponse.SaleItemResponse> itemResponses = new ArrayList<>();
|
||||
for (SaleItem item : sale.getItems()) {
|
||||
SaleResponse.SaleItemResponse itemResponse = new SaleResponse.SaleItemResponse();
|
||||
itemResponse.setId(item.getId());
|
||||
itemResponse.setProductId(item.getProduct().getId());
|
||||
itemResponse.setProductName(item.getProduct().getProductName());
|
||||
itemResponse.setSaleItemId(item.getSaleItemId());
|
||||
itemResponse.setProdId(item.getProduct().getProdId());
|
||||
itemResponse.setProductName(item.getProduct().getProdName());
|
||||
itemResponse.setQuantity(item.getQuantity());
|
||||
itemResponse.setUnitPrice(item.getUnitPrice());
|
||||
itemResponse.setSubtotal(item.getSubtotal());
|
||||
itemResponses.add(itemResponse);
|
||||
}
|
||||
response.setItems(itemResponses);
|
||||
|
||||
@@ -39,10 +39,9 @@ public class ServiceService {
|
||||
public ServiceResponse createService(ServiceRequest request) {
|
||||
com.petshop.backend.entity.Service service = new com.petshop.backend.entity.Service();
|
||||
service.setServiceName(request.getServiceName());
|
||||
service.setServiceDescription(request.getServiceDescription());
|
||||
service.setServiceDesc(request.getServiceDesc());
|
||||
service.setServicePrice(request.getServicePrice());
|
||||
service.setServiceDurationMinutes(request.getServiceDurationMinutes());
|
||||
service.setActive(request.getActive() != null ? request.getActive() : true);
|
||||
service.setServiceDuration(request.getServiceDuration());
|
||||
|
||||
service = serviceRepository.save(service);
|
||||
return mapToResponse(service);
|
||||
@@ -54,10 +53,9 @@ public class ServiceService {
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Service not found with id: " + id));
|
||||
|
||||
service.setServiceName(request.getServiceName());
|
||||
service.setServiceDescription(request.getServiceDescription());
|
||||
service.setServiceDesc(request.getServiceDesc());
|
||||
service.setServicePrice(request.getServicePrice());
|
||||
service.setServiceDurationMinutes(request.getServiceDurationMinutes());
|
||||
service.setActive(request.getActive() != null ? request.getActive() : true);
|
||||
service.setServiceDuration(request.getServiceDuration());
|
||||
|
||||
service = serviceRepository.save(service);
|
||||
return mapToResponse(service);
|
||||
@@ -78,12 +76,11 @@ public class ServiceService {
|
||||
|
||||
private ServiceResponse mapToResponse(com.petshop.backend.entity.Service service) {
|
||||
return new ServiceResponse(
|
||||
service.getId(),
|
||||
service.getServiceId(),
|
||||
service.getServiceName(),
|
||||
service.getServiceDescription(),
|
||||
service.getServiceDesc(),
|
||||
service.getServicePrice(),
|
||||
service.getServiceDurationMinutes(),
|
||||
service.getActive(),
|
||||
service.getServiceDuration(),
|
||||
service.getCreatedAt(),
|
||||
service.getUpdatedAt()
|
||||
);
|
||||
|
||||
@@ -39,12 +39,11 @@ public class SupplierService {
|
||||
@Transactional
|
||||
public SupplierResponse createSupplier(SupplierRequest request) {
|
||||
Supplier supplier = new Supplier();
|
||||
supplier.setSupplierName(request.getSupName());
|
||||
supplier.setSupplierContact(request.getSupContact());
|
||||
supplier.setSupplierEmail(request.getSupEmail());
|
||||
supplier.setSupplierPhone(request.getSupPhone());
|
||||
supplier.setSupplierAddress(request.getSupAddress());
|
||||
supplier.setActive(request.getActive());
|
||||
supplier.setSupCompany(request.getSupCompany());
|
||||
supplier.setSupContactFirstName(request.getSupContactFirstName());
|
||||
supplier.setSupContactLastName(request.getSupContactLastName());
|
||||
supplier.setSupEmail(request.getSupEmail());
|
||||
supplier.setSupPhone(request.getSupPhone());
|
||||
|
||||
supplier = supplierRepository.save(supplier);
|
||||
return mapToResponse(supplier);
|
||||
@@ -55,12 +54,11 @@ public class SupplierService {
|
||||
Supplier supplier = supplierRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Supplier not found with id: " + id));
|
||||
|
||||
supplier.setSupplierName(request.getSupName());
|
||||
supplier.setSupplierContact(request.getSupContact());
|
||||
supplier.setSupplierEmail(request.getSupEmail());
|
||||
supplier.setSupplierPhone(request.getSupPhone());
|
||||
supplier.setSupplierAddress(request.getSupAddress());
|
||||
supplier.setActive(request.getActive());
|
||||
supplier.setSupCompany(request.getSupCompany());
|
||||
supplier.setSupContactFirstName(request.getSupContactFirstName());
|
||||
supplier.setSupContactLastName(request.getSupContactLastName());
|
||||
supplier.setSupEmail(request.getSupEmail());
|
||||
supplier.setSupPhone(request.getSupPhone());
|
||||
|
||||
supplier = supplierRepository.save(supplier);
|
||||
return mapToResponse(supplier);
|
||||
@@ -81,13 +79,12 @@ public class SupplierService {
|
||||
|
||||
private SupplierResponse mapToResponse(Supplier supplier) {
|
||||
return new SupplierResponse(
|
||||
supplier.getId(),
|
||||
supplier.getSupplierName(),
|
||||
supplier.getSupplierContact(),
|
||||
supplier.getSupplierEmail(),
|
||||
supplier.getSupplierPhone(),
|
||||
supplier.getSupplierAddress(),
|
||||
supplier.getActive(),
|
||||
supplier.getSupId(),
|
||||
supplier.getSupCompany(),
|
||||
supplier.getSupContactFirstName(),
|
||||
supplier.getSupContactLastName(),
|
||||
supplier.getSupEmail(),
|
||||
supplier.getSupPhone(),
|
||||
supplier.getCreatedAt(),
|
||||
supplier.getUpdatedAt()
|
||||
);
|
||||
|
||||
@@ -44,10 +44,7 @@ public class UserService {
|
||||
User user = new User();
|
||||
user.setUsername(request.getUsername());
|
||||
user.setPassword(passwordEncoder.encode(request.getPassword()));
|
||||
user.setFullName(request.getFullName());
|
||||
user.setEmail(request.getEmail());
|
||||
user.setRole(request.getRole());
|
||||
user.setActive(request.getActive());
|
||||
|
||||
user = userRepository.save(user);
|
||||
return mapToResponse(user);
|
||||
@@ -62,10 +59,7 @@ public class UserService {
|
||||
if (request.getPassword() != null && !request.getPassword().trim().isEmpty()) {
|
||||
user.setPassword(passwordEncoder.encode(request.getPassword()));
|
||||
}
|
||||
user.setFullName(request.getFullName());
|
||||
user.setEmail(request.getEmail());
|
||||
user.setRole(request.getRole());
|
||||
user.setActive(request.getActive());
|
||||
|
||||
user = userRepository.save(user);
|
||||
return mapToResponse(user);
|
||||
@@ -85,15 +79,10 @@ public class UserService {
|
||||
}
|
||||
|
||||
private UserResponse mapToResponse(User user) {
|
||||
return new UserResponse(
|
||||
user.getId(),
|
||||
user.getUsername(),
|
||||
user.getFullName(),
|
||||
user.getEmail(),
|
||||
user.getRole().toString(),
|
||||
user.getActive(),
|
||||
user.getCreatedAt(),
|
||||
user.getUpdatedAt()
|
||||
);
|
||||
UserResponse response = new UserResponse();
|
||||
response.setId(user.getId());
|
||||
response.setUsername(user.getUsername());
|
||||
response.setRole(user.getRole().toString());
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ spring:
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: validate
|
||||
naming:
|
||||
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
|
||||
show-sql: ${JPA_SHOW_SQL:false}
|
||||
properties:
|
||||
hibernate:
|
||||
|
||||
Reference in New Issue
Block a user