Bug 19191 - Add ability to email receipts for account payments and write-offs
Summary: Add ability to email receipts for account payments and write-offs
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Fines and fees (show other bugs)
Version: Main
Hardware: All All
: P5 - low new feature (vote)
Assignee: Kyle M Hall
QA Contact: Katrin Fischer
URL:
Keywords:
: 13842 (view as bug list)
Depends on: 14826
Blocks: 19545 21396
  Show dependency treegraph
 
Reported: 2017-08-28 14:28 UTC by Kyle M Hall
Modified: 2020-11-12 15:07 UTC (History)
13 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Let your library go paperless. This enhancement enables the ability to send payment and write-off receipts by email.
Version(s) released in:


Attachments
Bug 19191 - Add ability to email receipts for account payments and write-offs (11.84 KB, patch)
2017-08-28 14:33 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191 - Add ability to email receipts for account payments and write-offs (13.31 KB, patch)
2017-10-26 13:17 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191 - Add ability to email receipts for account payments and write-offs (13.36 KB, patch)
2017-10-29 20:28 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 19191 [QA Followup] - Remove db update so feature is disabled by default for existing installations (19.05 KB, patch)
2018-01-12 12:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191 [QA Followup] - Remove db update so feature is disabled by default for existing installations (1.70 KB, patch)
2018-01-12 12:23 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191 - Add ability to email receipts for account payments and write-offs (8.54 KB, patch)
2018-01-12 15:49 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (8.19 KB, patch)
2018-03-02 15:04 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Remove need for bug 19966 (5.38 KB, patch)
2018-03-02 15:05 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Remove need for bug 19966 (1.27 KB, patch)
2018-03-02 15:30 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (8.30 KB, patch)
2018-04-10 12:33 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (8.30 KB, patch)
2018-04-12 13:37 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (8.30 KB, patch)
2018-04-12 13:40 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (8.30 KB, patch)
2018-04-12 13:40 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Remove need for bug 19966 (1.29 KB, patch)
2018-04-12 13:40 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add correct unit tests (5.08 KB, patch)
2018-04-12 14:11 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add correct unit tests (3.83 KB, patch)
2018-04-12 14:13 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Fix capitalization of notice titles (2.68 KB, patch)
2018-04-18 11:23 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add non-english notices (25.31 KB, patch)
2018-04-18 11:23 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (8.32 KB, patch)
2018-04-18 21:47 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 19191: Remove need for bug 19966 (1.32 KB, patch)
2018-04-18 21:47 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 19191: Add correct unit tests (3.87 KB, patch)
2018-04-18 21:47 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 19191: Fix capitalization of notice titles (2.71 KB, patch)
2018-04-18 21:47 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 19191: Add non-english notices (25.29 KB, patch)
2018-04-18 21:47 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (8.29 KB, patch)
2018-04-20 12:43 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (8.29 KB, patch)
2018-04-20 12:43 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Remove need for bug 19966 (1.34 KB, patch)
2018-04-20 12:43 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add correct unit tests (5.24 KB, patch)
2018-04-20 12:43 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Fix capitalization of notice titles (2.74 KB, patch)
2018-04-20 12:44 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add non-english notices (25.36 KB, patch)
2018-04-20 12:44 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add syspref to control use of email receipts, defaulting to disabled (9.38 KB, patch)
2018-04-20 12:44 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add syspref to control use of email receipts, defaulting to disabled (9.39 KB, patch)
2018-04-21 10:54 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (5.84 KB, patch)
2018-05-04 12:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add ability to email receipts for account payments and write-offs (5.84 KB, patch)
2018-05-04 12:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Remove need for bug 19966 (1.34 KB, patch)
2018-05-04 12:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add correct unit tests (5.23 KB, patch)
2018-05-04 12:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Fix capitalization of notice titles (2.74 KB, patch)
2018-05-04 12:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add non-english notices (25.36 KB, patch)
2018-05-04 12:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191: Add syspref to control use of email receipts, defaulting to disabled (7.48 KB, patch)
2018-05-04 12:21 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191 [QA Followup] - Remove double fetches from database (4.02 KB, patch)
2018-05-04 19:18 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 19191 [QA Followup]: Remove double fetches from database (4.02 KB, patch)
2018-05-07 15:07 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2017-08-28 14:28:25 UTC
Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.
Comment 1 Kyle M Hall 2017-08-28 14:33:31 UTC
Created attachment 66554 [details] [review]
Bug 19191 - Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Run updatedatabase.pl
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron
Comment 2 Kyle M Hall 2017-08-28 14:36:50 UTC
This patch also introduces a new method of passing objects directly through to the notice template without processing. This is incredibly efficient for notices that only support Template Toolkit syntax, as it does not require refetching the data from the database multiple times as the existing parameters may.
Comment 3 Simon Pouchol 2017-10-20 14:44:28 UTC
Hey,
I tried to test this patch, and couldn't apply it (Dependency patch 14826 applied just fine):

Applying: Bug 19191 - Add ability to email receipts for account payments and write-offs
Using index info to reconstruct a base tree...
M	C4/Letters.pm
M	Koha/Account/Offset.pm
M	t/db_dependent/Letters/TemplateToolkit.t
Falling back to patching base and 3-way merge...
Auto-merging t/db_dependent/Letters/TemplateToolkit.t
Auto-merging Koha/Account/Offset.pm
CONFLICT (content): Merge conflict in Koha/Account/Offset.pm
Auto-merging C4/Letters.pm
error: Failed to merge in the changes.
Patch failed at 0001 Bug 19191 - Add ability to email receipts for account payments and write-offs
Comment 4 Josef Moravec 2017-10-23 23:05:07 UTC
Kyle, thanks for this nice feature, just couple of thoughts:

> 2) Run updatedatabase.pl

You probably forget to add atomic update file - there is just sample_notices.sql addition


Will it be possible to NOT to send e-mail about payment? Let's say configurable for patrons or patron categories? Somehow similire to current "Enhanced Messaging" feature?
Comment 5 Kyle M Hall 2017-10-26 13:17:23 UTC
Created attachment 68605 [details] [review]
Bug 19191 - Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Run updatedatabase.pl
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron
Comment 6 Kyle M Hall 2017-10-26 13:19:01 UTC
(In reply to Josef Moravec from comment #4)
> Kyle, thanks for this nice feature, just couple of thoughts:
> 
> > 2) Run updatedatabase.pl
>
> You probably forget to add atomic update file - there is just
> sample_notices.sql addition

Good catch!
 
> Will it be possible to NOT to send e-mail about payment? Let's say
> configurable for patrons or patron categories? Somehow similire to current
> "Enhanced Messaging" feature?

That would be an excellent followup feature, but is outside the scope of this particular work. I'd love to see it! For now the feature can be turned on and off for each notice by simply having the notice exist or not.
Comment 7 Josef Moravec 2017-10-29 20:28:46 UTC
Created attachment 68812 [details] [review]
Bug 19191 - Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Run updatedatabase.pl
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 8 Kyle M Hall 2018-01-12 12:20:43 UTC
Created attachment 70465 [details] [review]
Bug 19191 [QA Followup] - Remove db update so feature is disabled by default for existing installations
Comment 9 Kyle M Hall 2018-01-12 12:23:19 UTC
Created attachment 70466 [details] [review]
Bug 19191 [QA Followup] - Remove db update so feature is disabled by default for existing installations
Comment 10 Kyle M Hall 2018-01-12 15:49:29 UTC
Created attachment 70471 [details] [review]
Bug 19191 - Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 11 Katrin Fischer 2018-02-17 23:12:44 UTC
BLOCKED by bug 19966 still needing a sign-off!
Comment 12 Kyle M Hall 2018-03-02 15:04:56 UTC
Created attachment 72366 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 13 Kyle M Hall 2018-03-02 15:05:04 UTC
Created attachment 72367 [details] [review]
Bug 19191: Remove need for bug 19966
Comment 14 Kyle M Hall 2018-03-02 15:30:37 UTC
Created attachment 72370 [details] [review]
Bug 19191: Remove need for bug 19966
Comment 15 Katrin Fischer 2018-04-10 06:16:13 UTC
Needs a real quick rebase!
Comment 16 Katrin Fischer 2018-04-10 06:20:13 UTC
We'll also need a follow up to include the new sample notices in the the translated web installers and in a database update!
Comment 17 Kyle M Hall 2018-04-10 12:33:25 UTC
Created attachment 73924 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 18 Katrin Fischer 2018-04-11 06:23:16 UTC
Continuing here, sample notices can be fixed once the base patch passes.
Comment 19 Katrin Fischer 2018-04-11 06:31:53 UTC
Question:
- How can you control the sending of the emails? (delete the notices?)

To fix after initial testing is finished:
- Fix capitalization on notice templates: Account Writeoff, Account Payment
- Add database update
- Add notices to other installers
Comment 20 Katrin Fischer 2018-04-12 12:47:21 UTC
Continuing here.
Comment 21 Kyle M Hall 2018-04-12 13:25:13 UTC
(In reply to Katrin Fischer from comment #19)
> Question:
> - How can you control the sending of the emails? (delete the notices?)

Yes, removing the notice disables the feature.
Comment 22 Katrin Fischer 2018-04-12 13:36:43 UTC
Ok, big problem:
- notice templates are there
- homebranch library has an email
- patron has an email
But no notice is generated on paying/writing off.
 
> To fix after initial testing is finished:
> - Fix capitalization on notice templates: Account Writeoff, Account Payment
> - Add database update
> - Add notices to other installers

Maybe related:

ERROR: nothing to substitute - both 'tables', 'loops' and 'substitute' are empty at /home/vagrant/kohaclone/Koha/Account.pm line 265.
Use of uninitialized value in string eq at /home/vagrant/kohaclone/members/paycollect.pl line 194.
Use of uninitialized value in string eq at /home/vagrant/kohaclone/members/pay.pl line 224.

Please fix all notes in one patch (installers now too, notices are ok afaikt if they work ;) )
Comment 23 Kyle M Hall 2018-04-12 13:37:37 UTC
Created attachment 74092 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 24 Kyle M Hall 2018-04-12 13:40:25 UTC
Created attachment 74093 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 25 Kyle M Hall 2018-04-12 13:40:42 UTC
Created attachment 74094 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 26 Kyle M Hall 2018-04-12 13:40:49 UTC
Created attachment 74095 [details] [review]
Bug 19191: Remove need for bug 19966
Comment 27 Kyle M Hall 2018-04-12 14:11:23 UTC
Created attachment 74104 [details] [review]
Bug 19191: Add correct unit tests
Comment 28 Kyle M Hall 2018-04-12 14:13:43 UTC
Created attachment 74105 [details] [review]
Bug 19191: Add correct unit tests
Comment 29 Katrin Fischer 2018-04-15 22:09:14 UTC
Hi Kyle, 

it works now!

Can you please fix the remaining issues in a follow-up?

- Fix capitalization on notice templates: Account Writeoff, Account Payment
- Add notices to other installers
Comment 30 Kyle M Hall 2018-04-18 11:23:20 UTC
Created attachment 74423 [details] [review]
Bug 19191: Fix capitalization of notice titles
Comment 31 Kyle M Hall 2018-04-18 11:23:28 UTC
Created attachment 74424 [details] [review]
Bug 19191: Add non-english notices
Comment 32 Katrin Fischer 2018-04-18 12:32:59 UTC
Hi Kyle, didn't sign them yet, will check the follow-up tonight!
Comment 33 Kyle M Hall 2018-04-18 13:58:12 UTC
(In reply to Katrin Fischer from comment #32)
> Hi Kyle, didn't sign them yet, will check the follow-up tonight!

My bad! Thanks!
Comment 34 Katrin Fischer 2018-04-18 21:47:38 UTC
Created attachment 74504 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 35 Katrin Fischer 2018-04-18 21:47:42 UTC
Created attachment 74505 [details] [review]
Bug 19191: Remove need for bug 19966

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 36 Katrin Fischer 2018-04-18 21:47:46 UTC
Created attachment 74506 [details] [review]
Bug 19191: Add correct unit tests

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 37 Katrin Fischer 2018-04-18 21:47:50 UTC
Created attachment 74507 [details] [review]
Bug 19191: Fix capitalization of notice titles

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 38 Katrin Fischer 2018-04-18 21:47:55 UTC
Created attachment 74508 [details] [review]
Bug 19191: Add non-english notices

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 39 Katrin Fischer 2018-04-18 21:59:06 UTC
Puh, ok, I found a problem: When we push this as is, we will immediately start sending out payment and writeoff notices after update. Libraries might not expect that to happen and it smells trouble, especially since you'd want to translate/adapt the notice. I think the easisest solution would be to not add them with a database update.

We could put the sample notices on a wiki page instead, so people can easily add them. Or into the manual.

Or: We could add a system preference to determine when to send them.
Comment 40 Kyle M Hall 2018-04-20 12:43:30 UTC
Created attachment 74625 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 41 Kyle M Hall 2018-04-20 12:43:48 UTC
Created attachment 74626 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 42 Kyle M Hall 2018-04-20 12:43:55 UTC
Created attachment 74627 [details] [review]
Bug 19191: Remove need for bug 19966

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 43 Kyle M Hall 2018-04-20 12:43:59 UTC
Created attachment 74628 [details] [review]
Bug 19191: Add correct unit tests

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 44 Kyle M Hall 2018-04-20 12:44:03 UTC
Created attachment 74629 [details] [review]
Bug 19191: Fix capitalization of notice titles

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 45 Kyle M Hall 2018-04-20 12:44:07 UTC
Created attachment 74630 [details] [review]
Bug 19191: Add non-english notices

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 46 Kyle M Hall 2018-04-20 12:44:10 UTC
Created attachment 74631 [details] [review]
Bug 19191: Add syspref to control use of email receipts, defaulting to disabled
Comment 47 Katrin Fischer 2018-04-21 10:54:40 UTC
Created attachment 74686 [details] [review]
Bug 19191: Add syspref to control use of email receipts, defaulting to disabled

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 48 Jonathan Druart 2018-05-03 15:49:55 UTC
Please rebase
CONFLICT (content): Merge conflict in t/db_dependent/Accounts.t
CONFLICT (content): Merge conflict in Koha/Account/Offset.pm
Comment 49 Kyle M Hall 2018-05-04 12:20:15 UTC
Created attachment 75066 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 50 Kyle M Hall 2018-05-04 12:20:36 UTC
Created attachment 75067 [details] [review]
Bug 19191: Add ability to email receipts for account payments and write-offs

Some libraries are paperless and require all payment receipts to be emailed. Koha should give libraries the option to send email receipts if a patron has an email address. If a notice for the type of "credit" exists ( payment or writeoff ), then an email receipt will be sent.

These notices only support Template Toolkit syntax.

Test Plan:
1) Apply this patch and dependencies
2) Add the two new notices, you can find them in installer/data/mysql/en/mandatory/sample_notices.sql
3) Note two new notices exist in the notices editor, ACCOUNT_PAYMENT and ACCOUNT_WRITEOFF
4) Find or create a patron with an email address that owes some amount of money
5) Make a payment for one or more fees
6) Note a new email is queued for the patron
7) Make a writeoff for one or more fees
8) Note a new new email is queued for the patron

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 51 Kyle M Hall 2018-05-04 12:20:45 UTC
Created attachment 75068 [details] [review]
Bug 19191: Remove need for bug 19966

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 52 Kyle M Hall 2018-05-04 12:20:50 UTC
Created attachment 75069 [details] [review]
Bug 19191: Add correct unit tests

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 53 Kyle M Hall 2018-05-04 12:20:54 UTC
Created attachment 75070 [details] [review]
Bug 19191: Fix capitalization of notice titles

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 54 Kyle M Hall 2018-05-04 12:20:59 UTC
Created attachment 75071 [details] [review]
Bug 19191: Add non-english notices

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 55 Kyle M Hall 2018-05-04 12:21:04 UTC
Created attachment 75072 [details] [review]
Bug 19191: Add syspref to control use of email receipts, defaulting to disabled

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 56 Jonathan Druart 2018-05-04 13:18:12 UTC
1. There is 'Account Writeoff' vs 'Account writeoff'

2. In Koha::Account->pay, why require C4::Letters; instead of use?

3. Koha/Account.pm:273
  lang    => Koha::Patrons->find( $self->{patron_id} )->lang,
No need to refetch the patron object, you did it already at the beginning of the method.

4. Koha/Account.pm:280
  offsets => scalar Koha::Account::Offsets->search( { id => { -in => [ map { $_->id } @account_offsets ] } } ),

I do not understand this line, we are refetching what we already have?
Comment 57 Kyle M Hall 2018-05-04 19:18:12 UTC
Created attachment 75093 [details] [review]
Bug 19191 [QA Followup] - Remove double fetches from database
Comment 58 Kyle M Hall 2018-05-04 19:19:51 UTC
(In reply to Jonathan Druart from comment #56)
> 1. There is 'Account Writeoff' vs 'Account writeoff'
> 
> 2. In Koha::Account->pay, why require C4::Letters; instead of use?
> 
> 3. Koha/Account.pm:273
>   lang    => Koha::Patrons->find( $self->{patron_id} )->lang,
> No need to refetch the patron object, you did it already at the beginning of
> the method.
> 
> 4. Koha/Account.pm:280
>   offsets => scalar Koha::Account::Offsets->search( { id => { -in => [ map {
> $_->id } @account_offsets ] } } ),
> 
> I do not understand this line, we are refetching what we already have?

Follow addresses everything but 2. I used require instead of use because use is hoisted and it would import it even if the feature is not being used. Basically it's a small efficiency improvement.
Comment 59 Jonathan Druart 2018-05-07 14:03:39 UTC
(In reply to Kyle M Hall from comment #58)
> (In reply to Jonathan Druart from comment #56)
> > 1. There is 'Account Writeoff' vs 'Account writeoff'
> > 
> > 2. In Koha::Account->pay, why require C4::Letters; instead of use?
> > 
> > 3. Koha/Account.pm:273
> >   lang    => Koha::Patrons->find( $self->{patron_id} )->lang,
> > No need to refetch the patron object, you did it already at the beginning of
> > the method.
> > 
> > 4. Koha/Account.pm:280
> >   offsets => scalar Koha::Account::Offsets->search( { id => { -in => [ map {
> > $_->id } @account_offsets ] } } ),
> > 
> > I do not understand this line, we are refetching what we already have?
> 
> Follow addresses everything but 2. I used require instead of use because use
> is hoisted and it would import it even if the feature is not being used.
> Basically it's a small efficiency improvement.

It's usually a bad idea to require instead of use, to catch errors at compilation time.
It's too late for 18.05 so I will let next RM decides.

Moreover the title of the last patch is not formatted correctly.
Comment 60 Kyle M Hall 2018-05-07 15:07:36 UTC
Created attachment 75134 [details] [review]
Bug 19191 [QA Followup]: Remove double fetches from database
Comment 61 Tomás Cohen Arazi 2018-07-23 14:11:47 UTC
(In reply to Jonathan Druart from comment #59)
> (In reply to Kyle M Hall from comment #58)
> > (In reply to Jonathan Druart from comment #56)
> > > 1. There is 'Account Writeoff' vs 'Account writeoff'
> > > 
> > > 2. In Koha::Account->pay, why require C4::Letters; instead of use?
> > > 
> > > 3. Koha/Account.pm:273
> > >   lang    => Koha::Patrons->find( $self->{patron_id} )->lang,
> > > No need to refetch the patron object, you did it already at the beginning of
> > > the method.
> > > 
> > > 4. Koha/Account.pm:280
> > >   offsets => scalar Koha::Account::Offsets->search( { id => { -in => [ map {
> > > $_->id } @account_offsets ] } } ),
> > > 
> > > I do not understand this line, we are refetching what we already have?
> > 
> > Follow addresses everything but 2. I used require instead of use because use
> > is hoisted and it would import it even if the feature is not being used.
> > Basically it's a small efficiency improvement.
> 
> It's usually a bad idea to require instead of use, to catch errors at
> compilation time.
> It's too late for 18.05 so I will let next RM decides.
> 
> Moreover the title of the last patch is not formatted correctly.

We already load C4::Letters in plack.psgi anyway. I agree with Jonathan it is better to use the lib, to catch problems in compilation time.
Comment 62 Nick Clemens 2018-07-23 15:37:57 UTC
Awesome work all!

Pushed to master for 18.11
Comment 63 Martin Renvoize 2018-08-02 14:23:50 UTC
Enhancement, will not be backported to 18.05.x series.
Comment 64 Jonathan Druart 2018-09-21 20:54:29 UTC
(In reply to Jonathan Druart from comment #59)
> It's usually a bad idea to require instead of use, to catch errors at
> compilation time.

See bug 21396.
Comment 65 Katrin Fischer 2018-11-10 10:14:28 UTC
This might be a nice candidate for 'new'.
Comment 66 Katrin Fischer 2019-01-03 12:48:41 UTC
*** Bug 13842 has been marked as a duplicate of this bug. ***