[Bug 42425] New: Add checkin_id FK to accountlines to link fee adjustments to checkin events
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 Bug ID: 42425 Summary: Add checkin_id FK to accountlines to link fee adjustments to checkin events Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org Depends on: 42418 Blocks: 24401 When AddReturn processes a checkin, it may create or modify several accountlines (lost item fee refunds/charges, processing fee refunds, etc.). Currently these fee adjustments have no persistent link back to the checkin event that triggered them. Bug 42418 introduced the checkins table as a first-class resource. Adding a checkin_id FK to accountlines would: - Allow Koha::Checkin->account_lines as a proper relationship - Enable embedding account_lines in the checkin REST API response (bug 24401) - Provide an audit trail linking financial transactions to the specific checkin that caused them - Eliminate the need to infer fee changes from timestamps or $messages parsing Implementation notes: - Add checkin_id INT(11) DEFAULT NULL to accountlines with FK to checkins.checkin_id ON DELETE SET NULL - Update AddReturn to pass the checkin_id when creating/modifying accountlines during return processing - The relevant C4::Circulation code paths are: _FixAccountForLostAndFound, _FixOverduesOnReturn, and the lost item fee charge logic Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24401 [Bug 24401] REST API: Check-in https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42418 [Bug 42418] Add Koha::Checkin(s) - checkin as a first-class resource -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | Patch complexity|--- |Small patch Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #1 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198235 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198235&action=edit Bug 42425: DB changes Adds a checkin_id column to accountlines so fee adjustments created during a checkin (lost item refunds, overdue fine updates, processing fee refunds) can be linked back to the specific checkin event. - checkin_id INT(11) DEFAULT NULL, FK ON DELETE SET NULL - Links existing accountlines to checkin records via old_issue_id -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #2 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198236 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198236&action=edit Bug 42425: DBIC schema changes [DO NOT PUSH] Adds checkin belongs_to relationship on Accountline and accountlines has_many relationship on Checkin. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #3 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198237 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198237&action=edit Bug 42425: Populate checkin_id on accountlines Creates the Koha::Checkin record early in AddReturn (before fee processing) so checkin_id is available, then updates it with outcomes after processing completes. Links accountlines created during the checkin by matching borrower, item, and timestamp. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #4 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198238 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198238&action=edit Bug 42425: Add accountlines, debits and credits accessors Adds filtered DBIC relationships (debits, credits) on Koha::Schema::Result::Checkin for API embedding support, and corresponding Koha::Checkin accessors (accountlines, debits, credits). -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #5 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Comment on attachment 198237 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198237 Bug 42425: Populate checkin_id on accountlines Review of attachment 198237: --> (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=42425&attachment=198237) ----------------------------------------------------------------- ::: C4/Circulation.pm @@ +2857,5 @@
+ { + borrowernumber => $borrowernumber, + itemnumber => $item->itemnumber, + checkin_id => undef, + date => { '>=' => $checkin_record->timestamp },
Is this reliable? This assumes all the related accountlines will be created on the exact same tick as the checkin record. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198235|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198236|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198237|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198238|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #6 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198562 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198562&action=edit Bug 42425: DB changes Adds a checkin_id column to accountlines so fee adjustments created during a checkin can be linked back to the specific checkin event. - checkin_id INT(11) DEFAULT NULL, FK ON DELETE SET NULL ON UPDATE CASCADE - Backfills existing accountlines via old_issue_id join to checkins -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #7 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198563 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198563&action=edit Bug 42425: DBIC schema changes [DO NOT PUSH] Patch from commit 5034c2d -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #8 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198564 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198564&action=edit Bug 42425: Add debits and credits accessors Adds filtered DBIC relationships (debits, credits) on Koha::Schema::Result::Checkin for API embedding support, and corresponding Koha::Checkin accessors. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Checkin.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #9 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 198565 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198565&action=edit Bug 42425: Populate checkin_id on accountlines Replaces the fragile timestamp-based matching approach with explicit checkin_id threading through the call chain. Each accountline receives its checkin_id at creation time. The Koha::Item->store() chokepoint for lost-item accounting is preserved: store() still detects itemlost transitions and calls _set_found_trigger. It now passes checkin_id context through so the resulting accountlines are linked deterministically. Changes: - Koha::Account->add_credit/add_debit: accept and store checkin_id - Koha::Item->store/_set_found_trigger: thread checkin_id to LOST_FOUND and PROCESSING_FOUND credits - C4::Items::ModDateLastSeen: pass checkin_id to store() - C4::Circulation::_FixOverduesOnReturn: accept checkin_id, pass to FORGIVEN credit - C4::Circulation::_CalculateAndUpdateFine: pass checkin_id to UpdateFine - C4::Overdues::UpdateFine: pass checkin_id to add_debit - C4::Circulation::AddReturn: pass checkin_record->id to all callers; remove timestamp-based matching block Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t => SUCCESS: Tests pass! 3. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198562|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198563|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198564|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198565|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #10 from David Nind <david@davidnind.com> --- Created attachment 198720 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198720&action=edit Bug 42425: DB changes Adds a checkin_id column to accountlines so fee adjustments created during a checkin can be linked back to the specific checkin event. - checkin_id INT(11) DEFAULT NULL, FK ON DELETE SET NULL ON UPDATE CASCADE - Backfills existing accountlines via old_issue_id join to checkins Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #11 from David Nind <david@davidnind.com> --- Created attachment 198721 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198721&action=edit Bug 42425: DBIC schema changes [DO NOT PUSH] Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #12 from David Nind <david@davidnind.com> --- Created attachment 198722 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198722&action=edit Bug 42425: Add debits and credits accessors Adds filtered DBIC relationships (debits, credits) on Koha::Schema::Result::Checkin for API embedding support, and corresponding Koha::Checkin accessors. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Checkin.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42425 --- Comment #13 from David Nind <david@davidnind.com> --- Created attachment 198723 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198723&action=edit Bug 42425: Populate checkin_id on accountlines Replaces the fragile timestamp-based matching approach with explicit checkin_id threading through the call chain. Each accountline receives its checkin_id at creation time. The Koha::Item->store() chokepoint for lost-item accounting is preserved: store() still detects itemlost transitions and calls _set_found_trigger. It now passes checkin_id context through so the resulting accountlines are linked deterministically. Changes: - Koha::Account->add_credit/add_debit: accept and store checkin_id - Koha::Item->store/_set_found_trigger: thread checkin_id to LOST_FOUND and PROCESSING_FOUND credits - C4::Items::ModDateLastSeen: pass checkin_id to store() - C4::Circulation::_FixOverduesOnReturn: accept checkin_id, pass to FORGIVEN credit - C4::Circulation::_CalculateAndUpdateFine: pass checkin_id to UpdateFine - C4::Overdues::UpdateFine: pass checkin_id to add_debit - C4::Circulation::AddReturn: pass checkin_record->id to all callers; remove timestamp-based matching block Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Circulation.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org