Skip to content

Commit

Permalink
https://github.com/danieleteti/delphimvcframework/issues/798
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Dec 17, 2024
1 parent 9ee2f5a commit 9e19652
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions sources/TemplatePro.pas
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ interface
System.Classes,
System.SysUtils,
System.TypInfo,
Data.DB,
System.DateUtils,
System.RTTI;
System.RTTI,
Data.DB;

const
TEMPLATEPRO_VERSION = '0.7.2';
Expand Down Expand Up @@ -294,7 +294,7 @@ implementation

uses
System.StrUtils, System.IOUtils, System.NetEncoding, System.Math, System.Character,
JsonDataObjects, MVCFramework.Nullables;
JsonDataObjects, MVCFramework.Nullables, Data.FmtBCD;

const
Sign = ['-', '+'];
Expand Down Expand Up @@ -536,18 +536,22 @@ function TTProCompiledTemplate.GetDataSetFieldAsTValue(const aDataSet: TDataSet;
Result := lField.AsLargeInt;
ftFloat:
Result := lField.AsFloat;
ftSingle:
Result := lField.AsSingle;
ftCurrency:
Result := lField.AsCurrency;
ftString, ftWideString, ftMemo, ftWideMemo:
Result := lField.AsWideString;
ftDate:
Result := TDate(Trunc(lField.AsDateTime));
ftDateTime:
ftDateTime, ftTimeStamp:
Result := lField.AsDateTime;
ftTime:
Result := lField.AsDateTime;
ftBoolean:
Result := lField.AsBoolean;
ftFMTBcd:
Result := TValue.From<TBCD>(lField.AsBCD);
else
Error('Invalid data type for field "%s": %s', [FieldName, TRttiEnumerationType.GetName<TFieldType>(lField.DataType)]);
end;
Expand Down Expand Up @@ -730,7 +734,7 @@ function TTProCompiledTemplate.GetTValueVarAsString(const Value: PValue; const V
end
else
begin
if Value.TypeInfo.Kind = tkRecord then
if (Value.TypeInfo.Kind = tkRecord) and (Value.TypeInfo <> TypeInfo(TBcd)) then
begin
Result := '';
if Value.TypeInfo = TypeInfo(NullableInt32) then
Expand Down Expand Up @@ -836,6 +840,17 @@ function TTProCompiledTemplate.GetTValueVarAsString(const Value: PValue; const V
end;
tkEnumeration:
Result := Value.ToString;
tkRecord:
begin
if Value.TypeInfo = TypeInfo(TBcd) then
begin
Result := BcdToStr(PBCD(Value.GetReferenceToRawData)^, fLocaleFormatSettings);
end
else
begin
raise ETProException.Create('Unsupported type for record variable "' + VarName + '"');
end;
end
else
raise ETProException.Create('Unsupported type for variable "' + VarName + '"');
end;
Expand Down

0 comments on commit 9e19652

Please sign in to comment.