// Iterate over attributes to find currency and rate
for i := 1 to xmlAttrCol.Count do begin
if xmlAttrCol.Get(i, xmlAttr) then begin
// GPT comment: xmlAttr is initialized from xmlAttrCol.Get(i, xmlAttr)
// Check for 'currency' attribute
if xmlAttr.Name = 'currency' then
TargetCurrency := xmlAttr.Value;
// Check for 'rate' attribute
if xmlAttr.Name = 'rate' then
if Evaluate(Rate, xmlAttr.Value) then begin
// Check if the target currency is one of our desired target currencies
if TargetCurrencies.Contains(TargetCurrency) then begin
// Insert or update the exchange rate in Currency Exchange Rate table
if CurrencyExchangeRate.Get('EUR', TargetCurrency, Today) then begin
CurrencyExchangeRate.Validate("Exchange Rate Amount", Rate);
CurrencyExchangeRate.Modify();
end else begin
CurrencyExchangeRate.Init();
CurrencyExchangeRate.Validate("Currency Code", TargetCurrency);
CurrencyExchangeRate.Validate("Starting Date", Today);
CurrencyExchangeRate.Validate("Exchange Rate Amount", Rate);
CurrencyExchangeRate.Insert();
end;
Message('I m inside 2 cu');
end;
end else
Error('Failed to convert rate for %1', TargetCurrency);
end;
end;
XmlElement := gXmlNode.AsXmlElement(); // GPT comment: Initialize XmlElement from gXmlNode
end;