Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[model]-new-model-for-payment #2

Merged
merged 1 commit into from
Nov 20, 2023
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
57 changes: 57 additions & 0 deletions src/main/java/model/Payment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package model;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.math.BigDecimal;
import java.net.URL;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@EqualsAndHashCode(exclude = {"rental"})
@ToString(exclude = {"rental"})
@Entity
@Table(name = "payments")
public class Payment {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private PaymentStatus status;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private PaymentType type;
@Column(nullable = false)
private URL sessionUrl;
@Column(nullable = false)
private String sessionId;
@Column(nullable = false)
private BigDecimal amountToPay;
Comment on lines +41 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add

Suggested change
@Column(nullable = false)
private BigDecimal amountToPay;
@Column(nullable = false, name = "amount_to_pay")
private BigDecimal amountToPay;

@ManyToOne(fetch = FetchType.LAZY, optional = false) // ?Lilja
@JoinColumn(name = "rental_id", nullable = false)
private Rental rental;

private enum PaymentStatus {
PENDING,
PAID,
CANCELED
}

private enum PaymentType {
PAYMENT,
FINE
}
}
13 changes: 13 additions & 0 deletions src/main/java/model/Rental.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package model;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;

@Entity
public class Rental {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
}
Loading