| 1 | =encoding iso-8859-1 | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =cut | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # Copyright (C) 2005, Maxime Soulé | ||||||||||||||||||||||||||||
| 7 | # You may distribute this file under the terms of the Artistic | ||||||||||||||||||||||||||||
| 8 | # License, as specified in the README file. | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | package Palm::MaTirelire::Currencies; | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Palm::BlockPack; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Palm::MaTirelire::DBItemId; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use base qw(Palm::MaTirelire::DBItemId); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | our $VERSION = '1.0'; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # AppInfoBlock | ||||||||||||||||||||||||||||
| 25 | 1 | my $APPINFO_BLOCK = Palm::BlockPack->new | |||||||||||||||||||||||||||
| 26 | (N => [ 'last_ext_creation_date' => 0 ]); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # Each record | ||||||||||||||||||||||||||||
| 29 | 1 | my $RECORD_BLOCK = Palm::BlockPack->new | |||||||||||||||||||||||||||
| 30 | (UInt32 => [ | ||||||||||||||||||||||||||||
| 31 | [ 'curr_id:8' => 0 ], | ||||||||||||||||||||||||||||
| 32 | [ 'reference:1' => 0 ], | ||||||||||||||||||||||||||||
| 33 | [ 'reserved:*' => 0 ], | ||||||||||||||||||||||||||||
| 34 | ], | ||||||||||||||||||||||||||||
| 35 | 'double' => [ 'reference_amount' => 1 ], | ||||||||||||||||||||||||||||
| 36 | 'double' => [ 'currency_amount' => 1 ], | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 'Z4' => [ 'iso4217' => '' ], | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 'Z*' => [ 'name' => '' ], | ||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub import | ||||||||||||||||||||||||||||
| 45 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 46 | 1 | &Palm::PDB::RegisterPDBHandlers(__PACKAGE__, [ "MaT2", 'Curr' ]); | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub meta_infos ($) | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
meta_infos: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 0 | return { name => "MaTi-Currencies", | |||||||||||||||||||||||||||
| 53 | type => "Curr", | ||||||||||||||||||||||||||||
| 54 | appinfo_block => $APPINFO_BLOCK, | ||||||||||||||||||||||||||||
| 55 | record_block => $RECORD_BLOCK, | ||||||||||||||||||||||||||||
| 56 | id_field => 'curr_id', | ||||||||||||||||||||||||||||
| 57 | num => (1 << 8), | ||||||||||||||||||||||||||||
| 58 | }; | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub reference ($) | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
reference: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | foreach my $rec (@{$self->{records}}) | |||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | return $rec if $rec->{reference}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | sub convert_amount ($$$$) | ||||||||||||||||||||||||||||
| 74 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
convert_amount: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | 0 | my($self, $amount, $rec_old, $rec_new) = @_; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return $amount if not defined $rec_old or not defined $rec_new; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $rec_old and defined $rec_new
MC/DC0%0/2
defined $rec_old and defined $rec_new
defined $rec_old
defined $rec_new
Truth table0%0/3
A and B
A= defined $rec_oldB= defined $rec_new
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | return sprintf('%.2f', ($amount * $rec_new->{currency_amount} | ||||||||||||||||||||||||||||
| 80 | * $rec_old->{reference_amount}) | ||||||||||||||||||||||||||||
| 81 | / ($rec_new->{reference_amount} | ||||||||||||||||||||||||||||
| 82 | 0 | * $rec_old->{currency_amount})); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 1 | 1; | |||||||||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||||||||||