Bug 14251: Allow use of CSS in discharge letter
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 28 Dec 2022 13:43:16 +0000 (10:43 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 27 Mar 2023 09:53:16 +0000 (11:53 +0200)
commit9d9ecdc49b4cb71aba99a7d7ca8bc89d426f7ca1
tree30006cc83974fd47de409f27dff93dcebc53580e
parentd22f885b064f599d753afc94ac7caf0a4ead5ce7
Bug 14251: Allow use of CSS in discharge letter

The discharge feature relies PDF::FromHTML which explicitly doesn't
handle CSS [1].

This patch makes it use the `weasyprint` command-line tool to generate
the PDF. This tool handles CSS correctly.

To test:
1. Install weasyprint:
   $ apt install weasyprint
2. Add some style to your DISCHARGE letter. I used:
<<today>>
<h1>Discharge confirmation</h1>
<p style="background-color: yellow;"><<branches.branchname>> certifies that the following borrower:<br>
<<borrowers.firstname>> <<borrowers.surname>> (cardnumber: <<borrowers.cardnumber>>)<br>
has returned all items.</p>
3. Have some non-latin chars on the patron name. I picked 'Henry
   Acevedo' and added 'Δοκιμή' as picked from bug 23589. Only to check no
   regressions.
4. Enable the 'UseDischarge' syspref
5. Go to Henry's detail page
6. Choose More > Discharge and Generate the discharge
=> SUCCESS:
   - Style is applied to the PDF
   - Greek characters are displayed correctly
7. Run the tests:
   $ kshell
  k$ prove -v t/db_dependent/Patron/Borrower_Discharge.t
=> SUCCESS: The rewritten tests pass!
8. Remove weasyprint:
   $ apt remove weasyprint
9. Repeat 7
=> SUCCESS: Tests pass, relevant test is skipped because of missing
            weasyprint
10. Sign off :-D

[1] https://metacpan.org/pod/PDF::FromHTML#CAVEATS

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/Patron/Discharge.pm
t/db_dependent/Patron/Borrower_Discharge.t