Comment 23 for bug 800478

Revision history for this message
Liam Whalen (whalen-ld) wrote :

I have modified acq.fund_transfer a fair bit and moved the returning of funds into a new function acq.return_funds_to_source.

The change are here:

http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/ldw/LP800478_fund_transfer

This fixes the following:

It locks the acq.exchange_rate table for the duration of a transfer to avoid fluctuating rates while transfering.

It checks to see if the amount being transferred is negative and if it does, it swaps the transferring and receiving funds and make the amount positive.

If removes the parameter that passed in the converted amount to be transferred to the new fund. This causes a problem if the rate used to convert outside of the function is different from the rate in acq.exchange_rate.

acq.transfer_fund now checks to make sure there is enough money left in the transferring fund before trying to transfer the amount to the new fund.

The new funciton acq.return_funds_to_source is essentially the same function without having to worry about a second fund.

This commit also adds two columns to acq.fund_allocation: fund_amount and conversion_ratio. fund_amount is the amount allocated in the currency of the fund receiving the allocation. This will allow the system to display the total value in the fund without that value changing due to changes in the exchange rate.

Currently, because the amount transferred is stored in the currency of the source, if the source and fund have different currencies then the VIEW acq.fund_allocation_total changes depending on the rate of exchange.

However, if 100 US allocated to a CDN account at 1 to 1 then that account has 100 CDN regardless of future rate changes. So that total needs to stay at 100.

As well, by adding the conversion_ratio we will allow the amounts transferred to be rolled back in a new INSERT if necessary, and for accounting to see what was done at what exchange rates.