Lines 90-97
subtest 'relationships_debt() tests' => sub {
Link Here
|
90 |
|
90 |
|
91 |
my $parent_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 1" } }); |
91 |
my $parent_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 1" } }); |
92 |
my $parent_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 2" } }); |
92 |
my $parent_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Parent 2" } }); |
93 |
my $child_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Child 1" } }); |
93 |
my $child_1 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => " Child 1" } }); |
94 |
my $child_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => "Child 2" } }); |
94 |
my $child_2 = $builder->build_object({ class => 'Koha::Patrons', value => { firstname => " Child 2" } }); |
95 |
|
95 |
|
96 |
$child_1->add_guarantor({ guarantor_id => $parent_1->borrowernumber, relationship => 'parent' }); |
96 |
$child_1->add_guarantor({ guarantor_id => $parent_1->borrowernumber, relationship => 'parent' }); |
97 |
$child_1->add_guarantor({ guarantor_id => $parent_2->borrowernumber, relationship => 'parent' }); |
97 |
$child_1->add_guarantor({ guarantor_id => $parent_2->borrowernumber, relationship => 'parent' }); |
Lines 135-141
subtest 'relationships_debt() tests' => sub {
Link Here
|
135 |
|
135 |
|
136 |
sub _test_combinations { |
136 |
sub _test_combinations { |
137 |
my ( $patrons, $parent1_debt, $parent2_debt, $child1_debt, $child2_debt ) = @_; |
137 |
my ( $patrons, $parent1_debt, $parent2_debt, $child1_debt, $child2_debt ) = @_; |
138 |
|
138 |
diag("Testing with parent 1 debt $parent1_debt | Parent 2 debt $parent2_debt | Child 1 debt $child1_debt | Child 2 debt $child2_debt"); |
139 |
# Options |
139 |
# Options |
140 |
# P1 => P1 + C1 + C2 ( - P1 ) ( + P2 ) |
140 |
# P1 => P1 + C1 + C2 ( - P1 ) ( + P2 ) |
141 |
# P2 => P2 + C1 + C2 ( - P2 ) ( + P1 ) |
141 |
# P2 => P2 + C1 + C2 ( - P2 ) ( + P1 ) |
Lines 146-151
sub _test_combinations {
Link Here
|
146 |
for my $i ( 0 .. 7 ) { |
146 |
for my $i ( 0 .. 7 ) { |
147 |
my ( $only_this_guarantor, $include_guarantors, $include_this_patron ) |
147 |
my ( $only_this_guarantor, $include_guarantors, $include_this_patron ) |
148 |
= split '', sprintf( "%03b", $i ); |
148 |
= split '', sprintf( "%03b", $i ); |
|
|
149 |
diag("---------------------"); |
149 |
for my $patron ( @$patrons ) { |
150 |
for my $patron ( @$patrons ) { |
150 |
if ( $only_this_guarantor |
151 |
if ( $only_this_guarantor |
151 |
&& !$patron->guarantee_relationships->count ) |
152 |
&& !$patron->guarantee_relationships->count ) |
Lines 176-182
sub _test_combinations {
Link Here
|
176 |
$debt += $child1_debt + $child2_debt; |
177 |
$debt += $child1_debt + $child2_debt; |
177 |
$debt += $parent1_debt unless ($only_this_guarantor || !$include_guarantors); |
178 |
$debt += $parent1_debt unless ($only_this_guarantor || !$include_guarantors); |
178 |
} |
179 |
} |
179 |
elsif ( $patron->firstname eq 'Child 1' ) { |
180 |
elsif ( $patron->firstname eq ' Child 1' ) { |
180 |
$debt += $child1_debt if ($include_this_patron); |
181 |
$debt += $child1_debt if ($include_this_patron); |
181 |
$debt += $child2_debt; |
182 |
$debt += $child2_debt; |
182 |
$debt += $parent1_debt + $parent2_debt if ($include_guarantors); |
183 |
$debt += $parent1_debt + $parent2_debt if ($include_guarantors); |
Lines 197-203
sub _test_combinations {
Link Here
|
197 |
), |
198 |
), |
198 |
$debt, |
199 |
$debt, |
199 |
$patron->firstname |
200 |
$patron->firstname |
200 |
. " debt of $debt calculated correctly for ( only_this_guarantor: $only_this_guarantor, include_guarantors: $include_guarantors, include_this_patron: $include_this_patron)" |
201 |
. " debt of " . sprintf('%02d',$debt) . " calculated correctly for ( only_this_guarantor: $only_this_guarantor, include_guarantors: $include_guarantors, include_this_patron: $include_this_patron)" |
201 |
); |
202 |
); |
202 |
} |
203 |
} |
203 |
} |
204 |
} |