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

(-)a/C4/Acquisition.pm (-31 / +39 lines)
Lines 2823-2831 sub GetBiblioCountByBasketno { Link Here
2823
    return $sth->fetchrow;
2823
    return $sth->fetchrow;
2824
}
2824
}
2825
2825
2826
# This is *not* the good way to calcul prices
2827
# But it's how it works at the moment into Koha
2828
# This will be fixed later.
2829
# Note this subroutine should be moved to Koha::Acquisition::Order
2826
# Note this subroutine should be moved to Koha::Acquisition::Order
2830
# Will do when a DBIC decision will be taken.
2827
# Will do when a DBIC decision will be taken.
2831
sub populate_order_with_prices {
2828
sub populate_order_with_prices {
Lines 2842-2889 sub populate_order_with_prices { Link Here
2842
    my $discount  = $order->{discount};
2839
    my $discount  = $order->{discount};
2843
    $discount /= 100 if $discount > 1;
2840
    $discount /= 100 if $discount > 1;
2844
2841
2845
    $order->{rrp}   = Koha::Number::Price->new( $order->{rrp} )->round;
2846
    $order->{ecost} = Koha::Number::Price->new( $order->{ecost} )->round;
2847
    if ($ordering) {
2842
    if ($ordering) {
2848
        if ( $bookseller->{listincgst} ) {
2843
        if ( $bookseller->{listincgst} ) {
2844
            # The user entered the rrp tax included
2849
            $order->{rrp_tax_included} = $order->{rrp};
2845
            $order->{rrp_tax_included} = $order->{rrp};
2850
            $order->{rrp_tax_excluded} = Koha::Number::Price->new(
2846
2851
                $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
2847
            # rrp tax excluded = rrp tax included / ( 1 + tax rate )
2852
            $order->{ecost_tax_included} = $order->{ecost};
2848
            $order->{rrp_tax_excluded} = $order->{rrp_tax_included} / ( 1 + $order->{tax_rate} );
2853
            $order->{ecost_tax_excluded} = Koha::Number::Price->new(
2849
2854
                $order->{ecost} / ( 1 + $order->{tax_rate} ) )->round;
2850
            # ecost tax excluded = rrp tax excluded * ( 1 - discount )
2855
            $order->{tax_value} = Koha::Number::Price->new(
2851
            $order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount );
2856
                ( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
2852
2857
                  $order->{quantity} )->round;
2853
            # ecost tax included = rrp tax included  ( 1 - discount )
2854
            $order->{ecost_tax_included} = $order->{rrp_tax_included} * ( 1 - $discount );
2858
        }
2855
        }
2859
        else {
2856
        else {
2857
            # The user entered the rrp tax excluded
2860
            $order->{rrp_tax_excluded} = $order->{rrp};
2858
            $order->{rrp_tax_excluded} = $order->{rrp};
2861
            $order->{rrp_tax_included} = Koha::Number::Price->new(
2859
2862
                $order->{rrp} * ( 1 + $order->{tax_rate} ) )->round;
2860
            # rrp tax included = rrp tax excluded * ( 1 - tax rate )
2863
            $order->{ecost_tax_excluded} = $order->{ecost};
2861
            $order->{rrp_tax_included} = $order->{rrp_tax_excluded} * ( 1 + $order->{tax_rate} );
2864
            $order->{ecost_tax_included} = Koha::Number::Price->new(
2862
2865
                $order->{ecost} * ( 1 + $order->{tax_rate} ) )->round;
2863
            # ecost tax excluded = rrp tax excluded * ( 1 - discount )
2866
            $order->{tax_value} = Koha::Number::Price->new(
2864
            $order->{ecost_tax_excluded} = $order->{rrp_tax_excluded} * ( 1 - $discount );
2867
                ( $order->{ecost_tax_included} - $order->{ecost_tax_excluded} ) *
2865
2868
                  $order->{quantity} )->round;
2866
            # ecost tax included = rrp tax excluded * ( 1 - tax rate ) * ( 1 - discount )
2867
            $order->{ecost_tax_included} =
2868
                $order->{rrp_tax_excluded} *
2869
                ( 1 + $order->{tax_rate} ) *
2870
                ( 1 - $discount );
2869
        }
2871
        }
2872
2873
        # tax value = quantity * ecost tax excluded * tax rate
2874
        $order->{tax_value} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate};
2870
    }
2875
    }
2871
2876
2872
    if ($receiving) {
2877
    if ($receiving) {
2873
        if ( $bookseller->{listincgst} ) {
2878
        if ( $bookseller->{invoiceincgst} ) {
2874
            $order->{unitprice_tax_included} = Koha::Number::Price->new( $order->{unitprice} )->round;
2879
            # The user entered the unit price tax included
2875
            $order->{unitprice_tax_excluded} = Koha::Number::Price->new(
2880
            $order->{unitprice_tax_included} = $order->{unitprice};
2876
              $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} ) )->round;
2881
2882
            # unit price tax excluded = unit price tax included / ( 1 + tax rate )
2883
            $order->{unitprice_tax_excluded} = $order->{unitprice_tax_included} / ( 1 + $order->{tax_rate} );
2877
        }
2884
        }
2878
        else {
2885
        else {
2879
            $order->{unitprice_tax_excluded} = Koha::Number::Price->new( $order->{unitprice} )->round;
2886
            # The user entered the unit price tax excluded
2880
            $order->{unitprice_tax_included} = Koha::Number::Price->new(
2887
            $order->{unitprice_tax_excluded} = $order->{unitprice};
2881
              $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} ) )->round;
2888
2889
            # unit price tax included = unit price tax included * ( 1 + tax rate )
2890
            $order->{unitprice_tax_included} = $order->{unitprice_tax_excluded} * ( 1 + $order->{tax_rate} );
2882
        }
2891
        }
2883
        $order->{tax_value} = Koha::Number::Price->new(
2884
          ( $order->{unitprice_tax_included} - $order->{unitprice_tax_excluded} )
2885
          * $order->{quantityreceived} )->round;
2886
2892
2893
        # tax value = quantity * unit price tax excluded * tax rate
2894
        $order->{tax_value} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate};
2887
    }
2895
    }
2888
2896
2889
    return $order;
2897
    return $order;
(-)a/acqui/basket.pl (-3 / +3 lines)
Lines 315-323 elsif ( $op eq 'ediorder' ) { Link Here
315
            $template->param( uncertainprices => 1 );
315
            $template->param( uncertainprices => 1 );
316
        }
316
        }
317
317
318
        $line->{total_tax_excluded} = Koha::Number::Price->new( $line->{ecost_tax_excluded} * $line->{quantity} )->format;
319
        $line->{total_tax_included} = Koha::Number::Price->new( $line->{ecost_tax_included} * $line->{quantity} )->format;
320
321
        push @books_loop, $line;
318
        push @books_loop, $line;
322
319
323
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
320
        $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate};
Lines 423-428 sub get_order_infos { Link Here
423
    $line{basketno}       = $basketno;
420
    $line{basketno}       = $basketno;
424
    $line{budget_name}    = $budget->{budget_name};
421
    $line{budget_name}    = $budget->{budget_name};
425
422
423
    $line{total_tax_included} = $line{ecost_tax_included} * $line{quantity};
424
    $line{total_tax_excluded} = $line{ecost_tax_excluded} * $line{quantity};
425
426
    if ( $line{uncertainprice} ) {
426
    if ( $line{uncertainprice} ) {
427
        $line{rrp_tax_excluded} .= ' (Uncertain)';
427
        $line{rrp_tax_excluded} .= ' (Uncertain)';
428
    }
428
    }
(-)a/acqui/basketgroup.pl (-4 lines)
Lines 80-89 sub BasketTotal { Link Here
80
        } else {
80
        } else {
81
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
81
            $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} );
82
        }
82
        }
83
        if ($bookseller->{invoiceincgst} && ! $bookseller->{listincgst} && ( $bookseller->{tax_rate} // C4::Context->preference("gist") )) {
84
            my $gst = $bookseller->{tax_rate} // C4::Context->preference("gist");
85
            $total = $total * ( $gst / 100 +1);
86
        }
87
    }
83
    }
88
    $total .= " " . ($bookseller->{invoiceprice} // 0);
84
    $total .= " " . ($bookseller->{invoiceprice} // 0);
89
    return $total;
85
    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 143-149 foreach my $order (@$orders) { Link Here
143
143
144
push @foot_loop, map {$_} values %foot;
144
push @foot_loop, map {$_} values %foot;
145
145
146
my $format = "%.2f";
147
my $budgets = GetBudgets();
146
my $budgets = GetBudgets();
148
my @budgets_loop;
147
my @budgets_loop;
149
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
148
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
Lines 170-180 $template->param( Link Here
170
    orders_loop      => \@orders_loop,
169
    orders_loop      => \@orders_loop,
171
    foot_loop        => \@foot_loop,
170
    foot_loop        => \@foot_loop,
172
    total_quantity   => $total_quantity,
171
    total_quantity   => $total_quantity,
173
    total_tax_excluded       => sprintf( $format, $total_tax_excluded ),
172
    total_tax_excluded => $total_tax_excluded,
174
    total_tax_included       => sprintf( $format, $total_tax_included ),
173
    total_tax_included => $total_tax_included,
175
    total_tax_value   => sprintf( $format, $total_tax_value ),
174
    total_tax_value  => $total_tax_value,
176
    total_tax_excluded_shipment => sprintf( $format, $total_tax_excluded + $details->{shipmentcost}),
175
    total_tax_excluded_shipment => $total_tax_excluded + $details->{shipmentcost},
177
    total_tax_included_shipment => sprintf( $format, $total_tax_included + $details->{shipmentcost}),
176
    total_tax_included_shipment => $total_tax_included + $details->{shipmentcost},
178
    invoiceincgst    => $bookseller->{invoiceincgst},
177
    invoiceincgst    => $bookseller->{invoiceincgst},
179
    currency         => Koha::Acquisition::Currencies->get_active,
178
    currency         => Koha::Acquisition::Currencies->get_active,
180
    budgets_loop     => \@budgets_loop,
179
    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 328-340 Link Here
328
            </div>
328
            </div>
329
          [% END %][%# IF (AcqCreateItemReceiving) %]
329
          [% END %][%# IF (AcqCreateItemReceiving) %]
330
		</li>
330
		</li>
331
        <li><label for="rrp">Replacement cost: </label><input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /></li>
331
332
        <li><label for="ecost">Budgeted cost: </label><input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" /></li>
332
        <li><label for="rrp">Replacement cost: </label>[% rrp | $Price %]</li>
333
        <li><label for="ecost">Budgeted cost: </label>[% ecost | $Price %]</li>
333
        <li><label for="cost">Actual cost:</label>
334
        <li><label for="cost">Actual cost:</label>
334
        [% IF ( unitprice ) %]
335
        [% IF ( unitprice ) %]
335
         <input type="text" size="20" name="cost" id="cost" value="[% unitprice %]" />
336
             <input type="text" size="20" name="cost" id="cost" value="[% unitprice | $Price %]" />
336
        [% ELSE %]
337
        [% ELSE %]
337
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
338
             <input type="text" size="20" name="cost" id="cost" value="[% ecost | $Price %]" />
338
        [% END %]</li>
339
        [% END %]</li>
339
        <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote %]</textarea></li>
340
        <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote %]</textarea></li>
340
        [% IF order_vendornote %]
341
        [% IF order_vendornote %]
(-)a/t/Prices.t (-160 / +20 lines)
Lines 47-53 my $today; Link Here
47
for my $currency_format ( qw( US FR ) ) {
47
for my $currency_format ( qw( US FR ) ) {
48
    t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
48
    t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
49
    subtest 'Configuration 1: 0 0' => sub {
49
    subtest 'Configuration 1: 0 0' => sub {
50
        plan tests => 12;
50
        plan tests => 8;
51
        $bookseller_module->mock(
51
        $bookseller_module->mock(
52
            'fetch',
52
            'fetch',
53
            sub {
53
            sub {
Lines 79-85 for my $currency_format ( qw( US FR ) ) { Link Here
79
            }
79
            }
80
        );
80
        );
81
81
82
        # Note that this configuration is correct \o/
83
        compare(
82
        compare(
84
            {
83
            {
85
                got      => $order_0_0->{rrp_tax_included},
84
                got      => $order_0_0->{rrp_tax_included},
Lines 120-141 for my $currency_format ( qw( US FR ) ) { Link Here
120
                field    => 'tax_value'
119
                field    => 'tax_value'
121
            }
120
            }
122
        );
121
        );
123
        compare(
124
            {
125
                got      => $order_0_0->{total_tax_included},
126
                expected => 154.98,
127
                conf     => '0 0',
128
                field    => 'total_tax_included'
129
            }
130
        );
131
        compare(
132
            {
133
                got      => $order_0_0->{total_tax_excluded},
134
                expected => 147.60,
135
                conf     => '0 0',
136
                field    => 'total_tax_excluded'
137
            }
138
        );
139
122
140
        $order_0_0 = C4::Acquisition::populate_order_with_prices(
123
        $order_0_0 = C4::Acquisition::populate_order_with_prices(
141
            {
124
            {
Lines 145-151 for my $currency_format ( qw( US FR ) ) { Link Here
145
            }
128
            }
146
        );
129
        );
147
130
148
        # Note that this configuration is correct \o/
149
        compare(
131
        compare(
150
            {
132
            {
151
                got      => $order_0_0->{unitprice_tax_included},
133
                got      => $order_0_0->{unitprice_tax_included},
Lines 170-195 for my $currency_format ( qw( US FR ) ) { Link Here
170
                field    => 'tax_value'
152
                field    => 'tax_value'
171
            }
153
            }
172
        );
154
        );
173
        compare(
174
            {
175
                got      => $order_0_0->{total_tax_included},
176
                expected => 154.98,
177
                conf     => '0 0',
178
                field    => 'total_tax_included'
179
            }
180
        );
181
        compare(
182
            {
183
                got      => $order_0_0->{total_tax_excluded},
184
                expected => 147.60,
185
                conf     => '0 0',
186
                field    => 'total_tax_excluded'
187
            }
188
        );
189
    };
155
    };
190
156
191
    subtest 'Configuration 1: 1 1' => sub {
157
    subtest 'Configuration 1: 1 1' => sub {
192
        plan tests => 12;
158
        plan tests => 8;
193
        $bookseller_module->mock(
159
        $bookseller_module->mock(
194
            'fetch',
160
            'fetch',
195
            sub {
161
            sub {
Lines 221-228 for my $currency_format ( qw( US FR ) ) { Link Here
221
            }
187
            }
222
        );
188
        );
223
189
224
        # Note that this configuration is *not* correct
225
        # tax_value should be 7.03 instead of 7.02
226
        compare(
190
        compare(
227
            {
191
            {
228
                got      => $order_1_1->{rrp_tax_included},
192
                got      => $order_1_1->{rrp_tax_included},
Lines 258-284 for my $currency_format ( qw( US FR ) ) { Link Here
258
        compare(
222
        compare(
259
            {
223
            {
260
                got      => $order_1_1->{tax_value},
224
                got      => $order_1_1->{tax_value},
261
                expected => 7.02,
225
                expected => 7.03,
262
                conf     => '1 1',
226
                conf     => '1 1',
263
                field    => 'tax_value'
227
                field    => 'tax_value'
264
            }
228
            }
265
        );
229
        );
266
        compare(
267
            {
268
                got      => $order_1_1->{total_tax_included},
269
                expected => 147.60,
270
                conf     => '1 1',
271
                field    => 'total_tax_included'
272
            }
273
        );
274
        compare(
275
            {
276
                got      => $order_1_1->{total_tax_excluded},
277
                expected => 140.58,
278
                conf     => '1 1',
279
                field    => 'total_tax_excluded'
280
            }
281
        );
282
230
283
        $order_1_1 = C4::Acquisition::populate_order_with_prices(
231
        $order_1_1 = C4::Acquisition::populate_order_with_prices(
284
            {
232
            {
Lines 287-294 for my $currency_format ( qw( US FR ) ) { Link Here
287
                receiving    => 1,
235
                receiving    => 1,
288
            }
236
            }
289
        );
237
        );
290
        # Note that this configuration is *not* correct!
238
291
        # tax_value should be 7.03
292
        compare(
239
        compare(
293
            {
240
            {
294
                got      => $order_1_1->{unitprice_tax_included},
241
                got      => $order_1_1->{unitprice_tax_included},
Lines 308-338 for my $currency_format ( qw( US FR ) ) { Link Here
308
        compare(
255
        compare(
309
            {
256
            {
310
                got      => $order_1_1->{tax_value},
257
                got      => $order_1_1->{tax_value},
311
                expected => 7.02,
258
                expected => 7.03,
312
                conf     => '1 1',
259
                conf     => '1 1',
313
                field    => 'tax_value'
260
                field    => 'tax_value'
314
            }
261
            }
315
        );
262
        );
316
        compare(
317
            {
318
                got      => $order_1_1->{total_tax_included},
319
                expected => 147.60,
320
                conf     => '1 1',
321
                field    => 'total_tax_included'
322
            }
323
        );
324
        compare(
325
            {
326
                got      => $order_1_1->{total_tax_excluded},
327
                expected => 140.58,
328
                conf     => '1 1',
329
                field    => 'total_tax_excluded'
330
            }
331
        );
332
    };
263
    };
333
264
334
    subtest 'Configuration 1: 1 0' => sub {
265
    subtest 'Configuration 1: 1 0' => sub {
335
        plan tests => 12;
266
        plan tests => 8;
336
        $bookseller_module->mock(
267
        $bookseller_module->mock(
337
            'fetch',
268
            'fetch',
338
            sub {
269
            sub {
Lines 345-355 for my $currency_format ( qw( US FR ) ) { Link Here
345
            biblionumber     => $biblionumber_1_0,
276
            biblionumber     => $biblionumber_1_0,
346
            quantity         => 2,
277
            quantity         => 2,
347
            listprice        => 82.000000,
278
            listprice        => 82.000000,
348
            unitprice        => 73.804500,
279
            unitprice        => 70.290000,
349
            quantityreceived => 2,
280
            quantityreceived => 2,
350
            basketno         => $basketno_1_1,
281
            basketno         => $basketno_1_1,
351
            invoiceid        => $invoiceid_1_1,
282
            invoiceid        => $invoiceid_1_1,
352
            rrp              => 82.01,
283
            rrp              => 82.00,
353
            ecost            => 73.80,
284
            ecost            => 73.80,
354
            tax_rate         => 0.0500,
285
            tax_rate         => 0.0500,
355
            discount         => 10.0000,
286
            discount         => 10.0000,
Lines 364-377 for my $currency_format ( qw( US FR ) ) { Link Here
364
            }
295
            }
365
        );
296
        );
366
297
367
        # Note that this configuration is *not* correct!
368
        # rrp_tax_included should be 82 (what we inserted!)
369
        # tax_value should be 7.03 instead of 7.02
370
371
        compare(
298
        compare(
372
            {
299
            {
373
                got      => $order_1_0->{rrp_tax_included},
300
                got      => $order_1_0->{rrp_tax_included},
374
                expected => 82.01,
301
                expected => 82,
375
                conf     => '1 0',
302
                conf     => '1 0',
376
                field    => 'rrp_tax_included'
303
                field    => 'rrp_tax_included'
377
            }
304
            }
Lines 403-429 for my $currency_format ( qw( US FR ) ) { Link Here
403
        compare(
330
        compare(
404
            {
331
            {
405
                got      => $order_1_0->{tax_value},
332
                got      => $order_1_0->{tax_value},
406
                expected => 7.02,
333
                expected => 7.03,
407
                conf     => '1 0',
334
                conf     => '1 0',
408
                field    => 'tax_value'
335
                field    => 'tax_value'
409
            }
336
            }
410
        );
337
        );
411
        compare(
412
            {
413
                got      => $order_1_0->{total_tax_included},
414
                expected => 147.60,
415
                conf     => '1 0',
416
                field    => 'total_tax_included'
417
            }
418
        );
419
        compare(
420
            {
421
                got      => $order_1_0->{total_tax_excluded},
422
                expected => 140.58,
423
                conf     => '1 0',
424
                field    => 'total_tax_excluded'
425
            }
426
        );
427
338
428
        $order_1_0 = C4::Acquisition::populate_order_with_prices(
339
        $order_1_0 = C4::Acquisition::populate_order_with_prices(
429
            {
340
            {
Lines 432-439 for my $currency_format ( qw( US FR ) ) { Link Here
432
                receiving    => 1,
343
                receiving    => 1,
433
            }
344
            }
434
        );
345
        );
435
        # Note that this configuration is *not* correct!
346
436
        # gstvalue should be 7.03
437
        compare(
347
        compare(
438
            {
348
            {
439
                got      => $order_1_0->{unitprice_tax_included},
349
                got      => $order_1_0->{unitprice_tax_included},
Lines 453-483 for my $currency_format ( qw( US FR ) ) { Link Here
453
        compare(
363
        compare(
454
            {
364
            {
455
                got      => $order_1_0->{tax_value},
365
                got      => $order_1_0->{tax_value},
456
                expected => 7.02,
366
                expected => 7.03,
457
                conf     => '1 0',
367
                conf     => '1 0',
458
                field    => 'tax_value'
368
                field    => 'tax_value'
459
            }
369
            }
460
        );
370
        );
461
        compare(
462
            {
463
                got      => $order_1_0->{total_tax_included},
464
                expected => 147.60,
465
                conf     => '1 0',
466
                field    => 'total_tax_included'
467
            }
468
        );
469
        compare(
470
            {
471
                got      => $order_1_0->{total_tax_excluded},
472
                expected => 140.58,
473
                conf     => '1 0',
474
                field    => 'total_tax_excluded'
475
            }
476
        );
477
    };
371
    };
478
372
479
    subtest 'Configuration 1: 0 1' => sub {
373
    subtest 'Configuration 1: 0 1' => sub {
480
        plan tests => 12;
374
        plan tests => 8;
481
        $bookseller_module->mock(
375
        $bookseller_module->mock(
482
            'fetch',
376
            'fetch',
483
            sub {
377
            sub {
Lines 490-496 for my $currency_format ( qw( US FR ) ) { Link Here
490
            biblionumber     => $biblionumber_0_1,
384
            biblionumber     => $biblionumber_0_1,
491
            quantity         => 2,
385
            quantity         => 2,
492
            listprice        => 82.000000,
386
            listprice        => 82.000000,
493
            unitprice        => 73.800000,
387
            unitprice        => 77.490000,
494
            quantityreceived => 2,
388
            quantityreceived => 2,
495
            basketno         => $basketno_1_1,
389
            basketno         => $basketno_1_1,
496
            invoiceid        => $invoiceid_1_1,
390
            invoiceid        => $invoiceid_1_1,
Lines 509-520 for my $currency_format ( qw( US FR ) ) { Link Here
509
            }
403
            }
510
        );
404
        );
511
405
512
        # Note that this configuration is correct \o/
513
        compare(
406
        compare(
514
            {
407
            {
515
                got      => $order_0_1->{rrp_tax_included},
408
                got      => $order_0_1->{rrp_tax_included},
516
                expected => 86.10,
409
                expected => 86.10,
517
                conf     => '1 0',
410
                conf     => '0 1',
518
                field    => 'rrp_tax_included'
411
                field    => 'rrp_tax_included'
519
            }
412
            }
520
        );
413
        );
Lines 522-528 for my $currency_format ( qw( US FR ) ) { Link Here
522
            {
415
            {
523
                got      => $order_0_1->{rrp_tax_excluded},
416
                got      => $order_0_1->{rrp_tax_excluded},
524
                expected => 82.00,
417
                expected => 82.00,
525
                conf     => '1 0',
418
                conf     => '0 1',
526
                field    => 'rrp_tax_excluded'
419
                field    => 'rrp_tax_excluded'
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_included},
424
                got      => $order_0_1->{ecost_tax_included},
532
                expected => 77.49,
425
                expected => 77.49,
533
                conf     => '1 0',
426
                conf     => '0 1',
534
                field    => 'ecost_tax_included'
427
                field    => 'ecost_tax_included'
535
            }
428
            }
536
        );
429
        );
Lines 538-544 for my $currency_format ( qw( US FR ) ) { Link Here
538
            {
431
            {
539
                got      => $order_0_1->{ecost_tax_excluded},
432
                got      => $order_0_1->{ecost_tax_excluded},
540
                expected => 73.80,
433
                expected => 73.80,
541
                conf     => '1 0',
434
                conf     => '0 1',
542
                field    => 'ecost_tax_excluded'
435
                field    => 'ecost_tax_excluded'
543
            }
436
            }
544
        );
437
        );
Lines 546-571 for my $currency_format ( qw( US FR ) ) { Link Here
546
            {
439
            {
547
                got      => $order_0_1->{tax_value},
440
                got      => $order_0_1->{tax_value},
548
                expected => 7.38,
441
                expected => 7.38,
549
                conf     => '1 0',
442
                conf     => '0 1',
550
                field    => 'tax_value'
443
                field    => 'tax_value'
551
            }
444
            }
552
        );
445
        );
553
        compare(
554
            {
555
                got      => $order_0_1->{total_tax_included},
556
                expected => 154.98,
557
                conf     => '1 0',
558
                field    => 'total_tax_included'
559
            }
560
        );
561
        compare(
562
            {
563
                got      => $order_0_1->{total_tax_excluded},
564
                expected => 147.60,
565
                conf     => '1 0',
566
                field    => 'total_tax_excluded'
567
            }
568
        );
569
446
570
        $order_0_1 = C4::Acquisition::populate_order_with_prices(
447
        $order_0_1 = C4::Acquisition::populate_order_with_prices(
571
            {
448
            {
Lines 574-580 for my $currency_format ( qw( US FR ) ) { Link Here
574
                receiving    => 1,
451
                receiving    => 1,
575
            }
452
            }
576
        );
453
        );
577
        # Note that this configuration is correct
454
578
        compare(
455
        compare(
579
            {
456
            {
580
                got      => $order_0_1->{unitprice_tax_included},
457
                got      => $order_0_1->{unitprice_tax_included},
Lines 599-620 for my $currency_format ( qw( US FR ) ) { Link Here
599
                field    => 'tax_value'
476
                field    => 'tax_value'
600
            }
477
            }
601
        );
478
        );
602
        compare(
603
            {
604
                got      => $order_0_1->{total_tax_included},
605
                expected => 154.98,
606
                conf     => '0 1',
607
                field    => 'total_tax_included'
608
            }
609
        );
610
        compare(
611
            {
612
                got      => $order_0_1->{total_tax_excluded},
613
                expected => 147.60,
614
                conf     => '0 1',
615
                field    => 'total_tax_excluded'
616
            }
617
        );
618
    };
479
    };
619
}
480
}
620
481
621
- 

Return to bug 13321