View | Details | Raw Unified | Return to bug 29754
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Patron.t (-5 / +6 lines)
Lines 89-96 subtest 'relationships_debt() tests' => sub { Link Here
89
89
90
    my $parent_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 1" } });
90
    my $parent_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 1" } });
91
    my $parent_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 2" } });
91
    my $parent_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 2" } });
92
    my $child_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Child 1" } });
92
    my $child_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => " Child 1" } });
93
    my $child_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Child 2" } });
93
    my $child_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => " Child 2" } });
94
94
95
    $child_1->add_guarantor({ guarantor_id => $parent_1->borrowernumber, relationship => 'parent' });
95
    $child_1->add_guarantor({ guarantor_id => $parent_1->borrowernumber, relationship => 'parent' });
96
    $child_1->add_guarantor({ guarantor_id => $parent_2->borrowernumber, relationship => 'parent' });
96
    $child_1->add_guarantor({ guarantor_id => $parent_2->borrowernumber, relationship => 'parent' });
Lines 134-140 subtest 'relationships_debt() tests' => sub { Link Here
134
134
135
sub _test_combinations {
135
sub _test_combinations {
136
    my ( $patrons, $parent1_debt, $parent2_debt, $child1_debt, $child2_debt ) = @_;
136
    my ( $patrons, $parent1_debt, $parent2_debt, $child1_debt, $child2_debt ) = @_;
137
137
    diag("Testing with parent 1 debt $parent1_debt | Parent 2 debt $parent2_debt | Child 1 debt $child1_debt | Child 2 debt $child2_debt");
138
    # Options
138
    # Options
139
    # P1 => P1 + C1 + C2 ( - P1 ) ( + P2 )
139
    # P1 => P1 + C1 + C2 ( - P1 ) ( + P2 )
140
    # P2 => P2 + C1 + C2 ( - P2 ) ( + P1 )
140
    # P2 => P2 + C1 + C2 ( - P2 ) ( + P1 )
Lines 145-150 sub _test_combinations { Link Here
145
    for my $i ( 0 .. 7 ) {
145
    for my $i ( 0 .. 7 ) {
146
        my ( $only_this_guarantor, $include_guarantors, $include_this_patron )
146
        my ( $only_this_guarantor, $include_guarantors, $include_this_patron )
147
          = split '', sprintf( "%03b", $i );
147
          = split '', sprintf( "%03b", $i );
148
        diag("---------------------");
148
        for my $patron ( @$patrons ) {
149
        for my $patron ( @$patrons ) {
149
            if ( $only_this_guarantor
150
            if ( $only_this_guarantor
150
                && !$patron->guarantee_relationships->count )
151
                && !$patron->guarantee_relationships->count )
Lines 175-181 sub _test_combinations { Link Here
175
                    $debt += $child1_debt + $child2_debt;
176
                    $debt += $child1_debt + $child2_debt;
176
                    $debt += $parent1_debt unless ($only_this_guarantor || !$include_guarantors);
177
                    $debt += $parent1_debt unless ($only_this_guarantor || !$include_guarantors);
177
                }
178
                }
178
                elsif ( $patron->firstname eq 'Child 1' ) {
179
                elsif ( $patron->firstname eq ' Child 1' ) {
179
                    $debt += $child1_debt if ($include_this_patron);
180
                    $debt += $child1_debt if ($include_this_patron);
180
                    $debt += $child2_debt;
181
                    $debt += $child2_debt;
181
                    $debt += $parent1_debt + $parent2_debt if ($include_guarantors);
182
                    $debt += $parent1_debt + $parent2_debt if ($include_guarantors);
Lines 196-202 sub _test_combinations { Link Here
196
                    ),
197
                    ),
197
                    $debt,
198
                    $debt,
198
                    $patron->firstname
199
                    $patron->firstname
199
                      . " debt of $debt calculated correctly for ( only_this_guarantor: $only_this_guarantor, include_guarantors: $include_guarantors, include_this_patron: $include_this_patron)"
200
                      . " debt of " . sprintf('%02d',$debt) . " calculated correctly for ( only_this_guarantor: $only_this_guarantor, include_guarantors: $include_guarantors, include_this_patron: $include_this_patron)"
200
                );
201
                );
201
            }
202
            }
202
        }
203
        }
(-)a/t/db_dependent/SIP/Patron.t (-2 / +38 lines)
Lines 4-10 Link Here
4
# This needs to be extended! Your help is appreciated..
4
# This needs to be extended! Your help is appreciated..
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use Test::More tests => 8;
7
use Test::More tests => 9;
8
8
9
use t::lib::Mocks;
9
use t::lib::Mocks;
10
use t::lib::TestBuilder;
10
use t::lib::TestBuilder;
Lines 272-275 subtest "fine_items tests" => sub { Link Here
272
    is( @$fine_items, 0, "Got zero fine items" );
272
    is( @$fine_items, 0, "Got zero fine items" );
273
};
273
};
274
274
275
subtest "NoIssuesChargeGuarantorsWithGuarantees tests" => sub {
276
277
    plan tests => 1;
278
279
    t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' );
280
281
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
282
    my $child  = $builder->build_object({ class => 'Koha::Patrons' });
283
    $child->add_guarantor({ guarantor_id => $patron->borrowernumber, relationship => 'parent' });
284
285
    t::lib::Mocks::mock_preference('NoIssuesChargeGuarantorsWithGuarantees', 1);
286
287
    my $fee1 = $builder->build_object(
288
        {
289
            class => 'Koha::Account::Lines',
290
            value  => {
291
                borrowernumber => $patron->borrowernumber,
292
                amountoutstanding => 11,
293
            }
294
        }
295
    )->store;
296
297
    my $fee2 = $builder->build_object(
298
        {
299
            class => 'Koha::Account::Lines',
300
            value  => {
301
                borrowernumber => $child->borrowernumber,
302
                amountoutstanding => 0.11,
303
            }
304
        }
305
    )->store;
306
307
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
308
309
    is( $sip_patron->fines_amount, 11.11,"Guarantee fines correctly included");
310
311
};
275
$schema->storage->txn_rollback;
312
$schema->storage->txn_rollback;
276
- 

Return to bug 29754