|
|
@@ -2,7 +2,6 @@ package bubble.model.bill; |
|
|
|
|
|
|
|
import bubble.model.account.Account; |
|
|
|
import bubble.model.account.HasAccountNoName; |
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.NoArgsConstructor; |
|
|
|
import lombok.Setter; |
|
|
@@ -14,8 +13,8 @@ import org.hibernate.annotations.Type; |
|
|
|
|
|
|
|
import javax.persistence.*; |
|
|
|
|
|
|
|
import static org.cobbzilla.util.daemon.ZillaRuntime.big; |
|
|
|
import static org.cobbzilla.wizard.model.crypto.EncryptedTypes.*; |
|
|
|
import static org.cobbzilla.wizard.model.crypto.EncryptedTypes.ENCRYPTED_LONG; |
|
|
|
import static org.cobbzilla.wizard.model.crypto.EncryptedTypes.ENC_LONG; |
|
|
|
|
|
|
|
@ECType(root=true) @ECTypeCreate(method="DISABLED") |
|
|
|
@ECTypeURIs(listFields={"name", "status", "type", "quantity", "price", "periodStart"}) |
|
|
@@ -47,42 +46,33 @@ public class Bill extends IdentifiableBase implements HasAccountNoName { |
|
|
|
public boolean paid() { return status == BillStatus.paid; } |
|
|
|
public boolean unpaid() { return !paid(); } |
|
|
|
|
|
|
|
@ECSearchable @ECField(index=50) |
|
|
|
@ECIndex @Enumerated(EnumType.STRING) |
|
|
|
@Column(nullable=false, updatable=false, length=20) |
|
|
|
@Getter @Setter private BillItemType type; |
|
|
|
|
|
|
|
@ECSearchable @ECField(index=60, type=EntityFieldType.opaque_string) |
|
|
|
@ECSearchable @ECField(index=50, type=EntityFieldType.opaque_string) |
|
|
|
@Column(nullable=false, updatable=false, length=20) |
|
|
|
@ECIndex @Getter @Setter private String periodLabel; |
|
|
|
|
|
|
|
@ECSearchable @ECField(index=70, type=EntityFieldType.opaque_string) |
|
|
|
@ECSearchable @ECField(index=60, type=EntityFieldType.opaque_string) |
|
|
|
@Column(nullable=false, updatable=false, length=20) |
|
|
|
@Getter @Setter private String periodStart; |
|
|
|
|
|
|
|
@ECSearchable @ECField(index=80, type=EntityFieldType.opaque_string) |
|
|
|
@ECSearchable @ECField(index=70, type=EntityFieldType.opaque_string) |
|
|
|
@Column(nullable=false, updatable=false, length=20) |
|
|
|
@Getter @Setter private String periodEnd; |
|
|
|
|
|
|
|
public int daysInPeriod () { return BillPeriod.daysInPeriod(periodStart, periodEnd); } |
|
|
|
|
|
|
|
@ECSearchable @ECField(index=90) |
|
|
|
@Type(type=ENCRYPTED_LONG) @Column(updatable=false, columnDefinition="varchar("+(ENC_LONG)+") NOT NULL") |
|
|
|
@Getter @Setter private Long quantity = 0L; |
|
|
|
|
|
|
|
@ECSearchable @ECField(index=100) |
|
|
|
@ECSearchable @ECField(index=80) |
|
|
|
@Type(type=ENCRYPTED_LONG) @Column(updatable=false, columnDefinition="varchar("+(ENC_LONG)+") NOT NULL") |
|
|
|
@Getter @Setter private Long price = 0L; |
|
|
|
@Getter @Setter private Long total = 0L; |
|
|
|
|
|
|
|
@ECSearchable @ECField(index=110) |
|
|
|
@ECSearchable @ECField(index=90) |
|
|
|
@ECIndex @Column(nullable=false, updatable=false, length=10) |
|
|
|
@Getter @Setter private String currency; |
|
|
|
|
|
|
|
@ECSearchable @ECField(index=120) |
|
|
|
@ECSearchable @ECField(index=100) |
|
|
|
@Type(type=ENCRYPTED_LONG) @Column(columnDefinition="varchar("+(ENC_LONG)+")") |
|
|
|
@Getter @Setter private Long refundedAmount = 0L; |
|
|
|
public boolean hasRefundedAmount () { return refundedAmount != null && refundedAmount > 0L; } |
|
|
|
|
|
|
|
@JsonIgnore @Transient public long getTotal() { return big(quantity).multiply(big(price)).longValue(); } |
|
|
|
@Transient @Getter @Setter private transient BubblePlan planObject; |
|
|
|
|
|
|
|
} |