Changeset 10 for trunk


Ignore:
Timestamp:
Apr 15, 2026, 9:35:17 AM (2 weeks ago)
Author:
chronos
Message:
  • Added: Show spot total price above zero for EANs.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ean.pas

    r9 r10  
    4747    function GetSharedPercent(TimeFrom, TimeTo: TDateTime): Double;
    4848    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;
    5050    procedure LoadFromXmlNode(Node: TDOMNode);
    5151    procedure SaveToXmlNode(Node: TDOMNode);
     
    198198  I: Integer;
    199199  SpotPrice: TSpotPrice;
     200  SpotPriceIndex: Integer;
    200201begin
    201202    if PriceLow = 0 then begin
     
    203204    for I := 0 to Values.Count - 1 do
    204205      if (Values[I].Time >= TimeFrom) and (Values[I].Time < TimeTo) then begin
    205         SpotPrice := SpotPrices.SearchByTime(Values[I].Time);
    206         if SpotPrice.Value <> 0 then
    207           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);
    208209      end;
    209210  end else begin
     
    214215end;
    215216
    216 function TEan.GetPrice(TimeFrom, TimeTo: TDateTime; SpotPrices: TSpotPrices): Currency;
    217 var
    218   I: Integer;
    219   SpotPrice: TSpotPrice;
     217function TEan.GetPrice(TimeFrom, TimeTo: TDateTime; SpotPrices: TSpotPrices; MinPrice: Currency): Currency;
     218var
     219  I: Integer;
     220  SpotPriceIndex: Integer;
     221  SpotPrice: Currency;
    220222begin
    221223  if PriceLow = 0 then begin
     
    223225    for I := 0 to Values.Count - 1 do
    224226      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;
    228233      end;
    229234  end else Result := GetTotalIn(TimeFrom, TimeTo) * PriceLow;
  • trunk/FormMain.lfm

    r9 r10  
    11object FormMain: TFormMain
    2   Left = 362
     2  Left = 357
    33  Height = 884
    4   Top = 356
     4  Top = 351
    55  Width = 1203
    66  Caption = 'EDC Stats'
     
    2020    Top = 56
    2121    Width = 1176
    22     ActivePage = TabSheetSpotPrices
     22    ActivePage = TabSheetOverview
    2323    Anchors = [akTop, akLeft, akRight, akBottom]
    24     TabIndex = 4
     24    TabIndex = 0
    2525    TabOrder = 0
    2626    object TabSheetOverview: TTabSheet
     
    8383          item
    8484            Caption = 'Tariff'
     85            Width = 100
     86          end       
     87          item
     88            Caption = 'Price above zero [Kč]'
    8589            Width = 100
    8690          end>
  • trunk/FormMain.lrj

    r9 r10  
    1414{"hash":215185821,"name":"tformmain.listviewoverview.columns[10].caption","sourcebytes":[83,97,118,105,110,103,115,32,91,75,196,141,93],"value":"Savings [K\u010D]"},
    1515{"hash":94932934,"name":"tformmain.listviewoverview.columns[11].caption","sourcebytes":[84,97,114,105,102,102],"value":"Tariff"},
     16{"hash":73101837,"name":"tformmain.listviewoverview.columns[12].caption","sourcebytes":[80,114,105,99,101,32,97,98,111,118,101,32,122,101,114,111,32,91,75,196,141,93],"value":"Price above zero [K\u010D]"},
    1617{"hash":21335,"name":"tformmain.tabsheetlog.caption","sourcebytes":[76,111,103],"value":"Log"},
    1718{"hash":4843668,"name":"tformmain.tabsheetchart.caption","sourcebytes":[67,104,97,114,116],"value":"Chart"},
  • trunk/FormMain.pas

    r9 r10  
    224224procedure TFormMain.MenuItemImportSpotPricesClick(Sender: TObject);
    225225begin
    226   EdcProject.SpotPrices.Import(SpotPricesDir);
    227   //EdcProject.SpotPrices.LoadSpotPricesFromWeb(StrToDate('1.4.2026'));
     226  //EdcProject.SpotPrices.Import(SpotPricesDir);
     227  EdcProject.SpotPrices.LoadFromWeb;
     228
    228229  ShowActiveTab;
    229230end;
     
    366367      ListItem.SubItems.Add(FloatToStr(PriceHigh));
    367368      ListItem.SubItems.Add(FloatToStr(PriceSpot));
    368       ListItem.SubItems.Add(CurrToStr(GetPrice(IntervalFrom, IntervalTo, EdcProject.SpotPrices)));
     369      ListItem.SubItems.Add(CurrToStr(GetPrice(IntervalFrom, IntervalTo, EdcProject.SpotPrices, Low(Integer))));
    369370      ListItem.SubItems.Add(CurrToStr(GetSavings(IntervalFrom, IntervalTo, EdcProject.SpotPrices)));
    370371      ListItem.SubItems.Add(DistributionTariff);
     372      ListItem.SubItems.Add(CurrToStr(GetPrice(IntervalFrom, IntervalTo, EdcProject.SpotPrices, 0)));
    371373    end;
    372374  finally
  • trunk/Languages/EdcStats.cs.po

    r9 r10  
    158158msgstr "Tarif"
    159159
     160#: tformmain.listviewoverview.columns[12].caption
     161msgid "Price above zero [Kč]"
     162msgstr "Cena nad nulou [Kč]"
     163
    160164#: tformmain.listviewoverview.columns[1].caption
    161165msgctxt "tformmain.listviewoverview.columns[1].caption"
  • trunk/Languages/EdcStats.pot

    r9 r10  
    148148msgstr ""
    149149
     150#: tformmain.listviewoverview.columns[12].caption
     151msgid "Price above zero [Kč]"
     152msgstr ""
     153
    150154#: tformmain.listviewoverview.columns[1].caption
    151155msgctxt "tformmain.listviewoverview.columns[1].caption"
  • trunk/SpotPrice.pas

    r9 r10  
    2626    procedure LoadSpotReport(FileName: string);
    2727  public
     28    procedure ClearInterval(IntervalFrom, IntervalTo: TDateTime);
    2829    function GetBlock(var Text: string; StartText, EndText: string): string;
    29     procedure LoadSpotPricesFromWeb(Date: TDate);
     30    procedure LoadFromWebDate(Date: TDate);
     31    procedure LoadFromWeb;
    3032    procedure Import(Directory: string);
    3133    procedure LoadFromXmlNode(Node: TDOMNode);
    3234    procedure SaveToXmlNode(Node: TDOMNode);
    33     function SearchByTime(Time: TDateTime): TSpotPrice;
     35    function SearchByTime(Time: TDateTime): Integer;
    3436  end;
    3537
     
    6264end;
    6365
    64 procedure TSpotPrices.LoadSpotPricesFromWeb(Date: TDate);
     66procedure TSpotPrices.LoadFromWebDate(Date: TDate);
    6567var
    6668  URL: string;
     
    7375  Value: Double;
    7476begin
    75   Clear;
     77  ClearInterval(Date, Date + 1);
     78
    7679  URL := 'https://spotovaelektrina.cz/denni-ceny/' + DateToStr(Date, XmlFormatSettings);
    7780  with TFPHttpClient.Create(nil) do
     
    102105end;
    103106
     107procedure TSpotPrices.LoadFromWeb;
     108var
     109  I: Integer;
     110begin
     111  for I := 1 to 15 do
     112    LoadFromWebDate(StrToDate(IntToStr(I) + '.4.2026'));
     113
     114  Sort(TComparer<TSpotPrice>.Construct(Comparer));
     115end;
     116
    104117function TSpotPrices.FileNameFilter(FileName: string): Boolean;
    105118begin
     
    134147end;
    135148
     149procedure TSpotPrices.ClearInterval(IntervalFrom, IntervalTo: TDateTime);
     150var
     151  I: Integer;
     152begin
     153  for I := Count - 1 downto 0 do
     154    if (Items[I].Time >= IntervalFrom) and (Items[I].Time < IntervalTo) then
     155      Delete(I);
     156end;
     157
    136158procedure TSpotPrices.Import(Directory: string);
    137159var
     
    178200end;
    179201
    180 function TSpotPrices.SearchByTime(Time: TDateTime): TSpotPrice;
     202function TSpotPrices.SearchByTime(Time: TDateTime): Integer;
    181203var
    182204  I: Integer;
     
    184206  I := 0;
    185207  while (I < Count) and (Items[I].Time <> Time) do Inc(I);
    186   if I < Count then Result := Items[I]
    187     else Result := TSpotPrice.Create(0, 0);
     208  if I < Count then Result := I
     209    else Result := -1;
    188210end;
    189211
Note: See TracChangeset for help on using the changeset viewer.