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

(-)a/C4/Accounts.pm (-2 / +73 lines)
Lines 159-169 sub chargelostitem{ Link Here
159
    unless ($existing_charges) {
159
    unless ($existing_charges) {
160
        #add processing fee
160
        #add processing fee
161
        if ($processfee && $processfee > 0){
161
        if ($processfee && $processfee > 0){
162
            manualinvoice($borrowernumber, $itemnumber, $description, 'PF', $processfee, $processingfeenote, 1);
162
            my $accountline = Koha::Account::Line->new(
163
                {
164
                    borrowernumber    => $borrowernumber,
165
                    accountno         => getnextacctno($borrowernumber),
166
                    date              => \'NOW()',
167
                    amount            => $processfee,
168
                    description       => $description,
169
                    accounttype       => 'PF',
170
                    amountoutstanding => $processfee,
171
                    itemnumber        => $itemnumber,
172
                    note              => $processingfeenote,
173
                    manager_id        => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0,
174
                }
175
            )->store();
176
177
            my $account_offset = Koha::Account::Offset->new(
178
                {
179
                    debit_id => $accountline->id,
180
                    type     => 'Processing Fee',
181
                    amount   => $accountline->amount,
182
                }
183
            )->store();
184
185
            if ( C4::Context->preference("FinesLog") ) {
186
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
187
                    action            => 'create_fee',
188
                    borrowernumber    => $accountline->borrowernumber,,
189
                    accountno         => $accountline->accountno,
190
                    amount            => $accountline->amount,
191
                    description       => $accountline->description,
192
                    accounttype       => $accountline->accounttype,
193
                    amountoutstanding => $accountline->amountoutstanding,
194
                    note              => $accountline->note,
195
                    itemnumber        => $accountline->itemnumber,
196
                    manager_id        => $accountline->manager_id,
197
                }));
198
            }
163
        }
199
        }
164
        #add replace cost
200
        #add replace cost
165
        if ($replacementprice > 0){
201
        if ($replacementprice > 0){
166
            manualinvoice($borrowernumber, $itemnumber, $description, 'L', $replacementprice, undef, 1);
202
            my $accountline = Koha::Account::Line->new(
203
                {
204
                    borrowernumber    => $borrowernumber,
205
                    accountno         => getnextacctno($borrowernumber),
206
                    date              => \'NOW()',
207
                    amount            => $replacementprice,
208
                    description       => $description,
209
                    accounttype       => 'L',
210
                    amountoutstanding => $replacementprice,
211
                    itemnumber        => $itemnumber,
212
                    manager_id        => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0,
213
                }
214
            )->store();
215
216
            my $account_offset = Koha::Account::Offset->new(
217
                {
218
                    debit_id => $accountline->id,
219
                    type     => 'Lost Item',
220
                    amount   => $accountline->amount,
221
                }
222
            )->store();
223
224
            if ( C4::Context->preference("FinesLog") ) {
225
                logaction("FINES", 'CREATE',$borrowernumber,Dumper({
226
                    action            => 'create_fee',
227
                    borrowernumber    => $accountline->borrowernumber,,
228
                    accountno         => $accountline->accountno,
229
                    amount            => $accountline->amount,
230
                    description       => $accountline->description,
231
                    accounttype       => $accountline->accounttype,
232
                    amountoutstanding => $accountline->amountoutstanding,
233
                    note              => $accountline->note,
234
                    itemnumber        => $accountline->itemnumber,
235
                    manager_id        => $accountline->manager_id,
236
                }));
237
            }
167
        }
238
        }
168
    }
239
    }
169
}
240
}
(-)a/installer/data/mysql/account_offset_types.sql (+1 lines)
Lines 2-7 INSERT INTO account_offset_types ( type ) VALUES Link Here
2
('Writeoff'),
2
('Writeoff'),
3
('Payment'),
3
('Payment'),
4
('Lost Item'),
4
('Lost Item'),
5
('Processing Fee'),
5
('Manual Debit'),
6
('Manual Debit'),
6
('Reverse Payment'),
7
('Reverse Payment'),
7
('Forgiven'),
8
('Forgiven'),
(-)a/installer/data/mysql/atomicupdate/processing_fee.sql (+1 lines)
Line 0 Link Here
1
INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Processing Fee' );
(-)a/t/db_dependent/Circulation/Chargelostitem.t (-2 / +8 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 4;
5
use Test::More tests => 6;
6
use Test::MockModule;
6
use Test::MockModule;
7
use t::lib::Mocks;
7
use t::lib::Mocks;
8
use t::lib::TestBuilder;
8
use t::lib::TestBuilder;
Lines 62-67 AddIssue($borrower, '0101'); Link Here
62
AddIssue($borrower, '0203');
62
AddIssue($borrower, '0203');
63
63
64
# Begin tests...
64
# Begin tests...
65
Koha::Account::Offsets->delete();
65
my $issue = Koha::Checkouts->search( { borrowernumber => $borrowernumber } )->next()->unblessed();
66
my $issue = Koha::Checkouts->search( { borrowernumber => $borrowernumber } )->next()->unblessed();
66
C4::Accounts::chargelostitem( $borrowernumber, $issue->{itemnumber}, '1.00');
67
C4::Accounts::chargelostitem( $borrowernumber, $issue->{itemnumber}, '1.00');
67
68
Lines 70-72 my $accountline = Koha::Account::Lines->search( { borrowernumber => $borrowernum Link Here
70
is( int($accountline->amount), $itemtype->{processfee}, "The accountline amount should be precessfee value " );
71
is( int($accountline->amount), $itemtype->{processfee}, "The accountline amount should be precessfee value " );
71
is( $accountline->itemnumber, $itemnumber1, "The accountline itemnumber should the linked with barcode '0101'" );
72
is( $accountline->itemnumber, $itemnumber1, "The accountline itemnumber should the linked with barcode '0101'" );
72
is( $accountline->note, C4::Context->preference("ProcessingFeeNote"), "The accountline description should be 'test'" );
73
is( $accountline->note, C4::Context->preference("ProcessingFeeNote"), "The accountline description should be 'test'" );
73
- 
74
75
my $lost_ao = Koha::Account::Offsets->single( { type => 'Lost Item' } );
76
ok( $lost_ao, 'Account offset of type "Lost Item" created' );
77
78
my $processing_fee_ao = Koha::Account::Offsets->single( { type => 'Processing Fee' } );
79
ok( $processing_fee_ao, 'Account offset of type "Processing Fee" created' );

Return to bug 12768