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

(-)a/t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t (-1 / +56 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
use Test::More tests => 3;
3
4
use C4::Context;
5
use C4::Members;
6
7
my $dbh = C4::Context->dbh;
8
$dbh->{AutoCommit} = 0;
9
$dbh->{RaiseError} = 1;
10
11
my $enrolmentfee_K = 5;
12
my $enrolmentfee_J = 10;
13
my $enrolmentfee_YA = 20;
14
15
$dbh->do(q{
16
    UPDATE categories
17
    SET enrolmentfee=?
18
    WHERE categorycode=?
19
}, {}, $enrolmentfee_K, 'K' );
20
21
$dbh->do(q{
22
    UPDATE categories
23
    SET enrolmentfee=?
24
    WHERE categorycode=?
25
}, {}, $enrolmentfee_J, 'J' );
26
27
$dbh->do(q{
28
    UPDATE categories
29
    SET enrolmentfee=?
30
    WHERE categorycode=?
31
}, {}, $enrolmentfee_YA, 'YA' );
32
33
my %borrower_data = (
34
    firstname =>  'my firstname',
35
    surname => 'my surname',
36
    categorycode => 'K',
37
    branchcode => 'CPL',
38
);
39
40
my $borrowernumber = C4::Members::AddMember( %borrower_data );
41
$borrower_data{borrowernumber} = $borrowernumber;
42
43
my ( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
44
is( $total, $enrolmentfee_K, "New kid pay $enrolmentfee_K" );
45
46
$borrower_data{categorycode} = 'J';
47
C4::Members::ModMember( %borrower_data );
48
( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
49
is( $total, $enrolmentfee_K + $enrolmentfee_J, "Kid growing and become a juvenile, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J ) );
50
51
# Check with calling directly AddEnrolmentFeeIfNeeded
52
C4::Members::AddEnrolmentFeeIfNeeded( 'YA', $borrowernumber );
53
( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
54
is( $total, $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA, "Juvenile growing and become an young adult, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA ) );
55
56
$dbh->rollback;

Return to bug 10481