Bugzilla – Attachment 25889 Details for
Bug 10613
Gst is not calculated correctly on the invoice page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 10613: The gst rate is not correctly calculated on the invoice page.
SIGNED-OFF-Bug-10613-The-gst-rate-is-not-correctly.patch (text/plain), 14.32 KB, created by
Jacek Ablewicz
on 2014-03-06 10:08:37 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 10613: The gst rate is not correctly calculated on the invoice page.
Filename:
MIME Type:
Creator:
Jacek Ablewicz
Created:
2014-03-06 10:08:37 UTC
Size:
14.32 KB
patch
obsolete
>From d2e035968cfa4aa25151b176f0cb2ba0109acb37 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 19 Jul 2013 11:44:51 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 10613: The gst rate is not correctly > calculated on the invoice page. > >Test plan: >Defined a gst rate on creating an order, receive it and check that all >prices are correctly calculated. >/!\ Behavior change function of supplier parameters (Include/Don't >include tax for list prices and invoice prices) > >Notes: patch tested with Bug 11755 applied first; confirmed that: >- price calculations are correct for all combinations of > listincgst/invoiceincgst settings in the vendor record >- unitprice (aka "Actual cost") is taken into account on the > invoice page instead of rrp/ecost, like it should. > >Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl> >--- > acqui/invoice.pl | 137 ++++++++------------ > .../intranet-tmpl/prog/en/modules/acqui/invoice.tt | 98 +++++++++----- > 2 files changed, 121 insertions(+), 114 deletions(-) > >diff --git a/acqui/invoice.pl b/acqui/invoice.pl >index 5971ed1..b2bda01 100755 >--- a/acqui/invoice.pl >+++ b/acqui/invoice.pl >@@ -98,86 +98,39 @@ elsif ( $op && $op eq 'delete' ) { > } > } > >-my $details = GetInvoiceDetails($invoiceid); >-my $bookseller = GetBookSellerFromId( $details->{booksellerid} ); >+ >+my $details = GetInvoiceDetails($invoiceid); >+my ($bookseller) = GetBookSellerFromId($details->{supplierid}); > my @orders_loop = (); >-my $orders = $details->{'orders'}; >+my $orders = $details->{'orders'}; > my $qty_total; >-my @books_loop; >-my @book_foot_loop; >+my @foot_loop; > my %foot; > my $total_quantity = 0; >-my $total_rrp = 0; >-my $total_est = 0; >- >+my $total_gste = 0; >+my $total_gsti = 0; >+my $total_gstvalue = 0; > foreach my $order (@$orders) { >- my $line = get_infos( $order, $bookseller ); >+ my $line = get_infos( $order, $bookseller); > >+ $foot{$$line{gstgsti}}{gstgsti} = $$line{gstgsti}; >+ $foot{$$line{gstgsti}}{gstvalue} += $$line{gstvalue}; >+ $total_gstvalue += $$line{gstvalue}; >+ $foot{$$line{gstgsti}}{quantity} += $$line{quantity}; > $total_quantity += $$line{quantity}; >- $total_rrp += $order->{quantity} * $order->{rrp}; >- $total_est += $order->{quantity} * $order->{'ecost'}; >+ $foot{$$line{gstgsti}}{totalgste} += $$line{totalgste}; >+ $total_gste += $$line{totalgste}; >+ $foot{$$line{gstgsti}}{totalgsti} += $$line{totalgsti}; >+ $total_gsti += $$line{totalgsti}; > >- my %row = ( %$order, %$line ); >+ my %row = %{ $order, $line }; >+ $row{'orderline'} = $row{'parent_ordernumber'}; > push @orders_loop, \%row; > } > >-my $gist = $bookseller->{gstrate} // C4::Context->preference("gist") // 0; >-my $discount = >- $bookseller->{'discount'} ? ( $bookseller->{discount} / 100 ) : 0; >-my $total_est_gste; >-my $total_est_gsti; >-my $total_rrp_gsti; # RRP Total, GST included >-my $total_rrp_gste; # RRP Total, GST excluded >-my $gist_est; >-my $gist_rrp; >-if ($gist) { >- >- # if we have GST >- if ( $bookseller->{'listincgst'} ) { >- >- # if prices already includes GST >- >- # we know $total_rrp_gsti >- $total_rrp_gsti = $total_rrp; >- >- # and can reverse compute other values >- $total_rrp_gste = $total_rrp_gsti / ( $gist + 1 ); >- >- $gist_rrp = $total_rrp_gsti - $total_rrp_gste; >- $total_est_gste = $total_rrp_gste - ( $total_rrp_gste * $discount ); >- $total_est_gsti = $total_est; >- } >- else { >- # if prices does not include GST >- >- # then we use the common way to compute other values >- $total_rrp_gste = $total_rrp; >- $gist_rrp = $total_rrp_gste * $gist; >- $total_rrp_gsti = $total_rrp_gste + $gist_rrp; >- $total_est_gste = $total_est; >- $total_est_gsti = $total_rrp_gsti - ( $total_rrp_gsti * $discount ); >- } >- $gist_est = $gist_rrp - ( $gist_rrp * $discount ); >-} >-else { >- $total_rrp_gste = $total_rrp_gsti = $total_rrp; >- $total_est_gste = $total_est_gsti = $total_est; >- $gist_rrp = $gist_est = 0; >-} >-my $total_gsti_shipment = $total_est_gsti + $details->{shipmentcost}; >+push @foot_loop, map {$_} values %foot; > > my $format = "%.2f"; >-$template->param( >- total_rrp_gste => sprintf( $format, $total_rrp_gste ), >- total_rrp_gsti => sprintf( $format, $total_rrp_gsti ), >- total_est_gste => sprintf( $format, $total_est_gste ), >- total_est_gsti => sprintf( $format, $total_est_gsti ), >- gist_rrp => sprintf( $format, $gist_rrp ), >- gist_est => sprintf( $format, $gist_est ), >- total_gsti_shipment => sprintf( $format, $total_gsti_shipment ), >- gist => sprintf( $format, $gist * 100 ), >-); >- > my $budgets = GetBudgets(); > my @budgets_loop; > my $shipmentcost_budgetid = $details->{shipmentcost_budgetid}; >@@ -196,34 +149,59 @@ $template->param( > invoiceid => $details->{'invoiceid'}, > invoicenumber => $details->{'invoicenumber'}, > suppliername => $details->{'suppliername'}, >- booksellerid => $details->{'booksellerid'}, >+ supplierid => $details->{'supplierid'}, > datereceived => $details->{'datereceived'}, >- shipmentdate => $details->{'shipmentdate'}, >- billingdate => $details->{'billingdate'}, >- invoiceclosedate => $details->{'closedate'}, >- shipmentcost => sprintf( $format, $details->{'shipmentcost'} || 0 ), >+ billingdate => C4::Dates->new($details->{'billingdate'}, "iso")->output(), >+ invoiceclosedate => $details->{'invoiceclosedate'}, >+ shipmentcost => $details->{'shipmentcost'}, > orders_loop => \@orders_loop, >+ foot_loop => \@foot_loop, > total_quantity => $total_quantity, >+ total_gste => sprintf( $format, $total_gste ), >+ total_gsti => sprintf( $format, $total_gsti ), >+ total_gstvalue => sprintf( $format, $total_gstvalue ), >+ total_gste_shipment => sprintf( $format, $total_gste + $details->{shipmentcost}), >+ total_gsti_shipment => sprintf( $format, $total_gsti + $details->{shipmentcost}), > invoiceincgst => $bookseller->{invoiceincgst}, >- currency => $bookseller->{listprice}, >- budgets_loop => \@budgets_loop, >+ currency => GetCurrency()->{currency}, >+ budgets_loop => \@budgets_loop, > ); > >+# FIXME >+# Fonction dupplicated from basket.pl >+# Code must to be exported. Where ?? > sub get_infos { >- my $order = shift; >+ my $order = shift; > my $bookseller = shift; >- my $qty = $order->{'quantity'} || 0; >+ my $qty = $order->{'quantity'} || 0; > if ( !defined $order->{quantityreceived} ) { > $order->{quantityreceived} = 0; > } > my $budget = GetBudget( $order->{'budget_id'} ); > >- my %line = %{$order}; >+ my %line = %{ $order }; > $line{order_received} = ( $qty == $order->{'quantityreceived'} ); > $line{budget_name} = $budget->{budget_name}; >- $line{total} = $qty * $order->{ecost}; >+ if ( $bookseller->{'listincgst'} ) { >+ $line{gstgsti} = sprintf( "%.2f", $line{gstrate} * 100 ); >+ $line{gstgste} = sprintf( "%.2f", $line{gstgsti} / ( 1 + ( $line{gstgsti} / 100 ) ) ); >+ $line{actualcostgsti} = sprintf( "%.2f", $line{unitprice} ); >+ $line{actualcostgste} = sprintf( "%.2f", $line{unitprice} / ( 1 + ( $line{gstgsti} / 100 ) ) ); >+ $line{gstvalue} = sprintf( "%.2f", ( $line{actualcostgsti} - $line{actualcostgste} ) * $line{quantity}); >+ $line{totalgste} = sprintf( "%.2f", $order->{quantity} * $line{actualcostgste} ); >+ $line{totalgsti} = sprintf( "%.2f", $order->{quantity} * $line{actualcostgsti} ); >+ } else { >+ $line{gstgsti} = sprintf( "%.2f", $line{gstrate} * 100 ); >+ $line{gstgste} = sprintf( "%.2f", $line{gstrate} * 100 ); >+ $line{actualcostgsti} = sprintf( "%.2f", $line{unitprice} * ( 1 + ( $line{gstrate} ) ) ); >+ $line{actualcostgste} = sprintf( "%.2f", $line{unitprice} ); >+ $line{gstvalue} = sprintf( "%.2f", ( $line{actualcostgsti} - $line{actualcostgste} ) * $line{quantity}); >+ $line{totalgste} = sprintf( "%.2f", $order->{quantity} * $line{actualcostgste} ); >+ $line{totalgsti} = sprintf( "%.2f", $order->{quantity} * $line{actualcostgsti} ); >+ } > > if ( $line{uncertainprice} ) { >+ $template->param( uncertainprices => 1 ); > $line{rrp} .= ' (Uncertain)'; > } > if ( $line{'title'} ) { >@@ -231,8 +209,7 @@ sub get_infos { > my $seriestitle = $order->{'seriestitle'}; > $line{'title'} .= " / $seriestitle" if $seriestitle; > $line{'title'} .= " / $volume" if $volume; >- } >- else { >+ } else { > $line{'title'} = "Deleted bibliographic notice, can't find title."; > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt >index 266aa65..35bc2da 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt >@@ -8,6 +8,18 @@ > [% INCLUDE 'datatables.inc' %] > <script type="text/javascript"> > //<![CDATA[ >+ function updateColumnsVisibility(visible) { >+ if ( visible ) { >+ $("table .gste, .gsti").show(); >+ } else { >+ [% IF ( invoiceincgst ) %] >+ $("table .gste").hide(); >+ [% ELSE %] >+ $("table .gsti").hide(); >+ [% END %] >+ } >+ } >+ > $(document).ready(function() { > $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, { > bInfo: false, >@@ -15,6 +27,13 @@ > bFilter: false, > sDom: "t" > })); >+ >+ $("#show_all_details").click(function(){ >+ updateColumnsVisibility($(this+":checked").val()); >+ }); >+ >+ $("#show_all_details").attr('checked', false); >+ updateColumnsVisibility(false); > }); > //]]> > </script> >@@ -92,16 +111,23 @@ > </p> > <h2>Invoice details</h2> > [% IF orders_loop.size %] >+ <label for="show_all_details"> >+ <input type="checkbox" style="vertical-align: middle;" id="show_all_details" /> >+ Show all details >+ </label> > <table id="orderst"> > <thead> > <tr> > <th>Summary</th> > <th>Publisher</th> > <th>Library</th> >- <th>RRP</th> >- <th>Est.</th> >+ <th class="gste">Actual cost tax exc.</th> >+ <th class="gsti">Actual cost tax inc.</th> > <th>Qty.</th> >- <th>Total</th> >+ <th class="gste">Total tax exc. ([% currency %])</th> >+ <th class="gsti">Total tax inc. ([% currency %])</th> >+ <th>GST %</th> >+ <th>GST</th> > <th>Fund</th> > </tr> > </thead> >@@ -123,47 +149,51 @@ > [% END %] > </td> > <td><p>[% order.branchcode %]</p></td> >- <td>[% order.rrp %]</td> >- <td>[% order.ecost %]</td> >+ <td class="number gste">[% order.actualcostgste %]</td> >+ <td class="number gsti">[% order.actualcostgsti %]</td> > <td class="number">[% order.quantity %]</td> >- <td>[% order.total %]</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.gstvalue %]</td> > <td>[% order.budget_name %]</td> > </tr> > [% END %] > </tbody> > <tfoot> >+ [% FOR tf IN foot_loop %] > <tr> >- <th colspan="3">Total tax exc.</th> >- <th>[% total_rrp_gste %]</th> >- <th> </th> >- <th>[% total_quantity %]</th> >- <th>[% total_est_gste %]</th> >- <th> </th> >- </tr> >- <tr> >- <th colspan='3'>Tax ([% gist %]%)</th> >- <th>[% gist_rrp %]</th> >- <th> </th> >- <th> </th> >- <th>[% gist_est %]</th> >- <th> </th> >- </tr> >- <tr> >- <th colspan='3'>Total tax inc. ([% currency %])</th> >- <th>[% total_rrp_gsti %]</th> >- <th> </th> >- <th>[% total_quantity %]</th> >- <th>[% total_est_gsti %]</th> >- <th> </th> >- </tr> >- <tr> >- <th colspan="3">Total + shipment cost ([% currency %])</th> >+ <th colspan='3'>Total (GST [% tf.gstgsti %] %)</th> >+ <th class="gste"/><th class="gsti"/> >+ <th>[% tf.quantity %]</th> >+ <th class="gste">[% tf.totalgste %]</th> >+ <th class="gsti">[% tf.totalgsti %]</th> > <th> </th> >- <th> </th> >- <th>[% total_quantity %]</th> >- <th>[% total_gsti_shipment %]</th> >+ <th>[% tf.gstvalue %]</th> > <th> </th> > </tr> >+ [% END %] >+ <tr> >+ <th colspan='3'>Total ([% currency %])</th> >+ <th class="gste"/><th class="gsti"/> >+ <th>[% total_quantity %]</th> >+ <th class="gste">[% total_gste %]</th> >+ <th class="gsti">[% total_gsti %]</th> >+ <th> </th> >+ <th>[% total_gstvalue %]</th> >+ <th> </th> >+ </tr> >+ <tr> >+ <th colspan="3">Total + Shipment cost ([% currency %])</th> >+ <th class="gste"></th> >+ <th class="gsti"></th> >+ <th>[% total_quantity %]</th> >+ <th class="gste">[% total_gste_shipment %]</th> >+ <th class="gsti">[% total_gsti_shipment %]</th> >+ <th> </th> >+ <th>[% total_gstvalue %]</th> >+ <th> </th> >+ </tr> > </tfoot> > </table> > [% ELSE %] >-- >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 10613
:
19788
|
22389
|
25889
|
25890
|
26529
|
26534
|
26535
|
26536
|
26558
|
26924
|
26925
|
26926