line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Author : Maxime Soulé |
3
|
|
|
|
|
|
|
# Created On : Mon Aug 30 20:55:45 2004 |
4
|
|
|
|
|
|
|
# Last Modified By: Maxime Soule |
5
|
|
|
|
|
|
|
# Last Modified On: Mon May 3 14:56:59 2010 |
6
|
|
|
|
|
|
|
# Update Count : 2 |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright (C) 2005, Maxime Soulé |
9
|
|
|
|
|
|
|
# You may distribute this file under the terms of the Artistic |
10
|
|
|
|
|
|
|
# License, as specified in the README file. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Palm::MaTirelire::Currencies; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1969
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
6
|
use Palm::BlockPack; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use Palm::MaTirelire::DBItemId; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
42
|
use base qw(Palm::MaTirelire::DBItemId); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
461
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '1.0'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# AppInfoBlock |
27
|
|
|
|
|
|
|
my $APPINFO_BLOCK = Palm::BlockPack->new |
28
|
|
|
|
|
|
|
(N => [ 'last_ext_creation_date' => 0 ]); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Each record |
31
|
|
|
|
|
|
|
my $RECORD_BLOCK = Palm::BlockPack->new |
32
|
|
|
|
|
|
|
(UInt32 => [ |
33
|
|
|
|
|
|
|
[ 'curr_id:8' => 0 ], |
34
|
|
|
|
|
|
|
[ 'reference:1' => 0 ], |
35
|
|
|
|
|
|
|
[ 'reserved:*' => 0 ], |
36
|
|
|
|
|
|
|
], |
37
|
|
|
|
|
|
|
'double' => [ 'reference_amount' => 1 ], |
38
|
|
|
|
|
|
|
'double' => [ 'currency_amount' => 1 ], |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
'Z4' => [ 'iso4217' => '' ], |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
'Z*' => [ 'name' => '' ], |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub import |
47
|
|
|
|
|
|
|
{ |
48
|
1
|
|
|
1
|
|
12
|
&Palm::PDB::RegisterPDBHandlers(__PACKAGE__, [ "MaT2", 'Curr' ]); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub meta_infos ($) |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
0
|
0
|
|
return { name => "MaTi-Currencies", |
55
|
|
|
|
|
|
|
type => "Curr", |
56
|
|
|
|
|
|
|
appinfo_block => $APPINFO_BLOCK, |
57
|
|
|
|
|
|
|
record_block => $RECORD_BLOCK, |
58
|
|
|
|
|
|
|
id_field => 'curr_id', |
59
|
|
|
|
|
|
|
num => (1 << 8), |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub reference ($) |
65
|
|
|
|
|
|
|
{ |
66
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
foreach my $rec (@{$self->{records}}) |
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
{ |
70
|
0
|
0
|
|
|
|
|
return $rec if $rec->{reference}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub convert_amount ($$$$) |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
0
|
|
my($self, $amount, $rec_old, $rec_new) = @_; |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
0
|
|
|
|
return $amount if not defined $rec_old or not defined $rec_new; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return sprintf('%.2f', ($amount * $rec_new->{currency_amount} |
82
|
|
|
|
|
|
|
* $rec_old->{reference_amount}) |
83
|
|
|
|
|
|
|
/ ($rec_new->{reference_amount} |
84
|
|
|
|
|
|
|
* $rec_old->{currency_amount})); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
__END__ |