Align backend schema with desktop application
This commit is contained in:
@@ -11,6 +11,7 @@ services:
|
|||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/mysql
|
- db_data:/var/lib/mysql
|
||||||
|
- ./sql:/docker-entrypoint-initdb.d
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"]
|
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.petshop.backend.controller;
|
|||||||
|
|
||||||
import com.petshop.backend.dto.auth.LoginRequest;
|
import com.petshop.backend.dto.auth.LoginRequest;
|
||||||
import com.petshop.backend.dto.auth.LoginResponse;
|
import com.petshop.backend.dto.auth.LoginResponse;
|
||||||
import com.petshop.backend.dto.auth.RegisterRequest;
|
|
||||||
import com.petshop.backend.dto.auth.UserInfoResponse;
|
import com.petshop.backend.dto.auth.UserInfoResponse;
|
||||||
import com.petshop.backend.entity.User;
|
import com.petshop.backend.entity.User;
|
||||||
import com.petshop.backend.repository.UserRepository;
|
import com.petshop.backend.repository.UserRepository;
|
||||||
@@ -39,40 +38,6 @@ public class AuthController {
|
|||||||
this.passwordEncoder = passwordEncoder;
|
this.passwordEncoder = passwordEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/register")
|
|
||||||
public ResponseEntity<?> register(@Valid @RequestBody RegisterRequest request) {
|
|
||||||
if (userRepository.findByUsername(request.getEmail()).isPresent()) {
|
|
||||||
Map<String, String> error = new HashMap<>();
|
|
||||||
error.put("message", "Email already registered");
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = new User();
|
|
||||||
user.setUsername(request.getEmail());
|
|
||||||
user.setEmail(request.getEmail());
|
|
||||||
user.setPassword(passwordEncoder.encode(request.getPassword()));
|
|
||||||
user.setFullName(request.getFirstName() + " " + request.getLastName());
|
|
||||||
user.setRole(User.Role.CUSTOMER);
|
|
||||||
user.setActive(true);
|
|
||||||
|
|
||||||
user = userRepository.save(user);
|
|
||||||
|
|
||||||
UserDetails userDetails = new org.springframework.security.core.userdetails.User(
|
|
||||||
user.getUsername(),
|
|
||||||
user.getPassword(),
|
|
||||||
java.util.Collections.emptyList()
|
|
||||||
);
|
|
||||||
|
|
||||||
String token = jwtUtil.generateToken(userDetails);
|
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(new LoginResponse(
|
|
||||||
token,
|
|
||||||
user.getUsername(),
|
|
||||||
user.getFullName(),
|
|
||||||
user.getRole().name()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public ResponseEntity<?> login(@Valid @RequestBody LoginRequest request) {
|
public ResponseEntity<?> login(@Valid @RequestBody LoginRequest request) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.petshop.backend.controller;
|
|
||||||
|
|
||||||
import com.petshop.backend.dto.refund.RefundRequest;
|
|
||||||
import com.petshop.backend.dto.refund.RefundResponse;
|
|
||||||
import com.petshop.backend.service.RefundService;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/v1/sales")
|
|
||||||
public class RefundController {
|
|
||||||
|
|
||||||
private final RefundService refundService;
|
|
||||||
|
|
||||||
public RefundController(RefundService refundService) {
|
|
||||||
this.refundService = refundService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/{saleId}/refunds")
|
|
||||||
public ResponseEntity<RefundResponse> createRefund(
|
|
||||||
@PathVariable Long saleId,
|
|
||||||
@Valid @RequestBody RefundRequest request) {
|
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(refundService.createRefund(saleId, request));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
package com.petshop.backend.dto.auth;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.Email;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class RegisterRequest {
|
|
||||||
@NotBlank(message = "First name is required")
|
|
||||||
private String firstName;
|
|
||||||
|
|
||||||
@NotBlank(message = "Last name is required")
|
|
||||||
private String lastName;
|
|
||||||
|
|
||||||
@NotBlank(message = "Email is required")
|
|
||||||
@Email(message = "Email must be valid")
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
@NotBlank(message = "Phone is required")
|
|
||||||
private String phone;
|
|
||||||
|
|
||||||
@NotBlank(message = "Password is required")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
public String getFirstName() {
|
|
||||||
return firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFirstName(String firstName) {
|
|
||||||
this.firstName = firstName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLastName() {
|
|
||||||
return lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastName(String lastName) {
|
|
||||||
this.lastName = lastName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmail() {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPhone() {
|
|
||||||
return phone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPhone(String phone) {
|
|
||||||
this.phone = phone;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
RegisterRequest that = (RegisterRequest) o;
|
|
||||||
return Objects.equals(firstName, that.firstName) &&
|
|
||||||
Objects.equals(lastName, that.lastName) &&
|
|
||||||
Objects.equals(email, that.email) &&
|
|
||||||
Objects.equals(phone, that.phone) &&
|
|
||||||
Objects.equals(password, that.password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(firstName, lastName, email, phone, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "RegisterRequest{" +
|
|
||||||
"firstName='" + firstName + '\'' +
|
|
||||||
", lastName='" + lastName + '\'' +
|
|
||||||
", email='" + email + '\'' +
|
|
||||||
", phone='" + phone + '\'' +
|
|
||||||
", password='[PROTECTED]'" +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package com.petshop.backend.dto.refund;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import jakarta.validation.constraints.Positive;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class RefundItemRequest {
|
|
||||||
@NotNull(message = "Sale item ID is required")
|
|
||||||
private Long saleItemId;
|
|
||||||
|
|
||||||
@NotNull(message = "Quantity is required")
|
|
||||||
@Positive(message = "Quantity must be positive")
|
|
||||||
private Integer quantity;
|
|
||||||
|
|
||||||
public Long getSaleItemId() {
|
|
||||||
return saleItemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSaleItemId(Long saleItemId) {
|
|
||||||
this.saleItemId = saleItemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getQuantity() {
|
|
||||||
return quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQuantity(Integer quantity) {
|
|
||||||
this.quantity = quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
RefundItemRequest that = (RefundItemRequest) o;
|
|
||||||
return Objects.equals(saleItemId, that.saleItemId) &&
|
|
||||||
Objects.equals(quantity, that.quantity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(saleItemId, quantity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "RefundItemRequest{" +
|
|
||||||
"saleItemId=" + saleItemId +
|
|
||||||
", quantity=" + quantity +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package com.petshop.backend.dto.refund;
|
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class RefundRequest {
|
|
||||||
@NotEmpty(message = "At least one item is required")
|
|
||||||
@Valid
|
|
||||||
private List<RefundItemRequest> items;
|
|
||||||
|
|
||||||
private String refundReason;
|
|
||||||
|
|
||||||
public List<RefundItemRequest> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItems(List<RefundItemRequest> items) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefundReason() {
|
|
||||||
return refundReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefundReason(String refundReason) {
|
|
||||||
this.refundReason = refundReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
RefundRequest that = (RefundRequest) o;
|
|
||||||
return Objects.equals(items, that.items) &&
|
|
||||||
Objects.equals(refundReason, that.refundReason);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(items, refundReason);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "RefundRequest{" +
|
|
||||||
"items=" + items +
|
|
||||||
", refundReason='" + refundReason + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
package com.petshop.backend.dto.refund;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class RefundResponse {
|
|
||||||
private Long id;
|
|
||||||
private Long saleId;
|
|
||||||
private LocalDateTime refundDate;
|
|
||||||
private BigDecimal refundAmount;
|
|
||||||
private String refundReason;
|
|
||||||
private Long processedBy;
|
|
||||||
private String processedByName;
|
|
||||||
private List<RefundItemResponse> items;
|
|
||||||
private LocalDateTime createdAt;
|
|
||||||
|
|
||||||
public RefundResponse() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public RefundResponse(Long id, Long saleId, LocalDateTime refundDate, BigDecimal refundAmount, String refundReason, Long processedBy, String processedByName, List<RefundItemResponse> items, LocalDateTime createdAt) {
|
|
||||||
this.id = id;
|
|
||||||
this.saleId = saleId;
|
|
||||||
this.refundDate = refundDate;
|
|
||||||
this.refundAmount = refundAmount;
|
|
||||||
this.refundReason = refundReason;
|
|
||||||
this.processedBy = processedBy;
|
|
||||||
this.processedByName = processedByName;
|
|
||||||
this.items = items;
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSaleId() {
|
|
||||||
return saleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSaleId(Long saleId) {
|
|
||||||
this.saleId = saleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDateTime getRefundDate() {
|
|
||||||
return refundDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefundDate(LocalDateTime refundDate) {
|
|
||||||
this.refundDate = refundDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getRefundAmount() {
|
|
||||||
return refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefundAmount(BigDecimal refundAmount) {
|
|
||||||
this.refundAmount = refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefundReason() {
|
|
||||||
return refundReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefundReason(String refundReason) {
|
|
||||||
this.refundReason = refundReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getProcessedBy() {
|
|
||||||
return processedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProcessedBy(Long processedBy) {
|
|
||||||
this.processedBy = processedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProcessedByName() {
|
|
||||||
return processedByName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProcessedByName(String processedByName) {
|
|
||||||
this.processedByName = processedByName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RefundItemResponse> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItems(List<RefundItemResponse> items) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedAt(LocalDateTime createdAt) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
RefundResponse that = (RefundResponse) o;
|
|
||||||
return Objects.equals(id, that.id) && Objects.equals(saleId, that.saleId) && Objects.equals(refundDate, that.refundDate) && Objects.equals(refundAmount, that.refundAmount) && Objects.equals(refundReason, that.refundReason) && Objects.equals(processedBy, that.processedBy) && Objects.equals(processedByName, that.processedByName) && Objects.equals(items, that.items) && Objects.equals(createdAt, that.createdAt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, saleId, refundDate, refundAmount, refundReason, processedBy, processedByName, items, createdAt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "RefundResponse{" +
|
|
||||||
"id=" + id +
|
|
||||||
", saleId=" + saleId +
|
|
||||||
", refundDate=" + refundDate +
|
|
||||||
", refundAmount=" + refundAmount +
|
|
||||||
", refundReason='" + refundReason + '\'' +
|
|
||||||
", processedBy=" + processedBy +
|
|
||||||
", processedByName='" + processedByName + '\'' +
|
|
||||||
", items=" + items +
|
|
||||||
", createdAt=" + createdAt +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class RefundItemResponse {
|
|
||||||
private Long id;
|
|
||||||
private Long saleItemId;
|
|
||||||
private Long productId;
|
|
||||||
private String productName;
|
|
||||||
private Integer quantity;
|
|
||||||
private BigDecimal refundAmount;
|
|
||||||
|
|
||||||
public RefundItemResponse() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public RefundItemResponse(Long id, Long saleItemId, Long productId, String productName, Integer quantity, BigDecimal refundAmount) {
|
|
||||||
this.id = id;
|
|
||||||
this.saleItemId = saleItemId;
|
|
||||||
this.productId = productId;
|
|
||||||
this.productName = productName;
|
|
||||||
this.quantity = quantity;
|
|
||||||
this.refundAmount = refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getSaleItemId() {
|
|
||||||
return saleItemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSaleItemId(Long saleItemId) {
|
|
||||||
this.saleItemId = saleItemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 getRefundAmount() {
|
|
||||||
return refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefundAmount(BigDecimal refundAmount) {
|
|
||||||
this.refundAmount = refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
RefundItemResponse that = (RefundItemResponse) o;
|
|
||||||
return Objects.equals(id, that.id) && Objects.equals(saleItemId, that.saleItemId) && Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(quantity, that.quantity) && Objects.equals(refundAmount, that.refundAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, saleItemId, productId, productName, quantity, refundAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "RefundItemResponse{" +
|
|
||||||
"id=" + id +
|
|
||||||
", saleItemId=" + saleItemId +
|
|
||||||
", productId=" + productId +
|
|
||||||
", productName='" + productName + '\'' +
|
|
||||||
", quantity=" + quantity +
|
|
||||||
", refundAmount=" + refundAmount +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
90
src/main/java/com/petshop/backend/entity/ActivityLog.java
Normal file
90
src/main/java/com/petshop/backend/entity/ActivityLog.java
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package com.petshop.backend.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "activityLog")
|
||||||
|
public class ActivityLog {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long logId;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "employeeId", nullable = false)
|
||||||
|
private Employee employee;
|
||||||
|
|
||||||
|
@Column(nullable = false, columnDefinition = "TEXT")
|
||||||
|
private String activity;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private LocalDateTime logTimestamp = LocalDateTime.now();
|
||||||
|
|
||||||
|
public ActivityLog() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLog(Long logId, Employee employee, String activity, LocalDateTime logTimestamp) {
|
||||||
|
this.logId = logId;
|
||||||
|
this.employee = employee;
|
||||||
|
this.activity = activity;
|
||||||
|
this.logTimestamp = logTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLogId() {
|
||||||
|
return logId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogId(Long logId) {
|
||||||
|
this.logId = logId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Employee getEmployee() {
|
||||||
|
return employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmployee(Employee employee) {
|
||||||
|
this.employee = employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivity() {
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivity(String activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getLogTimestamp() {
|
||||||
|
return logTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogTimestamp(LocalDateTime logTimestamp) {
|
||||||
|
this.logTimestamp = logTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
ActivityLog that = (ActivityLog) o;
|
||||||
|
return Objects.equals(logId, that.logId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(logId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ActivityLog{" +
|
||||||
|
"logId=" + logId +
|
||||||
|
", employee=" + employee +
|
||||||
|
", activity='" + activity + '\'' +
|
||||||
|
", logTimestamp=" + logTimestamp +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,29 +10,26 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "adoptions")
|
@Table(name = "adoption")
|
||||||
public class Adoption {
|
public class Adoption {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long adoptionId;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "pet_id", nullable = false)
|
@JoinColumn(name = "petId", nullable = false)
|
||||||
private Pet pet;
|
private Pet pet;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "customer_id", nullable = false)
|
@JoinColumn(name = "customerId", nullable = false)
|
||||||
private Customer customer;
|
private Customer customer;
|
||||||
|
|
||||||
@Column(name = "adoption_date", nullable = false)
|
@Column(nullable = false)
|
||||||
private LocalDate adoptionDate;
|
private LocalDate adoptionDate;
|
||||||
|
|
||||||
@Column(name = "adoption_fee", nullable = false, precision = 10, scale = 2)
|
@Column(nullable = false, length = 20)
|
||||||
private BigDecimal adoptionFee;
|
private String adoptionStatus;
|
||||||
|
|
||||||
@Column(columnDefinition = "TEXT")
|
|
||||||
private String notes;
|
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@@ -45,23 +42,22 @@ public class Adoption {
|
|||||||
public Adoption() {
|
public Adoption() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Adoption(Long id, Pet pet, Customer customer, LocalDate adoptionDate, BigDecimal adoptionFee, String notes, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public Adoption(Long adoptionId, Pet pet, Customer customer, LocalDate adoptionDate, String adoptionStatus, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.adoptionId = adoptionId;
|
||||||
this.pet = pet;
|
this.pet = pet;
|
||||||
this.customer = customer;
|
this.customer = customer;
|
||||||
this.adoptionDate = adoptionDate;
|
this.adoptionDate = adoptionDate;
|
||||||
this.adoptionFee = adoptionFee;
|
this.adoptionStatus = adoptionStatus;
|
||||||
this.notes = notes;
|
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getAdoptionId() {
|
||||||
return id;
|
return adoptionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setAdoptionId(Long adoptionId) {
|
||||||
this.id = id;
|
this.adoptionId = adoptionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pet getPet() {
|
public Pet getPet() {
|
||||||
@@ -88,20 +84,12 @@ public class Adoption {
|
|||||||
this.adoptionDate = adoptionDate;
|
this.adoptionDate = adoptionDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getAdoptionFee() {
|
public String getAdoptionStatus() {
|
||||||
return adoptionFee;
|
return adoptionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdoptionFee(BigDecimal adoptionFee) {
|
public void setAdoptionStatus(String adoptionStatus) {
|
||||||
this.adoptionFee = adoptionFee;
|
this.adoptionStatus = adoptionStatus;
|
||||||
}
|
|
||||||
|
|
||||||
public String getNotes() {
|
|
||||||
return notes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotes(String notes) {
|
|
||||||
this.notes = notes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
public LocalDateTime getCreatedAt() {
|
||||||
@@ -125,23 +113,22 @@ public class Adoption {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Adoption adoption = (Adoption) o;
|
Adoption adoption = (Adoption) o;
|
||||||
return Objects.equals(id, adoption.id);
|
return Objects.equals(adoptionId, adoption.adoptionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(adoptionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Adoption{" +
|
return "Adoption{" +
|
||||||
"id=" + id +
|
"adoptionId=" + adoptionId +
|
||||||
", pet=" + pet +
|
", pet=" + pet +
|
||||||
", customer=" + customer +
|
", customer=" + customer +
|
||||||
", adoptionDate=" + adoptionDate +
|
", adoptionDate=" + adoptionDate +
|
||||||
", adoptionFee=" + adoptionFee +
|
", adoptionStatus='" + adoptionStatus + '\'' +
|
||||||
", notes='" + notes + '\'' +
|
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -12,39 +12,35 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "appointments")
|
@Table(name = "appointment")
|
||||||
public class Appointment {
|
public class Appointment {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long appointmentId;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "customer_id", nullable = false)
|
@JoinColumn(name = "customerId", nullable = false)
|
||||||
private Customer customer;
|
private Customer customer;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "service_id", nullable = false)
|
@JoinColumn(name = "serviceId", nullable = false)
|
||||||
private Service service;
|
private Service service;
|
||||||
|
|
||||||
@Column(name = "appointment_date", nullable = false)
|
@Column(nullable = false)
|
||||||
private LocalDate appointmentDate;
|
private LocalDate appointmentDate;
|
||||||
|
|
||||||
@Column(name = "appointment_time", nullable = false)
|
@Column(nullable = false)
|
||||||
private LocalTime appointmentTime;
|
private LocalTime appointmentTime;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Column(nullable = false, length = 20)
|
||||||
@Column(nullable = false)
|
private String appointmentStatus;
|
||||||
private AppointmentStatus status = AppointmentStatus.Scheduled;
|
|
||||||
|
|
||||||
@Column(columnDefinition = "TEXT")
|
|
||||||
private String notes;
|
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "appointment_pets",
|
name = "appointmentPet",
|
||||||
joinColumns = @JoinColumn(name = "appointment_id"),
|
joinColumns = @JoinColumn(name = "appointmentId"),
|
||||||
inverseJoinColumns = @JoinColumn(name = "pet_id")
|
inverseJoinColumns = @JoinColumn(name = "petId")
|
||||||
)
|
)
|
||||||
private Set<Pet> pets = new HashSet<>();
|
private Set<Pet> pets = new HashSet<>();
|
||||||
|
|
||||||
@@ -56,32 +52,27 @@ public class Appointment {
|
|||||||
@Column(name = "updated_at")
|
@Column(name = "updated_at")
|
||||||
private LocalDateTime updatedAt;
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
public enum AppointmentStatus {
|
|
||||||
Scheduled, Completed, Cancelled
|
|
||||||
}
|
|
||||||
|
|
||||||
public Appointment() {
|
public Appointment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Appointment(Long id, Customer customer, Service service, LocalDate appointmentDate, LocalTime appointmentTime, AppointmentStatus status, String notes, Set<Pet> pets, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public Appointment(Long appointmentId, Customer customer, Service service, LocalDate appointmentDate, LocalTime appointmentTime, String appointmentStatus, Set<Pet> pets, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.appointmentId = appointmentId;
|
||||||
this.customer = customer;
|
this.customer = customer;
|
||||||
this.service = service;
|
this.service = service;
|
||||||
this.appointmentDate = appointmentDate;
|
this.appointmentDate = appointmentDate;
|
||||||
this.appointmentTime = appointmentTime;
|
this.appointmentTime = appointmentTime;
|
||||||
this.status = status;
|
this.appointmentStatus = appointmentStatus;
|
||||||
this.notes = notes;
|
|
||||||
this.pets = pets;
|
this.pets = pets;
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getAppointmentId() {
|
||||||
return id;
|
return appointmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setAppointmentId(Long appointmentId) {
|
||||||
this.id = id;
|
this.appointmentId = appointmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Customer getCustomer() {
|
public Customer getCustomer() {
|
||||||
@@ -116,20 +107,12 @@ public class Appointment {
|
|||||||
this.appointmentTime = appointmentTime;
|
this.appointmentTime = appointmentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppointmentStatus getStatus() {
|
public String getAppointmentStatus() {
|
||||||
return status;
|
return appointmentStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(AppointmentStatus status) {
|
public void setAppointmentStatus(String appointmentStatus) {
|
||||||
this.status = status;
|
this.appointmentStatus = appointmentStatus;
|
||||||
}
|
|
||||||
|
|
||||||
public String getNotes() {
|
|
||||||
return notes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotes(String notes) {
|
|
||||||
this.notes = notes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Pet> getPets() {
|
public Set<Pet> getPets() {
|
||||||
@@ -161,24 +144,23 @@ public class Appointment {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Appointment that = (Appointment) o;
|
Appointment that = (Appointment) o;
|
||||||
return Objects.equals(id, that.id);
|
return Objects.equals(appointmentId, that.appointmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(appointmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Appointment{" +
|
return "Appointment{" +
|
||||||
"id=" + id +
|
"appointmentId=" + appointmentId +
|
||||||
", customer=" + customer +
|
", customer=" + customer +
|
||||||
", service=" + service +
|
", service=" + service +
|
||||||
", appointmentDate=" + appointmentDate +
|
", appointmentDate=" + appointmentDate +
|
||||||
", appointmentTime=" + appointmentTime +
|
", appointmentTime=" + appointmentTime +
|
||||||
", status=" + status +
|
", appointmentStatus='" + appointmentStatus + '\'' +
|
||||||
", notes='" + notes + '\'' +
|
|
||||||
", pets=" + pets +
|
", pets=" + pets +
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
|
|||||||
@@ -8,18 +8,18 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "categories")
|
@Table(name = "category")
|
||||||
public class Category {
|
public class Category {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long categoryId;
|
||||||
|
|
||||||
@Column(name = "category_name", nullable = false, unique = true, length = 100)
|
@Column(nullable = false, length = 100)
|
||||||
private String categoryName;
|
private String categoryName;
|
||||||
|
|
||||||
@Column(name = "category_description", columnDefinition = "TEXT")
|
@Column(nullable = false, length = 50)
|
||||||
private String categoryDescription;
|
private String categoryType;
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@@ -32,20 +32,20 @@ public class Category {
|
|||||||
public Category() {
|
public Category() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Category(Long id, String categoryName, String categoryDescription, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public Category(Long categoryId, String categoryName, String categoryType, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.categoryId = categoryId;
|
||||||
this.categoryName = categoryName;
|
this.categoryName = categoryName;
|
||||||
this.categoryDescription = categoryDescription;
|
this.categoryType = categoryType;
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getCategoryId() {
|
||||||
return id;
|
return categoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setCategoryId(Long categoryId) {
|
||||||
this.id = id;
|
this.categoryId = categoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCategoryName() {
|
public String getCategoryName() {
|
||||||
@@ -56,12 +56,12 @@ public class Category {
|
|||||||
this.categoryName = categoryName;
|
this.categoryName = categoryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCategoryDescription() {
|
public String getCategoryType() {
|
||||||
return categoryDescription;
|
return categoryType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategoryDescription(String categoryDescription) {
|
public void setCategoryType(String categoryType) {
|
||||||
this.categoryDescription = categoryDescription;
|
this.categoryType = categoryType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
public LocalDateTime getCreatedAt() {
|
||||||
@@ -85,20 +85,20 @@ public class Category {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Category category = (Category) o;
|
Category category = (Category) o;
|
||||||
return Objects.equals(id, category.id);
|
return Objects.equals(categoryId, category.categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Category{" +
|
return "Category{" +
|
||||||
"id=" + id +
|
"categoryId=" + categoryId +
|
||||||
", categoryName='" + categoryName + '\'' +
|
", categoryName='" + categoryName + '\'' +
|
||||||
", categoryDescription='" + categoryDescription + '\'' +
|
", categoryType='" + categoryType + '\'' +
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -8,24 +8,24 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "customers")
|
@Table(name = "customer")
|
||||||
public class Customer {
|
public class Customer {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long customerId;
|
||||||
|
|
||||||
@Column(name = "customer_name", nullable = false, length = 100)
|
@Column(nullable = false, length = 50)
|
||||||
private String customerName;
|
private String firstName;
|
||||||
|
|
||||||
@Column(name = "customer_email", length = 100)
|
@Column(nullable = false, length = 50)
|
||||||
private String customerEmail;
|
private String lastName;
|
||||||
|
|
||||||
@Column(name = "customer_phone", length = 20)
|
@Column(nullable = false, length = 100)
|
||||||
private String customerPhone;
|
private String email;
|
||||||
|
|
||||||
@Column(name = "customer_address", columnDefinition = "TEXT")
|
@Column(nullable = false, length = 20)
|
||||||
private String customerAddress;
|
private String phone;
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@@ -38,54 +38,54 @@ public class Customer {
|
|||||||
public Customer() {
|
public Customer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Customer(Long id, String customerName, String customerEmail, String customerPhone, String customerAddress, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public Customer(Long customerId, String firstName, String lastName, String email, String phone, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.customerId = customerId;
|
||||||
this.customerName = customerName;
|
this.firstName = firstName;
|
||||||
this.customerEmail = customerEmail;
|
this.lastName = lastName;
|
||||||
this.customerPhone = customerPhone;
|
this.email = email;
|
||||||
this.customerAddress = customerAddress;
|
this.phone = phone;
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getCustomerId() {
|
||||||
return id;
|
return customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setCustomerId(Long customerId) {
|
||||||
this.id = id;
|
this.customerId = customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomerName() {
|
public String getFirstName() {
|
||||||
return customerName;
|
return firstName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomerName(String customerName) {
|
public void setFirstName(String firstName) {
|
||||||
this.customerName = customerName;
|
this.firstName = firstName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomerEmail() {
|
public String getLastName() {
|
||||||
return customerEmail;
|
return lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomerEmail(String customerEmail) {
|
public void setLastName(String lastName) {
|
||||||
this.customerEmail = customerEmail;
|
this.lastName = lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomerPhone() {
|
public String getEmail() {
|
||||||
return customerPhone;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomerPhone(String customerPhone) {
|
public void setEmail(String email) {
|
||||||
this.customerPhone = customerPhone;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomerAddress() {
|
public String getPhone() {
|
||||||
return customerAddress;
|
return phone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomerAddress(String customerAddress) {
|
public void setPhone(String phone) {
|
||||||
this.customerAddress = customerAddress;
|
this.phone = phone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
public LocalDateTime getCreatedAt() {
|
||||||
@@ -109,22 +109,22 @@ public class Customer {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Customer customer = (Customer) o;
|
Customer customer = (Customer) o;
|
||||||
return Objects.equals(id, customer.id);
|
return Objects.equals(customerId, customer.customerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(customerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Customer{" +
|
return "Customer{" +
|
||||||
"id=" + id +
|
"customerId=" + customerId +
|
||||||
", customerName='" + customerName + '\'' +
|
", firstName='" + firstName + '\'' +
|
||||||
", customerEmail='" + customerEmail + '\'' +
|
", lastName='" + lastName + '\'' +
|
||||||
", customerPhone='" + customerPhone + '\'' +
|
", email='" + email + '\'' +
|
||||||
", customerAddress='" + customerAddress + '\'' +
|
", phone='" + phone + '\'' +
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
158
src/main/java/com/petshop/backend/entity/Employee.java
Normal file
158
src/main/java/com/petshop/backend/entity/Employee.java
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
package com.petshop.backend.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import org.hibernate.annotations.CreationTimestamp;
|
||||||
|
import org.hibernate.annotations.UpdateTimestamp;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "employee")
|
||||||
|
public class Employee {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long employeeId;
|
||||||
|
|
||||||
|
@Column(nullable = false, length = 50)
|
||||||
|
private String firstName;
|
||||||
|
|
||||||
|
@Column(nullable = false, length = 50)
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
@Column(nullable = false, length = 100)
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@Column(nullable = false, length = 20)
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@Column(nullable = false, length = 50)
|
||||||
|
private String role;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Boolean isActive = true;
|
||||||
|
|
||||||
|
@CreationTimestamp
|
||||||
|
@Column(name = "created_at", updatable = false)
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@UpdateTimestamp
|
||||||
|
@Column(name = "updated_at")
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
|
public Employee() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Employee(Long employeeId, String firstName, String lastName, String email, String phone, String role, Boolean isActive, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
|
this.employeeId = employeeId;
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
this.email = email;
|
||||||
|
this.phone = phone;
|
||||||
|
this.role = role;
|
||||||
|
this.isActive = isActive;
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getEmployeeId() {
|
||||||
|
return employeeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmployeeId(Long employeeId) {
|
||||||
|
this.employeeId = employeeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(String role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActive(Boolean isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Employee employee = (Employee) o;
|
||||||
|
return Objects.equals(employeeId, employee.employeeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(employeeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Employee{" +
|
||||||
|
"employeeId=" + employeeId +
|
||||||
|
", firstName='" + firstName + '\'' +
|
||||||
|
", lastName='" + lastName + '\'' +
|
||||||
|
", email='" + email + '\'' +
|
||||||
|
", phone='" + phone + '\'' +
|
||||||
|
", role='" + role + '\'' +
|
||||||
|
", isActive=" + isActive +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", updatedAt=" + updatedAt +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
148
src/main/java/com/petshop/backend/entity/EmployeeStore.java
Normal file
148
src/main/java/com/petshop/backend/entity/EmployeeStore.java
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
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
|
||||||
|
@Table(name = "employeeStore")
|
||||||
|
@IdClass(EmployeeStore.EmployeeStoreId.class)
|
||||||
|
public class EmployeeStore {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "employeeId", nullable = false)
|
||||||
|
private Employee employee;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@ManyToOne
|
||||||
|
@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) {
|
||||||
|
this.employee = employee;
|
||||||
|
this.store = store;
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Employee getEmployee() {
|
||||||
|
return employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmployee(Employee employee) {
|
||||||
|
this.employee = employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreLocation getStore() {
|
||||||
|
return store;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStore(StoreLocation store) {
|
||||||
|
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;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
EmployeeStore that = (EmployeeStore) o;
|
||||||
|
return Objects.equals(employee, that.employee) && Objects.equals(store, that.store);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(employee, store);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "EmployeeStore{" +
|
||||||
|
"employee=" + employee +
|
||||||
|
", store=" + store +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", updatedAt=" + updatedAt +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class EmployeeStoreId implements Serializable {
|
||||||
|
private Long employee;
|
||||||
|
private Long store;
|
||||||
|
|
||||||
|
public EmployeeStoreId() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmployeeStoreId(Long employee, Long store) {
|
||||||
|
this.employee = employee;
|
||||||
|
this.store = store;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getEmployee() {
|
||||||
|
return employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmployee(Long employee) {
|
||||||
|
this.employee = employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStore() {
|
||||||
|
return store;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStore(Long store) {
|
||||||
|
this.store = store;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
EmployeeStoreId that = (EmployeeStoreId) o;
|
||||||
|
return Objects.equals(employee, that.employee) && Objects.equals(store, that.store);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(employee, store);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "EmployeeStoreId{" +
|
||||||
|
"employee=" + employee +
|
||||||
|
", store=" + store +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,32 +8,20 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "inventory", uniqueConstraints = {
|
@Table(name = "inventory")
|
||||||
@UniqueConstraint(name = "unique_product_store", columnNames = {"product_id", "store_id"})
|
|
||||||
})
|
|
||||||
public class Inventory {
|
public class Inventory {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long inventoryId;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "product_id", nullable = false)
|
@JoinColumn(name = "prodId", nullable = false)
|
||||||
private Product product;
|
private Product product;
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "store_id", nullable = true)
|
|
||||||
private Store store;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Integer quantity = 0;
|
private Integer quantity = 0;
|
||||||
|
|
||||||
@Column(name = "reorder_level")
|
|
||||||
private Integer reorderLevel = 10;
|
|
||||||
|
|
||||||
@Column(name = "last_restocked")
|
|
||||||
private LocalDateTime lastRestocked;
|
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
@@ -45,23 +33,20 @@ public class Inventory {
|
|||||||
public Inventory() {
|
public Inventory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory(Long id, Product product, Store store, Integer quantity, Integer reorderLevel, LocalDateTime lastRestocked, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public Inventory(Long inventoryId, Product product, Integer quantity, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.inventoryId = inventoryId;
|
||||||
this.product = product;
|
this.product = product;
|
||||||
this.store = store;
|
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.reorderLevel = reorderLevel;
|
|
||||||
this.lastRestocked = lastRestocked;
|
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getInventoryId() {
|
||||||
return id;
|
return inventoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setInventoryId(Long inventoryId) {
|
||||||
this.id = id;
|
this.inventoryId = inventoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Product getProduct() {
|
public Product getProduct() {
|
||||||
@@ -72,14 +57,6 @@ public class Inventory {
|
|||||||
this.product = product;
|
this.product = product;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Store getStore() {
|
|
||||||
return store;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStore(Store store) {
|
|
||||||
this.store = store;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getQuantity() {
|
public Integer getQuantity() {
|
||||||
return quantity;
|
return quantity;
|
||||||
}
|
}
|
||||||
@@ -88,22 +65,6 @@ public class Inventory {
|
|||||||
this.quantity = quantity;
|
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() {
|
public LocalDateTime getCreatedAt() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
@@ -125,23 +86,20 @@ public class Inventory {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Inventory inventory = (Inventory) o;
|
Inventory inventory = (Inventory) o;
|
||||||
return Objects.equals(id, inventory.id);
|
return Objects.equals(inventoryId, inventory.inventoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(inventoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Inventory{" +
|
return "Inventory{" +
|
||||||
"id=" + id +
|
"inventoryId=" + inventoryId +
|
||||||
", product=" + product +
|
", product=" + product +
|
||||||
", store=" + store +
|
|
||||||
", quantity=" + quantity +
|
", quantity=" + quantity +
|
||||||
", reorderLevel=" + reorderLevel +
|
|
||||||
", lastRestocked=" + lastRestocked +
|
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -9,30 +9,29 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "pets")
|
@Table(name = "pet")
|
||||||
public class Pet {
|
public class Pet {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long petId;
|
||||||
|
|
||||||
@Column(name = "pet_name", nullable = false, length = 100)
|
@Column(nullable = false, length = 50)
|
||||||
private String petName;
|
private String petName;
|
||||||
|
|
||||||
@Column(name = "pet_species", nullable = false, length = 50)
|
@Column(nullable = false, length = 50)
|
||||||
private String petSpecies;
|
private String petSpecies;
|
||||||
|
|
||||||
@Column(name = "pet_breed", length = 50)
|
@Column(nullable = false, length = 50)
|
||||||
private String petBreed;
|
private String petBreed;
|
||||||
|
|
||||||
@Column(name = "pet_age")
|
@Column(nullable = false)
|
||||||
private Integer petAge;
|
private Integer petAge;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Column(nullable = false, length = 20)
|
||||||
@Column(name = "pet_status", nullable = false)
|
private String petStatus;
|
||||||
private PetStatus petStatus = PetStatus.AVAILABLE;
|
|
||||||
|
|
||||||
@Column(name = "pet_price", precision = 10, scale = 2)
|
@Column(nullable = false, precision = 10, scale = 2)
|
||||||
private BigDecimal petPrice;
|
private BigDecimal petPrice;
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@@ -43,15 +42,11 @@ public class Pet {
|
|||||||
@Column(name = "updated_at")
|
@Column(name = "updated_at")
|
||||||
private LocalDateTime updatedAt;
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
public enum PetStatus {
|
|
||||||
AVAILABLE, ADOPTED, UNDER_CARE
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pet() {
|
public Pet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pet(Long id, String petName, String petSpecies, String petBreed, Integer petAge, PetStatus petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public Pet(Long petId, String petName, String petSpecies, String petBreed, Integer petAge, String petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.petId = petId;
|
||||||
this.petName = petName;
|
this.petName = petName;
|
||||||
this.petSpecies = petSpecies;
|
this.petSpecies = petSpecies;
|
||||||
this.petBreed = petBreed;
|
this.petBreed = petBreed;
|
||||||
@@ -62,12 +57,12 @@ public class Pet {
|
|||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getPetId() {
|
||||||
return id;
|
return petId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setPetId(Long petId) {
|
||||||
this.id = id;
|
this.petId = petId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPetName() {
|
public String getPetName() {
|
||||||
@@ -102,11 +97,11 @@ public class Pet {
|
|||||||
this.petAge = petAge;
|
this.petAge = petAge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PetStatus getPetStatus() {
|
public String getPetStatus() {
|
||||||
return petStatus;
|
return petStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPetStatus(PetStatus petStatus) {
|
public void setPetStatus(String petStatus) {
|
||||||
this.petStatus = petStatus;
|
this.petStatus = petStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,23 +134,23 @@ public class Pet {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Pet pet = (Pet) o;
|
Pet pet = (Pet) o;
|
||||||
return Objects.equals(id, pet.id);
|
return Objects.equals(petId, pet.petId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(petId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Pet{" +
|
return "Pet{" +
|
||||||
"id=" + id +
|
"petId=" + petId +
|
||||||
", petName='" + petName + '\'' +
|
", petName='" + petName + '\'' +
|
||||||
", petSpecies='" + petSpecies + '\'' +
|
", petSpecies='" + petSpecies + '\'' +
|
||||||
", petBreed='" + petBreed + '\'' +
|
", petBreed='" + petBreed + '\'' +
|
||||||
", petAge=" + petAge +
|
", petAge=" + petAge +
|
||||||
", petStatus=" + petStatus +
|
", petStatus='" + petStatus + '\'' +
|
||||||
", petPrice=" + petPrice +
|
", petPrice=" + petPrice +
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
|
|||||||
@@ -9,28 +9,25 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "products")
|
@Table(name = "product")
|
||||||
public class Product {
|
public class Product {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long prodId;
|
||||||
|
|
||||||
@Column(name = "product_name", nullable = false, length = 100)
|
@Column(nullable = false, length = 100)
|
||||||
private String productName;
|
private String prodName;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "category_id", nullable = false)
|
@JoinColumn(name = "categoryId", nullable = false)
|
||||||
private Category category;
|
private Category category;
|
||||||
|
|
||||||
@Column(name = "product_description", columnDefinition = "TEXT")
|
@Column(columnDefinition = "TEXT")
|
||||||
private String productDescription;
|
private String prodDesc;
|
||||||
|
|
||||||
@Column(name = "product_price", nullable = false, precision = 10, scale = 2)
|
@Column(nullable = false, precision = 10, scale = 2)
|
||||||
private BigDecimal productPrice;
|
private BigDecimal prodPrice;
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
private Boolean active = true;
|
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@@ -43,31 +40,30 @@ public class Product {
|
|||||||
public Product() {
|
public Product() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Product(Long id, String productName, Category category, String productDescription, BigDecimal productPrice, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public Product(Long prodId, String prodName, Category category, String prodDesc, BigDecimal prodPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.prodId = prodId;
|
||||||
this.productName = productName;
|
this.prodName = prodName;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
this.productDescription = productDescription;
|
this.prodDesc = prodDesc;
|
||||||
this.productPrice = productPrice;
|
this.prodPrice = prodPrice;
|
||||||
this.active = active;
|
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getProdId() {
|
||||||
return id;
|
return prodId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setProdId(Long prodId) {
|
||||||
this.id = id;
|
this.prodId = prodId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProductName() {
|
public String getProdName() {
|
||||||
return productName;
|
return prodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProductName(String productName) {
|
public void setProdName(String prodName) {
|
||||||
this.productName = productName;
|
this.prodName = prodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Category getCategory() {
|
public Category getCategory() {
|
||||||
@@ -78,28 +74,20 @@ public class Product {
|
|||||||
this.category = category;
|
this.category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProductDescription() {
|
public String getProdDesc() {
|
||||||
return productDescription;
|
return prodDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProductDescription(String productDescription) {
|
public void setProdDesc(String prodDesc) {
|
||||||
this.productDescription = productDescription;
|
this.prodDesc = prodDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getProductPrice() {
|
public BigDecimal getProdPrice() {
|
||||||
return productPrice;
|
return prodPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProductPrice(BigDecimal productPrice) {
|
public void setProdPrice(BigDecimal prodPrice) {
|
||||||
this.productPrice = productPrice;
|
this.prodPrice = prodPrice;
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getActive() {
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(Boolean active) {
|
|
||||||
this.active = active;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
public LocalDateTime getCreatedAt() {
|
||||||
@@ -123,23 +111,22 @@ public class Product {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Product product = (Product) o;
|
Product product = (Product) o;
|
||||||
return Objects.equals(id, product.id);
|
return Objects.equals(prodId, product.prodId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(prodId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Product{" +
|
return "Product{" +
|
||||||
"id=" + id +
|
"prodId=" + prodId +
|
||||||
", productName='" + productName + '\'' +
|
", prodName='" + prodName + '\'' +
|
||||||
", category=" + category +
|
", category=" + category +
|
||||||
", productDescription='" + productDescription + '\'' +
|
", prodDesc='" + prodDesc + '\'' +
|
||||||
", productPrice=" + productPrice +
|
", prodPrice=" + prodPrice +
|
||||||
", active=" + active +
|
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -10,28 +10,22 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "product_suppliers")
|
@Table(name = "productSupplier")
|
||||||
@IdClass(ProductSupplier.ProductSupplierId.class)
|
@IdClass(ProductSupplier.ProductSupplierId.class)
|
||||||
public class ProductSupplier {
|
public class ProductSupplier {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "product_id", nullable = false)
|
@JoinColumn(name = "prodId", nullable = false)
|
||||||
private Product product;
|
private Product product;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "supplier_id", nullable = false)
|
@JoinColumn(name = "supId", nullable = false)
|
||||||
private Supplier supplier;
|
private Supplier supplier;
|
||||||
|
|
||||||
@Column(name = "cost_price", nullable = false, precision = 10, scale = 2)
|
@Column(nullable = false, precision = 10, scale = 2)
|
||||||
private BigDecimal costPrice;
|
private BigDecimal cost;
|
||||||
|
|
||||||
@Column(name = "lead_time_days")
|
|
||||||
private Integer leadTimeDays;
|
|
||||||
|
|
||||||
@Column(name = "is_preferred")
|
|
||||||
private Boolean isPreferred = false;
|
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@@ -44,12 +38,10 @@ public class ProductSupplier {
|
|||||||
public ProductSupplier() {
|
public ProductSupplier() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductSupplier(Product product, Supplier supplier, BigDecimal costPrice, Integer leadTimeDays, Boolean isPreferred, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public ProductSupplier(Product product, Supplier supplier, BigDecimal cost, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.product = product;
|
this.product = product;
|
||||||
this.supplier = supplier;
|
this.supplier = supplier;
|
||||||
this.costPrice = costPrice;
|
this.cost = cost;
|
||||||
this.leadTimeDays = leadTimeDays;
|
|
||||||
this.isPreferred = isPreferred;
|
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
@@ -70,28 +62,12 @@ public class ProductSupplier {
|
|||||||
this.supplier = supplier;
|
this.supplier = supplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getCostPrice() {
|
public BigDecimal getCost() {
|
||||||
return costPrice;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCostPrice(BigDecimal costPrice) {
|
public void setCost(BigDecimal cost) {
|
||||||
this.costPrice = costPrice;
|
this.cost = cost;
|
||||||
}
|
|
||||||
|
|
||||||
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 LocalDateTime getCreatedAt() {
|
public LocalDateTime getCreatedAt() {
|
||||||
@@ -128,9 +104,7 @@ public class ProductSupplier {
|
|||||||
return "ProductSupplier{" +
|
return "ProductSupplier{" +
|
||||||
"product=" + product +
|
"product=" + product +
|
||||||
", supplier=" + supplier +
|
", supplier=" + supplier +
|
||||||
", costPrice=" + costPrice +
|
", cost=" + cost +
|
||||||
", leadTimeDays=" + leadTimeDays +
|
|
||||||
", isPreferred=" + isPreferred +
|
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -12,35 +12,22 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "purchase_orders")
|
@Table(name = "purchaseOrder")
|
||||||
public class PurchaseOrder {
|
public class PurchaseOrder {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long purchaseOrderId;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "supplier_id", nullable = false)
|
@JoinColumn(name = "supId", nullable = false)
|
||||||
private Supplier supplier;
|
private Supplier supplier;
|
||||||
|
|
||||||
@Column(name = "order_date", nullable = false)
|
@Column(nullable = false)
|
||||||
private LocalDate orderDate;
|
private LocalDate orderDate;
|
||||||
|
|
||||||
@Column(name = "expected_delivery")
|
@Column(nullable = false, length = 50)
|
||||||
private LocalDate expectedDelivery;
|
private String status;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
@Column(nullable = false)
|
|
||||||
private OrderStatus status = OrderStatus.Pending;
|
|
||||||
|
|
||||||
@Column(name = "total_amount", nullable = false, precision = 10, scale = 2)
|
|
||||||
private BigDecimal totalAmount;
|
|
||||||
|
|
||||||
@Column(columnDefinition = "TEXT")
|
|
||||||
private String notes;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "purchaseOrder", cascade = CascadeType.ALL)
|
|
||||||
private List<PurchaseOrderItem> items = new ArrayList<>();
|
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@@ -50,32 +37,24 @@ public class PurchaseOrder {
|
|||||||
@Column(name = "updated_at")
|
@Column(name = "updated_at")
|
||||||
private LocalDateTime updatedAt;
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
public enum OrderStatus {
|
|
||||||
Pending, Delivered, Cancelled
|
|
||||||
}
|
|
||||||
|
|
||||||
public PurchaseOrder() {
|
public PurchaseOrder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PurchaseOrder(Long id, Supplier supplier, LocalDate orderDate, LocalDate expectedDelivery, OrderStatus status, BigDecimal totalAmount, String notes, List<PurchaseOrderItem> items, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public PurchaseOrder(Long purchaseOrderId, Supplier supplier, LocalDate orderDate, String status, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.purchaseOrderId = purchaseOrderId;
|
||||||
this.supplier = supplier;
|
this.supplier = supplier;
|
||||||
this.orderDate = orderDate;
|
this.orderDate = orderDate;
|
||||||
this.expectedDelivery = expectedDelivery;
|
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.totalAmount = totalAmount;
|
|
||||||
this.notes = notes;
|
|
||||||
this.items = items;
|
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getPurchaseOrderId() {
|
||||||
return id;
|
return purchaseOrderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setPurchaseOrderId(Long purchaseOrderId) {
|
||||||
this.id = id;
|
this.purchaseOrderId = purchaseOrderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Supplier getSupplier() {
|
public Supplier getSupplier() {
|
||||||
@@ -94,46 +73,14 @@ public class PurchaseOrder {
|
|||||||
this.orderDate = orderDate;
|
this.orderDate = orderDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getExpectedDelivery() {
|
public String getStatus() {
|
||||||
return expectedDelivery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpectedDelivery(LocalDate expectedDelivery) {
|
|
||||||
this.expectedDelivery = expectedDelivery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrderStatus getStatus() {
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(OrderStatus status) {
|
public void setStatus(String status) {
|
||||||
this.status = status;
|
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<PurchaseOrderItem> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItems(List<PurchaseOrderItem> items) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
public LocalDateTime getCreatedAt() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
@@ -155,25 +102,21 @@ public class PurchaseOrder {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
PurchaseOrder that = (PurchaseOrder) o;
|
PurchaseOrder that = (PurchaseOrder) o;
|
||||||
return Objects.equals(id, that.id);
|
return Objects.equals(purchaseOrderId, that.purchaseOrderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(purchaseOrderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PurchaseOrder{" +
|
return "PurchaseOrder{" +
|
||||||
"id=" + id +
|
"purchaseOrderId=" + purchaseOrderId +
|
||||||
", supplier=" + supplier +
|
", supplier=" + supplier +
|
||||||
", orderDate=" + orderDate +
|
", orderDate=" + orderDate +
|
||||||
", expectedDelivery=" + expectedDelivery +
|
", status='" + status + '\'' +
|
||||||
", status=" + status +
|
|
||||||
", totalAmount=" + totalAmount +
|
|
||||||
", notes='" + notes + '\'' +
|
|
||||||
", items=" + items +
|
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -1,148 +0,0 @@
|
|||||||
package com.petshop.backend.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import org.hibernate.annotations.CreationTimestamp;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "refunds")
|
|
||||||
public class Refund {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "sale_id", nullable = false)
|
|
||||||
private Sale sale;
|
|
||||||
|
|
||||||
@Column(name = "refund_date", nullable = false)
|
|
||||||
private LocalDateTime refundDate = LocalDateTime.now();
|
|
||||||
|
|
||||||
@Column(name = "refund_amount", nullable = false, precision = 10, scale = 2)
|
|
||||||
private BigDecimal refundAmount;
|
|
||||||
|
|
||||||
@Column(name = "refund_reason", columnDefinition = "TEXT")
|
|
||||||
private String refundReason;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "processed_by", nullable = false)
|
|
||||||
private User processedBy;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "refund", cascade = CascadeType.ALL)
|
|
||||||
private List<RefundItem> items = new ArrayList<>();
|
|
||||||
|
|
||||||
@CreationTimestamp
|
|
||||||
@Column(name = "created_at", updatable = false)
|
|
||||||
private LocalDateTime createdAt;
|
|
||||||
|
|
||||||
public Refund() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Refund(Long id, Sale sale, LocalDateTime refundDate, BigDecimal refundAmount, String refundReason, User processedBy, List<RefundItem> items, LocalDateTime createdAt) {
|
|
||||||
this.id = id;
|
|
||||||
this.sale = sale;
|
|
||||||
this.refundDate = refundDate;
|
|
||||||
this.refundAmount = refundAmount;
|
|
||||||
this.refundReason = refundReason;
|
|
||||||
this.processedBy = processedBy;
|
|
||||||
this.items = items;
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Sale getSale() {
|
|
||||||
return sale;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSale(Sale sale) {
|
|
||||||
this.sale = sale;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDateTime getRefundDate() {
|
|
||||||
return refundDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefundDate(LocalDateTime refundDate) {
|
|
||||||
this.refundDate = refundDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getRefundAmount() {
|
|
||||||
return refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefundAmount(BigDecimal refundAmount) {
|
|
||||||
this.refundAmount = refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefundReason() {
|
|
||||||
return refundReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefundReason(String refundReason) {
|
|
||||||
this.refundReason = refundReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User getProcessedBy() {
|
|
||||||
return processedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProcessedBy(User processedBy) {
|
|
||||||
this.processedBy = processedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RefundItem> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItems(List<RefundItem> items) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedAt(LocalDateTime createdAt) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
Refund refund = (Refund) o;
|
|
||||||
return Objects.equals(id, refund.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Refund{" +
|
|
||||||
"id=" + id +
|
|
||||||
", sale=" + sale +
|
|
||||||
", refundDate=" + refundDate +
|
|
||||||
", refundAmount=" + refundAmount +
|
|
||||||
", refundReason='" + refundReason + '\'' +
|
|
||||||
", processedBy=" + processedBy +
|
|
||||||
", items=" + items +
|
|
||||||
", createdAt=" + createdAt +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
package com.petshop.backend.entity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "refund_items")
|
|
||||||
public class RefundItem {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "refund_id", nullable = false)
|
|
||||||
private Refund refund;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "sale_item_id", nullable = false)
|
|
||||||
private SaleItem saleItem;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
private Integer quantity;
|
|
||||||
|
|
||||||
@Column(name = "refund_amount", nullable = false, precision = 10, scale = 2)
|
|
||||||
private BigDecimal refundAmount;
|
|
||||||
|
|
||||||
public RefundItem() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public RefundItem(Long id, Refund refund, SaleItem saleItem, Integer quantity, BigDecimal refundAmount) {
|
|
||||||
this.id = id;
|
|
||||||
this.refund = refund;
|
|
||||||
this.saleItem = saleItem;
|
|
||||||
this.quantity = quantity;
|
|
||||||
this.refundAmount = refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Refund getRefund() {
|
|
||||||
return refund;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefund(Refund refund) {
|
|
||||||
this.refund = refund;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaleItem getSaleItem() {
|
|
||||||
return saleItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSaleItem(SaleItem saleItem) {
|
|
||||||
this.saleItem = saleItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getQuantity() {
|
|
||||||
return quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQuantity(Integer quantity) {
|
|
||||||
this.quantity = quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getRefundAmount() {
|
|
||||||
return refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefundAmount(BigDecimal refundAmount) {
|
|
||||||
this.refundAmount = refundAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
RefundItem that = (RefundItem) o;
|
|
||||||
return Objects.equals(id, that.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "RefundItem{" +
|
|
||||||
"id=" + id +
|
|
||||||
", refund=" + refund +
|
|
||||||
", saleItem=" + saleItem +
|
|
||||||
", quantity=" + quantity +
|
|
||||||
", refundAmount=" + refundAmount +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,42 +10,36 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sales")
|
@Table(name = "sale")
|
||||||
public class Sale {
|
public class Sale {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long saleId;
|
||||||
|
|
||||||
@Column(name = "sale_date", nullable = false)
|
@Column(nullable = false)
|
||||||
private LocalDateTime saleDate = LocalDateTime.now();
|
private LocalDateTime saleDate = LocalDateTime.now();
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "employee_id", nullable = false)
|
@JoinColumn(name = "employeeId", nullable = false)
|
||||||
private User employee;
|
private Employee employee;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "customer_id")
|
@JoinColumn(name = "storeId", nullable = false)
|
||||||
private Customer customer;
|
private StoreLocation store;
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "store_id")
|
|
||||||
private Store store;
|
|
||||||
|
|
||||||
@Column(nullable = false, precision = 10, scale = 2)
|
@Column(nullable = false, precision = 10, scale = 2)
|
||||||
private BigDecimal subtotal;
|
private BigDecimal totalAmount;
|
||||||
|
|
||||||
@Column(nullable = false, precision = 10, scale = 2)
|
@Column(nullable = false, length = 50)
|
||||||
private BigDecimal tax = BigDecimal.ZERO;
|
|
||||||
|
|
||||||
@Column(nullable = false, precision = 10, scale = 2)
|
|
||||||
private BigDecimal total;
|
|
||||||
|
|
||||||
@Column(name = "payment_method", length = 50)
|
|
||||||
private String paymentMethod;
|
private String paymentMethod;
|
||||||
|
|
||||||
@Column(columnDefinition = "TEXT")
|
@Column(nullable = false)
|
||||||
private String notes;
|
private Boolean isRefund = false;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "originalSaleId")
|
||||||
|
private Sale originalSale;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "sale", cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "sale", cascade = CascadeType.ALL)
|
||||||
private List<SaleItem> items = new ArrayList<>();
|
private List<SaleItem> items = new ArrayList<>();
|
||||||
@@ -57,27 +51,25 @@ public class Sale {
|
|||||||
public Sale() {
|
public Sale() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sale(Long id, LocalDateTime saleDate, User employee, Customer customer, Store store, BigDecimal subtotal, BigDecimal tax, BigDecimal total, String paymentMethod, String notes, 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) {
|
||||||
this.id = id;
|
this.saleId = saleId;
|
||||||
this.saleDate = saleDate;
|
this.saleDate = saleDate;
|
||||||
this.employee = employee;
|
this.employee = employee;
|
||||||
this.customer = customer;
|
|
||||||
this.store = store;
|
this.store = store;
|
||||||
this.subtotal = subtotal;
|
this.totalAmount = totalAmount;
|
||||||
this.tax = tax;
|
|
||||||
this.total = total;
|
|
||||||
this.paymentMethod = paymentMethod;
|
this.paymentMethod = paymentMethod;
|
||||||
this.notes = notes;
|
this.isRefund = isRefund;
|
||||||
|
this.originalSale = originalSale;
|
||||||
this.items = items;
|
this.items = items;
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getSaleId() {
|
||||||
return id;
|
return saleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setSaleId(Long saleId) {
|
||||||
this.id = id;
|
this.saleId = saleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getSaleDate() {
|
public LocalDateTime getSaleDate() {
|
||||||
@@ -88,52 +80,28 @@ public class Sale {
|
|||||||
this.saleDate = saleDate;
|
this.saleDate = saleDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getEmployee() {
|
public Employee getEmployee() {
|
||||||
return employee;
|
return employee;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmployee(User employee) {
|
public void setEmployee(Employee employee) {
|
||||||
this.employee = employee;
|
this.employee = employee;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Customer getCustomer() {
|
public StoreLocation getStore() {
|
||||||
return customer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCustomer(Customer customer) {
|
|
||||||
this.customer = customer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Store getStore() {
|
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStore(Store store) {
|
public void setStore(StoreLocation store) {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getSubtotal() {
|
public BigDecimal getTotalAmount() {
|
||||||
return subtotal;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubtotal(BigDecimal subtotal) {
|
public void setTotalAmount(BigDecimal totalAmount) {
|
||||||
this.subtotal = subtotal;
|
this.totalAmount = totalAmount;
|
||||||
}
|
|
||||||
|
|
||||||
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 String getPaymentMethod() {
|
public String getPaymentMethod() {
|
||||||
@@ -144,12 +112,20 @@ public class Sale {
|
|||||||
this.paymentMethod = paymentMethod;
|
this.paymentMethod = paymentMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNotes() {
|
public Boolean getIsRefund() {
|
||||||
return notes;
|
return isRefund;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotes(String notes) {
|
public void setIsRefund(Boolean isRefund) {
|
||||||
this.notes = notes;
|
this.isRefund = isRefund;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sale getOriginalSale() {
|
||||||
|
return originalSale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginalSale(Sale originalSale) {
|
||||||
|
this.originalSale = originalSale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SaleItem> getItems() {
|
public List<SaleItem> getItems() {
|
||||||
@@ -173,27 +149,25 @@ public class Sale {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Sale sale = (Sale) o;
|
Sale sale = (Sale) o;
|
||||||
return Objects.equals(id, sale.id);
|
return Objects.equals(saleId, sale.saleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(saleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Sale{" +
|
return "Sale{" +
|
||||||
"id=" + id +
|
"saleId=" + saleId +
|
||||||
", saleDate=" + saleDate +
|
", saleDate=" + saleDate +
|
||||||
", employee=" + employee +
|
", employee=" + employee +
|
||||||
", customer=" + customer +
|
|
||||||
", store=" + store +
|
", store=" + store +
|
||||||
", subtotal=" + subtotal +
|
", totalAmount=" + totalAmount +
|
||||||
", tax=" + tax +
|
|
||||||
", total=" + total +
|
|
||||||
", paymentMethod='" + paymentMethod + '\'' +
|
", paymentMethod='" + paymentMethod + '\'' +
|
||||||
", notes='" + notes + '\'' +
|
", isRefund=" + isRefund +
|
||||||
|
", originalSale=" + originalSale +
|
||||||
", items=" + items +
|
", items=" + items +
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -6,48 +6,44 @@ import java.math.BigDecimal;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sale_items")
|
@Table(name = "saleItem")
|
||||||
public class SaleItem {
|
public class SaleItem {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long saleItemId;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "sale_id", nullable = false)
|
@JoinColumn(name = "saleId", nullable = false)
|
||||||
private Sale sale;
|
private Sale sale;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "product_id", nullable = false)
|
@JoinColumn(name = "prodId", nullable = false)
|
||||||
private Product product;
|
private Product product;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Integer quantity;
|
private Integer quantity;
|
||||||
|
|
||||||
@Column(name = "unit_price", nullable = false, precision = 10, scale = 2)
|
|
||||||
private BigDecimal unitPrice;
|
|
||||||
|
|
||||||
@Column(nullable = false, precision = 10, scale = 2)
|
@Column(nullable = false, precision = 10, scale = 2)
|
||||||
private BigDecimal subtotal;
|
private BigDecimal unitPrice;
|
||||||
|
|
||||||
public SaleItem() {
|
public SaleItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SaleItem(Long id, Sale sale, Product product, Integer quantity, BigDecimal unitPrice, BigDecimal subtotal) {
|
public SaleItem(Long saleItemId, Sale sale, Product product, Integer quantity, BigDecimal unitPrice) {
|
||||||
this.id = id;
|
this.saleItemId = saleItemId;
|
||||||
this.sale = sale;
|
this.sale = sale;
|
||||||
this.product = product;
|
this.product = product;
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.unitPrice = unitPrice;
|
this.unitPrice = unitPrice;
|
||||||
this.subtotal = subtotal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getSaleItemId() {
|
||||||
return id;
|
return saleItemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setSaleItemId(Long saleItemId) {
|
||||||
this.id = id;
|
this.saleItemId = saleItemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sale getSale() {
|
public Sale getSale() {
|
||||||
@@ -82,36 +78,27 @@ public class SaleItem {
|
|||||||
this.unitPrice = unitPrice;
|
this.unitPrice = unitPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getSubtotal() {
|
|
||||||
return subtotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubtotal(BigDecimal subtotal) {
|
|
||||||
this.subtotal = subtotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
SaleItem saleItem = (SaleItem) o;
|
SaleItem saleItem = (SaleItem) o;
|
||||||
return Objects.equals(id, saleItem.id);
|
return Objects.equals(saleItemId, saleItem.saleItemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(saleItemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SaleItem{" +
|
return "SaleItem{" +
|
||||||
"id=" + id +
|
"saleItemId=" + saleItemId +
|
||||||
", sale=" + sale +
|
", sale=" + sale +
|
||||||
", product=" + product +
|
", product=" + product +
|
||||||
", quantity=" + quantity +
|
", quantity=" + quantity +
|
||||||
", unitPrice=" + unitPrice +
|
", unitPrice=" + unitPrice +
|
||||||
", subtotal=" + subtotal +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,27 +9,24 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "services")
|
@Table(name = "service")
|
||||||
public class Service {
|
public class Service {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long serviceId;
|
||||||
|
|
||||||
@Column(name = "service_name", nullable = false, length = 100)
|
@Column(nullable = false, length = 100)
|
||||||
private String serviceName;
|
private String serviceName;
|
||||||
|
|
||||||
@Column(name = "service_description", columnDefinition = "TEXT")
|
@Column(columnDefinition = "TEXT")
|
||||||
private String serviceDescription;
|
private String serviceDesc;
|
||||||
|
|
||||||
@Column(name = "service_price", nullable = false, precision = 10, scale = 2)
|
@Column(nullable = false, precision = 10, scale = 2)
|
||||||
private BigDecimal servicePrice;
|
private BigDecimal servicePrice;
|
||||||
|
|
||||||
@Column(name = "service_duration_minutes")
|
|
||||||
private Integer serviceDurationMinutes;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Boolean active = true;
|
private Integer serviceDuration;
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@@ -42,23 +39,22 @@ public class Service {
|
|||||||
public Service() {
|
public Service() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Service(Long id, String serviceName, String serviceDescription, BigDecimal servicePrice, Integer serviceDurationMinutes, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public Service(Long serviceId, String serviceName, String serviceDesc, BigDecimal servicePrice, Integer serviceDuration, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.serviceId = serviceId;
|
||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
this.serviceDescription = serviceDescription;
|
this.serviceDesc = serviceDesc;
|
||||||
this.servicePrice = servicePrice;
|
this.servicePrice = servicePrice;
|
||||||
this.serviceDurationMinutes = serviceDurationMinutes;
|
this.serviceDuration = serviceDuration;
|
||||||
this.active = active;
|
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getServiceId() {
|
||||||
return id;
|
return serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setServiceId(Long serviceId) {
|
||||||
this.id = id;
|
this.serviceId = serviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServiceName() {
|
public String getServiceName() {
|
||||||
@@ -69,12 +65,12 @@ public class Service {
|
|||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServiceDescription() {
|
public String getServiceDesc() {
|
||||||
return serviceDescription;
|
return serviceDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceDescription(String serviceDescription) {
|
public void setServiceDesc(String serviceDesc) {
|
||||||
this.serviceDescription = serviceDescription;
|
this.serviceDesc = serviceDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getServicePrice() {
|
public BigDecimal getServicePrice() {
|
||||||
@@ -85,20 +81,12 @@ public class Service {
|
|||||||
this.servicePrice = servicePrice;
|
this.servicePrice = servicePrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getServiceDurationMinutes() {
|
public Integer getServiceDuration() {
|
||||||
return serviceDurationMinutes;
|
return serviceDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceDurationMinutes(Integer serviceDurationMinutes) {
|
public void setServiceDuration(Integer serviceDuration) {
|
||||||
this.serviceDurationMinutes = serviceDurationMinutes;
|
this.serviceDuration = serviceDuration;
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getActive() {
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(Boolean active) {
|
|
||||||
this.active = active;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
public LocalDateTime getCreatedAt() {
|
||||||
@@ -122,23 +110,22 @@ public class Service {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Service service = (Service) o;
|
Service service = (Service) o;
|
||||||
return Objects.equals(id, service.id);
|
return Objects.equals(serviceId, service.serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Service{" +
|
return "Service{" +
|
||||||
"id=" + id +
|
"serviceId=" + serviceId +
|
||||||
", serviceName='" + serviceName + '\'' +
|
", serviceName='" + serviceName + '\'' +
|
||||||
", serviceDescription='" + serviceDescription + '\'' +
|
", serviceDesc='" + serviceDesc + '\'' +
|
||||||
", servicePrice=" + servicePrice +
|
", servicePrice=" + servicePrice +
|
||||||
", serviceDurationMinutes=" + serviceDurationMinutes +
|
", serviceDuration=" + serviceDuration +
|
||||||
", active=" + active +
|
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
132
src/main/java/com/petshop/backend/entity/StoreLocation.java
Normal file
132
src/main/java/com/petshop/backend/entity/StoreLocation.java
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
package com.petshop.backend.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import org.hibernate.annotations.CreationTimestamp;
|
||||||
|
import org.hibernate.annotations.UpdateTimestamp;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "storeLocation")
|
||||||
|
public class StoreLocation {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long storeId;
|
||||||
|
|
||||||
|
@Column(nullable = false, length = 100)
|
||||||
|
private String storeName;
|
||||||
|
|
||||||
|
@Column(nullable = false, length = 255)
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Column(nullable = false, length = 20)
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@Column(nullable = false, length = 100)
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@CreationTimestamp
|
||||||
|
@Column(name = "created_at", updatable = false)
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@UpdateTimestamp
|
||||||
|
@Column(name = "updated_at")
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
|
public StoreLocation() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreLocation(Long storeId, String storeName, String address, String phone, String email, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
|
this.storeId = storeId;
|
||||||
|
this.storeName = storeName;
|
||||||
|
this.address = address;
|
||||||
|
this.phone = phone;
|
||||||
|
this.email = email;
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
StoreLocation that = (StoreLocation) o;
|
||||||
|
return Objects.equals(storeId, that.storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "StoreLocation{" +
|
||||||
|
"storeId=" + storeId +
|
||||||
|
", storeName='" + storeName + '\'' +
|
||||||
|
", address='" + address + '\'' +
|
||||||
|
", phone='" + phone + '\'' +
|
||||||
|
", email='" + email + '\'' +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", updatedAt=" + updatedAt +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,30 +8,27 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "suppliers")
|
@Table(name = "supplier")
|
||||||
public class Supplier {
|
public class Supplier {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long supId;
|
||||||
|
|
||||||
@Column(name = "supplier_name", nullable = false, length = 100)
|
@Column(nullable = false, length = 100)
|
||||||
private String supplierName;
|
private String supCompany;
|
||||||
|
|
||||||
@Column(name = "supplier_contact", length = 100)
|
@Column(nullable = false, length = 50)
|
||||||
private String supplierContact;
|
private String supContactFirstName;
|
||||||
|
|
||||||
@Column(name = "supplier_email", length = 100)
|
@Column(nullable = false, length = 50)
|
||||||
private String supplierEmail;
|
private String supContactLastName;
|
||||||
|
|
||||||
@Column(name = "supplier_phone", length = 20)
|
@Column(nullable = false, length = 100)
|
||||||
private String supplierPhone;
|
private String supEmail;
|
||||||
|
|
||||||
@Column(name = "supplier_address", columnDefinition = "TEXT")
|
@Column(nullable = false, length = 20)
|
||||||
private String supplierAddress;
|
private String supPhone;
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
private Boolean active = true;
|
|
||||||
|
|
||||||
@CreationTimestamp
|
@CreationTimestamp
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@@ -44,72 +41,63 @@ public class Supplier {
|
|||||||
public Supplier() {
|
public Supplier() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Supplier(Long id, String supplierName, String supplierContact, String supplierEmail, String supplierPhone, String supplierAddress, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
public Supplier(Long supId, String supCompany, String supContactFirstName, String supContactLastName, String supEmail, String supPhone, LocalDateTime createdAt, LocalDateTime updatedAt) {
|
||||||
this.id = id;
|
this.supId = supId;
|
||||||
this.supplierName = supplierName;
|
this.supCompany = supCompany;
|
||||||
this.supplierContact = supplierContact;
|
this.supContactFirstName = supContactFirstName;
|
||||||
this.supplierEmail = supplierEmail;
|
this.supContactLastName = supContactLastName;
|
||||||
this.supplierPhone = supplierPhone;
|
this.supEmail = supEmail;
|
||||||
this.supplierAddress = supplierAddress;
|
this.supPhone = supPhone;
|
||||||
this.active = active;
|
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
this.updatedAt = updatedAt;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getSupId() {
|
||||||
return id;
|
return supId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setSupId(Long supId) {
|
||||||
this.id = id;
|
this.supId = supId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSupplierName() {
|
public String getSupCompany() {
|
||||||
return supplierName;
|
return supCompany;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSupplierName(String supplierName) {
|
public void setSupCompany(String supCompany) {
|
||||||
this.supplierName = supplierName;
|
this.supCompany = supCompany;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSupplierContact() {
|
public String getSupContactFirstName() {
|
||||||
return supplierContact;
|
return supContactFirstName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSupplierContact(String supplierContact) {
|
public void setSupContactFirstName(String supContactFirstName) {
|
||||||
this.supplierContact = supplierContact;
|
this.supContactFirstName = supContactFirstName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSupplierEmail() {
|
public String getSupContactLastName() {
|
||||||
return supplierEmail;
|
return supContactLastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSupplierEmail(String supplierEmail) {
|
public void setSupContactLastName(String supContactLastName) {
|
||||||
this.supplierEmail = supplierEmail;
|
this.supContactLastName = supContactLastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSupplierPhone() {
|
public String getSupEmail() {
|
||||||
return supplierPhone;
|
return supEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSupplierPhone(String supplierPhone) {
|
public void setSupEmail(String supEmail) {
|
||||||
this.supplierPhone = supplierPhone;
|
this.supEmail = supEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSupplierAddress() {
|
public String getSupPhone() {
|
||||||
return supplierAddress;
|
return supPhone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSupplierAddress(String supplierAddress) {
|
public void setSupPhone(String supPhone) {
|
||||||
this.supplierAddress = supplierAddress;
|
this.supPhone = supPhone;
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getActive() {
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(Boolean active) {
|
|
||||||
this.active = active;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getCreatedAt() {
|
public LocalDateTime getCreatedAt() {
|
||||||
@@ -133,24 +121,23 @@ public class Supplier {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Supplier supplier = (Supplier) o;
|
Supplier supplier = (Supplier) o;
|
||||||
return Objects.equals(id, supplier.id);
|
return Objects.equals(supId, supplier.supId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id);
|
return Objects.hash(supId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Supplier{" +
|
return "Supplier{" +
|
||||||
"id=" + id +
|
"supId=" + supId +
|
||||||
", supplierName='" + supplierName + '\'' +
|
", supCompany='" + supCompany + '\'' +
|
||||||
", supplierContact='" + supplierContact + '\'' +
|
", supContactFirstName='" + supContactFirstName + '\'' +
|
||||||
", supplierEmail='" + supplierEmail + '\'' +
|
", supContactLastName='" + supContactLastName + '\'' +
|
||||||
", supplierPhone='" + supplierPhone + '\'' +
|
", supEmail='" + supEmail + '\'' +
|
||||||
", supplierAddress='" + supplierAddress + '\'' +
|
", supPhone='" + supPhone + '\'' +
|
||||||
", active=" + active +
|
|
||||||
", createdAt=" + createdAt +
|
", createdAt=" + createdAt +
|
||||||
", updatedAt=" + updatedAt +
|
", updatedAt=" + updatedAt +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class User {
|
|||||||
private LocalDateTime updatedAt;
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
public enum Role {
|
public enum Role {
|
||||||
STAFF, ADMIN, CUSTOMER
|
STAFF, ADMIN
|
||||||
}
|
}
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.petshop.backend.repository;
|
|
||||||
|
|
||||||
import com.petshop.backend.entity.Refund;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface RefundRepository extends JpaRepository<Refund, Long> {
|
|
||||||
}
|
|
||||||
@@ -36,7 +36,7 @@ public class SecurityConfig {
|
|||||||
http
|
http
|
||||||
.csrf(AbstractHttpConfigurer::disable)
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers("/api/v1/auth/login", "/api/v1/auth/register").permitAll()
|
.requestMatchers("/api/v1/auth/login").permitAll()
|
||||||
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**", "/swagger-ui.html").permitAll()
|
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**", "/swagger-ui.html").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET, "/api/v1/dropdowns/suppliers").hasRole("ADMIN")
|
.requestMatchers(HttpMethod.GET, "/api/v1/dropdowns/suppliers").hasRole("ADMIN")
|
||||||
.requestMatchers("/api/v1/inventory/**").hasRole("ADMIN")
|
.requestMatchers("/api/v1/inventory/**").hasRole("ADMIN")
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
package com.petshop.backend.service;
|
|
||||||
|
|
||||||
import com.petshop.backend.dto.refund.RefundRequest;
|
|
||||||
import com.petshop.backend.dto.refund.RefundResponse;
|
|
||||||
import com.petshop.backend.entity.*;
|
|
||||||
import com.petshop.backend.exception.BusinessException;
|
|
||||||
import com.petshop.backend.exception.ResourceNotFoundException;
|
|
||||||
import com.petshop.backend.repository.*;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class RefundService {
|
|
||||||
|
|
||||||
private final RefundRepository refundRepository;
|
|
||||||
private final SaleRepository saleRepository;
|
|
||||||
private final SaleItemRepository saleItemRepository;
|
|
||||||
private final InventoryRepository inventoryRepository;
|
|
||||||
private final UserRepository userRepository;
|
|
||||||
|
|
||||||
public RefundService(RefundRepository refundRepository, SaleRepository saleRepository, SaleItemRepository saleItemRepository, InventoryRepository inventoryRepository, UserRepository userRepository) {
|
|
||||||
this.refundRepository = refundRepository;
|
|
||||||
this.saleRepository = saleRepository;
|
|
||||||
this.saleItemRepository = saleItemRepository;
|
|
||||||
this.inventoryRepository = inventoryRepository;
|
|
||||||
this.userRepository = userRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public RefundResponse createRefund(Long saleId, RefundRequest request) {
|
|
||||||
String username = SecurityContextHolder.getContext().getAuthentication().getName();
|
|
||||||
User processedBy = userRepository.findByUsername(username)
|
|
||||||
.orElseThrow(() -> new ResourceNotFoundException("User not found: " + username));
|
|
||||||
|
|
||||||
Sale sale = saleRepository.findById(saleId)
|
|
||||||
.orElseThrow(() -> new ResourceNotFoundException("Sale not found with id: " + saleId));
|
|
||||||
|
|
||||||
Refund refund = new Refund();
|
|
||||||
refund.setSale(sale);
|
|
||||||
refund.setRefundDate(LocalDateTime.now());
|
|
||||||
refund.setRefundReason(request.getRefundReason());
|
|
||||||
refund.setProcessedBy(processedBy);
|
|
||||||
|
|
||||||
BigDecimal totalRefundAmount = BigDecimal.ZERO;
|
|
||||||
List<RefundItem> refundItems = new ArrayList<>();
|
|
||||||
|
|
||||||
for (var itemRequest : request.getItems()) {
|
|
||||||
SaleItem saleItem = saleItemRepository.findById(itemRequest.getSaleItemId())
|
|
||||||
.orElseThrow(() -> new ResourceNotFoundException("Sale item not found with id: " + itemRequest.getSaleItemId()));
|
|
||||||
|
|
||||||
if (!saleItem.getSale().getId().equals(saleId)) {
|
|
||||||
throw new BusinessException("Sale item " + itemRequest.getSaleItemId() + " does not belong to sale " + saleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemRequest.getQuantity() > saleItem.getQuantity()) {
|
|
||||||
throw new BusinessException("Refund quantity (" + itemRequest.getQuantity() +
|
|
||||||
") exceeds original sale quantity (" + saleItem.getQuantity() + ") for product: " + saleItem.getProduct().getProductName());
|
|
||||||
}
|
|
||||||
|
|
||||||
Inventory inventory = inventoryRepository.findByProductIdAndStoreId(
|
|
||||||
saleItem.getProduct().getId(),
|
|
||||||
sale.getStore().getId())
|
|
||||||
.orElseThrow(() -> new ResourceNotFoundException("Inventory not found for product " +
|
|
||||||
saleItem.getProduct().getId() + " at store " + sale.getStore().getId()));
|
|
||||||
|
|
||||||
inventory.setQuantity(inventory.getQuantity() + itemRequest.getQuantity());
|
|
||||||
inventory.setLastRestocked(LocalDateTime.now());
|
|
||||||
inventoryRepository.save(inventory);
|
|
||||||
|
|
||||||
BigDecimal itemRefundAmount = saleItem.getUnitPrice().multiply(BigDecimal.valueOf(itemRequest.getQuantity()));
|
|
||||||
|
|
||||||
RefundItem refundItem = new RefundItem();
|
|
||||||
refundItem.setRefund(refund);
|
|
||||||
refundItem.setSaleItem(saleItem);
|
|
||||||
refundItem.setQuantity(itemRequest.getQuantity());
|
|
||||||
refundItem.setRefundAmount(itemRefundAmount);
|
|
||||||
|
|
||||||
refundItems.add(refundItem);
|
|
||||||
totalRefundAmount = totalRefundAmount.add(itemRefundAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
refund.setRefundAmount(totalRefundAmount);
|
|
||||||
refund.setItems(refundItems);
|
|
||||||
|
|
||||||
Refund savedRefund = refundRepository.save(refund);
|
|
||||||
return mapToResponse(savedRefund);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RefundResponse mapToResponse(Refund refund) {
|
|
||||||
RefundResponse response = new RefundResponse();
|
|
||||||
response.setId(refund.getId());
|
|
||||||
response.setSaleId(refund.getSale().getId());
|
|
||||||
response.setRefundDate(refund.getRefundDate());
|
|
||||||
response.setRefundAmount(refund.getRefundAmount());
|
|
||||||
response.setRefundReason(refund.getRefundReason());
|
|
||||||
response.setProcessedBy(refund.getProcessedBy().getId());
|
|
||||||
response.setProcessedByName(refund.getProcessedBy().getFullName());
|
|
||||||
response.setCreatedAt(refund.getCreatedAt());
|
|
||||||
|
|
||||||
List<RefundResponse.RefundItemResponse> itemResponses = new ArrayList<>();
|
|
||||||
for (RefundItem item : refund.getItems()) {
|
|
||||||
RefundResponse.RefundItemResponse itemResponse = new RefundResponse.RefundItemResponse();
|
|
||||||
itemResponse.setId(item.getId());
|
|
||||||
itemResponse.setSaleItemId(item.getSaleItem().getId());
|
|
||||||
itemResponse.setProductId(item.getSaleItem().getProduct().getId());
|
|
||||||
itemResponse.setProductName(item.getSaleItem().getProduct().getProductName());
|
|
||||||
itemResponse.setQuantity(item.getQuantity());
|
|
||||||
itemResponse.setRefundAmount(item.getRefundAmount());
|
|
||||||
itemResponses.add(itemResponse);
|
|
||||||
}
|
|
||||||
response.setItems(itemResponses);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ spring:
|
|||||||
|
|
||||||
jpa:
|
jpa:
|
||||||
hibernate:
|
hibernate:
|
||||||
ddl-auto: update
|
ddl-auto: validate
|
||||||
show-sql: ${JPA_SHOW_SQL:false}
|
show-sql: ${JPA_SHOW_SQL:false}
|
||||||
properties:
|
properties:
|
||||||
hibernate:
|
hibernate:
|
||||||
|
|||||||
Reference in New Issue
Block a user