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

(-)a/C4/Accounts.pm (-50 / +59 lines)
Lines 38-47 BEGIN { Link Here
38
		&manualinvoice
38
		&manualinvoice
39
		&getnextacctno
39
		&getnextacctno
40
		&reconcileaccount
40
		&reconcileaccount
41
		&getcharges
41
		&GetCharges
42
		&ModNote
42
		&ModNote
43
		&getcredits
43
		&GetCredits
44
		&getrefunds
44
		&GetRefunds
45
		&chargelostitem
45
		&chargelostitem
46
		&ReversePayment
46
		&ReversePayment
47
                &makepartialpayment
47
                &makepartialpayment
Lines 585-605 sub refund { Link Here
585
    return ($amountleft);
585
    return ($amountleft);
586
}
586
}
587
587
588
sub getcharges {
588
sub GetCharges {
589
	my ( $borrowerno, $timestamp, $accountno ) = @_;
589
    my ( $borrowerno, $timestamp, $accountno ) = @_;
590
	my $dbh        = C4::Context->dbh;
590
591
	my $timestamp2 = $timestamp - 1;
591
    my $dbh = C4::Context->dbh;
592
	my $query      = "";
592
593
	my $sth = $dbh->prepare(
593
    my $timestamp2 = $timestamp - 1;
594
			"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?"
594
595
          );
595
    my $sth = $dbh->prepare("
596
	$sth->execute( $borrowerno, $accountno );
596
        SELECT * 
597
	
597
        FROM accountlines 
598
    my @results;
598
        WHERE borrowernumber = ? 
599
    while ( my $data = $sth->fetchrow_hashref ) {
599
          AND accountno = ?
600
		push @results,$data;
600
    ");
601
	}
601
    $sth->execute( $borrowerno, $accountno );
602
    return (@results);
602
603
    my $results = $sth->fetchall_arrayref({});
604
    
605
    return @$results;
603
}
606
}
604
607
605
sub ModNote {
608
sub ModNote {
Lines 609-653 sub ModNote { Link Here
609
    $sth->execute( $note, $accountlines_id );
612
    $sth->execute( $note, $accountlines_id );
610
}
613
}
611
614
612
sub getcredits {
615
sub GetCredits {
613
	my ( $date, $date2 ) = @_;
616
    my ( $date, $date2 ) = @_;
614
	my $dbh = C4::Context->dbh;
617
    my $dbh = C4::Context->dbh;
615
	my $sth = $dbh->prepare(
618
    my $sth = $dbh->prepare("
616
			        "SELECT * FROM accountlines,borrowers
619
        SELECT *
617
      WHERE amount < 0 AND accounttype <> 'Pay' AND accountlines.borrowernumber = borrowers.borrowernumber
620
        FROM accountlines,
618
	  AND timestamp >=TIMESTAMP(?) AND timestamp < TIMESTAMP(?)"
621
             borrowers
619
      );  
622
        WHERE amount < 0
620
623
          AND accounttype <> 'Pay'
621
    $sth->execute( $date, $date2 );                                                                                                              
624
          AND accountlines.borrowernumber = borrowers.borrowernumber
622
    my @results;          
625
          AND TIMESTAMP >= TIMESTAMP(?)
626
          AND TIMESTAMP < TIMESTAMP(?)
627
    ");
628
629
    $sth->execute( $date, $date2 );
630
    my @results;
623
    while ( my $data = $sth->fetchrow_hashref ) {
631
    while ( my $data = $sth->fetchrow_hashref ) {
624
		$data->{'date'} = $data->{'timestamp'};
632
        $data->{'date'} = $data->{'timestamp'};
625
		push @results,$data;
633
        push @results,$data;
626
	}
634
    }
627
    return (@results);
635
    
636
    return @results;
628
} 
637
} 
629
638
630
639
631
sub getrefunds {
640
sub GetRefunds {
632
	my ( $date, $date2 ) = @_;
641
    my ( $date, $date2 ) = @_;
633
	my $dbh = C4::Context->dbh;
642
634
	
643
    my $dbh = C4::Context->dbh;
635
	my $sth = $dbh->prepare(
644
    my $sth = $dbh->prepare("
636
			        "SELECT *,timestamp AS datetime                                                                                      
645
        SELECT *,
637
                  FROM accountlines,borrowers
646
               TIMESTAMP AS datetime
638
                  WHERE (accounttype = 'REF'
647
        FROM accountlines,
639
					  AND accountlines.borrowernumber = borrowers.borrowernumber
648
             borrowers
640
					                  AND date  >=?  AND date  <?)"
649
        WHERE accounttype = 'REF'
641
    );
650
          AND accountlines.borrowernumber = borrowers.borrowernumber
651
          AND date >= ?
652
          AND date < ?
653
    ");
642
654
643
    $sth->execute( $date, $date2 );
655
    $sth->execute( $date, $date2 );
644
656
645
    my @results;
657
    my $results = $sth->fetchall_arrayref({});
646
    while ( my $data = $sth->fetchrow_hashref ) {
658
647
		push @results,$data;
659
    return @$results;
648
		
649
	}
650
    return (@results);
651
}
660
}
652
661
653
sub ReversePayment {
662
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 (-3 / +3 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 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