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

(-)a/C4/Accounts.pm (-32 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
      &ReversePayment
42
      &ReversePayment
44
      &purge_zero_balance_fees
43
      &purge_zero_balance_fees
Lines 61-89 patron. Link Here
61
60
62
=head1 FUNCTIONS
61
=head1 FUNCTIONS
63
62
64
=head2 getnextacctno
65
66
  $nextacct = &getnextacctno($borrowernumber);
67
68
Returns the next unused account number for the patron with the given
69
borrower number.
70
71
=cut
72
73
#'
74
# FIXME - Okay, so what does the above actually _mean_?
75
sub getnextacctno {
76
    my ($borrowernumber) = shift or return;
77
    my $sth = C4::Context->dbh->prepare(
78
        "SELECT accountno+1 FROM accountlines
79
            WHERE    (borrowernumber = ?)
80
            ORDER BY accountno DESC
81
            LIMIT 1"
82
    );
83
    $sth->execute($borrowernumber);
84
    return ($sth->fetchrow || 1);
85
}
86
87
=head2 chargelostitem
63
=head2 chargelostitem
88
64
89
In a default install of Koha the following lost values are set
65
In a default install of Koha the following lost values are set
Lines 129-135 sub chargelostitem{ Link Here
129
            my $accountline = Koha::Account::Line->new(
105
            my $accountline = Koha::Account::Line->new(
130
                {
106
                {
131
                    borrowernumber    => $borrowernumber,
107
                    borrowernumber    => $borrowernumber,
132
                    accountno         => getnextacctno($borrowernumber),
133
                    date              => \'NOW()',
108
                    date              => \'NOW()',
134
                    amount            => $processfee,
109
                    amount            => $processfee,
135
                    description       => $description,
110
                    description       => $description,
Lines 154-160 sub chargelostitem{ Link Here
154
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
129
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
155
                    action            => 'create_fee',
130
                    action            => 'create_fee',
156
                    borrowernumber    => $accountline->borrowernumber,,
131
                    borrowernumber    => $accountline->borrowernumber,,
157
                    accountno         => $accountline->accountno,
158
                    amount            => $accountline->amount,
132
                    amount            => $accountline->amount,
159
                    description       => $accountline->description,
133
                    description       => $accountline->description,
160
                    accounttype       => $accountline->accounttype,
134
                    accounttype       => $accountline->accounttype,
Lines 170-176 sub chargelostitem{ Link Here
170
            my $accountline = Koha::Account::Line->new(
144
            my $accountline = Koha::Account::Line->new(
171
                {
145
                {
172
                    borrowernumber    => $borrowernumber,
146
                    borrowernumber    => $borrowernumber,
173
                    accountno         => getnextacctno($borrowernumber),
174
                    date              => \'NOW()',
147
                    date              => \'NOW()',
175
                    amount            => $replacementprice,
148
                    amount            => $replacementprice,
176
                    description       => $description,
149
                    description       => $description,
Lines 194-200 sub chargelostitem{ Link Here
194
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
167
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
195
                    action            => 'create_fee',
168
                    action            => 'create_fee',
196
                    borrowernumber    => $accountline->borrowernumber,,
169
                    borrowernumber    => $accountline->borrowernumber,,
197
                    accountno         => $accountline->accountno,
198
                    amount            => $accountline->amount,
170
                    amount            => $accountline->amount,
199
                    description       => $accountline->description,
171
                    description       => $accountline->description,
200
                    accounttype       => $accountline->accounttype,
172
                    accounttype       => $accountline->accounttype,
Lines 240-246 sub manualinvoice { Link Here
240
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
212
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
241
    my $dbh      = C4::Context->dbh;
213
    my $dbh      = C4::Context->dbh;
242
    my $insert;
214
    my $insert;
243
    my $accountno  = getnextacctno($borrowernumber);
244
    my $amountleft = $amount;
215
    my $amountleft = $amount;
245
216
246
    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
217
    my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
Lines 248-254 sub manualinvoice { Link Here
248
    my $accountline = Koha::Account::Line->new(
219
    my $accountline = Koha::Account::Line->new(
249
        {
220
        {
250
            borrowernumber    => $borrowernumber,
221
            borrowernumber    => $borrowernumber,
251
            accountno         => $accountno,
252
            date              => \'NOW()',
222
            date              => \'NOW()',
253
            amount            => $amount,
223
            amount            => $amount,
254
            description       => $desc,
224
            description       => $desc,
Lines 273-279 sub manualinvoice { Link Here
273
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
243
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
274
            action            => 'create_fee',
244
            action            => 'create_fee',
275
            borrowernumber    => $borrowernumber,
245
            borrowernumber    => $borrowernumber,
276
            accountno         => $accountno,
277
            amount            => $amount,
246
            amount            => $amount,
278
            description       => $desc,
247
            description       => $desc,
279
            accounttype       => $type,
248
            accounttype       => $type,
Lines 325-331 sub ReversePayment { Link Here
325
                    new_amountoutstanding => $new_amountoutstanding,
294
                    new_amountoutstanding => $new_amountoutstanding,
326
                    ,
295
                    ,
327
                    accountlines_id => $accountline->id,
296
                    accountlines_id => $accountline->id,
328
                    accountno       => $accountline->accountno,
329
                    manager_id      => $manager_id,
297
                    manager_id      => $manager_id,
330
                }
298
                }
331
            )
299
            )
(-)a/C4/Circulation.pm (-4 / +1 lines)
Lines 2400-2406 sub _FixAccountForLostAndReturned { Link Here
2400
            accounttype => { -in => [ 'L', 'Rep', 'W' ] },
2400
            accounttype => { -in => [ 'L', 'Rep', 'W' ] },
2401
        },
2401
        },
2402
        {
2402
        {
2403
            order_by => { -desc => [ 'date', 'accountno' ] }
2403
            order_by => { -desc => [ 'date' ] }
2404
        }
2404
        }
2405
    )->next();
2405
    )->next();
2406
2406
Lines 3187-3194 sub AddIssuingCharge { Link Here
3187
3187
3188
    # FIXME What if checkout does not exist?
3188
    # FIXME What if checkout does not exist?
3189
3189
3190
    my $nextaccntno = getnextacctno($checkout->borrowernumber);
3191
3192
    my $manager_id  = 0;
3190
    my $manager_id  = 0;
3193
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
3191
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
3194
3192
Lines 3199-3205 sub AddIssuingCharge { Link Here
3199
            borrowernumber    => $checkout->borrowernumber,
3197
            borrowernumber    => $checkout->borrowernumber,
3200
            itemnumber        => $checkout->itemnumber,
3198
            itemnumber        => $checkout->itemnumber,
3201
            issue_id          => $checkout->issue_id,
3199
            issue_id          => $checkout->issue_id,
3202
            accountno         => $nextaccntno,
3203
            amount            => $charge,
3200
            amount            => $charge,
3204
            amountoutstanding => $charge,
3201
            amountoutstanding => $charge,
3205
            manager_id        => $manager_id,
3202
            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/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 (-23 lines)
Lines 85-101 sub pay { Link Here
85
85
86
    my $patron = Koha::Patrons->find( $self->{patron_id} );
86
    my $patron = Koha::Patrons->find( $self->{patron_id} );
87
87
88
    # We should remove accountno, it is no longer needed
89
    my $last = Koha::Account::Lines->search(
90
        {
91
            borrowernumber => $self->{patron_id}
92
        },
93
        {
94
            order_by => 'accountno'
95
        }
96
    )->next();
97
    my $accountno = $last ? $last->accountno + 1 : 1;
98
99
    my $manager_id = $userenv ? $userenv->{number} : 0;
88
    my $manager_id = $userenv ? $userenv->{number} : 0;
100
89
101
    my @fines_paid; # List of account lines paid on with this payment
90
    my @fines_paid; # List of account lines paid on with this payment
Lines 143-149 sub pay { Link Here
143
                        new_amountoutstanding => 0,
132
                        new_amountoutstanding => 0,
144
                        amount_paid           => $old_amountoutstanding,
133
                        amount_paid           => $old_amountoutstanding,
145
                        accountlines_id       => $fine->id,
134
                        accountlines_id       => $fine->id,
146
                        accountno             => $fine->accountno,
147
                        manager_id            => $manager_id,
135
                        manager_id            => $manager_id,
148
                        note                  => $note,
136
                        note                  => $note,
149
                    }
137
                    }
Lines 195-201 sub pay { Link Here
195
                        new_amountoutstanding => $fine->amountoutstanding,
183
                        new_amountoutstanding => $fine->amountoutstanding,
196
                        amount_paid           => $amount_to_pay,
184
                        amount_paid           => $amount_to_pay,
197
                        accountlines_id       => $fine->id,
185
                        accountlines_id       => $fine->id,
198
                        accountno             => $fine->accountno,
199
                        manager_id            => $manager_id,
186
                        manager_id            => $manager_id,
200
                        note                  => $note,
187
                        note                  => $note,
201
                    }
188
                    }
Lines 218-224 sub pay { Link Here
218
    my $payment = Koha::Account::Line->new(
205
    my $payment = Koha::Account::Line->new(
219
        {
206
        {
220
            borrowernumber    => $self->{patron_id},
207
            borrowernumber    => $self->{patron_id},
221
            accountno         => $accountno,
222
            date              => dt_from_string(),
208
            date              => dt_from_string(),
223
            amount            => 0 - $amount,
209
            amount            => 0 - $amount,
224
            description       => $description,
210
            description       => $description,
Lines 242-248 sub pay { Link Here
242
            type           => $type,
228
            type           => $type,
243
            amount         => $amount,
229
            amount         => $amount,
244
            borrowernumber => $self->{patron_id},
230
            borrowernumber => $self->{patron_id},
245
            accountno      => $accountno,
246
        }
231
        }
247
    );
232
    );
248
233
Lines 254-260 sub pay { Link Here
254
                {
239
                {
255
                    action            => "create_$type",
240
                    action            => "create_$type",
256
                    borrowernumber    => $self->{patron_id},
241
                    borrowernumber    => $self->{patron_id},
257
                    accountno         => $accountno,
258
                    amount            => 0 - $amount,
242
                    amount            => 0 - $amount,
259
                    amountoutstanding => 0 - $balance_remaining,
243
                    amountoutstanding => 0 - $balance_remaining,
260
                    accounttype       => $account_type,
244
                    accounttype       => $account_type,
Lines 349-359 sub add_credit { Link Here
349
333
350
    $schema->txn_do(
334
    $schema->txn_do(
351
        sub {
335
        sub {
352
            # We should remove accountno, it is no longer needed
353
            my $last = Koha::Account::Lines->search( { borrowernumber => $self->{patron_id} },
354
                { order_by => 'accountno' } )->next();
355
            my $accountno = $last ? $last->accountno + 1 : 1;
356
357
            # Insert the account line
336
            # Insert the account line
358
            $line = Koha::Account::Line->new(
337
            $line = Koha::Account::Line->new(
359
                {   borrowernumber    => $self->{patron_id},
338
                {   borrowernumber    => $self->{patron_id},
Lines 382-388 sub add_credit { Link Here
382
                    type           => $type,
361
                    type           => $type,
383
                    amount         => $amount,
362
                    amount         => $amount,
384
                    borrowernumber => $self->{patron_id},
363
                    borrowernumber => $self->{patron_id},
385
                    accountno      => $accountno,
386
                }
364
                }
387
            ) if grep { $type eq $_ } ('payment', 'writeoff') ;
365
            ) if grep { $type eq $_ } ('payment', 'writeoff') ;
388
366
Lines 393-399 sub add_credit { Link Here
393
                    Dumper(
371
                    Dumper(
394
                        {   action            => "create_$type",
372
                        {   action            => "create_$type",
395
                            borrowernumber    => $self->{patron_id},
373
                            borrowernumber    => $self->{patron_id},
396
                            accountno         => $accountno,
397
                            amount            => $amount,
374
                            amount            => $amount,
398
                            description       => $description,
375
                            description       => $description,
399
                            amountoutstanding => $amount,
376
                            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 (-5 lines)
Lines 54-63 my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in" Link Here
54
my $patron         = Koha::Patrons->find( $borrowernumber );
54
my $patron         = Koha::Patrons->find( $borrowernumber );
55
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
55
output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
56
56
57
if ( $action eq 'print' ) {
58
#  ReversePayment( $borrowernumber, $input->param('accountno') );
59
}
60
61
#get account details
57
#get account details
62
my $total = $patron->account->balance;
58
my $total = $patron->account->balance;
63
59
Lines 86-92 my %row = ( Link Here
86
    'description'             => $accountline->{'description'},
82
    'description'             => $accountline->{'description'},
87
    'amount'                  => $accountline->{'amount'},
83
    'amount'                  => $accountline->{'amount'},
88
    'amountoutstanding'       => $accountline->{'amountoutstanding'},
84
    'amountoutstanding'       => $accountline->{'amountoutstanding'},
89
    'accountno' => $accountline->{'accountno'},
90
    accounttype => $accountline->{accounttype},
85
    accounttype => $accountline->{accounttype},
91
    'note'      => $accountline->{'note'},
86
    'note'      => $accountline->{'note'},
92
);
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
        ReversePayment
46
        ReversePayment
Lines 688-694 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
688
    Koha::Account::Line->new(
687
    Koha::Account::Line->new(
689
        {
688
        {
690
            borrowernumber    => $patron->borrowernumber,
689
            borrowernumber    => $patron->borrowernumber,
691
            accountno         => 1,
692
            date              => $today,
690
            date              => $today,
693
            description       => 'a Res fee',
691
            description       => 'a Res fee',
694
            accounttype       => 'Res',
692
            accounttype       => 'Res',
Lines 698-704 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
698
    Koha::Account::Line->new(
696
    Koha::Account::Line->new(
699
        {
697
        {
700
            borrowernumber    => $patron->borrowernumber,
698
            borrowernumber    => $patron->borrowernumber,
701
            accountno         => 2,
702
            date              => $today,
699
            date              => $today,
703
            description       => 'a Rental fee',
700
            description       => 'a Rental fee',
704
            accounttype       => 'Rent',
701
            accounttype       => 'Rent',
Lines 708-714 subtest "Koha::Account::non_issues_charges tests" => sub { Link Here
708
    Koha::Account::Line->new(
705
    Koha::Account::Line->new(
709
        {
706
        {
710
            borrowernumber    => $patron->borrowernumber,
707
            borrowernumber    => $patron->borrowernumber,
711
            accountno         => 3,
712
            date              => $today,
708
            date              => $today,
713
            description       => 'a Manual invoice fee',
709
            description       => 'a Manual invoice fee',
714
            accounttype       => 'Copie',
710
            accounttype       => 'Copie',
(-)a/t/db_dependent/ILSDI_Services.t (-1 lines)
Lines 196-202 subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes Link Here
196
            source => 'Accountline',
196
            source => 'Accountline',
197
            value  => {
197
            value  => {
198
                borrowernumber    => $brwr->{borrowernumber},
198
                borrowernumber    => $brwr->{borrowernumber},
199
                accountno         => 1,
200
                accounttype       => 'xxx',
199
                accounttype       => 'xxx',
201
                amountoutstanding => 10
200
                amountoutstanding => 10
202
            }
201
            }
(-)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