Bugzilla – Attachment 31954 Details for
Bug 12970
Refactor VAT and price calculation - basket page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12970: Use the centralize VAT and prices calculation - basket.pl
0015-Bug-12970-Use-the-centralize-VAT-and-prices-calculat.patch (text/plain), 9.15 KB, created by
Paola Rossi
on 2014-09-30 15:58:22 UTC
(
hide
)
Description:
Bug 12970: Use the centralize VAT and prices calculation - basket.pl
Filename:
MIME Type:
Creator:
Paola Rossi
Created:
2014-09-30 15:58:22 UTC
Size:
9.15 KB
patch
obsolete
>From ead581171a4a9b66e49a70795e4fd9c6a0b2238e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 19 Sep 2014 17:09:34 +0200 >Subject: [PATCH 15/17] Bug 12970: Use the centralize VAT and prices > calculation - basket.pl > >Bug 12969 introduces a subroutine to centralize VAT and prices >calculation. >It should be use in the acqui/basket.pl script. > >Test plan: >0/ Don't apply the patch >1/ Create 4 suppliers with the different configurations >2/ Create a basket and create several orders >3/ Go on the basket page >4/ Apply the patch >5/ Verify you don't see any difference before and after applying the >patch > >Signed-off-by: Paola Rossi <paola.rossi@cineca.it> >--- > acqui/basket.pl | 34 ++++---------------- > .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 21 ++++++------ > 2 files changed, 17 insertions(+), 38 deletions(-) > >diff --git a/acqui/basket.pl b/acqui/basket.pl >index e04024a..18c8d8b 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -334,7 +334,7 @@ if ( $op eq 'delete_confirm' ) { > my $cur = GetCurrency(); > > >- my @results = GetOrders( $basketno ); >+ my @orders = GetOrders( $basketno ); > my @books_loop; > > my @book_foot_loop; >@@ -343,7 +343,8 @@ if ( $op eq 'delete_confirm' ) { > my $total_gste = 0; > my $total_gsti = 0; > my $total_gstvalue = 0; >- for my $order (@results) { >+ for my $order (@orders) { >+ $order = C4::Acquisition::populate_order_with_prices({ order => $order, booksellerid => $booksellerid, ordering => 1 }); > my $line = get_order_infos( $order, $bookseller); > if ( $line->{uncertainprice} ) { > $template->param( uncertainprices => 1 ); >@@ -351,7 +352,7 @@ if ( $op eq 'delete_confirm' ) { > > push @books_loop, $line; > >- $foot{$$line{gstgsti}}{gstgsti} = $$line{gstgsti}; >+ $foot{$$line{gstgsti}}{gstrate} = $$line{gstrate}; > $foot{$$line{gstgsti}}{gstvalue} += $$line{gstvalue}; > $total_gstvalue += $$line{gstvalue}; > $foot{$$line{gstgsti}}{quantity} += $$line{quantity}; >@@ -365,9 +366,9 @@ if ( $op eq 'delete_confirm' ) { > push @book_foot_loop, map {$_} values %foot; > > # Get cancelled orders >- @results = GetCancelledOrders($basketno); >+ my @cancelledorders = GetCancelledOrders($basketno); > my @cancelledorders_loop; >- for my $order (@results) { >+ for my $order (@cancelledorders) { > my $line = get_order_infos( $order, $bookseller); > push @cancelledorders_loop, $line; > } >@@ -375,7 +376,6 @@ if ( $op eq 'delete_confirm' ) { > my $contract = GetContract({ > contractnumber => $basket->{contractnumber} > }); >- my @orders = GetOrders($basketno); > > if ($basket->{basketgroupid}){ > $basketgroup = GetBasketgroup($basket->{basketgroupid}); >@@ -446,28 +446,6 @@ sub get_order_infos { > $line{order_received} = ( $qty == $order->{'quantityreceived'} ); > $line{basketno} = $basketno; > $line{budget_name} = $budget->{budget_name}; >- $line{rrp} = ConvertCurrency( $order->{'currency'}, $line{rrp} ); # FIXME from comm >- if ( $bookseller->{'listincgst'} ) { >- $line{rrpgsti} = sprintf( "%.2f", $line{rrp} ); >- $line{gstgsti} = sprintf( "%.2f", $line{gstrate} * 100 ); >- $line{rrpgste} = sprintf( "%.2f", $line{rrp} / ( 1 + ( $line{gstgsti} / 100 ) ) ); >- $line{gstgste} = sprintf( "%.2f", $line{gstgsti} / ( 1 + ( $line{gstgsti} / 100 ) ) ); >- $line{ecostgsti} = sprintf( "%.2f", $line{ecost} ); >- $line{ecostgste} = sprintf( "%.2f", $line{ecost} / ( 1 + ( $line{gstgsti} / 100 ) ) ); >- $line{gstvalue} = sprintf( "%.2f", ( $line{ecostgsti} - $line{ecostgste} ) * $line{quantity}); >- $line{totalgste} = sprintf( "%.2f", $order->{quantity} * $line{ecostgste} ); >- $line{totalgsti} = sprintf( "%.2f", $order->{quantity} * $line{ecostgsti} ); >- } else { >- $line{rrpgsti} = sprintf( "%.2f", $line{rrp} * ( 1 + ( $line{gstrate} ) ) ); >- $line{rrpgste} = sprintf( "%.2f", $line{rrp} ); >- $line{gstgsti} = sprintf( "%.2f", $line{gstrate} * 100 ); >- $line{gstgste} = sprintf( "%.2f", $line{gstrate} * 100 ); >- $line{ecostgsti} = sprintf( "%.2f", $line{ecost} * ( 1 + ( $line{gstrate} ) ) ); >- $line{ecostgste} = sprintf( "%.2f", $line{ecost} ); >- $line{gstvalue} = sprintf( "%.2f", ( $line{ecostgsti} - $line{ecostgste} ) * $line{quantity}); >- $line{totalgste} = sprintf( "%.2f", $order->{quantity} * $line{ecostgste} ); >- $line{totalgsti} = sprintf( "%.2f", $order->{quantity} * $line{ecostgsti} ); >- } > > if ( $line{uncertainprice} ) { > $line{rrpgste} .= ' (Uncertain)'; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index 37ac2d2..161648f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -1,4 +1,5 @@ > [% USE KohaDates %] >+[% USE Price %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Acquisitions › [% UNLESS ( basketno ) %]New [% END %][% IF ( delete_confirm ) %]Delete [% END %]Basket [% basketname|html %] ([% basketno %]) for [% name|html %]</title> > <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >@@ -429,7 +430,7 @@ > [% FOREACH foot_loo IN book_foot_loop %] > <tr> > <th></th> >- <th>Total (GST [% foot_loo.gstgsti %])</th> >+ <th>Total (GST [% foot_loo.gstrate * 100 | $Price %])</th> > <th class="gste"> </th> > <th class="gste"> </th> > <th class="gsti"> </th> >@@ -516,15 +517,15 @@ > </td> > [% SET zero_regex = "^0{1,}\.?0{1,}[^1-9]" %] [%# 0 or 0.0 or 0.00 or 00 or 00.0 or 00.00 or 0.000 ... %] > [%# FIXME: use of a regexp is not ideal; bugs 9410 and 10929 suggest better way of handling this %] >- <td class="number gste [% IF books_loo.rrpgste.search(zero_regex) %]error[% END %]">[% books_loo.rrpgste %]</td> >- <td class="number gste [% IF books_loo.ecostgste.search(zero_regex) %]error[% END %]">[% books_loo.ecostgste %]</td> >- <td class="number gsti [% IF books_loo.rrpgsti.search(zero_regex) %]error[% END %]">[% books_loo.rrpgsti %]</td> >- <td class="number gsti [% IF books_loo.ecostgsti.search(zero_regex) %]error[% END %]">[% books_loo.ecostgsti %]</td> >+ <td class="number gste [% IF books_loo.rrpgste.search(zero_regex) %]error[% END %]">[% books_loo.rrpgste | $Price %]</td> >+ <td class="number gste [% IF books_loo.ecostgste.search(zero_regex) %]error[% END %]">[% books_loo.ecostgste | $Price%]</td> >+ <td class="number gsti [% IF books_loo.rrpgsti.search(zero_regex) %]error[% END %]">[% books_loo.rrpgsti | $Price %]</td> >+ <td class="number gsti [% IF books_loo.ecostgsti.search(zero_regex) %]error[% END %]">[% books_loo.ecostgsti | $Price %]</td> > <td class="number [% IF books_loo.quantity.search(zero_regex) %]error[% END %]">[% books_loo.quantity %]</td> >- <td class="number gste [% IF books_loo.totalgste.search(zero_regex) %]error[% END %]">[% books_loo.totalgste %]</td> >- <td class="number gsti [% IF books_loo.totalgsti.search(zero_regex) %]error[% END %]">[% books_loo.totalgsti %]</td> >- <td class="number [% IF books_loo.gstgsti.search(zero_regex) %]error[% END %]">[% books_loo.gstgsti %]</td> >- <td class="number [% IF books_loo.gstvalue.search(zero_regex) %]error[% END %]">[% books_loo.gstvalue %]</td> >+ <td class="number gste [% IF books_loo.totalgste.search(zero_regex) %]error[% END %]">[% books_loo.totalgste | $Price %]</td> >+ <td class="number gsti [% IF books_loo.totalgsti.search(zero_regex) %]error[% END %]">[% books_loo.totalgsti | $Price %]</td> >+ <td class="number">[% books_loo.gstrate * 100 | $Price %]</td> >+ <td class="number [% IF books_loo.gstvalue.search(zero_regex) %]error[% END %]">[% books_loo.gstvalue | $Price %]</td> > <td>[% books_loo.budget_name %]</td> > [% IF ( active ) %] > [% UNLESS ( closedate ) %] >@@ -630,7 +631,7 @@ > <td class="number">[% order.quantity %]</td> > <td class="number gste">[% order.totalgste %]</td> > <td class="number gsti">[% order.totalgsti %]</td> >- <td class="number">[% order.gstgsti %]</td> >+ <td class="number">[% order.gstrate * 100 %]</td> > <td class="number">[% order.gstvalue %]</td> > <td>[% order.budget_name %] > </tr> >-- >1.7.10.4 >
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 12970
:
31747
|
31881
|
31882
|
31954
|
31955
|
31956
|
33572
|
34964
|
34965
|
34966
|
34967