5 use Support::TestSetup;
7 Support::TestSetup::login();
12 $config->{numberformat} = '1.000,00';
14 is($::form->parse_amount($config, '12345'), 12345, '12345 (numberformat: 1.000,00)');
15 is($::form->parse_amount($config, '1.234,5'), 1234.5, '1.234,5 (numberformat: 1.000,00)');
16 is($::form->parse_amount($config, '9.871.234,5'), 9871234.5, '9.871.234,5 (numberformat: 1.000,00)');
17 is($::form->parse_amount($config, '1234,5'), 1234.5, '1234,5 (numberformat: 1.000,00)');
18 is($::form->parse_amount($config, '012345'), 12345, '012345 (numberformat: 1.000,00)');
19 is($::form->parse_amount($config, '01.234,5'), 1234.5, '01.234,5 (numberformat: 1.000,00)');
20 is($::form->parse_amount($config, '01234,5'), 1234.5, '01234,5 (numberformat: 1.000,00)');
21 is($::form->parse_amount($config, '09.871.234,5'), 9871234.5, '09.871.234,5 (numberformat: 1.000,00)');
23 $config->{numberformat} = '1000,00';
25 is($::form->parse_amount($config, '12345'), 12345, '12345 (numberformat: 1000,00)');
26 is($::form->parse_amount($config, '1.234,5'), 1234.5, '1.234,5 (numberformat: 1000,00)');
27 is($::form->parse_amount($config, '9.871.234,5'), 9871234.5, '9.871.234,5 (numberformat: 1000,00)');
28 is($::form->parse_amount($config, '1234,5'), 1234.5, '1234,5 (numberformat: 1000,00)');
29 is($::form->parse_amount($config, '012345'), 12345, '012345 (numberformat: 1000,00)');
30 is($::form->parse_amount($config, '01.234,5'), 1234.5, '01.234,5 (numberformat: 1000,00)');
31 is($::form->parse_amount($config, '01234,5'), 1234.5, '01234,5 (numberformat: 1000,00)');
32 is($::form->parse_amount($config, '09.871.234,5'), 9871234.5, '09.871.234,5 (numberformat: 1000,00)');
34 $config->{numberformat} = '1,000.00';
36 is($::form->parse_amount($config, '12345'), 12345, '12345 (numberformat: 1,000.00)');
37 is($::form->parse_amount($config, '1,234.5'), 1234.5, '1,234.5 (numberformat: 1,000.00)');
38 is($::form->parse_amount($config, '9,871,234.5'), 9871234.5, '9,871,234,5 (numberformat: 1,000.00)');
39 is($::form->parse_amount($config, '1234.5'), 1234.5, '1234.5 (numberformat: 1,000.00)');
40 is($::form->parse_amount($config, '012345'), 12345, '012345 (numberformat: 1,000.00)');
41 is($::form->parse_amount($config, '01,234.5'), 1234.5, '01,234.5 (numberformat: 1,000.00)');
42 is($::form->parse_amount($config, '01234.5'), 1234.5, '01234.5 (numberformat: 1,000.00)');
43 is($::form->parse_amount($config, '09,871,234.5'), 9871234.5, '09,871,234,5 (numberformat: 1,000.00)');
45 $config->{numberformat} = '1000.00';
47 is($::form->parse_amount($config, '12345'), 12345, '12345 (numberformat: 1000.00)');
48 is($::form->parse_amount($config, '1,234.5'), 1234.5, '1,234.5 (numberformat: 1000.00)');
49 is($::form->parse_amount($config, '9,871,234.5'), 9871234.5, '9,871,234,5 (numberformat: 1000.00)');
50 is($::form->parse_amount($config, '1234.5'), 1234.5, '1234.5 (numberformat: 1000.00)');
51 is($::form->parse_amount($config, '012345'), 12345, '012345 (numberformat: 1000.00)');
52 is($::form->parse_amount($config, '01,234.5'), 1234.5, '01,234.5 (numberformat: 1000.00)');
53 is($::form->parse_amount($config, '01234.5'), 1234.5, '01234.5 (numberformat: 1000.00)');
54 is($::form->parse_amount($config, '09,871,234.5'), 9871234.5, '09,871,234,5 (numberformat: 1000.00)');
57 $config->{numberformat} = '1.000,00';
59 is($::form->parse_amount($config, '-12345'), -12345, '-12345 (numberformat: 1.000,00)');
60 is($::form->parse_amount($config, '-1.234,5'), -1234.5, '-1.234,5 (numberformat: 1.000,00)');
61 is($::form->parse_amount($config, '-9.871.234,5'), -9871234.5, '-9.871.234,5 (numberformat: 1.000,00)');
62 is($::form->parse_amount($config, '-1234,5'), -1234.5, '-1234,5 (numberformat: 1.000,00)');
63 is($::form->parse_amount($config, '-012345'), -12345, '-012345 (numberformat: 1.000,00)');
64 is($::form->parse_amount($config, '-01.234,5'), -1234.5, '-01.234,5 (numberformat: 1.000,00)');
65 is($::form->parse_amount($config, '-01234,5'), -1234.5, '-01234,5 (numberformat: 1.000,00)');
66 is($::form->parse_amount($config, '-09.871.234,5'), -9871234.5, '-09.871.234,5 (numberformat: 1.000,00)');
68 $config->{numberformat} = '1000,00';
70 is($::form->parse_amount($config, '-12345'), -12345, '-12345 (numberformat: 1000,00)');
71 is($::form->parse_amount($config, '-1.234,5'), -1234.5, '-1.234,5 (numberformat: 1000,00)');
72 is($::form->parse_amount($config, '-9.871.234,5'), -9871234.5, '-9.871.234,5 (numberformat: 1000,00)');
73 is($::form->parse_amount($config, '-1234,5'), -1234.5, '-1234,5 (numberformat: 1000,00)');
74 is($::form->parse_amount($config, '-012345'), -12345, '-012345 (numberformat: 1000,00)');
75 is($::form->parse_amount($config, '-01.234,5'), -1234.5, '-01.234,5 (numberformat: 1000,00)');
76 is($::form->parse_amount($config, '-01234,5'), -1234.5, '-01234,5 (numberformat: 1000,00)');
77 is($::form->parse_amount($config, '-09.871.234,5'), -9871234.5, '-09.871.234,5 (numberformat: 1000,00)');
79 $config->{numberformat} = '1,000.00';
81 is($::form->parse_amount($config, '-12345'), -12345, '-12345 (numberformat: 1,000.00)');
82 is($::form->parse_amount($config, '-1,234.5'), -1234.5, '-1,234.5 (numberformat: 1,000.00)');
83 is($::form->parse_amount($config, '-9,871,234.5'), -9871234.5, '-9,871,234,5 (numberformat: 1,000.00)');
84 is($::form->parse_amount($config, '-1234.5'), -1234.5, '-1234.5 (numberformat: 1,000.00)');
85 is($::form->parse_amount($config, '-012345'), -12345, '-012345 (numberformat: 1,000.00)');
86 is($::form->parse_amount($config, '-01,234.5'), -1234.5, '-01,234.5 (numberformat: 1,000.00)');
87 is($::form->parse_amount($config, '-01234.5'), -1234.5, '-01234.5 (numberformat: 1,000.00)');
88 is($::form->parse_amount($config, '-09,871,234.5'), -9871234.5, '-09,871,234,5 (numberformat: 1,000.00)');
90 $config->{numberformat} = '1000.00';
92 is($::form->parse_amount($config, '-12345'), -12345, '-12345 (numberformat: 1000.00)');
93 is($::form->parse_amount($config, '-1,234.5'), -1234.5, '-1,234.5 (numberformat: 1000.00)');
94 is($::form->parse_amount($config, '-9,871,234.5'), -9871234.5, '-9,871,234,5 (numberformat: 1000.00)');
95 is($::form->parse_amount($config, '-1234.5'), -1234.5, '-1234.5 (numberformat: 1000.00)');
96 is($::form->parse_amount($config, '-012345'), -12345, '-012345 (numberformat: 1000.00)');
97 is($::form->parse_amount($config, '-01,234.5'), -1234.5, '-01,234.5 (numberformat: 1000.00)');
98 is($::form->parse_amount($config, '-01234.5'), -1234.5, '-01234.5 (numberformat: 1000.00)');
99 is($::form->parse_amount($config, '-09,871,234.5'), -9871234.5, '-09,871,234,5 (numberformat: 1000.00)');
102 $config->{numberformat} = '1.000,00';
104 is($::form->parse_amount($config, '47/2+3,5*(4+5)'), 55, '47/2+3,5*(4+5) (numberformat: 1.000,00)');
105 is($::form->parse_amount($config, '047/002+003,05*(04+000005)'), 50.95, '047/002+003,05*(04+000005) (numberformat: 1.000,00)');
106 is($::form->parse_amount($config, '47 / 2+ 3,5*( 4 + 5)'), 55, '47 / 2+ 3.,*( 4 + 5) (numberformat: 1.000,00)');
107 is($::form->parse_amount($config, '047/ 002+ 003,05 * (04 +000005)'), 50.95, '047/ 002+ 003,05 * (04 +000005) (numberformat: 1.000,00)');
109 $config->{numberformat} = '1,000.00';
111 is($::form->parse_amount($config, '47/2+3.5*(4+5)'), 55, '47/2+3.5*(4+5) (numberformat: 1,000.00)');
112 is($::form->parse_amount($config, '047/002+003.05*(04+000005)'), 50.95, '047/002+003.05*(04+000005) (numberformat: 1,000.00)');
113 is($::form->parse_amount($config, '47 / 2+ 3.5*( 4 + 5)'), 55, '47 / 2+ 3.5*( 4 + 5) (numberformat: 1,000.00)');
114 is($::form->parse_amount($config, '047/ 002+ 003.05 * (04 +000005)'), 50.95, '047/ 002+ 003.05 * (04 +000005) (numberformat: 1,000.00)');
118 $config->{numberformat} = '1.000,00';
120 is($::form->parse_amount($config, '-0+1'), 1, '-0+1 (numberformat: 1.000,00)');
121 is($::form->parse_amount($config, '-0+9'), 9, '-0+9 (numberformat: 1.000,00)');
122 is($::form->parse_amount($config, '20*0'), 0, '20*0 (numberformat: 1.000,00)');
123 is($::form->parse_amount($config, '20*0123'), 2460, '20*0123 (numberformat: 1.000,00)');
124 is($::form->parse_amount($config, '010+010'), 20, '010+010 (numberformat: 1.000,00)');
125 is($::form->parse_amount($config, '+(010*2)'), 20, '+(010*2) (numberformat: 1.000,00)');