diff options
author | gjoranv <gjoranv@gmail.com> | 2023-10-31 12:53:06 +0100 |
---|---|---|
committer | gjoranv <gjoranv@gmail.com> | 2023-10-31 16:17:30 +0100 |
commit | 36b435a302357e198baeed816df79bdef0055292 (patch) | |
tree | 6c7c59cfadcdc5940733e905c67bc10cb37da979 /controller-api/src/main/java/com/yahoo | |
parent | 7c150cdc0bab88d5913de557fd24c31cd3bf18b4 (diff) |
Rename CLOSED -> SUCCESSFUL and introduce BillStatus.isFinal()
Diffstat (limited to 'controller-api/src/main/java/com/yahoo')
2 files changed, 12 insertions, 5 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java index 4f35b47219a..00aa43cce5d 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/BillStatus.java @@ -4,10 +4,10 @@ package com.yahoo.vespa.hosted.controller.api.integration.billing; * @author gjoranv */ public enum BillStatus { - OPEN, // All bills start in this state. The bill can be modified and exported/synced to external systems. - FROZEN, // Syncing to external systems is switched off. No changes can be made. - CLOSED, // End state for a valid bill. - VOID; // End state, indicating that the bill is not valid. + OPEN, // All bills start in this state. The bill can be modified and exported/synced to external systems. + FROZEN, // Syncing to external systems is switched off. No changes can be made. + SUCCESSFUL, // Final state for a valid bill. + VOID; // Final state, indicating that the bill is not valid. // Legacy states, used by historical bills private static final String LEGACY_ISSUED = "ISSUED"; @@ -24,6 +24,13 @@ public enum BillStatus { return value; } + /** + * Returns true if the bill is in a final state. + */ + public boolean isFinal() { + return this == SUCCESSFUL || this == VOID; + } + public static BillStatus from(String status) { if (LEGACY_ISSUED.equals(status) || LEGACY_EXPORTED.equals(status)) return OPEN; if (LEGACY_CANCELED.equals(status)) return VOID; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/StatusHistory.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/StatusHistory.java index f0c7f806c8c..788995555a8 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/StatusHistory.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/StatusHistory.java @@ -53,7 +53,7 @@ public class StatusHistory { return switch(current) { case OPEN -> true; case FROZEN -> newStatus != BillStatus.OPEN; // This could be subject to change. - case CLOSED -> newStatus == BillStatus.CLOSED; + case SUCCESSFUL -> newStatus == BillStatus.SUCCESSFUL; case VOID -> newStatus == BillStatus.VOID; }; } |