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

(-)a/C4/Acquisition.pm (-31 / +39 lines)
Lines 2800-2808 sub GetBiblioCountByBasketno { Link Here
2800
    return $sth->fetchrow;
2800
    return $sth->fetchrow;
2801
}
2801
}
2802
2802
2803
# This is *not* the good way to calcul prices
2804
# But it's how it works at the moment into Koha
2805
# This will be fixed later.
2806
# Note this subroutine should be moved to Koha::Acquisition::Order
2803
# Note this subroutine should be moved to Koha::Acquisition::Order
2807
# Will do when a DBIC decision will be taken.
2804
# Will do when a DBIC decision will be taken.
2808
sub populate_order_with_prices {
2805
sub populate_order_with_prices {
Lines 2819-2866 sub populate_order_with_prices { Link Here
2819
    my $discount  = $order->{discount};
2816
    my $discount  = $order->{discount};
2820
    $discount /= 100 if $discount > 1;
2817
    $discount /= 100 if $discount > 1;
2821
2818
2822
    $order->{rrp}   = Koha::Number::Price->new( $order->{rrp} )->round;
2823
    $order->{ecost} = Koha::Number::Price->new( $order->{ecost} )->round;
2824
    if ($ordering) {
2819
    if ($ordering) {
2825
        if ( $bookseller->{listincgst} ) {
2820
        if ( $bookseller->{listincgst} ) {
2821
            # The user entered the rrp tax included
2826
            $order->{rrp_tax_included} = $order->{rrp};
2822
            $order->{rrp_tax_included} = $order->{rrp};
2827
            $order->{rrp_tax_excluded} = Koha::Number::Price->new(
2823
2828
                $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
2824
            # rrp tax excluded = rrp tax included / ( 1 + tax rate )
2829
            $order->{ecost_tax_included} = $order->{ecost};
2825
            $order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} );
2830
            $order->{ecost_tax_excluded} = Koha::Number::Price->new(
2826
2831
                $order->{ecost} / ( 1 + $order->{tax_rate} ) )->round;
2827
            # ecost tax excluded = rrp tax excluded * ( 1 - discount )
2832
            $order->{tax_value} = Koha::Number::Price->new(
2828
            $order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount );
2833
                ( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
2829
2834
                  $order->{quantity} )->round;
2830
            # ecost tax included = rrp tax included  ( 1 - discount )
2831
            $order->{ecost_tax_included} = $order->{rrp_tax_included} * ( 1 - $discount );
2835
        }
2832
        }
2836
        else {
2833
        else {
2834
            # The user entered the rrp tax excluded
2837
            $order->{rrp_tax_excluded} = $order->{rrp};
2835
            $order->{rrp_tax_excluded} = $order->{rrp};
2838
            $order->{rrp_tax_included} = Koha::Number::Price->new(
2836
2839
                $order->{rrp} * ( 1 + $order->{tax_rate} ) )->round;
2837
            # rrp tax included = rrp tax excluded * ( 1 - tax rate )
2840
            $order->{ecost_tax_excluded} = $order->{ecost};
2838
            $order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate} );
2841
            $order->{ecost_tax_included} = Koha::Number::Price->new(
2839
2842
                $order->{ecost} * ( 1 + $order->{tax_rate} ) )->round;
2840
            # ecost tax excluded = rrp tax excluded * ( 1 - discount )
2843
            $order->{tax_value} = Koha::Number::Price->new(
2841
            $order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount );
2844
                ( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
2842
2845
                  $order->{quantity} )->round;
2843
            # ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount )
2844
            $order->{ecost_tax_included} =
2845
                $order->{rrp_tax_excluded} *
2846
                ( 1 + $order->{tax_rate} ) *
2847
                ( 1 - $discount );
2846
        }
2848
        }
2849
2850
        # tax value = quantity * ecost tax excluded * tax rate
2851
        $order->{tax_value} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate};
2847
    }
2852
    }
2848
2853
2849
    if ($receiving) {
2854
    if ($receiving) {
2850
        if ( $bookseller->{listincgst} ) {
2855
        if ( $bookseller->{invoiceincgst} ) {
2851
            $order->{unitprice_tax_included} = Koha::Number::Price->new( $order->{unitprice} )->round;
2856
            # The user entered the unit price tax included
2852
            $order->{unitprice_tax_excluded} = Koha::Number::Price->new(
2857
            $order->{unitprice_tax_included} = $order->{unitprice};
2853
              $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
2858
2859
            # unit price tax excluded = unit price tax included / ( 1 + tax rate )
2860
            $order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} );
2854
        }
2861
        }
2855
        else {
2862
        else {
2856
            $order->{unitprice_tax_excluded} = Koha::Number::Price->new( $order->{unitprice} )->round;
2863
            # The user entered the unit price tax excluded
2857
            $order->{unitprice_tax_included} = Koha::Number::Price->new(
2864
            $order->{unitprice_tax_excluded} = $order->{unitprice};
2858
              $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ) )->round;
2865
2866
            # unit price tax included = unit price tax included * ( 1 + tax rate )
2867
            $order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} );
2859
        }
2868
        }
2860
        $order->{tax_value} = Koha::Number::Price->new(
2861
          ( $order->{unitprice_tax_included} - $order->{unitprice_tax_excluded} )
2862
          * $order->{quantityreceived} )->round;
2863
2869
2870
        # tax value = quantity * unit price tax excluded * tax rate
2871
        $order->{tax_value} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate};
2864
    }
2872
    }
2865
2873
2866
    return $order;
2874
    return $order;
(-)a/acqui/basket.pl (-3 / +3 lines)
Lines 309-317 if ( $op eq 'delete_confirm' ) { Link Here
309
            $template->param( uncertainprices => 1 );
309
            $template->param( uncertainprices => 1 );
310
        }
310
        }
311
311
312
        $line->{total_tax_excluded} = Koha::Number::Price->new( $line->{ecost_tax_excluded} * $line->{quantity} )->format;
313
        $line->{total_tax_included} = Koha::Number::Price->new( $line->{ecost_tax_included} * $line->{quantity} )->format;
314
315
        push @books_loop, $line;
312
        push @books_loop, $line;
316
313
317
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
314
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
Lines 410-415 sub get_order_infos { Link Here
410
    $line{basketno}       = $basketno;
407
    $line{basketno}       = $basketno;
411
    $line{budget_name}    = $budget->{budget_name};
408
    $line{budget_name}    = $budget->{budget_name};
412
409
410
    $line{total_tax_included} = $line{ecost_tax_included} * $line{quantity};
411
    $line{total_tax_excluded} = $line{ecost_tax_excluded} * $line{quantity};
412
413
    if ( $line{uncertainprice} ) {
413
    if ( $line{uncertainprice} ) {
414
        $line{rrp_tax_excluded} .= ' (Uncertain)';
414
        $line{rrp_tax_excluded} .= ' (Uncertain)';
415
    }
415
    }
(-)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 140-146 foreach my $order (@$orders) { Link Here
140
140
141
push @foot_loop, map {$_} values %foot;
141
push @foot_loop, map {$_} values %foot;
142
142
143
my $format = "%.2f";
144
my $budgets = GetBudgets();
143
my $budgets = GetBudgets();
145
my @budgets_loop;
144
my @budgets_loop;
146
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
145
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
Lines 167-177 $template->param( Link Here
167
    orders_loop      => \@orders_loop,
166
    orders_loop      => \@orders_loop,
168
    foot_loop        => \@foot_loop,
167
    foot_loop        => \@foot_loop,
169
    total_quantity   => $total_quantity,
168
    total_quantity   => $total_quantity,
170
    total_tax_excluded       => sprintf( $format, $total_tax_excluded ),
169
    total_tax_excluded => $total_tax_excluded,
171
    total_tax_included       => sprintf( $format, $total_tax_included ),
170
    total_tax_included => $total_tax_included,
172
    total_tax_value   => sprintf( $format, $total_tax_value ),
171
    total_tax_value  => $total_tax_value,
173
    total_tax_excluded_shipment => sprintf( $format, $total_tax_excluded + $details->{shipmentcost}),
172
    total_tax_excluded_shipment => $total_tax_excluded + $details->{shipmentcost},
174
    total_tax_included_shipment => sprintf( $format, $total_tax_included + $details->{shipmentcost}),
173
    total_tax_included_shipment => $total_tax_included + $details->{shipmentcost},
175
    invoiceincgst    => $bookseller->{invoiceincgst},
174
    invoiceincgst    => $bookseller->{invoiceincgst},
176
    currency         => GetCurrency()->{currency},
175
    currency         => GetCurrency()->{currency},
177
    budgets_loop     => \@budgets_loop,
176
    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 23-29 my $today; Link Here
23
for my $currency_format ( qw( US FR ) ) {
23
for my $currency_format ( qw( US FR ) ) {
24
    t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
24
    t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
25
    subtest 'Configuration 1: 0 0' => sub {
25
    subtest 'Configuration 1: 0 0' => sub {
26
        plan tests => 12;
26
        plan tests => 8;
27
        $bookseller_module->mock(
27
        $bookseller_module->mock(
28
            'fetch',
28
            'fetch',
29
            sub {
29
            sub {
Lines 55-61 for my $currency_format ( qw( US FR ) ) { Link Here
55
            }
55
            }
56
        );
56
        );
57
57
58
        # Note that this configuration is correct \o/
59
        compare(
58
        compare(
60
            {
59
            {
61
                got      => $order_0_0->{rrp_tax_included},
60
                got      => $order_0_0->{rrp_tax_included},
Lines 96-117 for my $currency_format ( qw( US FR ) ) { Link Here
96
                field    => 'tax_value'
95
                field    => 'tax_value'
97
            }
96
            }
98
        );
97
        );
99
        compare(
100
            {
101
                got      => $order_0_0->{total_tax_included},
102
                expected => 154.98,
103
                conf     => '0 0',
104
                field    => 'total_tax_included'
105
            }
106
        );
107
        compare(
108
            {
109
                got      => $order_0_0->{total_tax_excluded},
110
                expected => 147.60,
111
                conf     => '0 0',
112
                field    => 'total_tax_excluded'
113
            }
114
        );
115
98
116
        $order_0_0 = C4::Acquisition::populate_order_with_prices(
99
        $order_0_0 = C4::Acquisition::populate_order_with_prices(
117
            {
100
            {
Lines 121-127 for my $currency_format ( qw( US FR ) ) { Link Here
121
            }
104
            }
122
        );
105
        );
123
106
124
        # Note that this configuration is correct \o/
125
        compare(
107
        compare(
126
            {
108
            {
127
                got      => $order_0_0->{unitprice_tax_included},
109
                got      => $order_0_0->{unitprice_tax_included},
Lines 146-171 for my $currency_format ( qw( US FR ) ) { Link Here
146
                field    => 'tax_value'
128
                field    => 'tax_value'
147
            }
129
            }
148
        );
130
        );
149
        compare(
150
            {
151
                got      => $order_0_0->{total_tax_included},
152
                expected => 154.98,
153
                conf     => '0 0',
154
                field    => 'total_tax_included'
155
            }
156
        );
157
        compare(
158
            {
159
                got      => $order_0_0->{total_tax_excluded},
160
                expected => 147.60,
161
                conf     => '0 0',
162
                field    => 'total_tax_excluded'
163
            }
164
        );
165
    };
131
    };
166
132
167
    subtest 'Configuration 1: 1 1' => sub {
133
    subtest 'Configuration 1: 1 1' => sub {
168
        plan tests => 12;
134
        plan tests => 8;
169
        $bookseller_module->mock(
135
        $bookseller_module->mock(
170
            'fetch',
136
            'fetch',
171
            sub {
137
            sub {
Lines 197-204 for my $currency_format ( qw( US FR ) ) { Link Here
197
            }
163
            }
198
        );
164
        );
199
165
200
        # Note that this configuration is *not* correct
201
        # tax_value should be 7.03 instead of 7.02
202
        compare(
166
        compare(
203
            {
167
            {
204
                got      => $order_1_1->{rrp_tax_included},
168
                got      => $order_1_1->{rrp_tax_included},
Lines 234-260 for my $currency_format ( qw( US FR ) ) { Link Here
234
        compare(
198
        compare(
235
            {
199
            {
236
                got      => $order_1_1->{tax_value},
200
                got      => $order_1_1->{tax_value},
237
                expected => 7.02,
201
                expected => 7.03,
238
                conf     => '1 1',
202
                conf     => '1 1',
239
                field    => 'tax_value'
203
                field    => 'tax_value'
240
            }
204
            }
241
        );
205
        );
242
        compare(
243
            {
244
                got      => $order_1_1->{total_tax_included},
245
                expected => 147.60,
246
                conf     => '1 1',
247
                field    => 'total_tax_included'
248
            }
249
        );
250
        compare(
251
            {
252
                got      => $order_1_1->{total_tax_excluded},
253
                expected => 140.58,
254
                conf     => '1 1',
255
                field    => 'total_tax_excluded'
256
            }
257
        );
258
206
259
        $order_1_1 = C4::Acquisition::populate_order_with_prices(
207
        $order_1_1 = C4::Acquisition::populate_order_with_prices(
260
            {
208
            {
Lines 263-270 for my $currency_format ( qw( US FR ) ) { Link Here
263
                receiving    => 1,
211
                receiving    => 1,
264
            }
212
            }
265
        );
213
        );
266
        # Note that this configuration is *not* correct!
214
267
        # tax_value should be 7.03
268
        compare(
215
        compare(
269
            {
216
            {
270
                got      => $order_1_1->{unitprice_tax_included},
217
                got      => $order_1_1->{unitprice_tax_included},
Lines 284-314 for my $currency_format ( qw( US FR ) ) { Link Here
284
        compare(
231
        compare(
285
            {
232
            {
286
                got      => $order_1_1->{tax_value},
233
                got      => $order_1_1->{tax_value},
287
                expected => 7.02,
234
                expected => 7.03,
288
                conf     => '1 1',
235
                conf     => '1 1',
289
                field    => 'tax_value'
236
                field    => 'tax_value'
290
            }
237
            }
291
        );
238
        );
292
        compare(
293
            {
294
                got      => $order_1_1->{total_tax_included},
295
                expected => 147.60,
296
                conf     => '1 1',
297
                field    => 'total_tax_included'
298
            }
299
        );
300
        compare(
301
            {
302
                got      => $order_1_1->{total_tax_excluded},
303
                expected => 140.58,
304
                conf     => '1 1',
305
                field    => 'total_tax_excluded'
306
            }
307
        );
308
    };
239
    };
309
240
310
    subtest 'Configuration 1: 1 0' => sub {
241
    subtest 'Configuration 1: 1 0' => sub {
311
        plan tests => 12;
242
        plan tests => 8;
312
        $bookseller_module->mock(
243
        $bookseller_module->mock(
313
            'fetch',
244
            'fetch',
314
            sub {
245
            sub {
Lines 321-331 for my $currency_format ( qw( US FR ) ) { Link Here
321
            biblionumber     => $biblionumber_1_0,
252
            biblionumber     => $biblionumber_1_0,
322
            quantity         => 2,
253
            quantity         => 2,
323
            listprice        => 82.000000,
254
            listprice        => 82.000000,
324
            unitprice        => 73.804500,
255
            unitprice        => 70.290000,
325
            quantityreceived => 2,
256
            quantityreceived => 2,
326
            basketno         => $basketno_1_1,
257
            basketno         => $basketno_1_1,
327
            invoiceid        => $invoiceid_1_1,
258
            invoiceid        => $invoiceid_1_1,
328
            rrp              => 82.01,
259
            rrp              => 82.00,
329
            ecost            => 73.80,
260
            ecost            => 73.80,
330
            tax_rate         => 0.0500,
261
            tax_rate         => 0.0500,
331
            discount         => 10.0000,
262
            discount         => 10.0000,
Lines 340-353 for my $currency_format ( qw( US FR ) ) { Link Here
340
            }
271
            }
341
        );
272
        );
342
273
343
        # Note that this configuration is *not* correct!
344
        # rrp_tax_included should be 82 (what we inserted!)
345
        # tax_value should be 7.03 instead of 7.02
346
347
        compare(
274
        compare(
348
            {
275
            {
349
                got      => $order_1_0->{rrp_tax_included},
276
                got      => $order_1_0->{rrp_tax_included},
350
                expected => 82.01,
277
                expected => 82,
351
                conf     => '1 0',
278
                conf     => '1 0',
352
                field    => 'rrp_tax_included'
279
                field    => 'rrp_tax_included'
353
            }
280
            }
Lines 379-405 for my $currency_format ( qw( US FR ) ) { Link Here
379
        compare(
306
        compare(
380
            {
307
            {
381
                got      => $order_1_0->{tax_value},
308
                got      => $order_1_0->{tax_value},
382
                expected => 7.02,
309
                expected => 7.03,
383
                conf     => '1 0',
310
                conf     => '1 0',
384
                field    => 'tax_value'
311
                field    => 'tax_value'
385
            }
312
            }
386
        );
313
        );
387
        compare(
388
            {
389
                got      => $order_1_0->{total_tax_included},
390
                expected => 147.60,
391
                conf     => '1 0',
392
                field    => 'total_tax_included'
393
            }
394
        );
395
        compare(
396
            {
397
                got      => $order_1_0->{total_tax_excluded},
398
                expected => 140.58,
399
                conf     => '1 0',
400
                field    => 'total_tax_excluded'
401
            }
402
        );
403
314
404
        $order_1_0 = C4::Acquisition::populate_order_with_prices(
315
        $order_1_0 = C4::Acquisition::populate_order_with_prices(
405
            {
316
            {
Lines 408-415 for my $currency_format ( qw( US FR ) ) { Link Here
408
                receiving    => 1,
319
                receiving    => 1,
409
            }
320
            }
410
        );
321
        );
411
        # Note that this configuration is *not* correct!
322
412
        # gstvalue should be 7.03
413
        compare(
323
        compare(
414
            {
324
            {
415
                got      => $order_1_0->{unitprice_tax_included},
325
                got      => $order_1_0->{unitprice_tax_included},
Lines 429-459 for my $currency_format ( qw( US FR ) ) { Link Here
429
        compare(
339
        compare(
430
            {
340
            {
431
                got      => $order_1_0->{tax_value},
341
                got      => $order_1_0->{tax_value},
432
                expected => 7.02,
342
                expected => 7.03,
433
                conf     => '1 0',
343
                conf     => '1 0',
434
                field    => 'tax_value'
344
                field    => 'tax_value'
435
            }
345
            }
436
        );
346
        );
437
        compare(
438
            {
439
                got      => $order_1_0->{total_tax_included},
440
                expected => 147.60,
441
                conf     => '1 0',
442
                field    => 'total_tax_included'
443
            }
444
        );
445
        compare(
446
            {
447
                got      => $order_1_0->{total_tax_excluded},
448
                expected => 140.58,
449
                conf     => '1 0',
450
                field    => 'total_tax_excluded'
451
            }
452
        );
453
    };
347
    };
454
348
455
    subtest 'Configuration 1: 0 1' => sub {
349
    subtest 'Configuration 1: 0 1' => sub {
456
        plan tests => 12;
350
        plan tests => 8;
457
        $bookseller_module->mock(
351
        $bookseller_module->mock(
458
            'fetch',
352
            'fetch',
459
            sub {
353
            sub {
Lines 466-472 for my $currency_format ( qw( US FR ) ) { Link Here
466
            biblionumber     => $biblionumber_0_1,
360
            biblionumber     => $biblionumber_0_1,
467
            quantity         => 2,
361
            quantity         => 2,
468
            listprice        => 82.000000,
362
            listprice        => 82.000000,
469
            unitprice        => 73.800000,
363
            unitprice        => 77.490000,
470
            quantityreceived => 2,
364
            quantityreceived => 2,
471
            basketno         => $basketno_1_1,
365
            basketno         => $basketno_1_1,
472
            invoiceid        => $invoiceid_1_1,
366
            invoiceid        => $invoiceid_1_1,
Lines 485-496 for my $currency_format ( qw( US FR ) ) { Link Here
485
            }
379
            }
486
        );
380
        );
487
381
488
        # Note that this configuration is correct \o/
489
        compare(
382
        compare(
490
            {
383
            {
491
                got      => $order_0_1->{rrp_tax_included},
384
                got      => $order_0_1->{rrp_tax_included},
492
                expected => 86.10,
385
                expected => 86.10,
493
                conf     => '1 0',
386
                conf     => '0 1',
494
                field    => 'rrp_tax_included'
387
                field    => 'rrp_tax_included'
495
            }
388
            }
496
        );
389
        );
Lines 498-504 for my $currency_format ( qw( US FR ) ) { Link Here
498
            {
391
            {
499
                got      => $order_0_1->{rrp_tax_excluded},
392
                got      => $order_0_1->{rrp_tax_excluded},
500
                expected => 82.00,
393
                expected => 82.00,
501
                conf     => '1 0',
394
                conf     => '0 1',
502
                field    => 'rrp_tax_excluded'
395
                field    => 'rrp_tax_excluded'
503
            }
396
            }
504
        );
397
        );
Lines 506-512 for my $currency_format ( qw( US FR ) ) { Link Here
506
            {
399
            {
507
                got      => $order_0_1->{ecost_tax_included},
400
                got      => $order_0_1->{ecost_tax_included},
508
                expected => 77.49,
401
                expected => 77.49,
509
                conf     => '1 0',
402
                conf     => '0 1',
510
                field    => 'ecost_tax_included'
403
                field    => 'ecost_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->{ecost_tax_excluded},
408
                got      => $order_0_1->{ecost_tax_excluded},
516
                expected => 73.80,
409
                expected => 73.80,
517
                conf     => '1 0',
410
                conf     => '0 1',
518
                field    => 'ecost_tax_excluded'
411
                field    => 'ecost_tax_excluded'
519
            }
412
            }
520
        );
413
        );
Lines 522-547 for my $currency_format ( qw( US FR ) ) { Link Here
522
            {
415
            {
523
                got      => $order_0_1->{tax_value},
416
                got      => $order_0_1->{tax_value},
524
                expected => 7.38,
417
                expected => 7.38,
525
                conf     => '1 0',
418
                conf     => '0 1',
526
                field    => 'tax_value'
419
                field    => 'tax_value'
527
            }
420
            }
528
        );
421
        );
529
        compare(
530
            {
531
                got      => $order_0_1->{total_tax_included},
532
                expected => 154.98,
533
                conf     => '1 0',
534
                field    => 'total_tax_included'
535
            }
536
        );
537
        compare(
538
            {
539
                got      => $order_0_1->{total_tax_excluded},
540
                expected => 147.60,
541
                conf     => '1 0',
542
                field    => 'total_tax_excluded'
543
            }
544
        );
545
422
546
        $order_0_1 = C4::Acquisition::populate_order_with_prices(
423
        $order_0_1 = C4::Acquisition::populate_order_with_prices(
547
            {
424
            {
Lines 550-556 for my $currency_format ( qw( US FR ) ) { Link Here
550
                receiving    => 1,
427
                receiving    => 1,
551
            }
428
            }
552
        );
429
        );
553
        # Note that this configuration is correct
430
554
        compare(
431
        compare(
555
            {
432
            {
556
                got      => $order_0_1->{unitprice_tax_included},
433
                got      => $order_0_1->{unitprice_tax_included},
Lines 575-596 for my $currency_format ( qw( US FR ) ) { Link Here
575
                field    => 'tax_value'
452
                field    => 'tax_value'
576
            }
453
            }
577
        );
454
        );
578
        compare(
579
            {
580
                got      => $order_0_1->{total_tax_included},
581
                expected => 154.98,
582
                conf     => '0 1',
583
                field    => 'total_tax_included'
584
            }
585
        );
586
        compare(
587
            {
588
                got      => $order_0_1->{total_tax_excluded},
589
                expected => 147.60,
590
                conf     => '0 1',
591
                field    => 'total_tax_excluded'
592
            }
593
        );
594
    };
455
    };
595
}
456
}
596
457
597
- 

Return to bug 13321