package nl.homeserver.energiecontract;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import nl.homeserver.energie.StroomTariefIndicator;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDate;

import static java.math.BigDecimal.ZERO;

@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Entity
@Table
public class Energiecontract {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Getter
    private Long id;

    @Column(nullable = false, unique = true)
    @Getter
    @Setter
    private LocalDate validFrom;

    @JsonIgnore
    @Getter
    @Setter
    private LocalDate validTo;

    @Column(precision = 7, scale = 6, nullable = false)
    @Getter
    @Setter
    private BigDecimal stroomPerKwhNormaalTarief;

    @Column(precision = 7, scale = 6)
    @Getter
    @Setter
    private BigDecimal stroomPerKwhDalTarief;

    @Column(precision = 7, scale = 6)
    @Getter
    @Setter
    private BigDecimal gasPerKuub;

    @Getter
    @Setter
    private String leverancier;

    public BigDecimal getStroomKosten(final StroomTariefIndicator stroomTariefIndicator) {
        switch (stroomTariefIndicator) {
            case DAL:
                if (stroomPerKwhDalTarief != null) {
                    return stroomPerKwhDalTarief;
                } else {
                    return stroomPerKwhNormaalTarief;
                }
            case NORMAAL:
                return stroomPerKwhNormaalTarief;
            default:
                return ZERO;
        }
    }
}

@@ -33,16 +33,360 @@
 tract;%0A%0A
+import static java.math.BigDecimal.ZERO;%0A%0Aimport java.math.BigDecimal;%0Aimport java.time.LocalDate;%0A%0Aimport javax.annotation.Nullable;%0Aimport javax.persistence.Column;%0Aimport javax.persistence.Entity;%0Aimport javax.persistence.GeneratedValue;%0Aimport javax.persistence.GenerationType;%0Aimport javax.persistence.Id;%0Aimport javax.persistence.Table;%0A%0A
 import c
@@ -429,16 +429,16 @@
 Ignore;%0A
-
 import c
@@ -491,16 +491,17 @@
 erties;%0A
+%0A
 import l
@@ -593,136 +593,8 @@
 r;%0A%0A
-import javax.persistence.*;%0Aimport java.math.BigDecimal;%0Aimport java.time.LocalDate;%0A%0Aimport static java.math.BigDecimal.ZERO;%0A%0A
 @Jso
@@ -920,32 +920,32 @@
 ore%0A    @Getter%0A
-
     @Setter%0A    
@@ -932,32 +932,46 @@
 ter%0A    @Setter%0A
+    @Nullable%0A
     private Loca

Fix issues found by SonarCloud