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

(-)a/C4/Accounts.pm (-31 lines)
Lines 38-44 BEGIN { Link Here
38
    @ISA    = qw(Exporter);
38
    @ISA    = qw(Exporter);
39
    @EXPORT = qw(
39
    @EXPORT = qw(
40
      &manualinvoice
40
      &manualinvoice
41
      &getnextacctno
42
      &chargelostitem
41
      &chargelostitem
43
      &purge_zero_balance_fees
42
      &purge_zero_balance_fees
44
    );
43
    );
Lines 60-88 patron. Link Here
60
59
61
=head1 FUNCTIONS
60
=head1 FUNCTIONS
62
61
63
=head2 getnextacctno
64
65
  $nextacct = &getnextacctno($borrowernumber);
66
67
Returns the next unused account number for the patron with the given
68
borrower number.
69
70
=cut
71
72
#'
73
# FIXME - Okay, so what does the above actually _mean_?
74
sub getnextacctno {
75
    my ($borrowernumber) = shift or return;
76
    my $sth = C4::Context->dbh->prepare(
77
        "SELECT accountno+1 FROM accountlines
78
            WHERE    (borrowernumber = ?)
79
            ORDER BY accountno DESC
80
            LIMIT 1"
81
    );
82
    $sth->execute($borrowernumber);
83
    return ($sth->fetchrow || 1);
84
}
85
86
=head2 chargelostitem
62
=head2 chargelostitem
87
63
88
In a default install of Koha the following lost values are set
64
In a default install of Koha the following lost values are set
Lines 125-131 sub chargelostitem{ Link Here
125
            my $accountline = Koha::Account::Line->new(
101
            my $accountline = Koha::Account::Line->new(
126
                {
102
                {
127
                    borrowernumber    => $borrowernumber,
103
                    borrowernumber    => $borrowernumber,
128
                    accountno         => getnextacctno($borrowernumber),
129
                    date              => \'NOW()',
104
                    date              => \'NOW()',
130
                    amount            => $processfee,
105
                    amount            => $processfee,
131
                    description       => $description,
106
                    description       => $description,
Lines 149-155 sub chargelostitem{ Link Here
149
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
124
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
150
                    action            => 'create_fee',
125
                    action            => 'create_fee',
151
                    borrowernumber    => $accountline->borrowernumber,,
126
                    borrowernumber    => $accountline->borrowernumber,,
152
                    accountno         => $accountline->accountno,
153
                    amount            => $accountline->amount,
127
                    amount            => $accountline->amount,
154
                    description       => $accountline->description,
128
                    description       => $accountline->description,
155
                    accounttype       => $accountline->accounttype,
129
                    accounttype       => $accountline->accounttype,
Lines 165-171 sub chargelostitem{ Link Here
165
            my $accountline = Koha::Account::Line->new(
139
            my $accountline = Koha::Account::Line->new(
166
                {
140
                {
167
                    borrowernumber    => $borrowernumber,
141
                    borrowernumber    => $borrowernumber,
168
                    accountno         => getnextacctno($borrowernumber),
169
                    date              => \'NOW()',
142
                    date              => \'NOW()',
170
                    amount            => $replacementprice,
143
                    amount            => $replacementprice,
171
                    description       => $description,
144
                    description       => $description,
Lines 188-194 sub chargelostitem{ Link Here
188
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
161
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
189
                    action            => 'create_fee',
162
                    action            => 'create_fee',
190
                    borrowernumber    => $accountline->borrowernumber,,
163
                    borrowernumber    => $accountline->borrowernumber,,
191
                    accountno         => $accountline->accountno,
192
                    amount            => $accountline->amount,
164
                    amount            => $accountline->amount,
193
                    description       => $accountline->description,
165
                    description       => $accountline->description,
194
                    accounttype       => $accountline->accounttype,
166
                    accounttype       => $accountline->accounttype,
Lines 234-246 sub manualinvoice { Link Here
234
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
206
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
235
    my $dbh      = C4::Context->dbh;
207
    my $dbh      = C4::Context->dbh;
236
    my $insert;
208
    my $insert;
237
    my $accountno  = getnextacctno($borrowernumber);
238
    my $amountleft = $amount;
209
    my $amountleft = $amount;
239
210
240
    my $accountline = Koha::Account::Line->new(
211
    my $accountline = Koha::Account::Line->new(
241
        {
212
        {
242
            borrowernumber    => $borrowernumber,
213
            borrowernumber    => $borrowernumber,
243
            accountno         => $accountno,
244
            date              => \'NOW()',
214
            date              => \'NOW()',
245
            amount            => $amount,
215
            amount            => $amount,
246
            description       => $desc,
216
            description       => $desc,
Lines 264-270 sub manualinvoice { Link Here
264
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
234
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
265
            action            => 'create_fee',
235
            action            => 'create_fee',
266
            borrowernumber    => $borrowernumber,
236
            borrowernumber    => $borrowernumber,
267
            accountno         => $accountno,
268
            amount            => $amount,
237
            amount            => $amount,
269
            description       => $desc,
238
            description       => $desc,
270
            accounttype       => $type,
239
            accounttype       => $type,
(-)a/C4/Circulation.pm (-8 / +4 lines)
Lines 2402-2408 sub _FixAccountForLostAndReturned { Link Here
2402
            accounttype => { -in => [ 'L', 'Rep', 'W' ] },
2402
            accounttype => { -in => [ 'L', 'Rep', 'W' ] },
2403
        },
2403
        },
2404
        {
2404
        {
2405
            order_by => { -desc => [ 'date', 'accountno' ] }
2405
            order_by => { -desc => [ 'date' ] }
2406
        }
2406
        }
2407
    );
2407
    );
2408
2408
Lines 2876-2891 sub AddRenewal { Link Here
2876
    # Charge a new rental fee, if applicable?
2876
    # Charge a new rental fee, if applicable?
2877
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
2877
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
2878
    if ( $charge > 0 ) {
2878
    if ( $charge > 0 ) {
2879
        my $accountno = C4::Accounts::getnextacctno( $borrowernumber );
2880
        my $manager_id = 0;
2879
        my $manager_id = 0;
2881
        $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
2880
        $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; 
2882
        $sth = $dbh->prepare(
2881
        $sth = $dbh->prepare(
2883
                "INSERT INTO accountlines
2882
                "INSERT INTO accountlines
2884
                    (date, borrowernumber, accountno, amount, manager_id,
2883
                    (date, borrowernumber, amount, manager_id,
2885
                    description,accounttype, amountoutstanding, itemnumber)
2884
                    description,accounttype, amountoutstanding, itemnumber)
2886
                    VALUES (now(),?,?,?,?,?,?,?,?)"
2885
                    VALUES (now(),?,?,?,?,?,?,?)"
2887
        );
2886
        );
2888
        $sth->execute( $borrowernumber, $accountno, $charge, $manager_id,
2887
        $sth->execute( $borrowernumber, $charge, $manager_id,
2889
            "Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}",
2888
            "Renewal of Rental Item " . $biblio->title . " $item->{'barcode'}",
2890
            'Rent', $charge, $itemnumber );
2889
            'Rent', $charge, $itemnumber );
2891
    }
2890
    }
Lines 3216-3223 sub AddIssuingCharge { Link Here
3216
3215
3217
    # FIXME What if checkout does not exist?
3216
    # FIXME What if checkout does not exist?
3218
3217
3219
    my $nextaccntno = C4::Accounts::getnextacctno( $checkout->borrowernumber );
3220
3221
    my $manager_id  = 0;
3218
    my $manager_id  = 0;
3222
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
3219
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
3223
3220
Lines 3226-3232 sub AddIssuingCharge { Link Here
3226
            borrowernumber    => $checkout->borrowernumber,
3223
            borrowernumber    => $checkout->borrowernumber,
3227
            itemnumber        => $checkout->itemnumber,
3224
            itemnumber        => $checkout->itemnumber,
3228
            issue_id          => $checkout->issue_id,
3225
            issue_id          => $checkout->issue_id,
3229
            accountno         => $nextaccntno,
3230
            amount            => $charge,
3226
            amount            => $charge,
3231
            amountoutstanding => $charge,
3227
            amountoutstanding => $charge,
3232
            manager_id        => $manager_id,
3228
            manager_id        => $manager_id,
(-)a/C4/Overdues.pm (-3 lines)
Lines 608-615 sub UpdateFine { Link Here
608
            $sth4->execute($itemnum);
608
            $sth4->execute($itemnum);
609
            my $title = $sth4->fetchrow;
609
            my $title = $sth4->fetchrow;
610
610
611
            my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
612
613
            my $desc = ( $type ? "$type " : '' ) . "$title $due";    # FIXEDME, avoid whitespace prefix on empty $type
611
            my $desc = ( $type ? "$type " : '' ) . "$title $due";    # FIXEDME, avoid whitespace prefix on empty $type
614
612
615
            my $accountline = Koha::Account::Line->new(
613
            my $accountline = Koha::Account::Line->new(
Lines 622-628 sub UpdateFine { Link Here
622
                    accounttype       => 'FU',
620
                    accounttype       => 'FU',
623
                    amountoutstanding => $amount,
621
                    amountoutstanding => $amount,
624
                    lastincrement     => $amount,
622
                    lastincrement     => $amount,
625
                    accountno         => $nextaccntno,
626
                    issue_id          => $issue_id,
623
                    issue_id          => $issue_id,
627
                }
624
                }
628
            )->store();
625
            )->store();
(-)a/C4/Reserves.pm (-3 / +2 lines)
Lines 568-578 sub ChargeReserveFee { Link Here
568
    my ( $borrowernumber, $fee, $title ) = @_;
568
    my ( $borrowernumber, $fee, $title ) = @_;
569
    return if !$fee || $fee==0; # the last test is needed to include 0.00
569
    return if !$fee || $fee==0; # the last test is needed to include 0.00
570
    my $accquery = qq{
570
    my $accquery = qq{
571
INSERT INTO accountlines ( borrowernumber, accountno, date, amount, description, accounttype, amountoutstanding ) VALUES (?, ?, NOW(), ?, ?, 'Res', ?)
571
INSERT INTO accountlines ( borrowernumber, date, amount, description, accounttype, amountoutstanding ) VALUES (?, ?, NOW(), ?, ?, 'Res', ?)
572
    };
572
    };
573
    my $dbh = C4::Context->dbh;
573
    my $dbh = C4::Context->dbh;
574
    my $nextacctno = &getnextacctno( $borrowernumber );
574
    $dbh->do( $accquery, undef, ( $borrowernumber, $fee, "Reserve Charge - $title", $fee ) );
575
    $dbh->do( $accquery, undef, ( $borrowernumber, $nextacctno, $fee, "Reserve Charge - $title", $fee ) );
576
}
575
}
577
576
578
=head2 GetReserveFee
577
=head2 GetReserveFee
(-)a/C4/Stats.pm (-6 / +4 lines)
Lines 64-70 C<$params> is an hashref whose expected keys are: Link Here
64
    amount             : the amount of the transaction
64
    amount             : the amount of the transaction
65
    other              : sipmode
65
    other              : sipmode
66
    itemtype           : the type of the item
66
    itemtype           : the type of the item
67
    accountno          : the count
68
    ccode              : the collection code of the item
67
    ccode              : the collection code of the item
69
68
70
type key is mandatory.
69
type key is mandatory.
Lines 83-89 sub UpdateStats { Link Here
83
# make some controls
82
# make some controls
84
    return () if ! defined $params;
83
    return () if ! defined $params;
85
# change these arrays if new types of transaction or new parameters are allowed
84
# change these arrays if new types of transaction or new parameters are allowed
86
    my @allowed_keys = qw (type branch amount other itemnumber itemtype borrowernumber accountno ccode location);
85
    my @allowed_keys = qw (type branch amount other itemnumber itemtype borrowernumber ccode location);
87
    my @allowed_circulation_types = qw (renew issue localuse return onsite_checkout);
86
    my @allowed_circulation_types = qw (renew issue localuse return onsite_checkout);
88
    my @allowed_accounts_types = qw (writeoff payment);
87
    my @allowed_accounts_types = qw (writeoff payment);
89
    my @circulation_mandatory_keys = qw (type branch borrowernumber itemnumber ccode itemtype);
88
    my @circulation_mandatory_keys = qw (type branch borrowernumber itemnumber ccode itemtype);
Lines 123-129 sub UpdateStats { Link Here
123
    my $other             = exists $params->{other}          ? $params->{other}          : '';
122
    my $other             = exists $params->{other}          ? $params->{other}          : '';
124
    my $itemtype          = exists $params->{itemtype}       ? $params->{itemtype}       : '';
123
    my $itemtype          = exists $params->{itemtype}       ? $params->{itemtype}       : '';
125
    my $location          = exists $params->{location}       ? $params->{location}       : undef;
124
    my $location          = exists $params->{location}       ? $params->{location}       : undef;
126
    my $accountno         = exists $params->{accountno}      ? $params->{accountno}      : '';
127
    my $ccode             = exists $params->{ccode}          ? $params->{ccode}          : '';
125
    my $ccode             = exists $params->{ccode}          ? $params->{ccode}          : '';
128
126
129
    my $dbh = C4::Context->dbh;
127
    my $dbh = C4::Context->dbh;
Lines 132-144 sub UpdateStats { Link Here
132
        (datetime,
130
        (datetime,
133
         branch,          type,        value,
131
         branch,          type,        value,
134
         other,           itemnumber,  itemtype, location,
132
         other,           itemnumber,  itemtype, location,
135
         borrowernumber,  proccode,    ccode)
133
         borrowernumber,  ccode)
136
         VALUES (now(),?,?,?,?,?,?,?,?,?,?)"
134
         VALUES (now(),?,?,?,?,?,?,?,?,?)"
137
    );
135
    );
138
    $sth->execute(
136
    $sth->execute(
139
        $branch,     $type,     $amount,   $other,
137
        $branch,     $type,     $amount,   $other,
140
        $itemnumber, $itemtype, $location, $borrowernumber,
138
        $itemnumber, $itemtype, $location, $borrowernumber,
141
        $accountno,  $ccode
139
        $ccode
142
    );
140
    );
143
}
141
}
144
142
(-)a/Koha/Account.pm (-19 lines)
Lines 84-95 sub pay { Link Here
84
84
85
    my $patron = Koha::Patrons->find( $self->{patron_id} );
85
    my $patron = Koha::Patrons->find( $self->{patron_id} );
86
86
87
    # We should remove accountno, it is no longer needed
88
    my $last = $self->lines->search(
89
        {},
90
        { order_by => 'accountno' } )->next();
91
    my $accountno = $last ? $last->accountno + 1 : 1;
92
93
    my $manager_id = $userenv ? $userenv->{number} : 0;
87
    my $manager_id = $userenv ? $userenv->{number} : 0;
94
88
95
    my @fines_paid; # List of account lines paid on with this payment
89
    my @fines_paid; # List of account lines paid on with this payment
Lines 137-143 sub pay { Link Here
137
                        new_amountoutstanding => 0,
131
                        new_amountoutstanding => 0,
138
                        amount_paid           => $old_amountoutstanding,
132
                        amount_paid           => $old_amountoutstanding,
139
                        accountlines_id       => $fine->id,
133
                        accountlines_id       => $fine->id,
140
                        accountno             => $fine->accountno,
141
                        manager_id            => $manager_id,
134
                        manager_id            => $manager_id,
142
                        note                  => $note,
135
                        note                  => $note,
143
                    }
136
                    }
Lines 188-194 sub pay { Link Here
188
                        new_amountoutstanding => $fine->amountoutstanding,
181
                        new_amountoutstanding => $fine->amountoutstanding,
189
                        amount_paid           => $amount_to_pay,
182
                        amount_paid           => $amount_to_pay,
190
                        accountlines_id       => $fine->id,
183
                        accountlines_id       => $fine->id,
191
                        accountno             => $fine->accountno,
192
                        manager_id            => $manager_id,
184
                        manager_id            => $manager_id,
193
                        note                  => $note,
185
                        note                  => $note,
194
                    }
186
                    }
Lines 211-217 sub pay { Link Here
211
    my $payment = Koha::Account::Line->new(
203
    my $payment = Koha::Account::Line->new(
212
        {
204
        {
213
            borrowernumber    => $self->{patron_id},
205
            borrowernumber    => $self->{patron_id},
214
            accountno         => $accountno,
215
            date              => dt_from_string(),
206
            date              => dt_from_string(),
216
            amount            => 0 - $amount,
207
            amount            => 0 - $amount,
217
            description       => $description,
208
            description       => $description,
Lines 236-242 sub pay { Link Here
236
            type           => $type,
227
            type           => $type,
237
            amount         => $amount,
228
            amount         => $amount,
238
            borrowernumber => $self->{patron_id},
229
            borrowernumber => $self->{patron_id},
239
            accountno      => $accountno,
240
        }
230
        }
241
    );
231
    );
242
232
Lines 248-254 sub pay { Link Here
248
                {
238
                {
249
                    action            => "create_$type",
239
                    action            => "create_$type",
250
                    borrowernumber    => $self->{patron_id},
240
                    borrowernumber    => $self->{patron_id},
251
                    accountno         => $accountno,
252
                    amount            => 0 - $amount,
241
                    amount            => 0 - $amount,
253
                    amountoutstanding => 0 - $balance_remaining,
242
                    amountoutstanding => 0 - $balance_remaining,
254
                    accounttype       => $account_type,
243
                    accounttype       => $account_type,
Lines 343-354 sub add_credit { Link Here
343
332
344
    $schema->txn_do(
333
    $schema->txn_do(
345
        sub {
334
        sub {
346
            # We should remove accountno, it is no longer needed
347
            my $last = $self->lines->search(
348
                {},
349
                { order_by => 'accountno' } )->next();
350
            my $accountno = $last ? $last->accountno + 1 : 1;
351
352
            # Insert the account line
335
            # Insert the account line
353
            $line = Koha::Account::Line->new(
336
            $line = Koha::Account::Line->new(
354
                {   borrowernumber    => $self->{patron_id},
337
                {   borrowernumber    => $self->{patron_id},
Lines 377-383 sub add_credit { Link Here
377
                    type           => $type,
360
                    type           => $type,
378
                    amount         => $amount,
361
                    amount         => $amount,
379
                    borrowernumber => $self->{patron_id},
362
                    borrowernumber => $self->{patron_id},
380
                    accountno      => $accountno,
381
                }
363
                }
382
            ) if grep { $type eq $_ } ('payment', 'writeoff') ;
364
            ) if grep { $type eq $_ } ('payment', 'writeoff') ;
383
365
Lines 388-394 sub add_credit { Link Here
388
                    Dumper(
370
                    Dumper(
389
                        {   action            => "create_$type",
371
                        {   action            => "create_$type",
390
                            borrowernumber    => $self->{patron_id},
372
                            borrowernumber    => $self->{patron_id},
391
                            accountno         => $accountno,
392
                            amount            => $amount,
373
                            amount            => $amount,
393
                            description       => $description,
374
                            description       => $description,
394
                            amountoutstanding => $amount,
375
                            amountoutstanding => $amount,
(-)a/Koha/REST/V1/Patrons/Account.pm (-1 lines)
Lines 224-230 sub _to_model { Link Here
224
224
225
our $to_api_mapping = {
225
our $to_api_mapping = {
226
    accountlines_id   => 'account_line_id',
226
    accountlines_id   => 'account_line_id',
227
    accountno         => undef,                  # removed
228
    accounttype       => 'account_type',
227
    accounttype       => 'account_type',
229
    amountoutstanding => 'amount_outstanding',
228
    amountoutstanding => 'amount_outstanding',
230
    borrowernumber    => 'patron_id',
229
    borrowernumber    => 'patron_id',
(-)a/members/printfeercpt.pl (-1 lines)
Lines 82-88 my %row = ( Link Here
82
    'description'             => $accountline->{'description'},
82
    'description'             => $accountline->{'description'},
83
    'amount'                  => $accountline->{'amount'},
83
    'amount'                  => $accountline->{'amount'},
84
    'amountoutstanding'       => $accountline->{'amountoutstanding'},
84
    'amountoutstanding'       => $accountline->{'amountoutstanding'},
85
    'accountno' => $accountline->{'accountno'},
86
    accounttype => $accountline->{accounttype},
85
    accounttype => $accountline->{accounttype},
87
    'note'      => $accountline->{'note'},
86
    'note'      => $accountline->{'note'},
88
);
87
);
(-)a/members/printinvoice.pl (-1 lines)
Lines 81-87 my %row = ( Link Here
81
    'amount'                  => sprintf( "%.2f", $accountline->{'amount'} ),
81
    'amount'                  => sprintf( "%.2f", $accountline->{'amount'} ),
82
    'amountoutstanding' =>
82
    'amountoutstanding' =>
83
      sprintf( "%.2f", $accountline->{'amountoutstanding'} ),
83
      sprintf( "%.2f", $accountline->{'amountoutstanding'} ),
84
    'accountno' => $accountline->{'accountno'},
85
    accounttype => $accountline->{accounttype},
84
    accounttype => $accountline->{accounttype},
86
    'note'      => $accountline->{'note'},
85
    'note'      => $accountline->{'note'},
87
);
86
);
(-)a/misc/cronjobs/staticfines.pl (-4 / +3 lines)
Lines 229-242 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
229
            $sth4->execute($itemnumber);
229
            $sth4->execute($itemnumber);
230
            my $title = $sth4->fetchrow;
230
            my $title = $sth4->fetchrow;
231
231
232
            my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
233
            my $desc        = "staticfine";
232
            my $desc        = "staticfine";
234
            my $query       = "INSERT INTO accountlines
233
            my $query       = "INSERT INTO accountlines
235
                        (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement,accountno)
234
                        (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement)
236
                                VALUES (?,?,now(),?,?,'F',?,?,?)";
235
                                VALUES (?,?,now(),?,?,'F',?,?,?)";
237
            my $sth2 = $dbh->prepare($query);
236
            my $sth2 = $dbh->prepare($query);
238
            $bigdebug and warn "query: $query\nw/ args: $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount, $nextaccntno\n";
237
            $bigdebug and warn "query: $query\nw/ args: $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount\n";
239
            $sth2->execute( $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount, $nextaccntno );
238
            $sth2->execute( $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount );
240
239
241
        }
240
        }
242
    }
241
    }
(-)a/misc/maintenance/fix_accountlines_date.pl (-3 / +3 lines)
Lines 127-133 if (not $result or $want_help or ($mode ne 'us' and $mode ne 'metric')) { Link Here
127
our $dbh = C4::Context->dbh;
127
our $dbh = C4::Context->dbh;
128
$dbh->{AutoCommit} = 0;
128
$dbh->{AutoCommit} = 0;
129
my $sth = $dbh->prepare("
129
my $sth = $dbh->prepare("
130
SELECT borrowernumber, itemnumber, accountno, description
130
SELECT accountlines_id, description
131
  FROM accountlines
131
  FROM accountlines
132
  WHERE accounttype in ('FU', 'F', 'O', 'M')
132
  WHERE accounttype in ('FU', 'F', 'O', 'M')
133
;");
133
;");
Lines 136-142 $sth->execute(); Link Here
136
my $update_sth = $dbh->prepare('
136
my $update_sth = $dbh->prepare('
137
UPDATE accountlines
137
UPDATE accountlines
138
  SET description = ?
138
  SET description = ?
139
  WHERE borrowernumber = ? AND itemnumber = ? AND accountno = ?
139
  WHERE accountlines_id = ?
140
;');
140
;');
141
141
142
142
Lines 161-167 while (my $accountline = $sth->fetchrow_hashref) { Link Here
161
    }
161
    }
162
162
163
    print "Changing description from '" . $accountline->{'description'} . "' to '" . $description . "'\n" if $DEBUG;
163
    print "Changing description from '" . $accountline->{'description'} . "' to '" . $description . "'\n" if $DEBUG;
164
    $update_sth->execute($description, $accountline->{'borrowernumber'}, $accountline->{'itemnumber'}, $accountline->{'accountno'});
164
    $update_sth->execute($description, $accountline->{'accountlines_id'});
165
165
166
    $done++;
166
    $done++;
167
167
(-)a/misc/maintenance/fix_accountlines_rmdupfines_bug8253.pl (-9 / +5 lines)
Lines 65-71 my $query = " Link Here
65
    SELECT * FROM accountlines
65
    SELECT * FROM accountlines
66
    WHERE ( accounttype =  'FU' OR accounttype =  'F' )
66
    WHERE ( accounttype =  'FU' OR accounttype =  'F' )
67
    AND description like '%23:59%'
67
    AND description like '%23:59%'
68
    ORDER BY borrowernumber, itemnumber, accountno, description
68
    ORDER BY borrowernumber, itemnumber, accountlines_id, description
69
";
69
";
70
my $sth = $dbh->prepare($query);
70
my $sth = $dbh->prepare($query);
71
$sth->execute();
71
$sth->execute();
Lines 98-117 foreach my $keeper (@$results) { Link Here
98
        }
98
        }
99
99
100
        my $sql =
100
        my $sql =
101
            "DELETE FROM accountlines WHERE borrowernumber = ? AND accountno = ? AND itemnumber = ? AND date = ? AND description = ? LIMIT 1";
101
            "DELETE FROM accountlines WHERE accountlines_id = ? LIMIT 1";
102
        $dbh->do( $sql, undef, $f->{'borrowernumber'},
102
        $dbh->do( $sql, undef, $f->{'accountlines_id'} );
103
            $f->{'accountno'}, $f->{'itemnumber'}, $f->{'date'},
104
            $f->{'description'} );
105
    }
103
    }
106
104
107
    if ($has_changed) {
105
    if ($has_changed) {
108
        my $sql =
106
        my $sql =
109
            "UPDATE accountlines SET amountoutstanding = ? WHERE borrowernumber = ? AND accountno = ? AND itemnumber = ? AND date = ? AND description = ? LIMIT 1";
107
            "UPDATE accountlines SET amountoutstanding = ? WHERE accountlines_id = ? LIMIT 1";
110
        $dbh->do(
108
        $dbh->do(
111
            $sql,                           undef,
109
            $sql,                           undef,
112
            $keeper->{'amountoutstanding'}, $keeper->{'borrowernumber'},
110
            $keeper->{'amountoutstanding'}, $keeper->{'accountlines_id'}
113
            $keeper->{'accountno'},         $keeper->{'itemnumber'},
114
            $keeper->{'date'},              $keeper->{'description'}
115
        );
111
        );
116
    }
112
    }
117
}
113
}
(-)a/t/db_dependent/Accounts.t (-4 lines)
Lines 41-47 BEGIN { Link Here
41
41
42
can_ok( 'C4::Accounts',
42
can_ok( 'C4::Accounts',
43
    qw(
43
    qw(
44
        getnextacctno
45
        chargelostitem
44
        chargelostitem
46
        manualinvoice
45
        manualinvoice
47
        purge_zero_balance_fees )
46
        purge_zero_balance_fees )
Lines 639-645 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
639
    Koha::Account::Line->new(
638
    Koha::Account::Line->new(
640
        {
639
        {
641
            borrowernumber    => $patron->borrowernumber,
640
            borrowernumber    => $patron->borrowernumber,
642
            accountno         => 1,
643
            date              => $today,
641
            date              => $today,
644
            description       => 'a Res fee',
642
            description       => 'a Res fee',
645
            accounttype       => 'Res',
643
            accounttype       => 'Res',
Lines 649-655 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
649
    Koha::Account::Line->new(
647
    Koha::Account::Line->new(
650
        {
648
        {
651
            borrowernumber    => $patron->borrowernumber,
649
            borrowernumber    => $patron->borrowernumber,
652
            accountno         => 2,
653
            date              => $today,
650
            date              => $today,
654
            description       => 'a Rental fee',
651
            description       => 'a Rental fee',
655
            accounttype       => 'Rent',
652
            accounttype       => 'Rent',
Lines 659-665 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
659
    Koha::Account::Line->new(
656
    Koha::Account::Line->new(
660
        {
657
        {
661
            borrowernumber    => $patron->borrowernumber,
658
            borrowernumber    => $patron->borrowernumber,
662
            accountno         => 3,
663
            date              => $today,
659
            date              => $today,
664
            description       => 'a Manual invoice fee',
660
            description       => 'a Manual invoice fee',
665
            accounttype       => 'Copie',
661
            accounttype       => 'Copie',
(-)a/t/db_dependent/ILSDI_Services.t (-1 lines)
Lines 197-203 subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes Link Here
197
            source => 'Accountline',
197
            source => 'Accountline',
198
            value  => {
198
            value  => {
199
                borrowernumber    => $brwr->{borrowernumber},
199
                borrowernumber    => $brwr->{borrowernumber},
200
                accountno         => 1,
201
                accounttype       => 'xxx',
200
                accounttype       => 'xxx',
202
                amountoutstanding => 10
201
                amountoutstanding => 10
203
            }
202
            }
(-)a/t/db_dependent/Stats.t (-6 / +1 lines)
Lines 3-9 Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
use C4::Stats;
4
use C4::Stats;
5
5
6
use Test::More tests => 19;
6
use Test::More tests => 18;
7
7
8
BEGIN {
8
BEGIN {
9
    use_ok('C4::Stats');
9
    use_ok('C4::Stats');
Lines 32-38 my $params = { Link Here
32
              other => "bla",
32
              other => "bla",
33
              itemtype => "BK",
33
              itemtype => "BK",
34
              location => "LOC",
34
              location => "LOC",
35
              accountno => 51,
36
              ccode => "CODE",
35
              ccode => "CODE",
37
};
36
};
38
my $return_error;
37
my $return_error;
Lines 105-111 $params = { Link Here
105
              other => "bla",
104
              other => "bla",
106
              itemtype => "BK",
105
              itemtype => "BK",
107
              location => "LOC",
106
              location => "LOC",
108
              accountno => 51,
109
              ccode => "CODE",
107
              ccode => "CODE",
110
              type => "return"
108
              type => "return"
111
};
109
};
Lines 120-126 cmp_ok($params->{amount},'==', $line->{value}, "UpdateStats save amount Link Here
120
is ($params->{other},          $line->{other},          "UpdateStats save other param in other field of statistics table");
118
is ($params->{other},          $line->{other},          "UpdateStats save other param in other field of statistics table");
121
is ($params->{itemtype},       $line->{itemtype},       "UpdateStats save itemtype param in itemtype field of statistics table");
119
is ($params->{itemtype},       $line->{itemtype},       "UpdateStats save itemtype param in itemtype field of statistics table");
122
is ($params->{location},       $line->{location},       "UpdateStats save location param in location field of statistics table");
120
is ($params->{location},       $line->{location},       "UpdateStats save location param in location field of statistics table");
123
is ($params->{accountno},      $line->{proccode},       "UpdateStats save accountno param in proccode field of statistics table");
124
is ($params->{ccode},          $line->{ccode},          "UpdateStats save ccode param in ccode field of statistics table");
121
is ($params->{ccode},          $line->{ccode},          "UpdateStats save ccode param in ccode field of statistics table");
125
122
126
$dbh->do(q|DELETE FROM statistics|);
123
$dbh->do(q|DELETE FROM statistics|);
Lines 131-137 $params = { Link Here
131
    amount         => 5.1,
128
    amount         => 5.1,
132
    other          => "bla",
129
    other          => "bla",
133
    itemtype       => "BK",
130
    itemtype       => "BK",
134
    accountno      => 51,
135
    ccode          => "CODE",
131
    ccode          => "CODE",
136
    type           => "return"
132
    type           => "return"
137
};
133
};
Lines 151-157 $params = { Link Here
151
    other          => "bla",
147
    other          => "bla",
152
    itemtype       => "BK",
148
    itemtype       => "BK",
153
    location       => undef,
149
    location       => undef,
154
    accountno      => 51,
155
    ccode          => "CODE",
150
    ccode          => "CODE",
156
    type           => "return"
151
    type           => "return"
157
};
152
};
(-)a/t/lib/TestBuilder.pm (-4 lines)
Lines 493-501 sub _gen_default_values { Link Here
493
        AuthHeader => {
493
        AuthHeader => {
494
            marcxml => '',
494
            marcxml => '',
495
        },
495
        },
496
        Accountline => {
497
            accountno => 0,
498
        },
499
    };
496
    };
500
}
497
}
501
498
502
- 

Return to bug 21683