Bugzilla – Attachment 99766 Details for
Bug 24158
Add ability to receive items in multiple currencies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24158: Convert actual cost in an other currency when receiving
Bug-24158-Convert-actual-cost-in-an-other-currency.patch (text/plain), 6.41 KB, created by
Devinim
on 2020-02-28 14:44:15 UTC
(
hide
)
Description:
Bug 24158: Convert actual cost in an other currency when receiving
Filename:
MIME Type:
Creator:
Devinim
Created:
2020-02-28 14:44:15 UTC
Size:
6.41 KB
patch
obsolete
>From e22cca2c49a219639e11f8b30173dbde5749a70c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 4 Dec 2019 17:40:17 +0100 >Subject: [PATCH] Bug 24158: Convert actual cost in an other currency when > receiving > >This patch adds a currency dropdown list to the Actual cost field when >receiving items in the acquisition module. >The idea is to let the librarian entered a price in a foreign currency >that will automatically be converted in the local currency ('active'). >This converted value will be use as the actual cost once the form is >submitted. > >Test plan: >- Create several currencies with different rates >- Create an order, close the basket and receive >- On the receipt page you will notice a new "change currency" checkbox >right close to the 'Actual cost' input. >- Check it >=> The 'Actual cost' input is readonly and a new line appears at the >bottom. >- Enter a number and select a currency >=> The 'Actual cost' input is automatically filled with the converted >value >- Save >=> The converted Actual cost has been inserted in the database. > >Sponsored-by: Athlone Institute of Technology > >Signed-off-by: Devinim <nazli@devinim.com.tr> >--- > acqui/orderreceive.pl | 7 ++-- > .../prog/en/modules/acqui/orderreceive.tt | 37 ++++++++++++++++++++-- > 2 files changed, 39 insertions(+), 5 deletions(-) > >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 0b9ef232b6..f676ae81f8 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -114,7 +114,8 @@ unless ( $results and @$results) { > my $order = $results->[0]; > my $order_object = Koha::Acquisition::Orders->find( $ordernumber ); > my $basket = $order_object->basket; >-my $active_currency = Koha::Acquisition::Currencies->get_active; >+my $currencies = Koha::Acquisition::Currencies->search; >+my $active_currency = $currencies->get_active; > > # Check if ACQ framework exists > my $acq_fw = GetMarcStructure( 1, 'ACQ', { unsafe => 1 } ); >@@ -228,8 +229,8 @@ $template->param( > booksellerid => $order->{'booksellerid'}, > freight => $freight, > name => $bookseller->name, >- cur_active_sym => $active_currency->symbol, >- cur_active => $active_currency->currency, >+ active_currency => $active_currency, >+ currencies => scalar $currencies->search({ rate => { '!=' => 1 } }), > invoiceincgst => $bookseller->invoiceincgst, > title => $order->{'title'}, > author => $order->{'author'}, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index a2159eaf96..a4a996a177 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -288,7 +288,7 @@ > <input type="hidden" name="tax_rate" value="0" /> > [% END %] > >- <li><label for="rrp">Retail price: </label>[% rrp | $Price %] <span class="hint">(adjusted for [% cur_active | html %], [% IF (invoiceincgst == 1) %]tax inclusive[% ELSE %]tax exclusive[% END %])</span></li> >+ <li><label for="rrp">Retail price: </label>[% rrp | $Price %] <span class="hint">(adjusted for [% active_currency.currency | html %], [% IF (invoiceincgst == 1) %]tax inclusive[% ELSE %]tax exclusive[% END %])</span></li> > <li> > <label for="replacementprice">Replacement price:</label> > <input type="text" size="20" name="replacementprice" id="replacementprice" value="[% replacementprice | $Price on_editing => 1 %]" /> >@@ -296,7 +296,21 @@ > <li><label for="ecost">Budgeted cost: </label>[% ecost | $Price %] <span class="hint">[% IF (invoiceincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span></li> > <li> > <label for="unitprice">Actual cost:</label> >- <input type="text" size="20" name="unitprice" id="unitprice" value="[% unitprice | $Price on_editing => 1 %]" /> <span class="hint">[% IF (invoiceincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span> >+ <input type="text" size="20" name="unitprice" id="unitprice" value="[% unitprice | $Price on_editing => 1 %]" /> >+ <span class="hint">[% IF (invoiceincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span> >+ <label style="font-weight: inherit; float:none;"><input type="checkbox" name="change_currency">Change currency</label> >+ </li> >+ <li id="select_currency"> >+ <label for="unitprice_currency"></label> >+ <input type="text" size="20" name="unitprice" id="unitprice_currency" value="" /> >+ [% IF currencies.count %] >+ <select name="currency"> >+ <option value="[% active_currency.rate %]" selected="selected">[% active_currency.currency %] ([% active_currency.symbol %])</option> >+ [% FOR currency IN currencies %] >+ <option value="[% currency.rate %]">[% currency.currency %] ([% currency.symbol %])</option> >+ [% END %] >+ </select> >+ [% END %] > </li> > <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote | html %]</textarea></li> > [% IF order_vendornote %] >@@ -436,6 +450,25 @@ > CheckNItems($(this).val()); > }); > [% END %] >+ >+ $("input[name='change_currency']").on("change", function(){ >+ if ( $(this).is(":checked") ) { >+ $("#select_currency").show(); >+ $("#unitprice").prop("readonly", "true"); >+ } else { >+ $("#select_currency").hide(); >+ $("#unitprice").prop("readonly", ""); >+ } >+ }).change(); >+ >+ function update_unitprice() { >+ var rate = Number($("select[name='currency'] option:selected").val()); >+ var unitprice = $("#unitprice_currency").val(); >+ var new_unitprice = Number( unitprice * rate ).toFixed(2); >+ $("#unitprice").val(new_unitprice); >+ } >+ $("select[name='currency']").on("change", function(){update_unitprice()} ); >+ $("#unitprice_currency").on("change", function(){update_unitprice()} ); > }); > </script> > [% END %] >-- >2.11.0
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 24158
:
96263
|
99766
|
101402
|
101682
|
101683