Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/example/crm/mapper/InvoiceMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public InvoiceDto toDtoFromProjection(InvoiceProjection projection) {
projection.getId(),
projection.getInvoiceNumber(),
projection.getAmount(),
projection.getIssuedAt(),
projection.getCreatedAt(),
new EnrollmentDto(
projection.getEnrollmentId(),
projection.getStudentId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ public interface InvoiceProjection {
String getStudentId();
String getGroupId();
String getReason();
BigDecimal getMonthlyFee();
BigDecimal getPaidAmount();
EnrollmentPaymentStatus getEnrollmentStatus();

BigDecimal getAmount();
LocalDateTime getIssuedAt();
LocalDateTime getCreatedAt();
}
11 changes: 3 additions & 8 deletions src/main/java/org/example/crm/repository/InvoiceRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ public interface InvoiceRepository extends JpaRepository<Invoice, String> {
s.id as studentId,
g.id as groupId,
e.leavingReason as reason,
e.monthlyFee as monthlyFee,
e.paidAmount as paidAmount,
e.status as enrollmentStatus,

i.amount as amount,
i.issuedAt as issuedAt,
i.paymentStatus as status
i.createdAt as createAt
from Invoice i
join i.enrollment e
join e.student s
Expand All @@ -49,8 +44,8 @@ public interface InvoiceRepository extends JpaRepository<Invoice, String> {
or su.phone ilike :search
or g.name ilike :search
or i.invoiceNumber ilike :search )
and (i.issuedAt >= :from)
and (i.issuedAt <= :to)
and (i.createdAt >= :from)
and (i.createdAt <= :to)
and (:status is null or i.paymentStatus = :status)
""")
Page<InvoiceProjection> getAllInvoicesByFilter(
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/example/crm/service/StudentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,6 @@ public StudentDto getMe() {
public Invoice getLatestInvoice(@NotNull String studentId) {
return repository.findLatestInvoiceByStudentId(studentId)
.orElseThrow(() -> new RestException(ErrorType.INVOICE_NOT_FOUND, ErrorCodes.NotFound));

}
}