Bug 7180: Order from staged file improvements
authorJonathan Druart <jonathan.druart@biblibre.com>
Thu, 8 Mar 2012 16:25:06 +0000 (17:25 +0100)
committerGalen Charlton <gmc@esilibrary.com>
Sun, 4 May 2014 19:41:30 +0000 (19:41 +0000)
commit2f2d7b9368fc5d8c9a14b4ffb4f441b2128dbef4
treee8f6f0891300f8a32a88d31f80527a3e92d60679
parent454bef0b795ad5ab38b659b0366d9edd1f592dd7
Bug 7180: Order from staged file improvements

This patch adds:
- 1 syspref MarcFieldsToOrder
- 1 Ajax script acqui/ajax-getauthvaluedropbox.pl
- 1 routine C4::Budgets::GetBudgetByCode

Before this patch you were not able to order 1 or all the records from
your staged file. You were allowed to specify some information ("Import
All" and "Accounting details" areas) for the order.

With this patch, the previous behaviour still exists.
But now you can *select* which records you want to ordered.
For these ones you can specify independently quantity,
price, budget, sort1 and sort2.

The cherry on the cake is that you can pre-fill these fields  with
values from the MARC record.

Test plan:
1. Fill the new syspref MarcFieldsToOrder with something like:
==BEGIN==
price: 947$c
quantity: 969$h
budget_code: 922$a
rrp: 010$d
discount: 969$d
sort1: 923$a
sort2: 924$a

==END==
The empty line at the end is mandatory!
The budget (corresponding to your budget_code) can be filled with
authorized value categories (statistic 1 and 2).
The sort1 and sort2 values can be filled with the an authorized value
(of the category previously selected)

2. Choose randomly one or more biblio(s) and fill fields with what is
   relevant.

3. Export the biblio and import it (with the "Stage MARC records for
   import" tool).

4. Go on a basket and add an order from a staged file. Select your
   staged file.

5. Well. Now you can see your biblio (or biblios if your had exported
   more than one). For each one, fields should be pre-filled with the
   biblio values. The budget should be selected on the budget
   corresponding to the budget_code (in the field 922$a) and the
   "planning values" too (with fields 923$a and 924$a).
   You can modify these values (or not) and choose a default value for
   budget and planning values (in the "Accounting details" area).

6. Save and check the prices values. Modify the order and check that
   budget and sort* are good

Prices are calculated following some parameters:
if there is no price => listprice = 0
else =>
  - the gstrate value for your order is the gstrate value of the bookseller
  - discount = if filled : the discount value / 100
               else: the discount value of the bookseller
  - if the bookseller includes tax( List item price includes tax: Yes )
        if a discount exists:
            ecost = price
            rrp   = ecost / ( 1 - discount )
        else: # a discount does not exist
            ecost = price * ( 1 - discount )
            rrp   = price
    else # the bookseller does not include tax
        if a discount exists:
            ecost = price / ( 1 + gstrate )
            rrp   = ecost / ( 1 - discount )
        else: # a discount does not exist
            rrp   = price / ( 1 + gstrate )
            ecost = rrp * ( 1 - discount )
  - in all cases:
        listprice = rrp / currency rate
        unitprice = ecost
        total = ecost * quantity

7. Retry with different parameters

8. Check the 'Import all' action still works

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Budgets.pm
acqui/addorderiso2709.pl
acqui/ajax-getauthvaluedropbox.pl [new file with mode: 0755]
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/js/acq.js
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref