Bug 23981

Summary: Inconsistencies with the different prices
Product: Koha Reporter: Caroline Cyr La Rose <caroline.cyr-la-rose>
Component: AcquisitionsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: caroline.cyr-la-rose, katrin.fischer, koha, marjorie.barry-vila, martin.renvoize, nick, philippe.blouin, severine.queune, thibaud.guillot
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5062
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35114
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Screenshot showing the price fields

Description Caroline Cyr La Rose 2019-11-06 17:17:18 UTC
I was investigating bug 18639 and I came across some inconsistencies in the prices, where they are used, the calculations, etc.

To reproduce :
(Note: my vendor setting is "tax excluded" for both list and invoice price, I tried with different settings and as far as I can tell, the result is the same)
1- Create a new basket
2- Add an order
3- In the financial details, enter the following informations (I know it doesn't make sense IRL, but we are entering different prices just to see what goes where):
   - Vendor price: 10.99
   - Tax rate: 0%
   - Discount: 0%
   - Retail price: 12.99
   - Replacement cost: 15.99
   - Actual cost: 18.99
4- Note that Budgeted cost and Total are based on *vendor* price (10.99)
5- Save your order
6- If you have access to your database, check the info that is entered (if you don't have access to your database, you can do an SQL report with the following query

SELECT * from aqorders where basketno = X;

Substitute de X for your basket number

My db shows the following:

listprice: 10.990000
unitprice: 18.990000
rrp: 12.99
replacementprice: 15.990000
rrp_tax_excluded: 12.990000
rrp_tax_included: 12.990000
ecost: 10.99
ecost_tax_excluded: 12.990000
ecost_tax_included: 12.990000

Note that the ecost_tax_excluded and ecost_tax_included are not based on ecost, but on rrp.
7- Go back to acquisitions home page and click on the amount ordered in your budget
8- Find your order and note that the estimated cost per unit is the retail price (12.99), not the vendor price (10.99) and not the budgeted cost as calculated during the order (10.99).
9- Close the basket
10- Receive the order
11- On the receipt summary page (which lists all the items yet to be received), the unit cost is the retail price (12.99) and the replacement cost is correct
12- On the item receiving page, the retail price is correct, the replacement price is correct, the budgeted cost is the retail price not the vendor price (listprice) nor the budgeted cost calculated during the order (ecost), the actual price is correct.
13- In the already received page, the prices are correct
14- In the "Spent column" of the budget, the price taken out of the fund is the actual price, which is correct.

Summary:
- The vendor price/listprice is not used anywhere else than during the first step of the order
- The budgeted cost (ecost) is based on the retail price, the order form needs to reflect that

Propositions:
- Unless there is a good reason to keep it (like someone wanting to discriminate between how much the vendor sells it vs how much another vendor might sell it), I would remove the vendor price completely and replace it with the retail price
- Correct the order form to show the real estimated price, based on the retail price
- Correct the db calculations to make sure the ecost is based on the rrp and that the tax are calculated on the ecost

I'm sorry if this is all over the place, hopefully by following the steps, you will see what I mean.
Comment 1 Caroline Cyr La Rose 2019-11-06 17:31:14 UTC
Another thing I noticed, when importing files into a basket, the fields are simply labeled "Price" and "Replacement price". Price is copied into every db field that is not replacementprice (rrp, ecost, listprice, unitprice, etc), so there is no risk of confusion here. However, we might want to relabel it Retail price?
Comment 2 Caroline Cyr La Rose 2019-11-06 17:35:19 UTC
Created attachment 95118 [details]
Screenshot showing the price fields

Sorry again, just a minor thing. I noticed there is not prefilled "0.00" in the retail price field as there is with other price fields. See attached screenshot
Comment 3 Caroline Cyr La Rose 2023-08-28 14:14:36 UTC
I tested this again and it's still valid. 

The most annoying part is the ecost_tax_* is based on rrp rather than ecost. This means that the "budgeted cost" changes in various pages.

Just from observations in the interface (i.e. without looking in the code), this is what is used where:

When placing a new order (empty) (neworderempty.pl)
- Vendor price = listprice (10.99)
- Actual cost = uniprice (18.99)
- Retail price = rrp (12.99)
- Replacement cost = replacementprice (15.99)
- Budgeted cost = ecost (10.99) **

When viewing the basket (basket.pl)
- Actual cost tax exc. = unit_price_tax_excluded (18.99)
- Replacement price = replacementprice (15.99)
- RRP tax exc. = rrp_tax_excluded (12.99)
- Budgeted cost tax exc. = ecost_tax_excluded (12.99) **
- Budgeted cost tax inc. = ecost_tax_included (12.99) **

When viewing ordered funds (ordered.pl)
- Estimated cost per unit = rrp (12.99) **

When receiving the order (parcel.pl)
- Unit cost = listprice (10.99)
- Replacement price = replacementprice (15.99)
- Order cost = ecost (10.99) **

When receiving the order (orderreceive.pl)
- Actual cost = uniprice (18.99)
- Retail price = rrp (12.99)
- Replacement price = replacementprice (15.99)
- Budgeted cost = ecost_tex_excluded (12.99) **

When viewing the invoice (invoice.pl)
- Actual cost tax exc. = unitprice_tax_excluded (18.99)
- Replacement price = replacementprice (15.99)

When viewing spent funds (spent.pl)
- Unit price = unitprice (18.99)
Comment 4 Caroline Cyr La Rose 2023-08-28 14:16:01 UTC
I made a table with the various terms used where : https://snipboard.io/wLaNtq.jpg
Comment 5 Mark Hofstetter 2023-12-04 13:28:34 UTC
hi,

I am not sure if our customer/we have the same problem but it seems to be related - I just tested it with 23.06.00.079, just to clarify things for me if I am looking the right place(s):

IMHO the price should be deducted from fund WITHOUT the tax (but it is with the the tax)

0) create a vendor 
List prices: Include tax 
Invoice prices: Don't include tax 

1) placing an order:
cgi-bin/koha/acqui/neworderempty.pl?booksellerid=3&basketno=4


Vendor price: 10  (tax inclusive)
Tax rate: 10%
Discount: 13%
Retail price: 10.00  (adjusted for USD, tax inclusive)
Replacement cost: 10.00
Budgeted cost: 8.70 (tax inclusive)
Total: 8.70 (budgeted cost * quantity)
Actual cost: 0.00

==> 10 * 0.87

2) cgi-bin/koha/acqui/basket.pl?basketno=4
RRP => 9.09 (10 / 1.1)  Price - Tax ie 
Budgeted cost tax ex => 7.91 ( 9.09 * 0.87 (13% Discount))
total ex tax => 7.91
GST => 0.79 (7,91 * 0.1 (10% Tax))

3) Close Basket => Yes

4) 
cgi-bin/koha/acqui/booksellers.pl?booksellerid=3
Click receive Shipment

fill in:
Vendor invoice: 123345 (some random number)
add no shippment costs

5) mark create book and click "Receive selected(1)"

6) mark item as received 
Actual cost: 7.91  (tax exclusive)


7) 
Total tax exc.	7.91	
Total (GST 10%)	0.79	
Total tax inc.	8.70	

there should be no tax because the vendor is tax excluded

8) 
Secondary fund	Secondary fund	1,000.00	0.00	0.00	8.70	8.70	991.30	991.30

the full amount is deducted even if you are tax exempt
Comment 6 Katrin Fischer 2023-12-04 18:38:19 UTC
(In reply to Mark Hofstetter from comment #5)
> hi,
> 
> I am not sure if our customer/we have the same problem but it seems to be
> related - I just tested it with 23.06.00.079, just to clarify things for me
> if I am looking the right place(s):
> 
> IMHO the price should be deducted from fund WITHOUT the tax (but it is with
> the the tax)

I believe with tax is standard as most libraries have to pay it and you need the funds to reflect that. But there is  CalculateFundValuesIncludingTax in 23.11 to change it.
 
> 0) create a vendor 
> List prices: Include tax 
> Invoice prices: Don't include tax 
> 
> 1) placing an order:
> cgi-bin/koha/acqui/neworderempty.pl?booksellerid=3&basketno=4
> 
> 
> Vendor price: 10  (tax inclusive)
> Tax rate: 10%
> Discount: 13%
> Retail price: 10.00  (adjusted for USD, tax inclusive)
> Replacement cost: 10.00
> Budgeted cost: 8.70 (tax inclusive)
> Total: 8.70 (budgeted cost * quantity)
> Actual cost: 0.00
> 
> ==> 10 * 0.87
> 
> 2) cgi-bin/koha/acqui/basket.pl?basketno=4
> RRP => 9.09 (10 / 1.1)  Price - Tax ie 
> Budgeted cost tax ex => 7.91 ( 9.09 * 0.87 (13% Discount))
> total ex tax => 7.91
> GST => 0.79 (7,91 * 0.1 (10% Tax))
> 
> 3) Close Basket => Yes
> 
> 4) 
> cgi-bin/koha/acqui/booksellers.pl?booksellerid=3
> Click receive Shipment
> 
> fill in:
> Vendor invoice: 123345 (some random number)
> add no shippment costs
> 
> 5) mark create book and click "Receive selected(1)"
> 
> 6) mark item as received 
> Actual cost: 7.91  (tax exclusive)
> 
> 
> 7) 
> Total tax exc.	7.91	
> Total (GST 10%)	0.79	
> Total tax inc.	8.70	
> 
> there should be no tax because the vendor is tax excluded

The vendor is not tax excluded, the setting means: the price is entered with or without tax. If you set a tax, it will still be calculated. You would need to set the tax percentage to 0 if you don't want tax.

> 
> 8) 
> Secondary fund	Secondary fund	1,000.00	0.00	0.00	8.70	8.70	991.30	991.30
> 
> the full amount is deducted even if you are tax exempt

There is no setting for tax exempt.
Comment 7 Thibaud Guillot 2024-02-08 09:32:45 UTC
Hello 

You may wish to consult bug 35114, which I've opened. It's about price differences and miscalculations on baskets;)