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

(-)a/C4/Accounts.pm (-51 / +57 lines)
Lines 41-50 BEGIN { Link Here
41
		&manualinvoice
41
		&manualinvoice
42
		&getnextacctno
42
		&getnextacctno
43
		&reconcileaccount
43
		&reconcileaccount
44
		&getcharges
44
          &GetCharges
45
		&ModNote
45
		&ModNote
46
		&getcredits
46
         &GetCredits
47
		&getrefunds
47
            &GetRefunds
48
		&chargelostitem
48
		&chargelostitem
49
		&ReversePayment
49
		&ReversePayment
50
                &makepartialpayment
50
                &makepartialpayment
Lines 666-686 sub refund { Link Here
666
    return ($amountleft);
666
    return ($amountleft);
667
}
667
}
668
668
669
sub getcharges {
669
sub GetCharges {
670
	my ( $borrowerno, $timestamp, $accountno ) = @_;
670
    my ( $borrowerno, $timestamp, $accountno ) = @_;
671
	my $dbh        = C4::Context->dbh;
671
672
	my $timestamp2 = $timestamp - 1;
672
    my $dbh = C4::Context->dbh;
673
	my $query      = "";
673
674
	my $sth = $dbh->prepare(
674
    my $timestamp2 = $timestamp - 1;
675
			"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?"
675
676
          );
676
    my $sth = $dbh->prepare("
677
	$sth->execute( $borrowerno, $accountno );
677
        SELECT *
678
	
678
        FROM accountlines
679
    my @results;
679
        WHERE borrowernumber = ?
680
    while ( my $data = $sth->fetchrow_hashref ) {
680
          AND accountno = ?
681
		push @results,$data;
681
    ");
682
	}
682
    $sth->execute( $borrowerno, $accountno );
683
    return (@results);
683
684
    my $results = $sth->fetchall_arrayref({});
685
686
    return @$results;
684
}
687
}
685
688
686
sub ModNote {
689
sub ModNote {
Lines 690-734 sub ModNote { Link Here
690
    $sth->execute( $note, $accountlines_id );
693
    $sth->execute( $note, $accountlines_id );
691
}
694
}
692
695
693
sub getcredits {
696
sub GetCredits {
694
	my ( $date, $date2 ) = @_;
697
    my ( $date, $date2 ) = @_;
695
	my $dbh = C4::Context->dbh;
698
    my $dbh = C4::Context->dbh;
696
	my $sth = $dbh->prepare(
699
    my $sth = $dbh->prepare("
697
			        "SELECT * FROM accountlines,borrowers
700
        SELECT *
698
      WHERE amount < 0 AND accounttype <> 'Pay' AND accountlines.borrowernumber = borrowers.borrowernumber
701
        FROM accountlines,
699
	  AND timestamp >=TIMESTAMP(?) AND timestamp < TIMESTAMP(?)"
702
             borrowers
700
      );  
703
        WHERE amount < 0
701
704
          AND accounttype <> 'Pay'
702
    $sth->execute( $date, $date2 );                                                                                                              
705
          AND accountlines.borrowernumber = borrowers.borrowernumber
703
    my @results;          
706
          AND TIMESTAMP >= TIMESTAMP(?)
704
    while ( my $data = $sth->fetchrow_hashref ) {
707
          AND TIMESTAMP < TIMESTAMP(?)
705
		$data->{'date'} = $data->{'timestamp'};
708
    ");
706
		push @results,$data;
709
707
	}
710
    $sth->execute( $date, $date2 );
708
    return (@results);
711
712
    my $results = $sth->fetchall_arrayref({});
713
714
    return @$results;
709
} 
715
} 
710
716
711
717
712
sub getrefunds {
718
sub GetRefunds {
713
	my ( $date, $date2 ) = @_;
719
    my ( $date, $date2 ) = @_;
714
	my $dbh = C4::Context->dbh;
720
715
	
721
    my $dbh = C4::Context->dbh;
716
	my $sth = $dbh->prepare(
722
    my $sth = $dbh->prepare("
717
			        "SELECT *,timestamp AS datetime                                                                                      
723
        SELECT *,
718
                  FROM accountlines,borrowers
724
               TIMESTAMP AS datetime
719
                  WHERE (accounttype = 'REF'
725
        FROM accountlines,
720
					  AND accountlines.borrowernumber = borrowers.borrowernumber
726
             borrowers
721
					                  AND date  >=?  AND date  <?)"
727
        WHERE accounttype = 'REF'
722
    );
728
          AND accountlines.borrowernumber = borrowers.borrowernumber
729
          AND date >= ?
730
          AND date < ?
731
    ");
723
732
724
    $sth->execute( $date, $date2 );
733
    $sth->execute( $date, $date2 );
725
734
726
    my @results;
735
    my $results = $sth->fetchall_arrayref({});
727
    while ( my $data = $sth->fetchrow_hashref ) {
736
728
		push @results,$data;
737
    return @$results;
729
		
730
	}
731
    return (@results);
732
}
738
}
733
739
734
sub ReversePayment {
740
sub ReversePayment {
(-)a/C4/ILSDI/Services.pm (-1 / +1 lines)
Lines 392-398 sub GetPatronInfo { Link Here
392
    # Fines management
392
    # Fines management
393
    if ( $cgi->param('show_fines') eq "1" ) {
393
    if ( $cgi->param('show_fines') eq "1" ) {
394
        my @charges;
394
        my @charges;
395
        for ( my $i = 1 ; my @charge = getcharges( $borrowernumber, undef, $i ) ; $i++ ) {
395
        for ( my $i = 1 ; my @charge = GetCharges( $borrowernumber, undef, $i ) ; $i++ ) {
396
            push( @charges, @charge );
396
            push( @charges, @charge );
397
        }
397
        }
398
        $borrower->{'fines'}->{'fine'} = \@charges;
398
        $borrower->{'fines'}->{'fine'} = \@charges;
(-)a/circ/stats.pl (-1 / +1 lines)
Lines 96-102 while ( $i < $count ) { Link Here
96
    my @temp     = split(/ /, $payments[$i]{'datetime'});
96
    my @temp     = split(/ /, $payments[$i]{'datetime'});
97
    my $date     = $temp[0];
97
    my $date     = $temp[0];
98
    my @charges  =
98
    my @charges  =
99
      getcharges( $payments[$i]{'borrowernumber'}, $payments[$i]{'timestamp'} );
99
      GetCharges( $payments[$i]{'borrowernumber'}, $payments[$i]{'timestamp'} );
100
    my $count        = @charges;
100
    my $count        = @charges;
101
    my $temptotalf   = 0;
101
    my $temptotalf   = 0;
102
    my $temptotalr   = 0;
102
    my $temptotalr   = 0;
(-)a/reports/stats.print.pl (-2 / +2 lines)
Lines 86-92 while ($i<$count ){ Link Here
86
       my @charges;
86
       my @charges;
87
87
88
       if ($payments[$i]{'type'} ne 'writeoff'){         # lets ignore writeoff payments!.
88
       if ($payments[$i]{'type'} ne 'writeoff'){         # lets ignore writeoff payments!.
89
           @charges=getcharges($payments[$i]{'borrowernumber'}, $payments[$i]{'timestamp'}, $payments[$i]{'proccode'});
89
           @charges=GetCharges($payments[$i]{'borrowernumber'}, $payments[$i]{'timestamp'}, $payments[$i]{'proccode'});
90
           $totalcharges++;
90
           $totalcharges++;
91
           $count=@charges;
91
           $count=@charges;
92
92
Lines 124-130 while ($i<$count ){ Link Here
124
}
124
}
125
125
126
#get credits and append to the bottom of payments
126
#get credits and append to the bottom of payments
127
my @credits=getcredits($date,$date2);
127
my @credits=GetCredits($date,$date2);
128
128
129
my $count=@credits;
129
my $count=@credits;
130
my $i=0;
130
my $i=0;
(-)a/reports/stats.screen.pl (-4 / +4 lines)
Lines 77-83 foreach my $payment (@payments) { Link Here
77
    my @charges;
77
    my @charges;
78
    if ( $payment->{'type'} ne 'writeoff' ) {
78
    if ( $payment->{'type'} ne 'writeoff' ) {
79
79
80
        @charges = getcharges(
80
        @charges = GetCharges(
81
            $payment->{'borrowernumber'},
81
            $payment->{'borrowernumber'},
82
            $payment->{'timestamp'},
82
            $payment->{'timestamp'},
83
            $payment->{'proccode'}
83
            $payment->{'proccode'}
Lines 124-130 foreach my $payment (@payments) { Link Here
124
}
124
}
125
125
126
#get credits and append to the bottom of payments
126
#get credits and append to the bottom of payments
127
my @credits = getcredits( $date, $date2 );
127
my @credits = GetCredits( $date, $date2 );
128
128
129
my $count = @credits;
129
my $count = @credits;
130
my $i     = 0;
130
my $i     = 0;
Lines 133-139 while ( $i < $count ) { Link Here
133
133
134
    my %rows2 = (
134
    my %rows2 = (
135
        creditbranch      => $credits[$i]->{'branchcode'},
135
        creditbranch      => $credits[$i]->{'branchcode'},
136
        creditdate        => $credits[$i]->{'date'},
136
        creditdate        => $credits[$i]->{'timestamp'},
137
        creditsurname     => $credits[$i]->{'surname'},
137
        creditsurname     => $credits[$i]->{'surname'},
138
        creditfirstname   => $credits[$i]->{'firstname'},
138
        creditfirstname   => $credits[$i]->{'firstname'},
139
        creditdescription => $credits[$i]->{'description'},
139
        creditdescription => $credits[$i]->{'description'},
Lines 151-157 $totalcredits = substr( $totalcredits, 1 ); Link Here
151
151
152
my $totalrefunds = 0;
152
my $totalrefunds = 0;
153
my @loop3;
153
my @loop3;
154
my @refunds = getrefunds( $date, $date2 );
154
my @refunds = GetRefunds( $date, $date2 );
155
$count = @refunds;
155
$count = @refunds;
156
$i     = 0;
156
$i     = 0;
157
157
(-)a/t/db_dependent/lib/KohaTest/Accounts.pm (-4 / +3 lines)
Lines 18-26 sub methods : Test( 1 ) { Link Here
18
                      manualinvoice
18
                      manualinvoice
19
                      fixcredit
19
                      fixcredit
20
                      refund
20
                      refund
21
                      getcharges
21
                      GetCharges
22
                      getcredits
22
                      GetCredits
23
                      getrefunds
23
                      GetRefunds
24
                );	# removed fixaccounts (unused by codebase)
24
                );	# removed fixaccounts (unused by codebase)
25
    
25
    
26
    can_ok( $self->testing_class, @methods );    
26
    can_ok( $self->testing_class, @methods );    
27
- 

Return to bug 7560