68 lines
2.0 KiB
Java
68 lines
2.0 KiB
Java
package zw.qantra.tm.domain.models;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
import jakarta.persistence.*;
|
|
import lombok.*;
|
|
import zw.qantra.tm.domain.enums.ChargeLabelEnum;
|
|
import zw.qantra.tm.domain.enums.CurrencyType;
|
|
import zw.qantra.tm.domain.enums.TargetEvent;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
@Entity
|
|
@Table(name = "charge", indexes = {
|
|
@Index(name = "idx_charge_currency", columnList = "currency"),
|
|
@Index(name = "idx_charge_label_currency", columnList = "charge_label, currency"),
|
|
})
|
|
@Getter
|
|
@Setter
|
|
@Builder
|
|
@AllArgsConstructor
|
|
@NoArgsConstructor
|
|
public class Charge extends BaseEntity {
|
|
private String description;
|
|
|
|
// % rate to charge
|
|
private BigDecimal percentageRate;
|
|
private BigDecimal flat;
|
|
private boolean composite; // composite is % plus flat
|
|
private boolean global;
|
|
|
|
private BigDecimal min;
|
|
private BigDecimal max;
|
|
private BigDecimal minimumAmount;
|
|
private BigDecimal maximumAmount;
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(name = "charge_label")
|
|
private ChargeLabelEnum chargeLabel;
|
|
@Enumerated(EnumType.STRING)
|
|
private CurrencyType currency;
|
|
private String account;
|
|
private String target;
|
|
private String targetValue;
|
|
@Enumerated(EnumType.STRING)
|
|
private TargetEvent targetEvent; // include / exclude
|
|
|
|
@JsonIgnore
|
|
@ManyToMany(fetch = FetchType.EAGER)
|
|
@JoinTable(
|
|
name = "charge_include_products",
|
|
joinColumns = @JoinColumn(name = "charge_id"),
|
|
inverseJoinColumns = @JoinColumn(name = "charge_condition_id")
|
|
)
|
|
private Set<ChargeCondition> includes = new HashSet<>();
|
|
|
|
@JsonIgnore
|
|
@ManyToMany(fetch = FetchType.EAGER)
|
|
@JoinTable(
|
|
name = "charge_exclude_products",
|
|
joinColumns = @JoinColumn(name = "charge_id"),
|
|
inverseJoinColumns = @JoinColumn(name = "charge_condition_id")
|
|
)
|
|
private Set<ChargeCondition> excludes = new HashSet<>();
|
|
|
|
}
|