Bug 12993 - Add a default tax rate on item types
Summary: Add a default tax rate on item types
Status: Patch doesn't apply
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Alex Arnaud
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-25 09:20 UTC by Jonathan Druart
Modified: 2016-02-17 09:27 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 12993: Add a default tax rate on item types (6.88 KB, patch)
2014-09-25 09:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12993: Add a default tax rate on item types - DB changes (1.96 KB, patch)
2014-10-06 18:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12993: Select automatically itemtype on neworderempty.pl (1.85 KB, patch)
2014-10-13 08:37 UTC, Julian Maurice
Details | Diff | Splinter Review
31863: Bug 12993: Add a default tax rate on item types (7.10 KB, patch)
2014-11-06 14:00 UTC, Paola Rossi
Details | Diff | Splinter Review
32018: Bug 12993: Add a default tax rate on item types - DB changes (2.08 KB, patch)
2014-11-06 14:01 UTC, Paola Rossi
Details | Diff | Splinter Review
Bug 12993: Select automatically itemtype on neworderempty.pl (1.96 KB, patch)
2014-11-06 14:03 UTC, Paola Rossi
Details | Diff | Splinter Review
Bug 12993: Add a default tax rate on item types - DB changes (2.01 KB, patch)
2014-12-29 10:34 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12993: (qa-follow-up) Display the column only when it is useful (3.16 KB, patch)
2015-01-19 15:54 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12993: Add a default tax rate on item types (6.95 KB, patch)
2015-05-27 08:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12993: Select automatically itemtype on neworderempty.pl (1.90 KB, patch)
2015-05-27 08:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Attachment to Bug 12993 - Add a default tax rate on item types (1.91 KB, patch)
2015-05-27 08:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12993: (qa-follow-up) Display the column only when it is useful (3.16 KB, patch)
2015-05-27 08:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12993: Add a default tax rate on item types (7.19 KB, patch)
2015-12-09 15:59 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 12993: Select automatically itemtype on neworderempty.pl (1.91 KB, patch)
2015-12-09 15:59 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 12993: Add a default tax rate on item types - DB changes (1.92 KB, patch)
2015-12-09 16:00 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 12993: (qa-follow-up) Display the column only when it is useful (3.17 KB, patch)
2015-12-09 16:00 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 12993: Fix operator errors in itemtypes.tt (2.16 KB, patch)
2015-12-09 16:00 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 12993: Add gstrate in itemtypes form and table (1.98 KB, patch)
2015-12-09 16:01 UTC, Alex Arnaud
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2014-09-25 09:20:08 UTC
This enhancement will permit to set a default tax rate for item types.
Comment 1 Jonathan Druart 2014-09-25 09:28:36 UTC Comment hidden (obsolete)
Comment 2 Paola Rossi 2014-10-06 15:33:06 UTC
I've applied the patch against master 3.17.00.025

I've set some values in the gist system pref.
Then, editing an itemtype, I could select a tax rate value in the drop down list of "Tax rate" field, but, after saving changes, the tax rate value was not recorded to the itemtype in the DB.

The patch is lacking in adding the "gstrate" field to the itemtypes DB-table. [The patch gives no updatedatabase.pl' diffs (at least).]

So I pass the patch to "Failed QA" status.
Comment 3 Jonathan Druart 2014-10-06 18:08:55 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2014-10-06 18:09:23 UTC
Sorry Paola, I forgot to attach the DB changes patch.
Comment 5 Paola Rossi 2014-10-07 16:09:12 UTC
Thanks, Jonathan.

I've tested adding orders from existing record and from subscription, and it's OK.

But from suggestion it is not OK: the document type of a suggestion has recently become mandatory, and so this is an error.

So I pass the patch to "Failed QA" status.

[Some problems could be from staged file, too. 
But perhaps the tool "Stage MARC records for import" might have an error in recognizing the document type of the input record biblio (942$c subfield). 
The tool should do it (see the "Match type" column in the table at the bottom of "Manage staged MARC records", on tols/manage-marc-import.pl?import_batch_id, after having "uploaded" and "Staged for import". 
If the tool has this error, no test here for 12933.]

Ordering "From an external source" doesn't assign the document type of the source to the order: the user has to use cataloguing to assign the 942$c subfield, so he should exit from ordering' path. So no test here. 
And ordering "From a new (empty) record" is the same.
Comment 6 Jonathan Druart 2014-10-07 17:47:40 UTC
(In reply to Paola Rossi from comment #5)

This works only on the neworderempty.pl script. So if you order from a suggestion, suscription, new record, existing record.
It looks to work for all of these cases.
I tried for a suggestion and if I change the value of the itemtype dropdown-list, the vat value is updated.
Comment 7 Paola Rossi 2014-10-09 16:49:37 UTC
Hi, Jonathan. My results didn't match your observations in comment 6, so I've made some further tests.

I've applied the patches.

On ADMIN in "Item Types" I set "Tax rate" of Book to 5%

On ADMIN I set the system pref gist to: 
0.10|0|0.05|0.23  [As ADMIN says: "First is the default."]

The vendor was configured 0-0, and his tax rate was set to 23%.

[I kept the system pref "AcqCreateItem" to default value "placing an order".]

The patches worked perfectly well in these 4 cases:
A) ordering from an existing record:
On a BK biblio record I _immediately_ saw 5% in the tax rate of the "Accounting details" in the "New order" page (RIGHT just as required, I think). 
And, on a biblio record with none itemtype, I _immediately_ saw 23% there (RIGHT, I also think)
B) ordering from a subscription
C) ordering from a staged file:
the neworderempty.pl script is used by way of the link "Add order", at the right of the uploaded-and-staged-file's titles, in the tag "Select to import" under "Add orders from (name of my file)"
D) ordering from titles with highest hold ratios.

Ordering from a BK suggestion [or from an empty record] I've seen 23% in the tax rate of the order: it's the vendor' tax rate, instead of the expected tax rate 5% of the BK' itemtype (ERROR).

Where have I been wrong, please? Did I forget anything?

I beg your pardon, but I should pass the patch to "Failed QA" status for now.

[Perhaps is there anything missing in the patches? there is nothing about neworderempty.pl, I see]

I've a lot of doubts.

Note that a suggestion has no corresponding biblio record in the DB until it has been ordered. So I ask myself how the neworderempty.pl script can find an "itemtype at the biblio level" ordering from a suggestion. [Anyway, I didn't find a way in koha to create a suggestion together with a biblio record: neither from ACQ nor from OPAC]. I'm in doubt: are we into the test for 12993 or not?

Moreover, the order had shown the suggestion' price very well in "Accounting details"! If we're into the 12993 test, couldn't the suggestion's itemtype have been read by the same way? It's not a biblio level' itemtype, as you required,  but it seems to me being no other way to have an itemtype for a BK suggestion.

In case, I invite you to let me know the steps of your test on suggestion, please.

------------------------------------------------------------
Comment 8 Julian Maurice 2014-10-13 08:37:40 UTC
(In reply to Paola Rossi from comment #7)
> Ordering from a BK suggestion [or from an empty record] I've seen 23% in the
> tax rate of the order: it's the vendor' tax rate, instead of the expected
> tax rate 5% of the BK' itemtype (ERROR).

I think this is due to the fact that suggestion's itemtype is not being selected automatically.
I'll provide a patch for that.
Comment 9 Julian Maurice 2014-10-13 08:37:54 UTC Comment hidden (obsolete)
Comment 10 Julian Maurice 2014-10-13 08:39:42 UTC
Could you test it again ?
Note that it works only when syspref item-level_itypes is OFF ("Use the item type of the biblio record").
Comment 11 Paola Rossi 2014-10-14 09:31:18 UTC
I've applied the 3 patches against master 3.17.00.027 .

Now ordering "from suggestion" and ordering "from a new (empty) record" let me see and set the type of the document! Thanks, Julian.

On ADMIN in "Item Types" I've set:

"Tax rate" of Book to 5%
"Tax rate" of Serial to 7%
"Tax rate" has been kept "none" elsewhere.
 
On ADMIN I set the syspref "gist" to: 
"0.10|0|0.05|0.07|0.23" [As ADMIN says: "First is the default."]
I set the syspref "item-level_itypes" to "biblio record", as you've kindly indicated.

The vendor was configured 0-0, and his tax rate was set to 23%.

[I kept the syspref "AcqCreateItem" to default value "placing an order".]

1) I was ordering music from a suggestion [or a new empty record].
On the page of neworderempty.pl the item-type default has been set to Book. So the default value is set to 5%, as on ADMIN (RIGHT).
So I changed the type to music, but the 5% has been kept (ERROR): it happened because the music's biblio level item-type was set to none on ADMIN.
If I changed the type to serial, and then to music, the music's tax rate was another one, 7% (ERROR).

In spite of 5% or 7%, the value I expected was 23%, the vendor's default tax rate, as if I ordered "from existing" music.

2) I ordered "from an external source", so using "neworderempty.pl". The shown tax rate was 23%, the vendor's default tax rate (RIGHT, I think).
No item type's dropdown list was available here for the document.
Perhaps could item type's dropdown list be added, like in the suggestion's case or in the empty record's case?

For 1) I pass the patches to "Failed QA" status.
Comment 12 Jonathan Druart 2014-11-04 09:43:01 UTC
(In reply to Paola Rossi from comment #11)
> For 1) I pass the patches to "Failed QA" status.

Paola, thanks for testing.
What you described is the expected behavior.
Comment 13 Paola Rossi 2014-11-06 14:00:15 UTC Comment hidden (obsolete)
Comment 14 Paola Rossi 2014-11-06 14:01:27 UTC Comment hidden (obsolete)
Comment 15 Paola Rossi 2014-11-06 14:03:13 UTC Comment hidden (obsolete)
Comment 16 Katrin Fischer 2014-12-27 19:56:34 UTC
Note for later: Add bug number to datebase update message
Comment 17 Jonathan Druart 2014-12-29 10:34:42 UTC Comment hidden (obsolete)
Comment 18 Jonathan Druart 2014-12-29 10:35:11 UTC
(In reply to Katrin Fischer from comment #16)
> Note for later: Add bug number to datebase update message

Done.
Comment 19 Marcel de Rooy 2015-01-19 13:16:09 UTC
QA Comment:

Tax rate: no default
This is a confusing term. Would something like manual be better? Or a word that expresses that it is a different/deviating rate than those in the table (read: preference)?

If you have item-level_itypes==biblio, the selection seems to work.
If you have item-level_itypes==item, the situation is confusing. The first rate of the pref is selected (fine). But I save my first item, I would expect that it would update my tax rate (at least the first time). It does not.
I understand that if you add another item of another type, you cannot make a choice. You could choose for defaulting to the rate of the first item.

When I set AcqCreateItem <> ordering, the situation is still different. You have no items/item types. So no defaults.

My conclusion is that adding this rate to the item type page in Administration promises much, but does not bring that much.
Note that the item type page does not tell you that filling the tax rate is only useful when you item-level_itypes==biblio and AcqCreateItem == ordering.
Perhaps you should tell that or only show them in that case?

I am moving this report to FQA for this functional perspective. This still needs some attention imo before pushing it to master.
Comment 20 Marcel de Rooy 2015-01-19 13:19:58 UTC
(In reply to M. de Rooy from comment #19)
> Tax rate: no default
> This is a confusing term. Would something like manual be better? Or a word
> that expresses that it is a different/deviating rate than those in the table
> (read: preference)?

Please add how this would work given the context.
Comment 21 Jonathan Druart 2015-01-19 15:54:42 UTC Comment hidden (obsolete)
Comment 22 Jonathan Druart 2015-01-19 15:56:57 UTC
(In reply to M. de Rooy from comment #19)

Hi Marcel,
Yes you are right, this development only works if the item types are defined at the biblio level and if the items are created on ordering.

The last patch removes the column in other cases.
Comment 23 Marc Véron 2015-05-27 06:53:46 UTC
Sorry, did not apply:

Applying: Bug 12993: Add a default tax rate on item types
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt
Auto-merging admin/itemtypes.pl
Applying: Bug 12993: Select automatically itemtype on neworderempty.pl
Applying: Bug 12993: Add a default tax rate on item types - DB changes
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging installer/data/mysql/updatedatabase.pl
CONFLICT (content): Merge conflict in installer/data/mysql/updatedatabase.pl
Auto-merging installer/data/mysql/kohastructure.sql
Failed to merge in the changes.
Patch failed at 0001 Bug 12993: Add a default tax rate on item types - DB changes
Comment 24 Jonathan Druart 2015-05-27 08:10:06 UTC Comment hidden (obsolete)
Comment 25 Jonathan Druart 2015-05-27 08:10:15 UTC Comment hidden (obsolete)
Comment 26 Jonathan Druart 2015-05-27 08:10:26 UTC Comment hidden (obsolete)
Comment 27 Jonathan Druart 2015-05-27 08:10:31 UTC Comment hidden (obsolete)
Comment 28 Joonas Kylmälä 2015-10-13 10:23:58 UTC
If I go to koha/admin/itemtypes.pl I get:

Software error:

Template process failed: file error - parse error - /home/putti/kohaclone/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt line 197: unexpected token (eq)
  [% IF Koha.Preference('AcqCreateItem') eq 'ordering' and Koha.Preference('item-level_itypes') eq '0' %] at /home/putti/kohaclone/C4/Templates.pm line 121.
Comment 29 Jonathan Druart 2015-10-13 11:02:52 UTC
The 3 occurrences of
+    [% IF Koha.Preference('AcqCreateItem') eq 'ordering' and Koha.Preference('item-level_itypes') eq '0' %]
should be s/eq/==
Comment 30 Alex Arnaud 2015-12-09 15:59:39 UTC
Created attachment 45538 [details] [review]
Bug 12993: Add a default tax rate on item types

This enhancement permits to set a default tax rate for item types.
If a default tax rate is defined for an item type, the tax rate will be
automatically selected when the librarian choose the type of the
item to order.

Test plan:
0/ Execute the updatedb entry.
1/ Define a default tax rate for some item types.
2/ Create an order and verify the tax rate is selected after you have
chosen the item type.

Note that the item type is only displayed if defined at the biblio
level.

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Comment 31 Alex Arnaud 2015-12-09 15:59:48 UTC
Created attachment 45539 [details] [review]
Bug 12993: Select automatically itemtype on neworderempty.pl

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Comment 32 Alex Arnaud 2015-12-09 16:00:42 UTC
Created attachment 45540 [details] [review]
Bug 12993: Add a default tax rate on item types - DB changes

This patch adds a new DB field: itemtypes.gstrate

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Comment 33 Alex Arnaud 2015-12-09 16:00:50 UTC
Created attachment 45541 [details] [review]
Bug 12993: (qa-follow-up) Display the column only when it is useful

As mention by comment 19, the default tax rate defined for item types is
only useful when the items are created on ordering and the item type is
defined at the biblio level.
Comment 34 Alex Arnaud 2015-12-09 16:00:56 UTC
Created attachment 45542 [details] [review]
Bug 12993: Fix operator errors in itemtypes.tt
Comment 35 Alex Arnaud 2015-12-09 16:01:01 UTC
Created attachment 45543 [details] [review]
Bug 12993: Add gstrate in itemtypes form and table
Comment 36 Josef Moravec 2016-02-17 09:27:40 UTC
Could you please rebase?