@@ -6,6 +6,8 @@ import { Polygon } from "../../../geometry";
66 * Details of energy consumption.
77 */
88export class EnergyBillV1EnergyUsage {
9+ /** The price per unit of energy consumed. */
10+ consumption : number | null ;
911 /** Description or details of the energy usage. */
1012 description : string | null ;
1113 /** The end date of the energy usage. */
@@ -16,6 +18,8 @@ export class EnergyBillV1EnergyUsage {
1618 taxRate : number | null ;
1719 /** The total cost of energy consumed. */
1820 total : number | null ;
21+ /** The unit of measurement for energy consumption. */
22+ unit : string | null ;
1923 /** The price per unit of energy consumed. */
2024 unitPrice : number | null ;
2125 /** Confidence score */
@@ -29,6 +33,15 @@ export class EnergyBillV1EnergyUsage {
2933 polygon : Polygon = [ ] ;
3034
3135 constructor ( { prediction = { } } : StringDict ) {
36+ if (
37+ prediction [ "consumption" ] !== undefined &&
38+ prediction [ "consumption" ] !== null &&
39+ ! isNaN ( prediction [ "consumption" ] )
40+ ) {
41+ this . consumption = + parseFloat ( prediction [ "consumption" ] ) ;
42+ } else {
43+ this . consumption = null ;
44+ }
3245 this . description = prediction [ "description" ] ;
3346 this . endDate = prediction [ "end_date" ] ;
3447 this . startDate = prediction [ "start_date" ] ;
@@ -50,6 +63,7 @@ export class EnergyBillV1EnergyUsage {
5063 } else {
5164 this . total = null ;
5265 }
66+ this . unit = prediction [ "unit" ] ;
5367 if (
5468 prediction [ "unit_price" ] !== undefined &&
5569 prediction [ "unit_price" ] !== null &&
@@ -71,6 +85,8 @@ export class EnergyBillV1EnergyUsage {
7185 */
7286 #printableValues( ) {
7387 return {
88+ consumption :
89+ this . consumption !== undefined ? floatToString ( this . consumption ) : "" ,
7490 description : this . description ?
7591 this . description . length <= 36 ?
7692 cleanSpecialChars ( this . description ) :
@@ -88,6 +104,11 @@ export class EnergyBillV1EnergyUsage {
88104 "" ,
89105 taxRate : this . taxRate !== undefined ? floatToString ( this . taxRate ) : "" ,
90106 total : this . total !== undefined ? floatToString ( this . total ) : "" ,
107+ unit : this . unit ?
108+ this . unit . length <= 15 ?
109+ cleanSpecialChars ( this . unit ) :
110+ cleanSpecialChars ( this . unit ) . slice ( 0 , 12 ) + "..." :
111+ "" ,
91112 unitPrice : this . unitPrice !== undefined ? floatToString ( this . unitPrice ) : "" ,
92113 } ;
93114 }
@@ -98,7 +119,9 @@ export class EnergyBillV1EnergyUsage {
98119 toString ( ) : string {
99120 const printable = this . #printableValues( ) ;
100121 return (
101- "Description: " +
122+ "Consumption: " +
123+ printable . consumption +
124+ ", Description: " +
102125 printable . description +
103126 ", End Date: " +
104127 printable . endDate +
@@ -108,6 +131,8 @@ export class EnergyBillV1EnergyUsage {
108131 printable . taxRate +
109132 ", Total: " +
110133 printable . total +
134+ ", Unit of Measure: " +
135+ printable . unit +
111136 ", Unit Price: " +
112137 printable . unitPrice
113138 ) ;
@@ -120,6 +145,8 @@ export class EnergyBillV1EnergyUsage {
120145 const printable = this . #printableValues( ) ;
121146 return (
122147 "| " +
148+ printable . consumption . padEnd ( 11 ) +
149+ " | " +
123150 printable . description . padEnd ( 36 ) +
124151 " | " +
125152 printable . endDate . padEnd ( 10 ) +
@@ -130,6 +157,8 @@ export class EnergyBillV1EnergyUsage {
130157 " | " +
131158 printable . total . padEnd ( 9 ) +
132159 " | " +
160+ printable . unit . padEnd ( 15 ) +
161+ " | " +
133162 printable . unitPrice . padEnd ( 10 ) +
134163 " |"
135164 ) ;
0 commit comments