Bug 12770 - Notice template tool enhancement
Summary: Notice template tool enhancement
Status: BLOCKED
Alias: None
Product: Koha
Classification: Unclassified
Component: Notices (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Maxime Beaulieu
QA Contact: Testopia
URL:
Keywords:
Depends on: 12769
Blocks:
  Show dependency treegraph
 
Reported: 2014-08-15 13:08 UTC by Francois Charbonnier
Modified: 2017-09-14 18:59 UTC (History)
13 users (show)

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


Attachments
Bug 12770 - Notice template tool enhancement (7.79 KB, patch)
2014-12-11 19:32 UTC, simith.doliveira
Details | Diff | Splinter Review
Bug 12770 - Notice template tool enhancement (7.87 KB, patch)
2015-10-15 18:05 UTC, Eivin Giske Skaaren
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Francois Charbonnier 2014-08-15 13:08:11 UTC
Sponsored by Halland County Library

RFC (with mockup) : http://wiki.koha-community.org/wiki/Overdue_Notice_Enhancement#Notice_template_tool_enhancement_.28to_display_fees.2C_fines.2C_total.2C_etc._and_create_invoices.29

Description :

The invoice will be set up as a notice in the « Notices & slips » tool. Three new tags will display the amounts charged to the patron for a specific item :

    <itemaccountlines>
    <noticefee>
    <total> 

<itemaccountlines> will display the note and the outstanding amount for a specific item. The values will come from the accountlines table (the values available in the « fines » tab from the patron account page). Before being inserted in the invoice, the information will be sorted by date. Only the daily fees will be displayed. The old fees will be put aside.

<itemaccountlines> will be used along with the <item> tag.

<itemaccountlines> is different from <fines> because it works with <item> tag. Set up together, they will build a table which will display for each item: the bibliographic information, the note from the accountlines table and the outstanding amount. See mock-up below.

Example : <item>biblio.title, biblio.author, items.barcode <itemaccountlines> </item>

<noticefee> will add the notice fee to the invoice. To avoid having multiple « notice fee » lines if several invoices are sent the same day, the system will take the first found in the accountlines table.

<total> will calcute the total amount.
Comment 1 Katrin Fischer 2014-08-15 13:41:12 UTC
Hi, just a quick question - I still have to read through the whole RFC: you write accountlines will be different to <items.fine> as it works inside <item> - but I think that is what <<items.fine>> does and how we use it currently. It outputs the fine for the specific item. I think I might misunderstand what is meant, can you explain?
Comment 2 Francois Charbonnier 2014-08-25 17:26:04 UTC
You're right Katrin. It does but <itemaccountlines> will do moreé

<fine> and <itemaccountline> will work with <item>.

* <fine> displays the fine for a specific item.

* <itemaccountline> will display the fine for a specific item + fees + the replacementcost if charged AND built a table to display the information. (See the mock-up in the rfc wiki page)
Comment 3 simith.doliveira 2014-12-11 19:32:51 UTC Comment hidden (obsolete)
Comment 4 simith.doliveira 2014-12-11 19:33:35 UTC
To test:

This patch adds new tags for the notice template tool.
They helps building invoices.
 
The new tags are :
<itemaccountlines> and <accountlines> to display information from biblio, biblioitems, items and accountlines table.
<<noticefee>> to display the notice fee (for future use. It's not usable before bug 12769 is pushed to master)
<<total>> to display the invoice total

The invoice generated with these tags will take the patron item daily fees, either charged by the fines.pl script or by the librarian directly throught the fine tab.

To test this :

1. Apply patch and update the database.
2. Add to the ODUE notice template (or any other late notice templates) this code (it's an example using html.)

<table style="width:70%; border: 1px solid black; border-collapse: collapse">
<tr>
  <th align="center" style="border: 1px solid black; border-collapse: collapse">TITLE</th>
  <th align="center" style="border: 1px solid black; border-collapse: collapse">AUTHOR</th>
  <th align="center" style="border: 1px solid black; border-collapse: collapse">BARCODE</th>
  <th align="center" style="border: 1px solid black; border-collapse: collapse">ITEMCALLNUMBER</th>
  <th align="center" style="border: 1px solid black; border-collapse: collapse">FINE</th>
</tr>

<itemaccountlines>
  <tr>
    <td align="center" style="border: 1px solid black; border-collapse: collapse"><<biblio.title>></td>
    <td align="center" style="border: 1px solid black; border-collapse: collapse"><<biblio.author>></td>        
    <td align="center" style="border: 1px solid black; border-collapse: collapse"><<items.barcode>></td>
    <td align="center" style="border: 1px solid black; border-collapse: collapse"><<items.itemcallnumber>></td>
    <td align="center" style="border: 1px solid black; border-collapse: collapse">$</td>
  </tr>
   <accountlines>
       <tr>
          <td align="right" colspan=4 style="border: 1px solid black; border-collapse: collapse"><<accountlines.description>><<accountlines.note>> +</td>
          <td style="border: 1px solid black; border-collapse: collapse"><<accountlines.amountoutstanding>></td>
       </tr>
   </accountlines>
</itemaccountlines>

<tr>
  <td align="right" colspan=4 style="border: 1px solid black; border-collapse: collapse">Notice fee +</td>
  <td style="border: 1px solid black; border-collapse: collapse"><<noticefee>></td>
<tr>

<tr>
  <td align="right" colspan=4 style="border: 1px solid black; border-collapse: collapse"><b>TOTAL =</b></td>
  <td style="border: 1px solid black; border-collapse: collapse"><b><<total>></b></td>
<tr>
</table>

3. Checkout items with a due dates in the past to get the ODUE notice and fines according to your set up
4. Run fines.pl
5. Run overdue_notices.pl
6. Run process_message_queue.pl

Check that :
7. the overdue notice diplays the fines correctly. If you used the example, it should be a table with the title, author, barcode, itemcallnumber. For each late items with fines, you should have the fine descriptions, notes and amounts to cover. You also should see the total amount to pay.
Comment 5 Eivin Giske Skaaren 2015-06-15 19:38:49 UTC
I have tested this quite extensively both from a clean master and with patch 12769 installed. 

There is something that does not work as it should since the table is created and accountlines values are shown while itemaccountlines values are not shown. 

To be more specific none of the values in this part shows up:

<itemaccountlines>
  <tr>
    <td align="center" style="border: 1px solid black; border-collapse: collapse"><<biblio.title>></td>
    <td align="center" style="border: 1px solid black; border-collapse: collapse"><<biblio.author>></td>        
    <td align="center" style="border: 1px solid black; border-collapse: collapse"><<items.barcode>></td>
    <td align="center" style="border: 1px solid black; border-collapse: collapse"><<items.itemcallnumber>></td>
    <td align="center" style="border: 1px solid black; border-collapse: collapse">$</td>
Comment 6 Maxime Beaulieu 2015-07-21 13:04:25 UTC
(In reply to Eivin Giske Skaaren from comment #5)
> There is something that does not work as it should since the table is
> created and accountlines values are shown while itemaccountlines values are
> not shown. 

Hi Eivin,
I just retested the patch. I could see the item's data in the table.

Can you test this again?
Make sure a fine is added to the item. ( accountlines table )
Comment 7 Martin Stenberg 2015-08-31 15:54:24 UTC
Tried to apply patch to master (208400f) but got merge conflicts in misc/cronjobs/overdue_notices.pl.

It works well against 2331a21 (random pick from 2015-07-21 when patch was last said to work).

All values show as described. Would perhaps be nice to add accountlines in the SQLfieldnames ($field_selection, letter.pl:247)?
Comment 8 Eivin Giske Skaaren 2015-10-15 18:05:22 UTC
Created attachment 43442 [details] [review]
Bug 12770 - Notice template tool enhancement

Fixed merge conflict and rebased.

Tested OK. Values now show up i table.

Signed-off-by: Eivin Giske Skaaren <eivin@sysmystic.com>
Comment 9 Jonathan Druart 2015-10-16 11:09:05 UTC
Blocked by 12769.
At first glance I don't understand the change made in C4::Letters.
And no tests for this change.
Then, you add sql queries to pl file: should be in module and covered by tests.