1616@ JsonIgnoreProperties (ignoreUnknown = true )
1717public class EnergyBillV1EnergyUsage extends BaseField implements LineItemField {
1818
19+ /**
20+ * The price per unit of energy consumed.
21+ */
22+ @ JsonProperty ("consumption" )
23+ Double consumption ;
1924 /**
2025 * Description or details of the energy usage.
2126 */
@@ -41,6 +46,11 @@ public class EnergyBillV1EnergyUsage extends BaseField implements LineItemField
4146 */
4247 @ JsonProperty ("total" )
4348 Double total ;
49+ /**
50+ * The unit of measurement for energy consumption.
51+ */
52+ @ JsonProperty ("unit" )
53+ String unit ;
4454 /**
4555 * The price per unit of energy consumed.
4656 */
@@ -49,18 +59,24 @@ public class EnergyBillV1EnergyUsage extends BaseField implements LineItemField
4959
5060 public boolean isEmpty () {
5161 return (
52- (description == null || description .isEmpty ())
62+ consumption == null
63+ && (description == null || description .isEmpty ())
5364 && (endDate == null || endDate .isEmpty ())
5465 && (startDate == null || startDate .isEmpty ())
5566 && taxRate == null
5667 && total == null
68+ && (unit == null || unit .isEmpty ())
5769 && unitPrice == null
5870 );
5971 }
6072
6173 private Map <String , String > tablePrintableValues () {
6274 Map <String , String > printable = new HashMap <>();
6375
76+ printable .put (
77+ "consumption" ,
78+ SummaryHelper .formatAmount (this .consumption )
79+ );
6480 printable .put ("description" , SummaryHelper .formatForDisplay (this .description , 36 ));
6581 printable .put ("endDate" , SummaryHelper .formatForDisplay (this .endDate , 10 ));
6682 printable .put ("startDate" , SummaryHelper .formatForDisplay (this .startDate , null ));
@@ -72,6 +88,7 @@ private Map<String, String> tablePrintableValues() {
7288 "total" ,
7389 SummaryHelper .formatAmount (this .total )
7490 );
91+ printable .put ("unit" , SummaryHelper .formatForDisplay (this .unit , null ));
7592 printable .put (
7693 "unitPrice" ,
7794 SummaryHelper .formatAmount (this .unitPrice )
@@ -84,28 +101,36 @@ private Map<String, String> tablePrintableValues() {
84101 */
85102 public String toTableLine () {
86103 Map <String , String > printable = this .tablePrintableValues ();
87- return String .format ("| %-36s " , printable .get ("description" ))
104+ return String .format ("| %-11s " , printable .get ("consumption" ))
105+ + String .format ("| %-36s " , printable .get ("description" ))
88106 + String .format ("| %-10s " , printable .get ("endDate" ))
89107 + String .format ("| %-10s " , printable .get ("startDate" ))
90108 + String .format ("| %-8s " , printable .get ("taxRate" ))
91109 + String .format ("| %-9s " , printable .get ("total" ))
110+ + String .format ("| %-15s " , printable .get ("unit" ))
92111 + String .format ("| %-10s |" , printable .get ("unitPrice" ));
93112 }
94113
95114 @ Override
96115 public String toString () {
97116 Map <String , String > printable = this .printableValues ();
98- return String .format ("Description: %s" , printable .get ("description" ))
117+ return String .format ("Consumption: %s" , printable .get ("consumption" ))
118+ + String .format (", Description: %s" , printable .get ("description" ))
99119 + String .format (", End Date: %s" , printable .get ("endDate" ))
100120 + String .format (", Start Date: %s" , printable .get ("startDate" ))
101121 + String .format (", Tax Rate: %s" , printable .get ("taxRate" ))
102122 + String .format (", Total: %s" , printable .get ("total" ))
123+ + String .format (", Unit of Measure: %s" , printable .get ("unit" ))
103124 + String .format (", Unit Price: %s" , printable .get ("unitPrice" ));
104125 }
105126
106127 private Map <String , String > printableValues () {
107128 Map <String , String > printable = new HashMap <>();
108129
130+ printable .put (
131+ "consumption" ,
132+ SummaryHelper .formatAmount (this .consumption )
133+ );
109134 printable .put ("description" , SummaryHelper .formatForDisplay (this .description , null ));
110135 printable .put ("endDate" , SummaryHelper .formatForDisplay (this .endDate , null ));
111136 printable .put ("startDate" , SummaryHelper .formatForDisplay (this .startDate , null ));
@@ -117,6 +142,7 @@ private Map<String, String> printableValues() {
117142 "total" ,
118143 SummaryHelper .formatAmount (this .total )
119144 );
145+ printable .put ("unit" , SummaryHelper .formatForDisplay (this .unit , null ));
120146 printable .put (
121147 "unitPrice" ,
122148 SummaryHelper .formatAmount (this .unitPrice )
0 commit comments