diff --git a/src/main/java/org/example/crm/mapper/InvoiceMapper.java b/src/main/java/org/example/crm/mapper/InvoiceMapper.java index 762b394..cff0130 100644 --- a/src/main/java/org/example/crm/mapper/InvoiceMapper.java +++ b/src/main/java/org/example/crm/mapper/InvoiceMapper.java @@ -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(), diff --git a/src/main/java/org/example/crm/projection/InvoiceProjection.java b/src/main/java/org/example/crm/projection/InvoiceProjection.java index 9ea645b..58f83f7 100644 --- a/src/main/java/org/example/crm/projection/InvoiceProjection.java +++ b/src/main/java/org/example/crm/projection/InvoiceProjection.java @@ -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(); } diff --git a/src/main/java/org/example/crm/repository/InvoiceRepository.java b/src/main/java/org/example/crm/repository/InvoiceRepository.java index 58dfec1..5632e54 100644 --- a/src/main/java/org/example/crm/repository/InvoiceRepository.java +++ b/src/main/java/org/example/crm/repository/InvoiceRepository.java @@ -28,13 +28,8 @@ public interface InvoiceRepository extends JpaRepository { 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 @@ -49,8 +44,8 @@ public interface InvoiceRepository extends JpaRepository { 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 getAllInvoicesByFilter( diff --git a/src/main/java/org/example/crm/service/StudentService.java b/src/main/java/org/example/crm/service/StudentService.java index 31179b9..c1c4e5c 100644 --- a/src/main/java/org/example/crm/service/StudentService.java +++ b/src/main/java/org/example/crm/service/StudentService.java @@ -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)); + } }