Bugzilla – Attachment 161800 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), 6.24 KB, created by
Thibaud Guillot (thibaud_g)
on 2024-02-07 13:20:53 UTC
(
hide
)
Description:
Bug 35114: Fix calculation around basketgroup and basket details
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2024-02-07 13:20:53 UTC
Size:
6.24 KB
patch
obsolete
>From bee21069b134c660387af688a6d30381dbde5066 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 >--- > acqui/basket.pl | 32 +++++++++++++++----------- > acqui/basketgroup.pl | 8 +++---- > koha-tmpl/intranet-tmpl/prog/js/acq.js | 2 +- > 3 files changed, 24 insertions(+), 18 deletions(-) > >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 80c633cf56..65bc943307 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -341,16 +341,22 @@ 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}; >- $foot{$$line{tax_rate}}{total_tax_included} += $$line{total_tax_included}; >- $total_tax_included += $$line{total_tax_included}; >+ $foot{$$line{tax_rate}}{total_tax_excluded} += $$line{sum_total_tax_excluded}; >+ $total_tax_excluded += $$line{sum_total_tax_excluded}; >+ $foot{$$line{tax_rate}}{total_tax_included} += $$line{sum_total_tax_included}; >+ $total_tax_included += $$line{sum_total_tax_included}; > } > >+ foreach my $tax_rate (keys %foot) { >+ $foot{$tax_rate}{total_tax_excluded} = get_rounded_price($foot{$tax_rate}{total_tax_excluded}); >+ $foot{$tax_rate}{total_tax_included} = get_rounded_price($foot{$tax_rate}{total_tax_included}); >+ } >+ >+ > push @book_foot_loop, map {$_} values %foot; > > # Get cancelled orders >@@ -408,9 +414,9 @@ if ( $op eq 'list' ) { > book_foot_loop => \@book_foot_loop, > cancelledorders_loop => \@cancelledorders_loop, > total_quantity => $total_quantity, >- total_tax_excluded => $total_tax_excluded, >- total_tax_included => $total_tax_included, >- total_tax_value => $total_tax_value, >+ total_tax_excluded => get_rounded_price($total_tax_excluded), >+ total_tax_included => get_rounded_price($total_tax_included), >+ total_tax_value => get_rounded_price($total_tax_value), > currency => $active_currency->currency, > listincgst => $bookseller->listincgst, > basketgroups => $basketgroups, >@@ -454,10 +460,10 @@ 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{sum_total_tax_included} = $line{ecost_tax_included} * $line{quantity}; >+ $line{sum_total_tax_excluded} = $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 38f7b6b44c..1f83708002 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 89e1ad1fc4..83e70b7361 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.30.2
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