Lines 71-86
Koha::Account->new( { patron_id => $borrowernumber } )->pay(
Link Here
|
71 |
sub pay { |
71 |
sub pay { |
72 |
my ( $self, $params ) = @_; |
72 |
my ( $self, $params ) = @_; |
73 |
|
73 |
|
74 |
my $amount = $params->{amount}; |
74 |
my $amount = $params->{amount}; |
75 |
my $sip = $params->{sip}; |
75 |
my $sip = $params->{sip}; |
76 |
my $description = $params->{description}; |
76 |
my $description = $params->{description}; |
77 |
my $note = $params->{note} || q{}; |
77 |
my $note = $params->{note} || q{}; |
78 |
my $library_id = $params->{library_id}; |
78 |
my $library_id = $params->{library_id}; |
79 |
my $lines = $params->{lines}; |
79 |
my $lines = $params->{lines}; |
80 |
my $type = $params->{type} || 'payment'; |
80 |
my $type = $params->{type} || 'payment'; |
81 |
my $payment_type = $params->{payment_type} || undef; |
81 |
my $payment_type = $params->{payment_type} || undef; |
82 |
my $account_type = $params->{account_type}; |
82 |
my $account_type = $params->{account_type}; |
83 |
my $offset_type = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment'; |
83 |
my $offset_type = $params->{offset_type} || $type eq 'writeoff' ? 'Writeoff' : 'Payment'; |
|
|
84 |
my $cash_register = $params->{cash_register}; |
84 |
|
85 |
|
85 |
my $userenv = C4::Context->userenv; |
86 |
my $userenv = C4::Context->userenv; |
86 |
|
87 |
|
Lines 88-93
sub pay {
Link Here
|
88 |
|
89 |
|
89 |
my $manager_id = $userenv ? $userenv->{number} : 0; |
90 |
my $manager_id = $userenv ? $userenv->{number} : 0; |
90 |
my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface; |
91 |
my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface; |
|
|
92 |
Koha::Exceptions::Account::RegisterRequired->throw() |
93 |
if ( C4::Context->preference("UseCashRegisters") |
94 |
&& !defined($cash_register) |
95 |
&& ( $interface ne 'opac' ) ); |
91 |
|
96 |
|
92 |
my @fines_paid; # List of account lines paid on with this payment |
97 |
my @fines_paid; # List of account lines paid on with this payment |
93 |
|
98 |
|
Lines 229-234
sub pay {
Link Here
|
229 |
manager_id => $manager_id, |
234 |
manager_id => $manager_id, |
230 |
interface => $interface, |
235 |
interface => $interface, |
231 |
branchcode => $library_id, |
236 |
branchcode => $library_id, |
|
|
237 |
cash_register => $cash_register, |
232 |
note => $note, |
238 |
note => $note, |
233 |
} |
239 |
} |
234 |
)->store(); |
240 |
)->store(); |
Lines 330-345
sub add_credit {
Link Here
|
330 |
my ( $self, $params ) = @_; |
336 |
my ( $self, $params ) = @_; |
331 |
|
337 |
|
332 |
# amount is passed as a positive value, but we store credit as negative values |
338 |
# amount is passed as a positive value, but we store credit as negative values |
333 |
my $amount = $params->{amount} * -1; |
339 |
my $amount = $params->{amount} * -1; |
334 |
my $description = $params->{description} // q{}; |
340 |
my $description = $params->{description} // q{}; |
335 |
my $note = $params->{note} // q{}; |
341 |
my $note = $params->{note} // q{}; |
336 |
my $user_id = $params->{user_id}; |
342 |
my $user_id = $params->{user_id}; |
337 |
my $interface = $params->{interface}; |
343 |
my $interface = $params->{interface}; |
338 |
my $library_id = $params->{library_id}; |
344 |
my $library_id = $params->{library_id}; |
339 |
my $sip = $params->{sip}; |
345 |
my $cash_register = $params->{cash_register}; |
340 |
my $payment_type = $params->{payment_type}; |
346 |
my $sip = $params->{sip}; |
341 |
my $type = $params->{type} || 'payment'; |
347 |
my $payment_type = $params->{payment_type}; |
342 |
my $item_id = $params->{item_id}; |
348 |
my $type = $params->{type} || 'payment'; |
|
|
349 |
my $item_id = $params->{item_id}; |
343 |
|
350 |
|
344 |
unless ( $interface ) { |
351 |
unless ( $interface ) { |
345 |
Koha::Exceptions::MissingParameter->throw( |
352 |
Koha::Exceptions::MissingParameter->throw( |
Lines 347-352
sub add_credit {
Link Here
|
347 |
); |
354 |
); |
348 |
} |
355 |
} |
349 |
|
356 |
|
|
|
357 |
Koha::Exceptions::Account::RegisterRequired->throw() |
358 |
if ( C4::Context->preference("UseCashRegisters") |
359 |
&& !defined($cash_register) |
360 |
&& ( $payment_type eq 'CASH' ) ); |
361 |
|
350 |
my $schema = Koha::Database->new->schema; |
362 |
my $schema = Koha::Database->new->schema; |
351 |
|
363 |
|
352 |
my $account_type = $Koha::Account::account_type_credit->{$type}; |
364 |
my $account_type = $Koha::Account::account_type_credit->{$type}; |
Lines 372-377
sub add_credit {
Link Here
|
372 |
manager_id => $user_id, |
384 |
manager_id => $user_id, |
373 |
interface => $interface, |
385 |
interface => $interface, |
374 |
branchcode => $library_id, |
386 |
branchcode => $library_id, |
|
|
387 |
cash_register => $cash_register, |
375 |
itemnumber => $item_id, |
388 |
itemnumber => $item_id, |
376 |
} |
389 |
} |
377 |
)->store(); |
390 |
)->store(); |