Bugzilla – Attachment 172124 Details for
Bug 35114
Calculation around basket details and basketgroup not correct
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35114: Fix calculation around basketgroup and basket details
Bug-35114-Fix-calculation-around-basketgroup-and-b.patch (text/plain), 4.97 KB, created by
Sonia Bouis
on 2024-09-27 15:19:45 UTC
(
hide
)
Description:
Bug 35114: Fix calculation around basketgroup and basket details
Filename:
MIME Type:
Creator:
Sonia Bouis
Created:
2024-09-27 15:19:45 UTC
Size:
4.97 KB
patch
obsolete
>From b02da41ad6bc1fb8c4b1520c92e8d53e93a5d85f Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Tue, 16 Jan 2024 16:02:11 +0100 >Subject: [PATCH] Bug 35114: Fix calculation around basketgroup and basket > details > >Test plan: > >1) I purpose a simple way to test it with new fresh data. First of all >go to one of your vendor and set a discount of 9%. Then create a new >basket, add to basket a new line from an empty record. >Set a vendor price to 15.90 and just add this order > >2) Configure the basket.pl table to show all columns, see budgeted cost >and actual cost (exc or inc). There is already a difference of one cent. > >3) Let's take a look at the basket groups now, for this, close this >basket. Go on tab menu and select basket group. Click on new basket >group. Normally you will see the new basket created on step 1. The total >here is 14.47.. and when you check on basket detail it's 14.46 cause >this total (from basket groups) comes from ecost exc. while total line >on basket detail comes from actual cost exc. > >4) Apply this patch and see changes > >Sponsored-by: BibLibre >Signed-off-by: Sonia Bouis <sonia.bouis@univ-lyon3.fr> >--- > acqui/basket.pl | 14 ++++++-------- > acqui/basketgroup.pl | 8 ++++---- > koha-tmpl/intranet-tmpl/prog/js/acq.js | 2 +- > 3 files changed, 11 insertions(+), 13 deletions(-) > >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 1a6ef3ca47..1d30cbbdea 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -357,14 +357,14 @@ if ( $op eq 'list' ) { > push @books_loop, $line; > > $foot{$$line{tax_rate}}{tax_rate} = $$line{tax_rate}; >- $foot{$$line{tax_rate}}{tax_value} += get_rounded_price($$line{tax_value}); >+ $foot{$$line{tax_rate}}{tax_value} += $$line{tax_value}; > $total_tax_value += $$line{tax_value}; >- $foot{$$line{tax_rate}}{quantity} += get_rounded_price($$line{quantity}); >+ $foot{$$line{tax_rate}}{quantity} += $$line{quantity}; > $total_quantity += $$line{quantity}; > $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{total_tax_excluded}; >- $total_tax_excluded += $$line{total_tax_excluded}; >+ $total_tax_excluded += get_rounded_price($$line{total_tax_excluded}); > $foot{$$line{tax_rate}}{total_tax_included} += $$line{total_tax_included}; >- $total_tax_included += $$line{total_tax_included}; >+ $total_tax_included += get_rounded_price($$line{total_tax_included}); > } > > push @book_foot_loop, map {$_} values %foot; >@@ -471,10 +471,8 @@ sub get_order_infos { > # If we have an actual cost that should be the total, otherwise use the ecost > $line{unitprice_tax_included} += 0; > $line{unitprice_tax_excluded} += 0; >- my $cost_tax_included = $line{unitprice_tax_included} || $line{ecost_tax_included}; >- my $cost_tax_excluded = $line{unitprice_tax_excluded} || $line{ecost_tax_excluded}; >- $line{total_tax_included} = get_rounded_price($cost_tax_included) * $line{quantity}; >- $line{total_tax_excluded} = get_rounded_price($cost_tax_excluded) * $line{quantity}; >+ $line{total_tax_included} = get_rounded_price($line{ecost_tax_included} * $line{quantity}); >+ $line{total_tax_excluded} = get_rounded_price($line{ecost_tax_excluded} * $line{quantity}); > $line{tax_value} = $line{tax_value_on_ordering}; > $line{tax_rate} = $line{tax_rate_on_ordering}; > >diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl >index e785bfd545..842a597428 100755 >--- a/acqui/basketgroup.pl >+++ b/acqui/basketgroup.pl >@@ -75,14 +75,14 @@ sub BasketTotal { > my $total = 0; > my @orders = GetOrders($basketno); > for my $order (@orders){ >- # FIXME The following is wrong >+ # FIXME The following is wrong <- still true ? remove if patch 35114 fixed it > if ( $bookseller->listincgst ) { >- $total = $total + ( get_rounded_price($order->{ecost_tax_included}) * $order->{quantity} ); >+ $total = $total + ( $order->{ecost_tax_included} * $order->{quantity} ); > } else { >- $total = $total + ( get_rounded_price($order->{ecost_tax_excluded}) * $order->{quantity} ); >+ $total = $total + ( $order->{ecost_tax_excluded} * $order->{quantity} ); > } > } >- return $total; >+ return get_rounded_price($total); > } > > #displays all basketgroups and all closed baskets (in their respective groups) >diff --git a/koha-tmpl/intranet-tmpl/prog/js/acq.js b/koha-tmpl/intranet-tmpl/prog/js/acq.js >index 059cd4cea2..c2e0fea6c9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/acq.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/acq.js >@@ -190,7 +190,7 @@ function updateCosts(){ > var rep = new Number(listprice*exchangerate); > var ecost = rrp; > if ( 100-discount != 100 ) { //Prevent rounding issues if no discount >- ecost = new Number(Math.floor(rrp * (100 - discount )) / 100); >+ ecost = new Number(Math.round(rrp * (100 - discount )) / 100); > } > var total = new Number( ecost * quantity); > $("#rrp").val(rrp.toFixed(2)); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35114
:
157495
|
161066
|
161691
|
161799
|
161800
|
162060
| 172124