Bugzilla – Attachment 121764 Details for
Bug 22435
Clarify account_offset types by converting them to clear codes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22435: Fix _set_found_trigger
Bug-22435-Fix-setfoundtrigger.patch (text/plain), 4.28 KB, created by
Martin Renvoize (ashimema)
on 2021-06-10 11:09:46 UTC
(
hide
)
Description:
Bug 22435: Fix _set_found_trigger
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-06-10 11:09:46 UTC
Size:
4.28 KB
patch
obsolete
>From ffd75c2cd3dd9a88791ff74f09db333d7dbd7c47 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 14 May 2021 14:04:35 +0100 >Subject: [PATCH] Bug 22435: Fix _set_found_trigger > >The _set_found_trigger utilised the 'Writeoff' offset type to >distinguish between the application of a writeoff and any other form of >offset application. > >This patch updates the trigger to use the full link through from offset >to account credit line to get the credit type being offset. > >Test plan >1/ Run t/db_dependent/Koha/Items.t and prove it fails before the patch, >but passes after applying this patch. >2/ Run t/db_dependent/Koha/Account/Offsets.t and prove it passes both >before and after applying this patch. >--- > Koha/Account/Line.pm | 8 ++++---- > Koha/Account/Offsets.pm | 2 +- > Koha/Item.pm | 15 +++++++-------- > t/db_dependent/Koha/Account/Offsets.t | 2 +- > 4 files changed, 13 insertions(+), 14 deletions(-) > >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index c1f0613dc0..1d91cef2f7 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -132,8 +132,8 @@ Return the credit_offsets linked to this account line if some exist > =cut > > sub credit_offsets { >- my ( $self ) = @_; >- my $rs = $self->_result->account_offsets_credits; >+ my ( $self, $cond, $attr ) = @_; >+ my $rs = $self->_result->search_related( 'account_offsets_credits', $cond, $attr); > return unless $rs; > return Koha::Account::Offsets->_new_from_dbic($rs); > } >@@ -145,8 +145,8 @@ Return the debit_offsets linked to this account line if some exist > =cut > > sub debit_offsets { >- my ( $self ) = @_; >- my $rs = $self->_result->account_offsets_debits; >+ my ( $self, $cond, $attr ) = @_; >+ my $rs = $self->_result->search_related( 'account_offsets_debits', $cond, $attr); > return unless $rs; > return Koha::Account::Offsets->_new_from_dbic($rs); > } >diff --git a/Koha/Account/Offsets.pm b/Koha/Account/Offsets.pm >index 0083f0d3ab..0e6971ff57 100644 >--- a/Koha/Account/Offsets.pm >+++ b/Koha/Account/Offsets.pm >@@ -51,7 +51,7 @@ sub total { > my $offsets = $self->search( > {}, > { >- select => [ { sum => 'amount' } ], >+ select => [ { sum => 'me.amount' } ], > as => ['total_amount'], > } > ); >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 2bad020287..de0fb17fce 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1006,17 +1006,16 @@ sub _set_found_trigger { > # some amount has been cancelled. collect the offsets that are not writeoffs > # this works because the only way to subtract from this kind of a debt is > # using the UI buttons 'Pay' and 'Write off' >- my $credits_offsets = Koha::Account::Offsets->search( >+ my $credit_offsets = $lost_charge->debit_offsets( > { >- debit_id => $lost_charge->id, >- credit_id => { '!=' => undef }, # it is not the debit itself >- type => { '!=' => 'Writeoff' }, >- amount => { '<' => 0 } # credits are negative on the DB >- } >+ 'credit_id' => { '!=' => undef }, >+ 'credit.credit_type_code' => { '!=' => 'Writeoff' } >+ }, >+ { join => 'credit' } > ); > >- $total_to_refund = ( $credits_offsets->count > 0 ) >- ? $credits_offsets->total * -1 # credits are negative on the DB >+ $total_to_refund = ( $credit_offsets->count > 0 ) >+ ? $credit_offsets->total * -1 # credits are negative on the DB > : 0; > } > >diff --git a/t/db_dependent/Koha/Account/Offsets.t b/t/db_dependent/Koha/Account/Offsets.t >index 7e5e33f44b..cc271b5086 100755 >--- a/t/db_dependent/Koha/Account/Offsets.t >+++ b/t/db_dependent/Koha/Account/Offsets.t >@@ -29,7 +29,7 @@ use t::lib::TestBuilder; > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >-subtest 'total_outstanding() tests' => sub { >+subtest 'total() tests' => sub { > > plan tests => 4; > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22435
:
118340
|
118341
|
118541
|
118542
|
118543
|
118544
|
118545
|
118546
|
118547
|
120040
|
120041
|
120042
|
120043
|
120044
|
120045
|
120046
|
120963
|
120964
|
120965
|
120966
|
120967
|
120968
|
120969
|
120970
|
120979
|
120980
|
120981
|
120982
|
120983
|
120984
|
120985
|
120986
|
120987
|
120988
|
120989
|
120990
|
120991
|
121004
|
121005
|
121006
|
121007
|
121008
|
121009
|
121010
|
121011
|
121012
|
121013
|
121014
|
121015
|
121016
|
121028
|
121757
|
121758
|
121759
|
121760
|
121761
|
121762
|
121763
|
121764
|
121765
|
121766
|
121767
|
121768
|
121769
|
121960
|
121961
|
121962
|
121963
|
121964
|
121965
|
121966
|
121967
|
121968
|
121969
|
121970
|
121971
|
121972
|
122148
|
122149
|
122150
|
122151
|
122152
|
122153
|
122154
|
122155
|
122156
|
122157
|
122158
|
122159
|
122160
|
122161
|
122235
|
122236
|
122237
|
122238
|
122239
|
122240
|
122241
|
122242
|
122243
|
122244
|
122245
|
122246
|
122247
|
122248
|
122249
|
122250
|
122251
|
122252
|
122253
|
122256
|
122257
|
122258
|
122259
|
122260
|
122261
|
122262
|
122263
|
122264
|
122265
|
122266
|
122267
|
122268
|
122269
|
122270
|
122271
|
122272
|
122273
|
122274
|
122553
|
122554
|
122555
|
122556
|
122557
|
122558
|
122559
|
122560
|
122561
|
122562
|
122563
|
122564
|
122565
|
122566
|
122567
|
122568
|
122569
|
122570
|
122571
|
122586
|
122899
|
122900
|
122901
|
122902
|
122903
|
122904
|
122905
|
122906
|
122907
|
122908
|
122909
|
122910
|
122911
|
122912
|
122913
|
122914
|
122915
|
122916
|
122917
|
122918
|
122937
|
123423
|
123424
|
123425
|
123426
|
123427
|
123428
|
123429
|
123430
|
123431
|
123432
|
123433
|
123434
|
123435
|
123436
|
123437
|
123438
|
123439
|
123440
|
123441
|
123442
|
123443