View | Details | Raw Unified | Return to bug 13321
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-31 / +39 lines)
Lines 2815-2823 sub GetBiblioCountByBasketno { Link Here
2815
    return $sth->fetchrow;
2815
    return $sth->fetchrow;
2816
}
2816
}
2817
2817
2818
# This is *not* the good way to calcul prices
2819
# But it's how it works at the moment into Koha
2820
# This will be fixed later.
2821
# Note this subroutine should be moved to Koha::Acquisition::Order
2818
# Note this subroutine should be moved to Koha::Acquisition::Order
2822
# Will do when a DBIC decision will be taken.
2819
# Will do when a DBIC decision will be taken.
2823
sub populate_order_with_prices {
2820
sub populate_order_with_prices {
Lines 2834-2881 sub populate_order_with_prices { Link Here
2834
    my $discount  = $order->{discount};
2831
    my $discount  = $order->{discount};
2835
    $discount /= 100 if $discount > 1;
2832
    $discount /= 100 if $discount > 1;
2836
2833
2837
    $order->{rrp}   = Koha::Number::Price->new( $order->{rrp} )->round;
2838
    $order->{ecost} = Koha::Number::Price->new( $order->{ecost} )->round;
2839
    if ($ordering) {
2834
    if ($ordering) {
2840
        if ( $bookseller->{listincgst} ) {
2835
        if ( $bookseller->{listincgst} ) {
2836
            # The user entered the rrp tax included
2841
            $order->{rrp_tax_included} = $order->{rrp};
2837
            $order->{rrp_tax_included} = $order->{rrp};
2842
            $order->{rrp_tax_excluded} = Koha::Number::Price->new(
2838
2843
                $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
2839
            # rrp tax excluded = rrp tax included / ( 1 + tax rate )
2844
            $order->{ecost_tax_included} = $order->{ecost};
2840
            $order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} );
2845
            $order->{ecost_tax_excluded} = Koha::Number::Price->new(
2841
2846
                $order->{ecost} / ( 1 + $order->{tax_rate} ) )->round;
2842
            # ecost tax excluded = rrp tax excluded * ( 1 - discount )
2847
            $order->{tax_value} = Koha::Number::Price->new(
2843
            $order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount );
2848
                ( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
2844
2849
                  $order->{quantity} )->round;
2845
            # ecost tax included = rrp tax included  ( 1 - discount )
2846
            $order->{ecost_tax_included} = $order->{rrp_tax_included} * ( 1 - $discount );
2850
        }
2847
        }
2851
        else {
2848
        else {
2849
            # The user entered the rrp tax excluded
2852
            $order->{rrp_tax_excluded} = $order->{rrp};
2850
            $order->{rrp_tax_excluded} = $order->{rrp};
2853
            $order->{rrp_tax_included} = Koha::Number::Price->new(
2851
2854
                $order->{rrp} * ( 1 + $order->{tax_rate} ) )->round;
2852
            # rrp tax included = rrp tax excluded * ( 1 - tax rate )
2855
            $order->{ecost_tax_excluded} = $order->{ecost};
2853
            $order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate} );
2856
            $order->{ecost_tax_included} = Koha::Number::Price->new(
2854
2857
                $order->{ecost} * ( 1 + $order->{tax_rate} ) )->round;
2855
            # ecost tax excluded = rrp tax excluded * ( 1 - discount )
2858
            $order->{tax_value} = Koha::Number::Price->new(
2856
            $order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount );
2859
                ( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
2857
2860
                  $order->{quantity} )->round;
2858
            # ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount )
2859
            $order->{ecost_tax_included} =
2860
                $order->{rrp_tax_excluded} *
2861
                ( 1 + $order->{tax_rate} ) *
2862
                ( 1 - $discount );
2861
        }
2863
        }
2864
2865
        # tax value = quantity * ecost tax excluded * tax rate
2866
        $order->{tax_value} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate};
2862
    }
2867
    }
2863
2868
2864
    if ($receiving) {
2869
    if ($receiving) {
2865
        if ( $bookseller->{listincgst} ) {
2870
        if ( $bookseller->{invoiceincgst} ) {
2866
            $order->{unitprice_tax_included} = Koha::Number::Price->new( $order->{unitprice} )->round;
2871
            # The user entered the unit price tax included
2867
            $order->{unitprice_tax_excluded} = Koha::Number::Price->new(
2872
            $order->{unitprice_tax_included} = $order->{unitprice};
2868
              $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
2873
2874
            # unit price tax excluded = unit price tax included / ( 1 + tax rate )
2875
            $order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} );
2869
        }
2876
        }
2870
        else {
2877
        else {
2871
            $order->{unitprice_tax_excluded} = Koha::Number::Price->new( $order->{unitprice} )->round;
2878
            # The user entered the unit price tax excluded
2872
            $order->{unitprice_tax_included} = Koha::Number::Price->new(
2879
            $order->{unitprice_tax_excluded} = $order->{unitprice};
2873
              $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ) )->round;
2880
2881
            # unit price tax included = unit price tax included * ( 1 + tax rate )
2882
            $order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} );
2874
        }
2883
        }
2875
        $order->{tax_value} = Koha::Number::Price->new(
2876
          ( $order->{unitprice_tax_included} - $order->{unitprice_tax_excluded} )
2877
          * $order->{quantityreceived} )->round;
2878
2884
2885
        # tax value = quantity * unit price tax excluded * tax rate
2886
        $order->{tax_value} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate};
2879
    }
2887
    }
2880
2888
2881
    return $order;
2889
    return $order;
(-)a/acqui/basket.pl (-3 / +3 lines)
Lines 317-325 elsif ( $op eq 'ediorder' ) { Link Here
317
            $template->param( uncertainprices => 1 );
317
            $template->param( uncertainprices => 1 );
318
        }
318
        }
319
319
320
        $line->{total_tax_excluded} = Koha::Number::Price->new( $line->{ecost_tax_excluded} * $line->{quantity} )->format;
321
        $line->{total_tax_included} = Koha::Number::Price->new( $line->{ecost_tax_included} * $line->{quantity} )->format;
322
323
        push @books_loop, $line;
320
        push @books_loop, $line;
324
321
325
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
322
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
Lines 427-432 sub get_order_infos { Link Here
427
    $line{basketno}       = $basketno;
424
    $line{basketno}       = $basketno;
428
    $line{budget_name}    = $budget->{budget_name};
425
    $line{budget_name}    = $budget->{budget_name};
429
426
427
    $line{total_tax_included} = $line{ecost_tax_included} * $line{quantity};
428
    $line{total_tax_excluded} = $line{ecost_tax_excluded} * $line{quantity};
429
430
    if ( $line{uncertainprice} ) {
430
    if ( $line{uncertainprice} ) {
431
        $line{rrp_tax_excluded} .= ' (Uncertain)';
431
        $line{rrp_tax_excluded} .= ' (Uncertain)';
432
    }
432
    }
(-)a/acqui/basketgroup.pl (-4 lines)
Lines 81-90 sub BasketTotal { Link Here
81
        } else {
81
        } else {
82
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
82
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
83
        }
83
        }
84
        if ($bookseller->{invoiceincgst} && ! $bookseller->{listincgst} && ( $bookseller->{tax_rate} // C4::Context->preference("gist") )) {
85
            my $gst = $bookseller->{tax_rate} // C4::Context->preference("gist");
86
            $total = $total * ( $gst / 100 +1);
87
        }
88
    }
84
    }
89
    $total .= " " . ($bookseller->{invoiceprice} // 0);
85
    $total .= " " . ($bookseller->{invoiceprice} // 0);
90
    return $total;
86
    return $total;
(-)a/acqui/finishreceive.pl (-19 / +1 lines)
Lines 54-61 my $invoice = GetInvoice($invoiceid); Link Here
54
my $invoiceno        = $invoice->{invoicenumber};
54
my $invoiceno        = $invoice->{invoicenumber};
55
my $booksellerid     = $input->param('booksellerid');
55
my $booksellerid     = $input->param('booksellerid');
56
my $cnt              = 0;
56
my $cnt              = 0;
57
my $ecost            = $input->param('ecost');
58
my $rrp              = $input->param('rrp');
59
my $bookfund         = $input->param("bookfund");
57
my $bookfund         = $input->param("bookfund");
60
my $order            = GetOrder($ordernumber);
58
my $order            = GetOrder($ordernumber);
61
my $new_ordernumber  = $ordernumber;
59
my $new_ordernumber  = $ordernumber;
Lines 83-107 if ($quantityrec > $origquantityrec ) { Link Here
83
    }
81
    }
84
82
85
    $order->{order_internalnote} = $input->param("order_internalnote");
83
    $order->{order_internalnote} = $input->param("order_internalnote");
86
    $order->{rrp} = $rrp;
87
    $order->{ecost} = $ecost;
88
    $order->{unitprice} = $unitprice;
84
    $order->{unitprice} = $unitprice;
89
85
90
    # FIXME is it still useful?
91
    my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
86
    my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
92
    if ( $bookseller->{listincgst} ) {
93
        if ( not $bookseller->{invoiceincgst} ) {
94
            $order->{rrp} = $order->{rrp} * ( 1 + $order->{tax_rate} );
95
            $order->{ecost} = $order->{ecost} * ( 1 + $order->{tax_rate} );
96
            $order->{unitprice} = $order->{unitprice} * ( 1 + $order->{tax_rate} );
97
        }
98
    } else {
99
        if ( $bookseller->{invoiceincgst} ) {
100
            $order->{rrp} = $order->{rrp} / ( 1 + $order->{tax_rate} );
101
            $order->{ecost} = $order->{ecost} / ( 1 + $order->{tax_rate} );
102
            $order->{unitprice} = $order->{unitprice} / ( 1 + $order->{tax_rate} );
103
        }
104
    }
105
87
106
    $order = C4::Acquisition::populate_order_with_prices(
88
    $order = C4::Acquisition::populate_order_with_prices(
107
        {
89
        {
Lines 171-177 ModItem( Link Here
171
        booksellerid         => $booksellerid,
153
        booksellerid         => $booksellerid,
172
        dateaccessioned      => $datereceived,
154
        dateaccessioned      => $datereceived,
173
        price                => $unitprice,
155
        price                => $unitprice,
174
        replacementprice     => $rrp,
156
        replacementprice     => $order->{rrp},
175
        replacementpricedate => $datereceived,
157
        replacementpricedate => $datereceived,
176
    },
158
    },
177
    $biblionumber,
159
    $biblionumber,
(-)a/acqui/invoice.pl (-6 / +5 lines)
Lines 141-147 foreach my $order (@$orders) { Link Here
141
141
142
push @foot_loop, map {$_} values %foot;
142
push @foot_loop, map {$_} values %foot;
143
143
144
my $format = "%.2f";
145
my $budgets = GetBudgets();
144
my $budgets = GetBudgets();
146
my @budgets_loop;
145
my @budgets_loop;
147
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
146
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
Lines 168-178 $template->param( Link Here
168
    orders_loop      => \@orders_loop,
167
    orders_loop      => \@orders_loop,
169
    foot_loop        => \@foot_loop,
168
    foot_loop        => \@foot_loop,
170
    total_quantity   => $total_quantity,
169
    total_quantity   => $total_quantity,
171
    total_tax_excluded       => sprintf( $format, $total_tax_excluded ),
170
    total_tax_excluded => $total_tax_excluded,
172
    total_tax_included       => sprintf( $format, $total_tax_included ),
171
    total_tax_included => $total_tax_included,
173
    total_tax_value   => sprintf( $format, $total_tax_value ),
172
    total_tax_value  => $total_tax_value,
174
    total_tax_excluded_shipment => sprintf( $format, $total_tax_excluded + $details->{shipmentcost}),
173
    total_tax_excluded_shipment => $total_tax_excluded + $details->{shipmentcost},
175
    total_tax_included_shipment => sprintf( $format, $total_tax_included + $details->{shipmentcost}),
174
    total_tax_included_shipment => $total_tax_included + $details->{shipmentcost},
176
    invoiceincgst    => $bookseller->{invoiceincgst},
175
    invoiceincgst    => $bookseller->{invoiceincgst},
177
    currency         => Koha::Acquisition::Currencies->get_active,
176
    currency         => Koha::Acquisition::Currencies->get_active,
178
    budgets_loop     => \@budgets_loop,
177
    budgets_loop     => \@budgets_loop,
(-)a/acqui/parcel.pl (-2 / +2 lines)
Lines 149-156 for my $order ( @orders ) { Link Here
149
    $line{budget} = GetBudgetByOrderNumber( $line{ordernumber} );
149
    $line{budget} = GetBudgetByOrderNumber( $line{ordernumber} );
150
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
150
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
151
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
151
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
152
    $total_tax_excluded += Koha::Number::Price->new( $line{ecost_tax_excluded} * $line{quantity} )->format;
152
    $total_tax_excluded += $line{unitprice_tax_excluded} * $line{quantity};
153
    $total_tax_included += Koha::Number::Price->new( $line{ecost_tax_included} * $line{quantity} )->format;
153
    $total_tax_included += $line{unitprice_tax_included} * $line{quantity};
154
154
155
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
155
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
156
    $line{suggestionid}         = $suggestion->{suggestionid};
156
    $line{suggestionid}         = $suggestion->{suggestionid};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-4 / +5 lines)
Lines 327-339 Link Here
327
            </div>
327
            </div>
328
          [% END %][%# IF (AcqCreateItemReceiving) %]
328
          [% END %][%# IF (AcqCreateItemReceiving) %]
329
		</li>
329
		</li>
330
        <li><label for="rrp">Replacement cost: </label><input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /></li>
330
331
        <li><label for="ecost">Budgeted cost: </label><input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" /></li>
331
        <li><label for="rrp">Replacement cost: </label>[% rrp | $Price %]</li>
332
        <li><label for="ecost">Budgeted cost: </label>[% ecost | $Price %]</li>
332
        <li><label for="cost">Actual cost:</label>
333
        <li><label for="cost">Actual cost:</label>
333
        [% IF ( unitprice ) %]
334
        [% IF ( unitprice ) %]
334
         <input type="text" size="20" name="cost" id="cost" value="[% unitprice %]" />
335
             <input type="text" size="20" name="cost" id="cost" value="[% unitprice | $Price %]" />
335
        [% ELSE %]
336
        [% ELSE %]
336
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
337
             <input type="text" size="20" name="cost" id="cost" value="[% ecost | $Price %]" />
337
        [% END %]</li>
338
        [% END %]</li>
338
        <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote %]</textarea></li>
339
        <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote %]</textarea></li>
339
        [% IF order_vendornote %]
340
        [% IF order_vendornote %]
(-)a/t/Prices.t (-160 / +20 lines)
Lines 39-45 my $today; Link Here
39
for my $currency_format ( qw( US FR ) ) {
39
for my $currency_format ( qw( US FR ) ) {
40
    t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
40
    t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
41
    subtest 'Configuration 1: 0 0' => sub {
41
    subtest 'Configuration 1: 0 0' => sub {
42
        plan tests => 12;
42
        plan tests => 8;
43
        $bookseller_module->mock(
43
        $bookseller_module->mock(
44
            'fetch',
44
            'fetch',
45
            sub {
45
            sub {
Lines 71-77 for my $currency_format ( qw( US FR ) ) { Link Here
71
            }
71
            }
72
        );
72
        );
73
73
74
        # Note that this configuration is correct \o/
75
        compare(
74
        compare(
76
            {
75
            {
77
                got      => $order_0_0->{rrp_tax_included},
76
                got      => $order_0_0->{rrp_tax_included},
Lines 112-133 for my $currency_format ( qw( US FR ) ) { Link Here
112
                field    => 'tax_value'
111
                field    => 'tax_value'
113
            }
112
            }
114
        );
113
        );
115
        compare(
116
            {
117
                got      => $order_0_0->{total_tax_included},
118
                expected => 154.98,
119
                conf     => '0 0',
120
                field    => 'total_tax_included'
121
            }
122
        );
123
        compare(
124
            {
125
                got      => $order_0_0->{total_tax_excluded},
126
                expected => 147.60,
127
                conf     => '0 0',
128
                field    => 'total_tax_excluded'
129
            }
130
        );
131
114
132
        $order_0_0 = C4::Acquisition::populate_order_with_prices(
115
        $order_0_0 = C4::Acquisition::populate_order_with_prices(
133
            {
116
            {
Lines 137-143 for my $currency_format ( qw( US FR ) ) { Link Here
137
            }
120
            }
138
        );
121
        );
139
122
140
        # Note that this configuration is correct \o/
141
        compare(
123
        compare(
142
            {
124
            {
143
                got      => $order_0_0->{unitprice_tax_included},
125
                got      => $order_0_0->{unitprice_tax_included},
Lines 162-187 for my $currency_format ( qw( US FR ) ) { Link Here
162
                field    => 'tax_value'
144
                field    => 'tax_value'
163
            }
145
            }
164
        );
146
        );
165
        compare(
166
            {
167
                got      => $order_0_0->{total_tax_included},
168
                expected => 154.98,
169
                conf     => '0 0',
170
                field    => 'total_tax_included'
171
            }
172
        );
173
        compare(
174
            {
175
                got      => $order_0_0->{total_tax_excluded},
176
                expected => 147.60,
177
                conf     => '0 0',
178
                field    => 'total_tax_excluded'
179
            }
180
        );
181
    };
147
    };
182
148
183
    subtest 'Configuration 1: 1 1' => sub {
149
    subtest 'Configuration 1: 1 1' => sub {
184
        plan tests => 12;
150
        plan tests => 8;
185
        $bookseller_module->mock(
151
        $bookseller_module->mock(
186
            'fetch',
152
            'fetch',
187
            sub {
153
            sub {
Lines 213-220 for my $currency_format ( qw( US FR ) ) { Link Here
213
            }
179
            }
214
        );
180
        );
215
181
216
        # Note that this configuration is *not* correct
217
        # tax_value should be 7.03 instead of 7.02
218
        compare(
182
        compare(
219
            {
183
            {
220
                got      => $order_1_1->{rrp_tax_included},
184
                got      => $order_1_1->{rrp_tax_included},
Lines 250-276 for my $currency_format ( qw( US FR ) ) { Link Here
250
        compare(
214
        compare(
251
            {
215
            {
252
                got      => $order_1_1->{tax_value},
216
                got      => $order_1_1->{tax_value},
253
                expected => 7.02,
217
                expected => 7.03,
254
                conf     => '1 1',
218
                conf     => '1 1',
255
                field    => 'tax_value'
219
                field    => 'tax_value'
256
            }
220
            }
257
        );
221
        );
258
        compare(
259
            {
260
                got      => $order_1_1->{total_tax_included},
261
                expected => 147.60,
262
                conf     => '1 1',
263
                field    => 'total_tax_included'
264
            }
265
        );
266
        compare(
267
            {
268
                got      => $order_1_1->{total_tax_excluded},
269
                expected => 140.58,
270
                conf     => '1 1',
271
                field    => 'total_tax_excluded'
272
            }
273
        );
274
222
275
        $order_1_1 = C4::Acquisition::populate_order_with_prices(
223
        $order_1_1 = C4::Acquisition::populate_order_with_prices(
276
            {
224
            {
Lines 279-286 for my $currency_format ( qw( US FR ) ) { Link Here
279
                receiving    => 1,
227
                receiving    => 1,
280
            }
228
            }
281
        );
229
        );
282
        # Note that this configuration is *not* correct!
230
283
        # tax_value should be 7.03
284
        compare(
231
        compare(
285
            {
232
            {
286
                got      => $order_1_1->{unitprice_tax_included},
233
                got      => $order_1_1->{unitprice_tax_included},
Lines 300-330 for my $currency_format ( qw( US FR ) ) { Link Here
300
        compare(
247
        compare(
301
            {
248
            {
302
                got      => $order_1_1->{tax_value},
249
                got      => $order_1_1->{tax_value},
303
                expected => 7.02,
250
                expected => 7.03,
304
                conf     => '1 1',
251
                conf     => '1 1',
305
                field    => 'tax_value'
252
                field    => 'tax_value'
306
            }
253
            }
307
        );
254
        );
308
        compare(
309
            {
310
                got      => $order_1_1->{total_tax_included},
311
                expected => 147.60,
312
                conf     => '1 1',
313
                field    => 'total_tax_included'
314
            }
315
        );
316
        compare(
317
            {
318
                got      => $order_1_1->{total_tax_excluded},
319
                expected => 140.58,
320
                conf     => '1 1',
321
                field    => 'total_tax_excluded'
322
            }
323
        );
324
    };
255
    };
325
256
326
    subtest 'Configuration 1: 1 0' => sub {
257
    subtest 'Configuration 1: 1 0' => sub {
327
        plan tests => 12;
258
        plan tests => 8;
328
        $bookseller_module->mock(
259
        $bookseller_module->mock(
329
            'fetch',
260
            'fetch',
330
            sub {
261
            sub {
Lines 337-347 for my $currency_format ( qw( US FR ) ) { Link Here
337
            biblionumber     => $biblionumber_1_0,
268
            biblionumber     => $biblionumber_1_0,
338
            quantity         => 2,
269
            quantity         => 2,
339
            listprice        => 82.000000,
270
            listprice        => 82.000000,
340
            unitprice        => 73.804500,
271
            unitprice        => 70.290000,
341
            quantityreceived => 2,
272
            quantityreceived => 2,
342
            basketno         => $basketno_1_1,
273
            basketno         => $basketno_1_1,
343
            invoiceid        => $invoiceid_1_1,
274
            invoiceid        => $invoiceid_1_1,
344
            rrp              => 82.01,
275
            rrp              => 82.00,
345
            ecost            => 73.80,
276
            ecost            => 73.80,
346
            tax_rate         => 0.0500,
277
            tax_rate         => 0.0500,
347
            discount         => 10.0000,
278
            discount         => 10.0000,
Lines 356-369 for my $currency_format ( qw( US FR ) ) { Link Here
356
            }
287
            }
357
        );
288
        );
358
289
359
        # Note that this configuration is *not* correct!
360
        # rrp_tax_included should be 82 (what we inserted!)
361
        # tax_value should be 7.03 instead of 7.02
362
363
        compare(
290
        compare(
364
            {
291
            {
365
                got      => $order_1_0->{rrp_tax_included},
292
                got      => $order_1_0->{rrp_tax_included},
366
                expected => 82.01,
293
                expected => 82,
367
                conf     => '1 0',
294
                conf     => '1 0',
368
                field    => 'rrp_tax_included'
295
                field    => 'rrp_tax_included'
369
            }
296
            }
Lines 395-421 for my $currency_format ( qw( US FR ) ) { Link Here
395
        compare(
322
        compare(
396
            {
323
            {
397
                got      => $order_1_0->{tax_value},
324
                got      => $order_1_0->{tax_value},
398
                expected => 7.02,
325
                expected => 7.03,
399
                conf     => '1 0',
326
                conf     => '1 0',
400
                field    => 'tax_value'
327
                field    => 'tax_value'
401
            }
328
            }
402
        );
329
        );
403
        compare(
404
            {
405
                got      => $order_1_0->{total_tax_included},
406
                expected => 147.60,
407
                conf     => '1 0',
408
                field    => 'total_tax_included'
409
            }
410
        );
411
        compare(
412
            {
413
                got      => $order_1_0->{total_tax_excluded},
414
                expected => 140.58,
415
                conf     => '1 0',
416
                field    => 'total_tax_excluded'
417
            }
418
        );
419
330
420
        $order_1_0 = C4::Acquisition::populate_order_with_prices(
331
        $order_1_0 = C4::Acquisition::populate_order_with_prices(
421
            {
332
            {
Lines 424-431 for my $currency_format ( qw( US FR ) ) { Link Here
424
                receiving    => 1,
335
                receiving    => 1,
425
            }
336
            }
426
        );
337
        );
427
        # Note that this configuration is *not* correct!
338
428
        # gstvalue should be 7.03
429
        compare(
339
        compare(
430
            {
340
            {
431
                got      => $order_1_0->{unitprice_tax_included},
341
                got      => $order_1_0->{unitprice_tax_included},
Lines 445-475 for my $currency_format ( qw( US FR ) ) { Link Here
445
        compare(
355
        compare(
446
            {
356
            {
447
                got      => $order_1_0->{tax_value},
357
                got      => $order_1_0->{tax_value},
448
                expected => 7.02,
358
                expected => 7.03,
449
                conf     => '1 0',
359
                conf     => '1 0',
450
                field    => 'tax_value'
360
                field    => 'tax_value'
451
            }
361
            }
452
        );
362
        );
453
        compare(
454
            {
455
                got      => $order_1_0->{total_tax_included},
456
                expected => 147.60,
457
                conf     => '1 0',
458
                field    => 'total_tax_included'
459
            }
460
        );
461
        compare(
462
            {
463
                got      => $order_1_0->{total_tax_excluded},
464
                expected => 140.58,
465
                conf     => '1 0',
466
                field    => 'total_tax_excluded'
467
            }
468
        );
469
    };
363
    };
470
364
471
    subtest 'Configuration 1: 0 1' => sub {
365
    subtest 'Configuration 1: 0 1' => sub {
472
        plan tests => 12;
366
        plan tests => 8;
473
        $bookseller_module->mock(
367
        $bookseller_module->mock(
474
            'fetch',
368
            'fetch',
475
            sub {
369
            sub {
Lines 482-488 for my $currency_format ( qw( US FR ) ) { Link Here
482
            biblionumber     => $biblionumber_0_1,
376
            biblionumber     => $biblionumber_0_1,
483
            quantity         => 2,
377
            quantity         => 2,
484
            listprice        => 82.000000,
378
            listprice        => 82.000000,
485
            unitprice        => 73.800000,
379
            unitprice        => 77.490000,
486
            quantityreceived => 2,
380
            quantityreceived => 2,
487
            basketno         => $basketno_1_1,
381
            basketno         => $basketno_1_1,
488
            invoiceid        => $invoiceid_1_1,
382
            invoiceid        => $invoiceid_1_1,
Lines 501-512 for my $currency_format ( qw( US FR ) ) { Link Here
501
            }
395
            }
502
        );
396
        );
503
397
504
        # Note that this configuration is correct \o/
505
        compare(
398
        compare(
506
            {
399
            {
507
                got      => $order_0_1->{rrp_tax_included},
400
                got      => $order_0_1->{rrp_tax_included},
508
                expected => 86.10,
401
                expected => 86.10,
509
                conf     => '1 0',
402
                conf     => '0 1',
510
                field    => 'rrp_tax_included'
403
                field    => 'rrp_tax_included'
511
            }
404
            }
512
        );
405
        );
Lines 514-520 for my $currency_format ( qw( US FR ) ) { Link Here
514
            {
407
            {
515
                got      => $order_0_1->{rrp_tax_excluded},
408
                got      => $order_0_1->{rrp_tax_excluded},
516
                expected => 82.00,
409
                expected => 82.00,
517
                conf     => '1 0',
410
                conf     => '0 1',
518
                field    => 'rrp_tax_excluded'
411
                field    => 'rrp_tax_excluded'
519
            }
412
            }
520
        );
413
        );
Lines 522-528 for my $currency_format ( qw( US FR ) ) { Link Here
522
            {
415
            {
523
                got      => $order_0_1->{ecost_tax_included},
416
                got      => $order_0_1->{ecost_tax_included},
524
                expected => 77.49,
417
                expected => 77.49,
525
                conf     => '1 0',
418
                conf     => '0 1',
526
                field    => 'ecost_tax_included'
419
                field    => 'ecost_tax_included'
527
            }
420
            }
528
        );
421
        );
Lines 530-536 for my $currency_format ( qw( US FR ) ) { Link Here
530
            {
423
            {
531
                got      => $order_0_1->{ecost_tax_excluded},
424
                got      => $order_0_1->{ecost_tax_excluded},
532
                expected => 73.80,
425
                expected => 73.80,
533
                conf     => '1 0',
426
                conf     => '0 1',
534
                field    => 'ecost_tax_excluded'
427
                field    => 'ecost_tax_excluded'
535
            }
428
            }
536
        );
429
        );
Lines 538-563 for my $currency_format ( qw( US FR ) ) { Link Here
538
            {
431
            {
539
                got      => $order_0_1->{tax_value},
432
                got      => $order_0_1->{tax_value},
540
                expected => 7.38,
433
                expected => 7.38,
541
                conf     => '1 0',
434
                conf     => '0 1',
542
                field    => 'tax_value'
435
                field    => 'tax_value'
543
            }
436
            }
544
        );
437
        );
545
        compare(
546
            {
547
                got      => $order_0_1->{total_tax_included},
548
                expected => 154.98,
549
                conf     => '1 0',
550
                field    => 'total_tax_included'
551
            }
552
        );
553
        compare(
554
            {
555
                got      => $order_0_1->{total_tax_excluded},
556
                expected => 147.60,
557
                conf     => '1 0',
558
                field    => 'total_tax_excluded'
559
            }
560
        );
561
438
562
        $order_0_1 = C4::Acquisition::populate_order_with_prices(
439
        $order_0_1 = C4::Acquisition::populate_order_with_prices(
563
            {
440
            {
Lines 566-572 for my $currency_format ( qw( US FR ) ) { Link Here
566
                receiving    => 1,
443
                receiving    => 1,
567
            }
444
            }
568
        );
445
        );
569
        # Note that this configuration is correct
446
570
        compare(
447
        compare(
571
            {
448
            {
572
                got      => $order_0_1->{unitprice_tax_included},
449
                got      => $order_0_1->{unitprice_tax_included},
Lines 591-612 for my $currency_format ( qw( US FR ) ) { Link Here
591
                field    => 'tax_value'
468
                field    => 'tax_value'
592
            }
469
            }
593
        );
470
        );
594
        compare(
595
            {
596
                got      => $order_0_1->{total_tax_included},
597
                expected => 154.98,
598
                conf     => '0 1',
599
                field    => 'total_tax_included'
600
            }
601
        );
602
        compare(
603
            {
604
                got      => $order_0_1->{total_tax_excluded},
605
                expected => 147.60,
606
                conf     => '0 1',
607
                field    => 'total_tax_excluded'
608
            }
609
        );
610
    };
471
    };
611
}
472
}
612
473
613
- 

Return to bug 13321