cashe_1.0.0_d142893b/src/cashe-exchange.ads

  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
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
pragma Ada_2022;
pragma Assertion_Policy (Check);
with ISO.Currencies;
with Cashe.Currency_Handling;
with Cashe.Money_Handling;
with Ada.Containers.Hashed_Maps;
--  ****h* Cashe/Exchange
--  SOURCE
package Cashe.Exchange is
--  DESCRIPTION
--    This package provides the ability to utilize a currency exchange.
--  ****

   --  ****c* Exchange/Exchange.Currency_Exchange
   --  SOURCE
   type Currency_Exchange is tagged private;
   --  DESCRIPTION
   --    An exchange containing various currencies and their conversions.
   --  USAGE
   --    declare
   --       My_Exchange : Currency_Exchange;
   --    begin
   --       My_Exchange.Set_Rate ("USD", "GBP", 0.5);
   --       --  Print £ 50.00 from a provided $ 100.00
   --       Put_Line
   --          (My_Exchange.Convert
   --             (From => From_Minor (100_00, "GBP"),
   --              To   => "USD")'Image
   --          );
   --    end;
   --  METHODS
   --  * Exchange.Currency_Exchange/Set_Base
   --  * Exchange.Currency_Exchange/Base_Is_Set
   --  * Exchange.Currency_Exchange/Set_Rate
   --  * Exchange.Currency_Exchange/Convert
   --  * Exchange.Currency_Exchange/Contains
   --  * Exchange.Currency_Exchange/Rate
   --  ****

   --  ****m* Exchange.Currency_Exchange/Set_Base
   --  SOURCE
   procedure Set_Base
      (This : in out Currency_Exchange;
       --  The currency exchange to set the base for
       Base : ISO.Currencies.Currency
       --  The base currency to set the exchange to
      );
   procedure Set_Base
      (This : in out Currency_Exchange;
       --  The currency exchange to set the base for
       Base : ISO.Currencies.Alphabetic_Code
       --  The base currency to set the exchange to
      );
   procedure Set_Base
      (This : in out Currency_Exchange;
       --  The currency exchange to set the base for
       Base : Currency_Handling.Custom_Currency
       --  The base currency to set the exchange to
      );
   --  FUNCTION
   --    Set the default base for the currency exchange.  Once this is called,
   --    "from" will no longer have to be passed when setting the rate.
   --  PARAMETERS
   --    Base - The currency to set the exchange to. Either custom or ISO
   --  EXAMPLE
   --    declare
   --       US_Exchange : Currency_Exchange;
   --    begin
   --       US_Exchange.Set_Base ("USD");
   --       --  Set USD:GBP to 1:0.5
   --       US_Exchange.Set_Rate ("GBP", 0.5);
   --       --  Set USD:BTC to 1:0.0000331163
   --       US_Exchange.Set_Rate (Bitcoin, 0.0000331163);
   --    end;
   --  SEE ALSO
   --    * Exchange.Currency_Exchange/Base_Is_Set
   --    * Exchange.Currency_Exchange/Set_Rate
   --  ****

   --  ****m* Exchange.Currency_Exchange/Base_Is_Set
   --  SOURCE
   function Base_Is_Set (This : Currency_Exchange) return Boolean;
   --  FUNCTION
   --    Quries if a base is set or not.
   --  RETURN VALUE
   --    Boolean:
   --      * True if a base has been set
   --      * False if a base has not been set
   --  EXAMPLE
   --    if not US_Exchange.Base_Is_Set then
   --       US_Exchange.Set_Base ("USD");
   --    end if;
   --  ****

   --  ****m* Exchange.Currency_Exchange/Set_Rate
   --  SOURCE
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       From : ISO.Currencies.Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Currency;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      );
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       From : ISO.Currencies.Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      );
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       From : ISO.Currencies.Currency;
       --  The currency to convert from
       To   : Currency_Handling.Custom_Currency;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      );
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       From : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert from
       To   : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      );
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       From : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert from
       To   : ISO.Currencies.Currency;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      );
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       From : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert from
       To   : Currency_Handling.Custom_Currency;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      );
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       From : Currency_Handling.Custom_Currency;
       --  The currency to convert from
       To   : Currency_Handling.Custom_Currency;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      );
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       From : Currency_Handling.Custom_Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Currency;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      );
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       From : Currency_Handling.Custom_Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      );
   --  These can be used if the base is enabled.
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       To   : Currency_Handling.Custom_Currency;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      ) with pre => This.Base_Is_Set;
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       To   : ISO.Currencies.Currency;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      ) with pre => This.Base_Is_Set;
   procedure Set_Rate
      (This : in out Currency_Exchange;
       --  The currency exchange to set the rate in
       To   : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert to
       Rate : Decimal
       --  The exchange rate, in decimal format.
      ) with pre => This.Base_Is_Set;
   --  FUNCTION
   --    Add or update a new exchange rate into the current exchange.
   --  PARAMETERS
   --    From - The currency exchange to set the rate in
   --    To   - The currency to convert to
   --    Rate - The exchange rate, in decimal format.
   --  NOTES
   --    As a courtesy, the inverse of the exchange rate is also added to the
   --    exchange so both USD:GBP and GBP:USD will be accessible.  I recommend
   --    adding the inverse explicitly if it's different than 1.0 / Rate.
   --  EXAMPLE
   --    declare
   --       --  Create some currencies to test
   --       Bitcoin : Custom_Currency :=
   --          Create (Code => "BTC", Minor_Unit => 8,
   --                  Name => "Bitcoin", Symbol => "฿");
   --       --  based on the Jul. 9, 2023 exchange rate
   --       --  from openexchangerates.org.
   --       BTC_to_USD : constant Decimal := 30196.620159;
   --       USD_to_BTC : constant Decimal := 0.0000331163;
   --       USD_to_JPY : constant Decimal := 142.17488666;
   --       JPY_to_USD : constant Decimal := 0.007033591;
   --       --   Create the exchanges
   --       Test_Ex : Currency_Exchange;
   --       BTC_Ex  : Currency_Exchange;
   --    begin
   --       --  If you use USD -> GBP as 0.40 then it will automatically create
   --       --  GBP -> USD as 2.50
   --       Test_Ex.Set_Rate ("USD", "GBP", 0.40);
   --       --  You can also use the inverse.
   --       Test_Ex.Set_Rate ("USD", "JPY", USD_to_BTC);
   --       Test_Ex.Set_Rate ("JPY", "USD", USD_to_JPY);
   --       --  You can also set the base.
   --       BTC_Ex.Set_Base (Bitcoin);
   --       BTC_Ex.Set_Rate  ("USD", BTC_to_USD);
   --       --  You can still set other values if the base is set.
   --       BTC_Ex.Set_Rate  ("USD", Bitcoin, USD_to_BTC);
   --  SEE ALSO
   --    * Exchange.Currency_Exchange/Set_Base
   --    * Exchange.Currency_Exchange/Base_Is_Set
   --  ****

   --  ****m* Exchange.Currency_Exchange/Convert
   --  SOURCE
   function Convert
      (This : Currency_Exchange;
       From : Money_Handling.Money;
       --  The money with the currency to convert from
       To   : ISO.Currencies.Currency
       --  The currency to convert to
      )
   return Money_Handling.Money;
   function Convert
      (This : Currency_Exchange;
       From : Money_Handling.Money;
       --  The money with the currency to convert from
       To   : ISO.Currencies.Alphabetic_Code
       --  The currency to convert to
      )
   return Money_Handling.Money;
   function Convert
      (This : Currency_Exchange;
       From : Money_Handling.Money;
       --  The money with the currency to convert from
       To   : Currency_Handling.Custom_Currency
       --  The currency to convert to
      )
   return Money_Handling.Money;
   --  FUNCTION
   --    Converts money of one currency to another
   --  PARAMETERS
   --    From - The money with the currency to convert from
   --    To   - The currency to convert to
   --  RETURN VALUE
   --    A new money object with the new currency and value when converted or
   --    a money value of 0 if not found in the exchange.
   --  EXAMPLE
   --    declare
   --       My_Exchange : Currency_Exchange;
   --    begin
   --       My_Exchange.Set_Rate ("USD", "GBP", 0.5);
   --       --  Print £ 50.00 from a provided $ 100.00
   --       if My_Exchange.Contains ("USD", "GBP) then
   --          Put_Line
   --             (My_Exchange.Convert
   --                (From => From_Minor (100_00, "GBP"),
   --                 To   => "USD")'Image
   --             );
   --       else
   --          Put_Line ("Not in exchange");
   --       end if;
   --    end;
   --  SEE ALSO
   --    * Exchange.Currency_Exchange/Set_Rate
  --     * Exchange.Currency_Exchange/Contains
   --  ****

   --  ****m* Exchange.Currency_Exchange/Contains
   --  SOURCE
   function Contains
      (This : Currency_Exchange;
       From : ISO.Currencies.Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Currency
       --  The currency to convert to
      )
   return Boolean;
   function Contains
      (This : Currency_Exchange;
       From : ISO.Currencies.Currency;
       --  The currency to convert from
       To   : Currency_Handling.Custom_Currency
       --  The currency to convert to
      )
   return Boolean;
   function Contains
      (This : Currency_Exchange;
       From : ISO.Currencies.Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Alphabetic_Code
       --  The currency to convert to
      )
   return Boolean;
   function Contains
      (This : Currency_Exchange;
       From : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert from
       To   : ISO.Currencies.Alphabetic_Code
       --  The currency to convert to
      )
   return Boolean;
   function Contains
      (This : Currency_Exchange;
       From : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert from
       To   : ISO.Currencies.Currency
       --  The currency to convert to
      )
   return Boolean;
   function Contains
      (This : Currency_Exchange;
       From : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert from
       To   : Currency_Handling.Custom_Currency
       --  The currency to convert to
      )
   return Boolean;
   function Contains
      (This : Currency_Exchange;
       From : Currency_Handling.Custom_Currency;
       --  The currency to convert from
       To   : Currency_Handling.Custom_Currency
       --  The currency to convert to
      )
   return Boolean;
   function Contains
      (This : Currency_Exchange;
       From : Currency_Handling.Custom_Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Currency
       --  The currency to convert to
      )
   return Boolean;
   function Contains
      (This : Currency_Exchange;
       From : Currency_Handling.Custom_Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Alphabetic_Code
       --  The currency to convert to
      )
   return Boolean;
   --  FUNCTION
   --    Validate if a conversion is in the exchange.
   --  PARAMETERS
   --    From - The currency to convert from
   --    To   - The currency to convert to
   --  RETURN VALUE
   --    Boolean:
   --       * True if there is a match of From -> To
   --       * False if From -> To not exist in the Exchange
   --  EXAMPLE
   --    if My_Exchange.Contains ("USD", "GBP) then
   --       Put_Line
   --          (My_Exchange.Convert
   --             (From => From_Minor (100_00, "GBP"),
   --              To   => "USD")'Image
   --          );
   --    else
   --       Put_Line ("Not in exchange");
   --    end if;
   --  SEE ALSO
   --    * Exchange.Currency_Exchange/Set_Rate
   --    * Exchange.Currency_Exchange/Convert
   --  ****

   --  Get the rate for a specific currency
   --  ****m* Exchange.Currency_Exchange/Rate
   --  SOURCE
   function Rate
      (This : Currency_Exchange;
       From : ISO.Currencies.Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Currency)
       --  The currency to convert to
   return Decimal;
   function Rate
      (This : Currency_Exchange;
       From : ISO.Currencies.Currency;
       --  The currency to convert from
       To   : Currency_Handling.Custom_Currency
       --  The currency to convert to
      )
   return Decimal;
   function Rate
      (This : Currency_Exchange;
       From : ISO.Currencies.Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Alphabetic_Code
       --  The currency to convert to
      )
   return Decimal;
   function Rate
      (This : Currency_Exchange;
       From : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert from
       To   : ISO.Currencies.Alphabetic_Code
       --  The currency to convert to
      )
   return Decimal;
   function Rate
      (This : Currency_Exchange;
       From : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert from
       To   : ISO.Currencies.Currency
       --  The currency to convert to
      )
   return Decimal;
   function Rate
      (This : Currency_Exchange;
       From : ISO.Currencies.Alphabetic_Code;
       --  The currency to convert from
       To   : Currency_Handling.Custom_Currency
       --  The currency to convert to
      )
   return Decimal;
   function Rate
      (This : Currency_Exchange;
       From : Currency_Handling.Custom_Currency;
       --  The currency to convert from
       To   : Currency_Handling.Custom_Currency
       --  The currency to convert to
      )
   return Decimal;
   function Rate
      (This : Currency_Exchange;
       From : Currency_Handling.Custom_Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Currency
       --  The currency to convert to
      )
   return Decimal;
   function Rate
      (This : Currency_Exchange;
       From : Currency_Handling.Custom_Currency;
       --  The currency to convert from
       To   : ISO.Currencies.Alphabetic_Code
       --  The currency to convert to
      )
   return Decimal;
   --  These can be used if base rate is enabled
   function Rate
      (This : Currency_Exchange;
       To   : Currency_Handling.Custom_Currency
       --  The currency to convert to
      )
   return Decimal with pre => This.Base_Is_Set;
   function Rate
      (This : Currency_Exchange;
       To   : ISO.Currencies.Currency
       --  The currency to convert to
      )
   return Decimal with pre => This.Base_Is_Set;
   function Rate
      (This : Currency_Exchange;
       To   : ISO.Currencies.Alphabetic_Code
       --  The currency to convert to
      )
   return Decimal with pre => This.Base_Is_Set;
   --  FUNCTION
   --    Converts money of one currency to another
   --  PARAMETERS
   --    From - The currency to convert from
   --    To   - The currency to convert to
   --  RETURN VALUE
   --    The exchangce rate corresponding to From:To in Decimal form
   --  EXAMPLE
   --    declare
   --       My_Exchange : Currency_Exchange;
   --    begin
   --       My_Exchange.Set_Rate ("USD", "GBP", 0.5);
   --       --  Print the GBP exchange rate
   --       Put_Line ("Rate is " & My_Exchange.Rate ("USD", "GBP")'Image);
   --    end;
   --  SEE ALSO
   --    * Exchange.Currency_Exchange/Set_Rate
   --    * Exchange.Currency_Exchange/Contains
   --  ****

private
   --  This checks if the exchange is enabled or not.
   Exchange_Is_Enabled : Boolean := False;
   type Exchange_Rate is record
      From   : Currency_Handling.Currency_Data;
      To     : Currency_Handling.Currency_Data;
      ExRate : Decimal := 0.0;
   end record;

   function Exchange_Hashed (Item : Currency_Handling.Currency_Data)
      return Ada.Containers.Hash_Type;

   package To_Map is new Ada.Containers.Hashed_Maps
     (Key_Type        => Currency_Handling.Currency_Data,
      Element_Type    => Exchange_Rate,
      Hash            => Exchange_Hashed,
      Equivalent_Keys => Currency_Handling."=");
   --  To prevent any recursion
   function "=" (Left, Right : To_Map.Map) return Boolean is
      (To_Map."=" (Left, Right));

   package From_Map is new Ada.Containers.Hashed_Maps
     (Key_Type        => Currency_Handling.Currency_Data,
      Element_Type    => To_Map.Map,
      Hash            => Exchange_Hashed,
      Equivalent_Keys => Currency_Handling."=");

   type Currency_Exchange is tagged record
      Exchange : From_Map.Map;
      Base_Set : Boolean := False;
      Base     : Currency_Handling.Currency_Data :=
                  (Currency_Handling.Type_ISO_Currency,
                  (Key => ISO.Currencies.C_ZZZ));
   end record;
   --  The true implimentations.
   procedure Internal_Set_Base
      (This : in out Currency_Exchange;
       Base : Currency_Handling.Currency_Data);
   procedure Internal_Set_Rate
      (This : in out Currency_Exchange;
       Item : Exchange_Rate);
   function Internal_Search_Rate
      (This : Currency_Exchange;
       Search : Exchange_Rate)
   return Exchange_Rate;
   function Internal_Convert
      (This : Exchange_Rate;
       From : Money_Handling.Money)
   return Money_Handling.Money;

   --  Intermediate create functions
   function Create
      (From : Currency_Handling.Currency_Data;
       To   : ISO.Currencies.Currency;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : Currency_Handling.Currency_Data;
       To   : ISO.Currencies.Alphabetic_Code;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : Currency_Handling.Currency_Data;
       To   : Currency_Handling.Custom_Currency;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : ISO.Currencies.Currency;
       To   : ISO.Currencies.Currency;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : ISO.Currencies.Currency;
       To   : Currency_Handling.Custom_Currency;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : ISO.Currencies.Currency;
       To   : ISO.Currencies.Alphabetic_Code;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : ISO.Currencies.Alphabetic_Code;
       To   : ISO.Currencies.Alphabetic_Code;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : ISO.Currencies.Alphabetic_Code;
       To   : ISO.Currencies.Currency;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : ISO.Currencies.Alphabetic_Code;
       To   : Currency_Handling.Custom_Currency;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : Currency_Handling.Custom_Currency;
       To   : Currency_Handling.Custom_Currency;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : Currency_Handling.Custom_Currency;
       To   : ISO.Currencies.Currency;
       Rate : Decimal)
   return Exchange_Rate;
   function Create
      (From : Currency_Handling.Custom_Currency;
       To   : ISO.Currencies.Alphabetic_Code;
       Rate : Decimal)
   return Exchange_Rate;

end Cashe.Exchange;