Bug 14778: Install fixtures for t/Calendar.t
[koha.git] / t / Prices.t
index aa864d2..7ba1cc1 100644 (file)
@@ -23,7 +23,7 @@ my $today;
 for my $currency_format ( qw( US FR ) ) {
     t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
     subtest 'Configuration 1: 0 0' => sub {
-        plan tests => 7;
+        plan tests => 12;
         $bookseller_module->mock(
             'fetch',
             sub {
@@ -112,10 +112,60 @@ for my $currency_format ( qw( US FR ) ) {
                 field    => 'totalgste'
             }
         );
+
+        $order_0_0 = C4::Acquisition::populate_order_with_prices(
+            {
+                order        => $order_0_0,
+                booksellerid => 'just_something',
+                receiving    => 1,
+            }
+        );
+
+        # Note that this configuration is correct \o/
+        compare(
+            {
+                got      => $order_0_0->{unitpricegsti},
+                expected => 77.49,
+                conf     => '0 0',
+                field    => 'unitpricegsti'
+            }
+        );
+        compare(
+            {
+                got      => $order_0_0->{unitpricegste},
+                expected => 73.80,
+                conf     => '0 0',
+                field    => 'unitpricegste'
+            }
+        );
+        compare(
+            {
+                got      => $order_0_0->{gstvalue},
+                expected => 7.38,
+                conf     => '0 0',
+                field    => 'gstvalue'
+            }
+        );
+        compare(
+            {
+                got      => $order_0_0->{totalgsti},
+                expected => 154.98,
+                conf     => '0 0',
+                field    => 'totalgsti'
+            }
+        );
+        compare(
+            {
+                got      => $order_0_0->{totalgste},
+                expected => 147.60,
+                conf     => '0 0',
+                field    => 'totalgste'
+            }
+        );
     };
 
     subtest 'Configuration 1: 1 1' => sub {
-        plan tests => 7;
+        plan tests => 12;
         $bookseller_module->mock(
             'fetch',
             sub {
@@ -205,10 +255,60 @@ for my $currency_format ( qw( US FR ) ) {
                 field    => 'totalgste'
             }
         );
+
+        $order_1_1 = C4::Acquisition::populate_order_with_prices(
+            {
+                order        => $order_1_1,
+                booksellerid => 'just_something',
+                receiving    => 1,
+            }
+        );
+        # Note that this configuration is *not* correct!
+        # gstvalue should be 7.03
+        compare(
+            {
+                got      => $order_1_1->{unitpricegsti},
+                expected => 73.80,
+                conf     => '1 1',
+                field    => 'unitpricegsti'
+            }
+        );
+        compare(
+            {
+                got      => $order_1_1->{unitpricegste},
+                expected => 70.29,
+                conf     => '1 1',
+                field    => 'unitpricegste'
+            }
+        );
+        compare(
+            {
+                got      => $order_1_1->{gstvalue},
+                expected => 7.02,
+                conf     => '1 1',
+                field    => 'gstvalue'
+            }
+        );
+        compare(
+            {
+                got      => $order_1_1->{totalgsti},
+                expected => 147.60,
+                conf     => '1 1',
+                field    => 'totalgsti'
+            }
+        );
+        compare(
+            {
+                got      => $order_1_1->{totalgste},
+                expected => 140.58,
+                conf     => '1 1',
+                field    => 'totalgste'
+            }
+        );
     };
 
     subtest 'Configuration 1: 1 0' => sub {
-        plan tests => 7;
+        plan tests => 12;
         $bookseller_module->mock(
             'fetch',
             sub {
@@ -242,6 +342,7 @@ for my $currency_format ( qw( US FR ) ) {
 
         # Note that this configuration is *not* correct!
         # rrp gsti should be 82 (what we inserted!)
+        # => Actually we need to fix the inserted value (here we have 82.01 in DB)
         # gstvalue should be 7.03 instead of 7.02
 
         compare(
@@ -300,10 +401,60 @@ for my $currency_format ( qw( US FR ) ) {
                 field    => 'totalgste'
             }
         );
+
+        $order_1_0 = C4::Acquisition::populate_order_with_prices(
+            {
+                order        => $order_1_0,
+                booksellerid => 'just_something',
+                receiving    => 1,
+            }
+        );
+        # Note that this configuration is *not* correct!
+        # gstvalue should be 7.03
+        compare(
+            {
+                got      => $order_1_0->{unitpricegsti},
+                expected => 73.80,
+                conf     => '1 0',
+                field    => 'unitpricegsti'
+            }
+        );
+        compare(
+            {
+                got      => $order_1_0->{unitpricegste},
+                expected => 70.29,
+                conf     => '1 0',
+                field    => 'unitpricegste'
+            }
+        );
+        compare(
+            {
+                got      => $order_1_0->{gstvalue},
+                expected => 7.02,
+                conf     => '1 0',
+                field    => 'gstvalue'
+            }
+        );
+        compare(
+            {
+                got      => $order_1_0->{totalgsti},
+                expected => 147.60,
+                conf     => '1 0',
+                field    => 'totalgsti'
+            }
+        );
+        compare(
+            {
+                got      => $order_1_0->{totalgste},
+                expected => 140.58,
+                conf     => '1 0',
+                field    => 'totalgste'
+            }
+        );
     };
 
     subtest 'Configuration 1: 0 1' => sub {
-        plan tests => 7;
+        plan tests => 12;
         $bookseller_module->mock(
             'fetch',
             sub {
@@ -392,6 +543,55 @@ for my $currency_format ( qw( US FR ) ) {
                 field    => 'totalgste'
             }
         );
+
+        $order_0_1 = C4::Acquisition::populate_order_with_prices(
+            {
+                order        => $order_0_1,
+                booksellerid => 'just_something',
+                receiving    => 1,
+            }
+        );
+        # Note that this configuration is correct
+        compare(
+            {
+                got      => $order_0_1->{unitpricegsti},
+                expected => 77.49,
+                conf     => '0 1',
+                field    => 'unitpricegsti'
+            }
+        );
+        compare(
+            {
+                got      => $order_0_1->{unitpricegste},
+                expected => 73.80,
+                conf     => '0 1',
+                field    => 'unitpricegste'
+            }
+        );
+        compare(
+            {
+                got      => $order_0_1->{gstvalue},
+                expected => 7.38,
+                conf     => '0 1',
+                field    => 'gstvalue'
+            }
+        );
+        compare(
+            {
+                got      => $order_0_1->{totalgsti},
+                expected => 154.98,
+                conf     => '0 1',
+                field    => 'totalgsti'
+            }
+        );
+        compare(
+            {
+                got      => $order_0_1->{totalgste},
+                expected => 147.60,
+                conf     => '0 1',
+                field    => 'totalgste'
+            }
+        );
     };
 }