Changeset 10 for trunk/Ean.pas
- Timestamp:
- Apr 15, 2026, 9:35:17 AM (2 weeks ago)
- File:
-
- 1 edited
-
trunk/Ean.pas (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ean.pas
r9 r10 47 47 function GetSharedPercent(TimeFrom, TimeTo: TDateTime): Double; 48 48 function GetSavings(TimeFrom, TimeTo: TDateTime; SpotPrices: TSpotPrices): Currency; 49 function GetPrice(TimeFrom, TimeTo: TDateTime; SpotPrices: TSpotPrices ): Currency;49 function GetPrice(TimeFrom, TimeTo: TDateTime; SpotPrices: TSpotPrices; MinPrice: Currency): Currency; 50 50 procedure LoadFromXmlNode(Node: TDOMNode); 51 51 procedure SaveToXmlNode(Node: TDOMNode); … … 198 198 I: Integer; 199 199 SpotPrice: TSpotPrice; 200 SpotPriceIndex: Integer; 200 201 begin 201 202 if PriceLow = 0 then begin … … 203 204 for I := 0 to Values.Count - 1 do 204 205 if (Values[I].Time >= TimeFrom) and (Values[I].Time < TimeTo) then begin 205 SpotPrice := SpotPrices.SearchByTime(Values[I].Time);206 if SpotPrice .Value <> 0then207 Result := Result + (Values[I].ValueIn - Values[I].ValueOut) * (SpotPrice .Value - PriceSpot);206 SpotPriceIndex := SpotPrices.SearchByTime(Values[I].Time); 207 if SpotPriceIndex <> -1 then 208 Result := Result + (Values[I].ValueIn - Values[I].ValueOut) * (SpotPrices[SpotPriceIndex].Value - PriceSpot); 208 209 end; 209 210 end else begin … … 214 215 end; 215 216 216 function TEan.GetPrice(TimeFrom, TimeTo: TDateTime; SpotPrices: TSpotPrices): Currency; 217 var 218 I: Integer; 219 SpotPrice: TSpotPrice; 217 function TEan.GetPrice(TimeFrom, TimeTo: TDateTime; SpotPrices: TSpotPrices; MinPrice: Currency): Currency; 218 var 219 I: Integer; 220 SpotPriceIndex: Integer; 221 SpotPrice: Currency; 220 222 begin 221 223 if PriceLow = 0 then begin … … 223 225 for I := 0 to Values.Count - 1 do 224 226 if (Values[I].Time >= TimeFrom) and (Values[I].Time < TimeTo) then begin 225 SpotPrice := SpotPrices.SearchByTime(Values[I].Time); 226 if SpotPrice.Value <> 0 then 227 Result := Result + Values[I].ValueIn * (SpotPrice.Value - PriceSpot); 227 SpotPriceIndex := SpotPrices.SearchByTime(Values[I].Time); 228 if (SpotPriceIndex <> -1) then begin 229 SpotPrice := SpotPrices[SpotPriceIndex].Value - PriceSpot; 230 if SpotPrice > MinPrice then 231 Result := Result + Values[I].ValueIn * SpotPrice; 232 end; 228 233 end; 229 234 end else Result := GetTotalIn(TimeFrom, TimeTo) * PriceLow;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/edc-stats/chrome/site/your_project_logo.png)