Quintiq file version 2.0
|
#parent: #root
|
StaticMethod CreateFromJson (
|
MacroPlan macroPlan,
|
JSON json
|
) as CurrencyRate_MP
|
{
|
TextBody:
|
[*
|
// yypsybs Aug-14-2023 (created)
|
|
if( not json.Has( "CurrencyID" ) or not json.Has( "Rate" ) or not json.Has( "Start" ) ){
|
error( "illegal currency rate data" );
|
}
|
|
currencyID := json.Get("CurrencyID").GetString();
|
rate := json.Get("Rate").GetReal();
|
startStr := json.Get("Start").GetString();
|
|
cnv := StringToDateTime::StandardConverter();
|
cnv.SetCustomConversion();
|
cnv.CustomFormatString( "yyyy/MM/dd" );
|
|
start := DateTime::MinDateTime();
|
|
try {
|
start := cnv.Convert( startStr );
|
} onerror {
|
error( "wrong date format" )
|
}
|
|
parent := Currency_MP::FindById( macroPlan, currencyID );
|
|
if( isnull( parent ) ) {
|
error( "currency not found with id : " + currencyID );
|
}
|
|
result := parent.CurrencyRate_MP( relnew, CurrencyID := currencyID, Rate := rate, Start := start.Date() );
|
|
return result;
|
*]
|
}
|