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 349-357 if ( $op eq 'delete_confirm' ) { Link Here
349
            $template->param( uncertainprices => 1 );
349
            $template->param( uncertainprices => 1 );
350
        }
350
        }
351
351
352
        $line->{total_tax_excluded} = Koha::Number::Price->new( $line->{ecost_tax_excluded} * $line->{quantity} )->format;
353
        $line->{total_tax_included} = Koha::Number::Price->new( $line->{ecost_tax_included} * $line->{quantity} )->format;
354
355
        push @books_loop, $line;
352
        push @books_loop, $line;
356
353
357
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
354
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
Lines 449-454 sub get_order_infos { Link Here
449
    $line{basketno}       = $basketno;
446
    $line{basketno}       = $basketno;
450
    $line{budget_name}    = $budget->{budget_name};
447
    $line{budget_name}    = $budget->{budget_name};
451
448
449
    $line{total_tax_included} = $line{ecost_tax_included} * $line{quantity};
450
    $line{total_tax_excluded} = $line{ecost_tax_excluded} * $line{quantity};
451
452
    if ( $line{uncertainprice} ) {
452
    if ( $line{uncertainprice} ) {
453
        $line{rrp_tax_excluded} .= ' (Uncertain)';
453
        $line{rrp_tax_excluded} .= ' (Uncertain)';
454
    }
454
    }
(-)a/acqui/basketgroup.pl (-4 lines)
Lines 82-91 sub BasketTotal { Link Here
82
        } else {
82
        } else {
83
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
83
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
84
        }
84
        }
85
        if ($bookseller->{invoiceincgst} && ! $bookseller->{listincgst} && ( $bookseller->{tax_rate} // C4::Context->preference("gist") )) {
86
            my $gst = $bookseller->{tax_rate} // C4::Context->preference("gist");
87
            $total = $total * ( $gst / 100 +1);
88
        }
89
    }
85
    }
90
    $total .= " " . ($bookseller->{invoiceprice} // 0);
86
    $total .= " " . ($bookseller->{invoiceprice} // 0);
91
    return $total;
87
    return $total;
(-)a/acqui/finishreceive.pl (-19 / +1 lines)
Lines 54-61 my $invoiceno = $invoice->{invoicenumber}; Link Here
54
my $datereceived     = $invoice->{shipmentdate};
54
my $datereceived     = $invoice->{shipmentdate};
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 170-176 ModItem( Link Here
170
        booksellerid         => $booksellerid,
152
        booksellerid         => $booksellerid,
171
        dateaccessioned      => $datereceived,
153
        dateaccessioned      => $datereceived,
172
        price                => $unitprice,
154
        price                => $unitprice,
173
        replacementprice     => $rrp,
155
        replacementprice     => $order->{rrp},
174
        replacementpricedate => $datereceived,
156
        replacementpricedate => $datereceived,
175
    },
157
    },
176
    $biblionumber,
158
    $biblionumber,
(-)a/acqui/invoice.pl (-6 / +5 lines)
Lines 142-148 foreach my $order (@$orders) { Link Here
142
142
143
push @foot_loop, map {$_} values %foot;
143
push @foot_loop, map {$_} values %foot;
144
144
145
my $format = "%.2f";
146
my $budgets = GetBudgets();
145
my $budgets = GetBudgets();
147
my @budgets_loop;
146
my @budgets_loop;
148
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
147
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
Lines 169-179 $template->param( Link Here
169
    orders_loop      => \@orders_loop,
168
    orders_loop      => \@orders_loop,
170
    foot_loop        => \@foot_loop,
169
    foot_loop        => \@foot_loop,
171
    total_quantity   => $total_quantity,
170
    total_quantity   => $total_quantity,
172
    total_tax_excluded       => sprintf( $format, $total_tax_excluded ),
171
    total_tax_excluded => $total_tax_excluded,
173
    total_tax_included       => sprintf( $format, $total_tax_included ),
172
    total_tax_included => $total_tax_included,
174
    total_tax_value   => sprintf( $format, $total_tax_value ),
173
    total_tax_value  => $total_tax_value,
175
    total_tax_excluded_shipment => sprintf( $format, $total_tax_excluded + $details->{shipmentcost}),
174
    total_tax_excluded_shipment => $total_tax_excluded + $details->{shipmentcost},
176
    total_tax_included_shipment => sprintf( $format, $total_tax_included + $details->{shipmentcost}),
175
    total_tax_included_shipment => $total_tax_included + $details->{shipmentcost},
177
    invoiceincgst    => $bookseller->{invoiceincgst},
176
    invoiceincgst    => $bookseller->{invoiceincgst},
178
    currency         => GetCurrency()->{currency},
177
    currency         => GetCurrency()->{currency},
179
    budgets_loop     => \@budgets_loop,
178
    budgets_loop     => \@budgets_loop,
(-)a/acqui/parcel.pl (-2 / +2 lines)
Lines 150-157 for my $order ( @orders ) { Link Here
150
    $line{budget} = GetBudgetByOrderNumber( $line{ordernumber} );
150
    $line{budget} = GetBudgetByOrderNumber( $line{ordernumber} );
151
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
151
    $foot{$line{tax_rate}}{tax_rate} = $line{tax_rate};
152
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
152
    $foot{$line{tax_rate}}{tax_value} += $line{tax_value};
153
    $total_tax_excluded += Koha::Number::Price->new( $line{ecost_tax_excluded} * $line{quantity} )->format;
153
    $total_tax_excluded += $line{unitprice_tax_excluded} * $line{quantity};
154
    $total_tax_included += Koha::Number::Price->new( $line{ecost_tax_included} * $line{quantity} )->format;
154
    $total_tax_included += $line{unitprice_tax_included} * $line{quantity};
155
155
156
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
156
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
157
    $line{suggestionid}         = $suggestion->{suggestionid};
157
    $line{suggestionid}         = $suggestion->{suggestionid};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-4 / +5 lines)
Lines 321-333 Link Here
321
            </div>
321
            </div>
322
          [% END %][%# IF (AcqCreateItemReceiving) %]
322
          [% END %][%# IF (AcqCreateItemReceiving) %]
323
		</li>
323
		</li>
324
        <li><label for="rrp">Replacement cost: </label><input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /></li>
324
325
        <li><label for="ecost">Budgeted cost: </label><input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" /></li>
325
        <li><label for="rrp">Replacement cost: </label>[% rrp | $Price %]</li>
326
        <li><label for="ecost">Budgeted cost: </label>[% ecost | $Price %]</li>
326
        <li><label for="cost">Actual cost:</label>
327
        <li><label for="cost">Actual cost:</label>
327
        [% IF ( unitprice ) %]
328
        [% IF ( unitprice ) %]
328
         <input type="text" size="20" name="cost" id="cost" value="[% unitprice %]" />
329
             <input type="text" size="20" name="cost" id="cost" value="[% unitprice | $Price %]" />
329
        [% ELSE %]
330
        [% ELSE %]
330
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
331
             <input type="text" size="20" name="cost" id="cost" value="[% ecost | $Price %]" />
331
        [% END %]</li>
332
        [% END %]</li>
332
        <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote %]</textarea></li>
333
        <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote %]</textarea></li>
333
        <li><label for="order_vendornote">Vendor note: </label><span>[% order_vendornote %]</span></li>
334
        <li><label for="order_vendornote">Vendor note: </label><span>[% order_vendornote %]</span></li>
(-)a/t/Prices.t (-160 / +20 lines)
Lines 21-27 my $today; Link Here
21
for my $currency_format ( qw( US FR ) ) {
21
for my $currency_format ( qw( US FR ) ) {
22
    t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
22
    t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
23
    subtest 'Configuration 1: 0 0' => sub {
23
    subtest 'Configuration 1: 0 0' => sub {
24
        plan tests => 12;
24
        plan tests => 8;
25
        $bookseller_module->mock(
25
        $bookseller_module->mock(
26
            'fetch',
26
            'fetch',
27
            sub {
27
            sub {
Lines 53-59 for my $currency_format ( qw( US FR ) ) { Link Here
53
            }
53
            }
54
        );
54
        );
55
55
56
        # Note that this configuration is correct \o/
57
        compare(
56
        compare(
58
            {
57
            {
59
                got      => $order_0_0->{rrp_tax_included},
58
                got      => $order_0_0->{rrp_tax_included},
Lines 94-115 for my $currency_format ( qw( US FR ) ) { Link Here
94
                field    => 'tax_value'
93
                field    => 'tax_value'
95
            }
94
            }
96
        );
95
        );
97
        compare(
98
            {
99
                got      => $order_0_0->{total_tax_included},
100
                expected => 154.98,
101
                conf     => '0 0',
102
                field    => 'total_tax_included'
103
            }
104
        );
105
        compare(
106
            {
107
                got      => $order_0_0->{total_tax_excluded},
108
                expected => 147.60,
109
                conf     => '0 0',
110
                field    => 'total_tax_excluded'
111
            }
112
        );
113
96
114
        $order_0_0 = C4::Acquisition::populate_order_with_prices(
97
        $order_0_0 = C4::Acquisition::populate_order_with_prices(
115
            {
98
            {
Lines 119-125 for my $currency_format ( qw( US FR ) ) { Link Here
119
            }
102
            }
120
        );
103
        );
121
104
122
        # Note that this configuration is correct \o/
123
        compare(
105
        compare(
124
            {
106
            {
125
                got      => $order_0_0->{unitprice_tax_included},
107
                got      => $order_0_0->{unitprice_tax_included},
Lines 144-169 for my $currency_format ( qw( US FR ) ) { Link Here
144
                field    => 'tax_value'
126
                field    => 'tax_value'
145
            }
127
            }
146
        );
128
        );
147
        compare(
148
            {
149
                got      => $order_0_0->{total_tax_included},
150
                expected => 154.98,
151
                conf     => '0 0',
152
                field    => 'total_tax_included'
153
            }
154
        );
155
        compare(
156
            {
157
                got      => $order_0_0->{total_tax_excluded},
158
                expected => 147.60,
159
                conf     => '0 0',
160
                field    => 'total_tax_excluded'
161
            }
162
        );
163
    };
129
    };
164
130
165
    subtest 'Configuration 1: 1 1' => sub {
131
    subtest 'Configuration 1: 1 1' => sub {
166
        plan tests => 12;
132
        plan tests => 8;
167
        $bookseller_module->mock(
133
        $bookseller_module->mock(
168
            'fetch',
134
            'fetch',
169
            sub {
135
            sub {
Lines 195-202 for my $currency_format ( qw( US FR ) ) { Link Here
195
            }
161
            }
196
        );
162
        );
197
163
198
        # Note that this configuration is *not* correct
199
        # tax_value should be 7.03 instead of 7.02
200
        compare(
164
        compare(
201
            {
165
            {
202
                got      => $order_1_1->{rrp_tax_included},
166
                got      => $order_1_1->{rrp_tax_included},
Lines 232-258 for my $currency_format ( qw( US FR ) ) { Link Here
232
        compare(
196
        compare(
233
            {
197
            {
234
                got      => $order_1_1->{tax_value},
198
                got      => $order_1_1->{tax_value},
235
                expected => 7.02,
199
                expected => 7.03,
236
                conf     => '1 1',
200
                conf     => '1 1',
237
                field    => 'tax_value'
201
                field    => 'tax_value'
238
            }
202
            }
239
        );
203
        );
240
        compare(
241
            {
242
                got      => $order_1_1->{total_tax_included},
243
                expected => 147.60,
244
                conf     => '1 1',
245
                field    => 'total_tax_included'
246
            }
247
        );
248
        compare(
249
            {
250
                got      => $order_1_1->{total_tax_excluded},
251
                expected => 140.58,
252
                conf     => '1 1',
253
                field    => 'total_tax_excluded'
254
            }
255
        );
256
204
257
        $order_1_1 = C4::Acquisition::populate_order_with_prices(
205
        $order_1_1 = C4::Acquisition::populate_order_with_prices(
258
            {
206
            {
Lines 261-268 for my $currency_format ( qw( US FR ) ) { Link Here
261
                receiving    => 1,
209
                receiving    => 1,
262
            }
210
            }
263
        );
211
        );
264
        # Note that this configuration is *not* correct!
212
265
        # tax_value should be 7.03
266
        compare(
213
        compare(
267
            {
214
            {
268
                got      => $order_1_1->{unitprice_tax_included},
215
                got      => $order_1_1->{unitprice_tax_included},
Lines 282-312 for my $currency_format ( qw( US FR ) ) { Link Here
282
        compare(
229
        compare(
283
            {
230
            {
284
                got      => $order_1_1->{tax_value},
231
                got      => $order_1_1->{tax_value},
285
                expected => 7.02,
232
                expected => 7.03,
286
                conf     => '1 1',
233
                conf     => '1 1',
287
                field    => 'tax_value'
234
                field    => 'tax_value'
288
            }
235
            }
289
        );
236
        );
290
        compare(
291
            {
292
                got      => $order_1_1->{total_tax_included},
293
                expected => 147.60,
294
                conf     => '1 1',
295
                field    => 'total_tax_included'
296
            }
297
        );
298
        compare(
299
            {
300
                got      => $order_1_1->{total_tax_excluded},
301
                expected => 140.58,
302
                conf     => '1 1',
303
                field    => 'total_tax_excluded'
304
            }
305
        );
306
    };
237
    };
307
238
308
    subtest 'Configuration 1: 1 0' => sub {
239
    subtest 'Configuration 1: 1 0' => sub {
309
        plan tests => 12;
240
        plan tests => 8;
310
        $bookseller_module->mock(
241
        $bookseller_module->mock(
311
            'fetch',
242
            'fetch',
312
            sub {
243
            sub {
Lines 319-329 for my $currency_format ( qw( US FR ) ) { Link Here
319
            biblionumber     => $biblionumber_1_0,
250
            biblionumber     => $biblionumber_1_0,
320
            quantity         => 2,
251
            quantity         => 2,
321
            listprice        => 82.000000,
252
            listprice        => 82.000000,
322
            unitprice        => 73.804500,
253
            unitprice        => 70.290000,
323
            quantityreceived => 2,
254
            quantityreceived => 2,
324
            basketno         => $basketno_1_1,
255
            basketno         => $basketno_1_1,
325
            invoiceid        => $invoiceid_1_1,
256
            invoiceid        => $invoiceid_1_1,
326
            rrp              => 82.01,
257
            rrp              => 82.00,
327
            ecost            => 73.80,
258
            ecost            => 73.80,
328
            tax_rate         => 0.0500,
259
            tax_rate         => 0.0500,
329
            discount         => 10.0000,
260
            discount         => 10.0000,
Lines 338-351 for my $currency_format ( qw( US FR ) ) { Link Here
338
            }
269
            }
339
        );
270
        );
340
271
341
        # Note that this configuration is *not* correct!
342
        # rrp_tax_included should be 82 (what we inserted!)
343
        # tax_value should be 7.03 instead of 7.02
344
345
        compare(
272
        compare(
346
            {
273
            {
347
                got      => $order_1_0->{rrp_tax_included},
274
                got      => $order_1_0->{rrp_tax_included},
348
                expected => 82.01,
275
                expected => 82,
349
                conf     => '1 0',
276
                conf     => '1 0',
350
                field    => 'rrp_tax_included'
277
                field    => 'rrp_tax_included'
351
            }
278
            }
Lines 377-403 for my $currency_format ( qw( US FR ) ) { Link Here
377
        compare(
304
        compare(
378
            {
305
            {
379
                got      => $order_1_0->{tax_value},
306
                got      => $order_1_0->{tax_value},
380
                expected => 7.02,
307
                expected => 7.03,
381
                conf     => '1 0',
308
                conf     => '1 0',
382
                field    => 'tax_value'
309
                field    => 'tax_value'
383
            }
310
            }
384
        );
311
        );
385
        compare(
386
            {
387
                got      => $order_1_0->{total_tax_included},
388
                expected => 147.60,
389
                conf     => '1 0',
390
                field    => 'total_tax_included'
391
            }
392
        );
393
        compare(
394
            {
395
                got      => $order_1_0->{total_tax_excluded},
396
                expected => 140.58,
397
                conf     => '1 0',
398
                field    => 'total_tax_excluded'
399
            }
400
        );
401
312
402
        $order_1_0 = C4::Acquisition::populate_order_with_prices(
313
        $order_1_0 = C4::Acquisition::populate_order_with_prices(
403
            {
314
            {
Lines 406-413 for my $currency_format ( qw( US FR ) ) { Link Here
406
                receiving    => 1,
317
                receiving    => 1,
407
            }
318
            }
408
        );
319
        );
409
        # Note that this configuration is *not* correct!
320
410
        # gstvalue should be 7.03
411
        compare(
321
        compare(
412
            {
322
            {
413
                got      => $order_1_0->{unitprice_tax_included},
323
                got      => $order_1_0->{unitprice_tax_included},
Lines 427-457 for my $currency_format ( qw( US FR ) ) { Link Here
427
        compare(
337
        compare(
428
            {
338
            {
429
                got      => $order_1_0->{tax_value},
339
                got      => $order_1_0->{tax_value},
430
                expected => 7.02,
340
                expected => 7.03,
431
                conf     => '1 0',
341
                conf     => '1 0',
432
                field    => 'tax_value'
342
                field    => 'tax_value'
433
            }
343
            }
434
        );
344
        );
435
        compare(
436
            {
437
                got      => $order_1_0->{total_tax_included},
438
                expected => 147.60,
439
                conf     => '1 0',
440
                field    => 'total_tax_included'
441
            }
442
        );
443
        compare(
444
            {
445
                got      => $order_1_0->{total_tax_excluded},
446
                expected => 140.58,
447
                conf     => '1 0',
448
                field    => 'total_tax_excluded'
449
            }
450
        );
451
    };
345
    };
452
346
453
    subtest 'Configuration 1: 0 1' => sub {
347
    subtest 'Configuration 1: 0 1' => sub {
454
        plan tests => 12;
348
        plan tests => 8;
455
        $bookseller_module->mock(
349
        $bookseller_module->mock(
456
            'fetch',
350
            'fetch',
457
            sub {
351
            sub {
Lines 464-470 for my $currency_format ( qw( US FR ) ) { Link Here
464
            biblionumber     => $biblionumber_0_1,
358
            biblionumber     => $biblionumber_0_1,
465
            quantity         => 2,
359
            quantity         => 2,
466
            listprice        => 82.000000,
360
            listprice        => 82.000000,
467
            unitprice        => 73.800000,
361
            unitprice        => 77.490000,
468
            quantityreceived => 2,
362
            quantityreceived => 2,
469
            basketno         => $basketno_1_1,
363
            basketno         => $basketno_1_1,
470
            invoiceid        => $invoiceid_1_1,
364
            invoiceid        => $invoiceid_1_1,
Lines 483-494 for my $currency_format ( qw( US FR ) ) { Link Here
483
            }
377
            }
484
        );
378
        );
485
379
486
        # Note that this configuration is correct \o/
487
        compare(
380
        compare(
488
            {
381
            {
489
                got      => $order_0_1->{rrp_tax_included},
382
                got      => $order_0_1->{rrp_tax_included},
490
                expected => 86.10,
383
                expected => 86.10,
491
                conf     => '1 0',
384
                conf     => '0 1',
492
                field    => 'rrp_tax_included'
385
                field    => 'rrp_tax_included'
493
            }
386
            }
494
        );
387
        );
Lines 496-502 for my $currency_format ( qw( US FR ) ) { Link Here
496
            {
389
            {
497
                got      => $order_0_1->{rrp_tax_excluded},
390
                got      => $order_0_1->{rrp_tax_excluded},
498
                expected => 82.00,
391
                expected => 82.00,
499
                conf     => '1 0',
392
                conf     => '0 1',
500
                field    => 'rrp_tax_excluded'
393
                field    => 'rrp_tax_excluded'
501
            }
394
            }
502
        );
395
        );
Lines 504-510 for my $currency_format ( qw( US FR ) ) { Link Here
504
            {
397
            {
505
                got      => $order_0_1->{ecost_tax_included},
398
                got      => $order_0_1->{ecost_tax_included},
506
                expected => 77.49,
399
                expected => 77.49,
507
                conf     => '1 0',
400
                conf     => '0 1',
508
                field    => 'ecost_tax_included'
401
                field    => 'ecost_tax_included'
509
            }
402
            }
510
        );
403
        );
Lines 512-518 for my $currency_format ( qw( US FR ) ) { Link Here
512
            {
405
            {
513
                got      => $order_0_1->{ecost_tax_excluded},
406
                got      => $order_0_1->{ecost_tax_excluded},
514
                expected => 73.80,
407
                expected => 73.80,
515
                conf     => '1 0',
408
                conf     => '0 1',
516
                field    => 'ecost_tax_excluded'
409
                field    => 'ecost_tax_excluded'
517
            }
410
            }
518
        );
411
        );
Lines 520-545 for my $currency_format ( qw( US FR ) ) { Link Here
520
            {
413
            {
521
                got      => $order_0_1->{tax_value},
414
                got      => $order_0_1->{tax_value},
522
                expected => 7.38,
415
                expected => 7.38,
523
                conf     => '1 0',
416
                conf     => '0 1',
524
                field    => 'tax_value'
417
                field    => 'tax_value'
525
            }
418
            }
526
        );
419
        );
527
        compare(
528
            {
529
                got      => $order_0_1->{total_tax_included},
530
                expected => 154.98,
531
                conf     => '1 0',
532
                field    => 'total_tax_included'
533
            }
534
        );
535
        compare(
536
            {
537
                got      => $order_0_1->{total_tax_excluded},
538
                expected => 147.60,
539
                conf     => '1 0',
540
                field    => 'total_tax_excluded'
541
            }
542
        );
543
420
544
        $order_0_1 = C4::Acquisition::populate_order_with_prices(
421
        $order_0_1 = C4::Acquisition::populate_order_with_prices(
545
            {
422
            {
Lines 548-554 for my $currency_format ( qw( US FR ) ) { Link Here
548
                receiving    => 1,
425
                receiving    => 1,
549
            }
426
            }
550
        );
427
        );
551
        # Note that this configuration is correct
428
552
        compare(
429
        compare(
553
            {
430
            {
554
                got      => $order_0_1->{unitprice_tax_included},
431
                got      => $order_0_1->{unitprice_tax_included},
Lines 573-594 for my $currency_format ( qw( US FR ) ) { Link Here
573
                field    => 'tax_value'
450
                field    => 'tax_value'
574
            }
451
            }
575
        );
452
        );
576
        compare(
577
            {
578
                got      => $order_0_1->{total_tax_included},
579
                expected => 154.98,
580
                conf     => '0 1',
581
                field    => 'total_tax_included'
582
            }
583
        );
584
        compare(
585
            {
586
                got      => $order_0_1->{total_tax_excluded},
587
                expected => 147.60,
588
                conf     => '0 1',
589
                field    => 'total_tax_excluded'
590
            }
591
        );
592
    };
453
    };
593
}
454
}
594
455
595
- 

Return to bug 13321