Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit 8940120

Browse files
committed
feat: Add supporting entities, repositories, services, and file storage
1 parent f2b5ab3 commit 8940120

16 files changed

Lines changed: 401 additions & 0 deletions
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.techtorque.project_service.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.*;
5+
import org.hibernate.annotations.CreationTimestamp;
6+
import org.hibernate.annotations.UpdateTimestamp;
7+
8+
import java.math.BigDecimal;
9+
import java.time.LocalDateTime;
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
13+
@Entity
14+
@Table(name = "invoices")
15+
@Data
16+
@Builder
17+
@NoArgsConstructor
18+
@AllArgsConstructor
19+
public class Invoice {
20+
@Id
21+
@GeneratedValue(strategy = GenerationType.UUID)
22+
private String id;
23+
24+
@Column(nullable = false, unique = true)
25+
private String invoiceNumber;
26+
27+
@Column(nullable = false)
28+
private String serviceId;
29+
30+
@Column(nullable = false)
31+
private String customerId;
32+
33+
@OneToMany(mappedBy = "invoice", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
34+
@Builder.Default
35+
private List<InvoiceItem> items = new ArrayList<>();
36+
37+
@Column(nullable = false)
38+
private BigDecimal subtotal;
39+
40+
@Column(nullable = false)
41+
private BigDecimal taxAmount;
42+
43+
@Column(nullable = false)
44+
private BigDecimal totalAmount;
45+
46+
@Enumerated(EnumType.STRING)
47+
@Column(nullable = false)
48+
private InvoiceStatus status;
49+
50+
private LocalDateTime paidAt;
51+
52+
@CreationTimestamp
53+
private LocalDateTime createdAt;
54+
55+
@UpdateTimestamp
56+
private LocalDateTime updatedAt;
57+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.techtorque.project_service.entity;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
import jakarta.persistence.*;
5+
import lombok.*;
6+
7+
import java.math.BigDecimal;
8+
9+
@Entity
10+
@Table(name = "invoice_items")
11+
@Data
12+
@Builder
13+
@NoArgsConstructor
14+
@AllArgsConstructor
15+
public class InvoiceItem {
16+
@Id
17+
@GeneratedValue(strategy = GenerationType.UUID)
18+
private String id;
19+
20+
@ManyToOne(fetch = FetchType.LAZY)
21+
@JoinColumn(name = "invoice_id", nullable = false)
22+
@JsonIgnore
23+
private Invoice invoice;
24+
25+
@Column(nullable = false)
26+
private String description;
27+
28+
@Column(nullable = false)
29+
private int quantity;
30+
31+
@Column(nullable = false)
32+
private BigDecimal unitPrice;
33+
34+
@Column(nullable = false)
35+
private BigDecimal amount;
36+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.techtorque.project_service.entity;
2+
3+
public enum InvoiceStatus {
4+
DRAFT,
5+
PENDING,
6+
PAID,
7+
OVERDUE,
8+
CANCELLED
9+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.techtorque.project_service.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.*;
5+
import org.hibernate.annotations.CreationTimestamp;
6+
7+
import java.time.LocalDateTime;
8+
9+
@Entity
10+
@Table(name = "progress_photos")
11+
@Data
12+
@Builder
13+
@NoArgsConstructor
14+
@AllArgsConstructor
15+
public class ProgressPhoto {
16+
@Id
17+
@GeneratedValue(strategy = GenerationType.UUID)
18+
private String id;
19+
20+
@Column(nullable = false)
21+
private String serviceId;
22+
23+
@Column(nullable = false)
24+
private String photoUrl;
25+
26+
private String description;
27+
28+
@Column(nullable = false)
29+
private String uploadedBy;
30+
31+
@CreationTimestamp
32+
private LocalDateTime uploadedAt;
33+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.techtorque.project_service.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.*;
5+
import org.hibernate.annotations.CreationTimestamp;
6+
7+
import java.math.BigDecimal;
8+
import java.time.LocalDateTime;
9+
10+
@Entity
11+
@Table(name = "quotes")
12+
@Data
13+
@Builder
14+
@NoArgsConstructor
15+
@AllArgsConstructor
16+
public class Quote {
17+
@Id
18+
@GeneratedValue(strategy = GenerationType.UUID)
19+
private String id;
20+
21+
@Column(nullable = false)
22+
private String projectId;
23+
24+
@Column(nullable = false)
25+
private BigDecimal laborCost;
26+
27+
@Column(nullable = false)
28+
private BigDecimal partsCost;
29+
30+
@Column(nullable = false)
31+
private BigDecimal totalCost;
32+
33+
@Column(nullable = false)
34+
private int estimatedDays;
35+
36+
@Lob
37+
private String breakdown;
38+
39+
@Column(nullable = false)
40+
private String submittedBy;
41+
42+
@CreationTimestamp
43+
private LocalDateTime submittedAt;
44+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.techtorque.project_service.entity;
2+
3+
import jakarta.persistence.*;
4+
import lombok.*;
5+
import org.hibernate.annotations.CreationTimestamp;
6+
7+
import java.time.LocalDateTime;
8+
9+
@Entity
10+
@Table(name = "service_notes")
11+
@Data
12+
@Builder
13+
@NoArgsConstructor
14+
@AllArgsConstructor
15+
public class ServiceNote {
16+
@Id
17+
@GeneratedValue(strategy = GenerationType.UUID)
18+
private String id;
19+
20+
@Column(nullable = false)
21+
private String serviceId;
22+
23+
@Column(nullable = false)
24+
private String employeeId;
25+
26+
@Column(nullable = false, length = 2000)
27+
private String note;
28+
29+
@Column(nullable = false)
30+
private boolean isCustomerVisible;
31+
32+
@CreationTimestamp
33+
private LocalDateTime createdAt;
34+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.techtorque.project_service.exception;
2+
3+
public class FileStorageException extends RuntimeException {
4+
public FileStorageException(String message) {
5+
super(message);
6+
}
7+
8+
public FileStorageException(String message, Throwable cause) {
9+
super(message, cause);
10+
}
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.techtorque.project_service.exception;
2+
3+
public class ServiceNotFoundException extends RuntimeException {
4+
public ServiceNotFoundException(String message) {
5+
super(message);
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.techtorque.project_service.exception;
2+
3+
public class UnauthorizedAccessException extends RuntimeException {
4+
public UnauthorizedAccessException(String message) {
5+
super(message);
6+
}
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.techtorque.project_service.repository;
2+
3+
import com.techtorque.project_service.entity.Invoice;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.stereotype.Repository;
6+
7+
import java.util.List;
8+
import java.util.Optional;
9+
10+
@Repository
11+
public interface InvoiceRepository extends JpaRepository<Invoice, String> {
12+
List<Invoice> findByCustomerId(String customerId);
13+
Optional<Invoice> findByServiceId(String serviceId);
14+
Optional<Invoice> findByInvoiceNumber(String invoiceNumber);
15+
}

0 commit comments

Comments
 (0)