Bug 24158

Summary: Add ability to receive items in multiple currencies
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: AcquisitionsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: enhancement    
Priority: P5 - low CC: 1joynelson, kohadevinim, mark.gavillet, martin.renvoize
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25655
Change sponsored?: Sponsored Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This enhancement adds a currency dropdown to the actual cost field on the accounting details panel at the point of receipt.
Version(s) released in:
20.05.00
Circulation function:
Bug Depends on:    
Bug Blocks: 24971    
Attachments: Bug 24158: Convert actual cost in an other currency when receiving
Bug 24158: Convert actual cost in an other currency when receiving
Bug 24158: Add missing html filters
Bug 24158: Convert actual cost in an other currency when receiving
Bug 24158: Add missing html filters

Description Jonathan Druart 2019-12-03 19:35:43 UTC
When receiving items, add a currency dropdown to the Actual Cost field in the Accounting Details panel.
The currency dropdown will list all currencies on the system that have an exchange rate specified.
When a currency is selected a conversion will be made from the selected currency to the currency marked as active at the exchange rate specified at the point of receipt.

The converted amount will be shown in the Accounting Details panel and written to the database when the form is submitted.
Comment 1 Jonathan Druart 2019-12-13 15:31:58 UTC
Created attachment 96263 [details] [review]
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
Comment 2 Jonathan Druart 2019-12-13 15:33:48 UTC
The implementation differs a bit from what was specified originally. I have tried several versions of this and ended up with this one, which seems the more ergonomic and intuitive in my opinion.

https://snipboard.io/FhkwAS.jpg

https://snipboard.io/GqrsVE.jpg

https://snipboard.io/GhRLav.jpg
Comment 3 Devinim 2020-02-28 14:44:15 UTC
Created attachment 99766 [details] [review]
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>
Comment 4 Katrin Fischer 2020-03-22 17:56:32 UTC
QA tools fail:

 FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt
   FAIL	  filters
		missing_filter at line 308 (                    <option value="[% active_currency.rate %]" selected="selected">[% active_currency.currency %] ([% active_currency.symbol %])</option>)
		missing_filter at line 308 (                    <option value="[% active_currency.rate %]" selected="selected">[% active_currency.currency %] ([% active_currency.symbol %])</option>)
		missing_filter at line 308 (                    <option value="[% active_currency.rate %]" selected="selected">[% active_currency.currency %] ([% active_currency.symbol %])</option>)
		missing_filter at line 310 (                        <option value="[% currency.rate %]">[% currency.currency %] ([% currency.symbol %])</option>)
		missing_filter at line 310 (                        <option value="[% currency.rate %]">[% currency.currency %] ([% currency.symbol %])</option>)
		missing_filter at line 310 (                        <option value="[% currency.rate %]">[% currency.currency %] ([% currency.symbol %])</option>)

I know this will bounce back quickly :)
Comment 5 Jonathan Druart 2020-03-23 08:34:02 UTC
Created attachment 101402 [details] [review]
Bug 24158: Add missing html filters
Comment 6 Katrin Fischer 2020-03-24 10:07:00 UTC
This works for me, but I have some big question marks about the currency calculation on receive:

If you have set 'invoice prices' to another currency than standard in the vendor, this is not visible anywhere in the receive form. And it doesn't appear to be taken into account?

I set 'invoice price' to USD and the rate to 3. Then entered 10 on receive and expected it to be converted to 30, but it didn't happen :(

Where is this setting used and how will it possibly affect this change here?

My impression was that you will enter the price in the currency set in the vendor, like you do for the ordering price and it will recalculate, but that doesn't seem to happen.

I'd like this to be cleared up, before we move on with this to make sure we don't step on toes/workflows.
Comment 7 Katrin Fischer 2020-03-24 10:21:41 UTC
Tested on 18.11 as well - not sure what the invoice price setting is used for still :(
Comment 8 Jonathan Druart 2020-03-24 17:17:38 UTC
Talked with Katrin.
We may want to preselect the new dropdown list to the value of the invoiceprice's vendor. But that would be for a follow-up bug anyway.
Comment 9 Katrin Fischer 2020-03-25 11:14:50 UTC
Created attachment 101682 [details] [review]
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>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 10 Katrin Fischer 2020-03-25 11:14:53 UTC
Created attachment 101683 [details] [review]
Bug 24158: Add missing html filters

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 11 Martin Renvoize (ashimema) 2020-03-25 13:55:06 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 12 Joy Nelson 2020-04-03 22:19:39 UTC
enhancement not backported to 19.11.x