writeoff_debts.pl currently supports --added_before to make it work on fines added before a given date. It would be nice if we could also tell it to work on fines added after a given date, with --added_after.
Created attachment 127463 [details] [review] Bug 28995: Add `--added_after` filter to writeoff_debts script This adds, as requested, the `added_after` filter option to writeoff_debts.
Options should be named --added-before and --added-after (_vs -)
Created attachment 127624 [details] [review] Bug 28995: Add `--added_after` filter to writeoff_debts script This adds, as requested, the `added_after` filter option to writeoff_debts.
Created attachment 127625 [details] [review] Bug 28995: Update aliases Add an alias for added-before, added-after (Using an alias makes it backwards compatible) and update the POD.
Fair.. follow-up added.. I kept it backward compatible with the _ notation as I believe there may be uses already int the wild.
Martin, this still applies cleanly and seems to work for me. Do you have a test plan so I can sign it off?
Hmm, I was hoping Magnus would SO as he asked for the feature.. From memory, it would be to add some debts to a patron record.. adapt the `date` (i.e when the charge was added) field of those charges to a date in the past and then run this script with the --added_after option with a date after the date you just set and check the lines remain unchanged.. then run again passing a date before the date you added above and this time the lines should have been written off.
Created attachment 152520 [details] [review] Bug 28995: Add `--added_after` filter to writeoff_debts script This adds, as requested, the `added_after` filter option to writeoff_debts. Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Created attachment 152521 [details] [review] Bug 28995: Update aliases Add an alias for added-before, added-after (Using an alias makes it backwards compatible) and update the POD. Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
I wrote what I did as a test plan, I hope it helps 1. Add two fees in a patron account 1.1. Go into a patron record > Accounting tab 1.2. Go to the Create a manual invoice tab 1.3. Fill out the form 1.4. Click 'Save' 1.5. Redo steps 1.2 to 1.4 to add a second fee 2. Manually change the date in the database 2.1. In the database, find the accountlines_id for the two fees Here's what I did select * from accountlines where borrowernumber = 21 and amountoutstanding > 0; +-----------------+----------+----------------+------------+---------------------+-----------+-------------+------------------+-----------------+---------------+--------+--------------+-------------------+---------------------+------+------------+-------------+-----------+------------+ | accountlines_id | issue_id | borrowernumber | itemnumber | date | amount | description | credit_type_code | debit_type_code | credit_number | status | payment_type | amountoutstanding | timestamp | note | manager_id | register_id | interface | branchcode | +-----------------+----------+----------------+------------+---------------------+-----------+-------------+------------------+-----------------+---------------+--------+--------------+-------------------+---------------------+------+------------+-------------+-----------+------------+ | 652 | NULL | 21 | NULL | 2023-06-21 09:34:05 | 10.000000 | Lost item | NULL | LOST | NULL | NULL | NULL | 10.000000 | 2023-06-21 09:34:05 | | 51 | NULL | intranet | CPL | | 653 | NULL | 21 | NULL | 2023-06-21 09:35:44 | 2.000000 | Lost item | NULL | LOST | NULL | NULL | NULL | 2.000000 | 2023-06-21 09:35:44 | | 51 | NULL | intranet | CPL | +-----------------+----------+----------------+------------+---------------------+-----------+-------------+------------------+-----------------+---------------+--------+--------------+-------------------+---------------------+------+------------+-------------+-----------+------------+ 2 rows in set (0.001 sec) select * from account_offsets where debit_id = '652'; +-----+-----------+----------+--------+-----------+---------------------+ | id | credit_id | debit_id | type | amount | created_on | +-----+-----------+----------+--------+-----------+---------------------+ | 799 | NULL | 652 | CREATE | 10.000000 | 2023-06-21 09:34:05 | +-----+-----------+----------+--------+-----------+---------------------+ 1 row in set (0.001 sec) 2.2. Update the date for one of the fees using the accountlines_id Here's what I did update accountlines set date = '2023-06-01 09:34:05' where accountlines_id = 652; update account_offsets set created_on = '2023-06-01 09:34:05' where debit_id = '652'; I now have one fee on June 1st and one fee on June 21st, the account_offset is also modified (not sure if that last part is necessary). select * from accountlines where borrowernumber = 21 and amountoutstanding > 0; +-----------------+----------+----------------+------------+---------------------+-----------+-------------+------------------+-----------------+---------------+--------+--------------+-------------------+---------------------+------+------------+-------------+-----------+------------+ | accountlines_id | issue_id | borrowernumber | itemnumber | date | amount | description | credit_type_code | debit_type_code | credit_number | status | payment_type | amountoutstanding | timestamp | note | manager_id | register_id | interface | branchcode | +-----------------+----------+----------------+------------+---------------------+-----------+-------------+------------------+-----------------+---------------+--------+--------------+-------------------+---------------------+------+------------+-------------+-----------+------------+ | 652 | NULL | 21 | NULL | 2023-06-01 09:34:05 | 10.000000 | Lost item | NULL | LOST | NULL | NULL | NULL | 10.000000 | 2023-06-21 09:40:46 | | 51 | NULL | intranet | CPL | | 653 | NULL | 21 | NULL | 2023-06-21 09:35:44 | 2.000000 | Lost item | NULL | LOST | NULL | NULL | NULL | 2.000000 | 2023-06-21 09:35:44 | | 51 | NULL | intranet | CPL | +-----------------+----------+----------------+------------+---------------------+-----------+-------------+------------------+-----------------+---------------+--------+--------------+-------------------+---------------------+------+------------+-------------+-----------+------------+ 2 rows in set (0.001 sec) select * from account_offsets where debit_id = '652'; +-----+-----------+----------+--------+-----------+---------------------+ | id | credit_id | debit_id | type | amount | created_on | +-----+-----------+----------+--------+-----------+---------------------+ | 799 | NULL | 652 | CREATE | 10.000000 | 2023-06-01 09:34:05 | +-----+-----------+----------+--------+-----------+---------------------+ 1 row in set (0.001 sec) 3. Run writeoff_debts.pl with --added_after with a date after the first fee but before the second 3.1. In the terminal, run (for example) ./misc/cronjobs/writeoff_debts.pl --added_after 2023-06-20 --confirm 4. Check the patron record --> The fee with the date after should be written off
Looking here
Created attachment 155385 [details] [review] Bug 28995: Add `--added_after` filter to writeoff_debts script This adds, as requested, the `added_after` filter option to writeoff_debts. Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 155386 [details] [review] Bug 28995: Update aliases Add an alias for added-before, added-after (Using an alias makes it backwards compatible) and update the POD. Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
- print " added before " . $added if $added; + print " added before " . $before if $before; Nothing about after here? No blocker
Pushed to master for 23.11. Nice work everyone, thanks!
Small nice enhancement. I think it is safe to backport. Pushed to 23.05.x for 23.05.04
Enhancement - not backporting to 22.11.x Nice work everyone!