Kevin Kok Khah Whey
2023-11-07 5ae534ab606e6f2ba5ea60914224d665b0447d5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Quintiq file version 2.0
#parent: #root
Method ApiCurencyRatesData (
  MacroPlan mp,
  JSON data
)
{
  Description: 'Get Currency rates data from https'
  TextBody:
  [*
    // Administrator Aug-18-2023 (created)
    
    data_length := data.Size();
    updates := construct( CurrencyRate_MPs );
    for( i:=0; i<data_length; i++ )
    {
      datarow := data.Get( i );
      a := CurrencyRate_MP::CreateCurrencyRateFromJson( mp, datarow );
      updates.Add( a );
      }
    origindataset := selectset( this, Currency_MP.CurrencyRate_MP, cr, true );
    obsoletes := origindataset.Difference( updates );
    // delete obsoleted
    difflength := obsoletes.Size();
    for( j:=0; j<difflength; j++ )
    {
      obsolete := obsoletes.Element( j );
      obsolete.Delete();
      }
  *]
}