program dp_183568;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
CurrencyValue
in '
CurrencyValue.pas',
MemoryCurrencyRepository
in '
MemoryCurrencyRepository.pas';
procedure Prepare;
begin
TDateType.Freezed := False;
TCurrencyType.
DEFAULT := '
EUR';
TCurrencyValue.CurrencyRepository := TMemoryCurrencyRepository.Create;
TCurrencyValue.CurrencyRepository.StoreConvertValue( TCurrencyConvertValue.Create( '
01.01.2000', TCurrencyFactorValue.Create( '
EUR', '
DEM', 1.9558 ) ) );
TCurrencyValue.CurrencyRepository.StoreConvertValue( TCurrencyConvertValue.Create( '
01.01.2000', TCurrencyFactorValue.Create( '
EUR', '
ATS', 13.7603 ) ) );
TCurrencyValue.CurrencyRepository.StoreConvertValue( TCurrencyConvertValue.Create( '
01.10.2014', TCurrencyFactorValue.Create( '
EUR', '
USD', 1.00 ) ) );
TCurrencyValue.CurrencyRepository.StoreConvertValue( TCurrencyConvertValue.Create( '
01.11.2014', TCurrencyFactorValue.Create( '
EUR', '
USD', 1.10 ) ) );
TCurrencyValue.CurrencyRepository.StoreConvertValue( TCurrencyConvertValue.Create( '
01.12.2014', TCurrencyFactorValue.Create( '
EUR', '
USD', 1.20 ) ) );
TCurrencyValue.CurrencyRepository.StoreConvertValue( TCurrencyConvertValue.Create( '
01.01.2015', TCurrencyFactorValue.Create( '
EUR', '
USD', 1.30 ) ) );
end;
procedure OutputCurrencyValueIn( AValue: TCurrencyValue; ACurrency: TCurrencyType );
begin
Writeln( AValue.ToString, '
==(', TDateType.TODAY.ToString, '
)=> ', AValue.Convert( ACurrency ).ToString );
end;
procedure Test;
var
LValue: TCurrencyValue;
begin
LValue := 500;
// Wegen dem DEFAULT Wert sind das 500,00 EUR
OutputCurrencyValueIn( LValue, '
DEM' );
OutputCurrencyValueIn( LValue, '
ATS' );
OutputCurrencyValueIn( LValue, '
USD' );
TDateType.TODAY := '
15.12.2014';
// TODAY-Datum festlegen
OutputCurrencyValueIn( LValue, '
USD' );
TDateType.Freezed := False;
// TODAY folgt nun wieder dem SYSTEM-Datum
OutputCurrencyValueIn( LValue, '
USD' );
TDateType.TODAY := '
15.11.2014';
// TODAY-Datum festlegen
OutputCurrencyValueIn( LValue, '
USD' );
TDateType.TODAY := '
15.10.2014';
// TODAY-Datum festlegen
OutputCurrencyValueIn( LValue, '
USD' );
TDateType.TODAY := '
15.09.2014';
// TODAY-Datum festlegen
OutputCurrencyValueIn( LValue, '
USD' );
TDateType.Freezed := False;
// TODAY folgt wieder dem SYSTEM-Datum
end;
begin
try
Prepare;
Test;
except
on E:
Exception do
Writeln( E.ClassName, '
: ', E.
Message );
end;
Readln;
end.