Browse Source

Bug 22600: Add 'interface' to accountlines

This patch adds the 'interface' field to the accountlines table and
updates all Koha::Object routines and calls to use it.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
19.05.x
Martin Renvoize 3 years ago
committed by Nick Clemens
parent
commit
9ec4d86636
  1. 2
      C4/Accounts.pm
  2. 10
      C4/Circulation.pm
  3. 2
      C4/Log.pm
  4. 14
      C4/Overdues.pm
  5. 1
      C4/Reserves.pm
  6. 16
      C4/SIP/ILS/Transaction/FeePayment.pm
  7. 4
      C4/SIP/SIPServer.pm
  8. 23
      Koha/Account.pm
  9. 7
      Koha/Account/Line.pm
  10. 9
      Koha/Hold.pm
  11. 7
      Koha/Patron.pm
  12. 1
      Koha/REST/V1/Patrons/Account.pm
  13. 52
      installer/data/mysql/atomicupdate/bug_22600.perl
  14. 1
      installer/data/mysql/kohastructure.sql
  15. 3
      members/mancredit.pl
  16. 2
      members/pay.pl
  17. 3
      members/paycollect.pl
  18. 2
      offline_circ/process_koc.pl
  19. 3
      opac/opac-account-pay-paypal-return.pl

2
C4/Accounts.pm

@ -107,6 +107,7 @@ sub chargelostitem{
description => $description,
note => $processingfeenote,
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
interface => C4::Context->interface,
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
type => 'processing',
item_id => $itemnumber,
@ -122,6 +123,7 @@ sub chargelostitem{
description => $description,
note => undef,
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
interface => C4::Context->interface,
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
type => 'lost_item',
item_id => $itemnumber,

10
C4/Circulation.pm

@ -2416,6 +2416,7 @@ sub _FixAccountForLostAndReturned {
{ amount => $credit_total,
description => 'Item Returned ' . $item_id,
type => 'lost_item_return',
interface => C4::Context->interface,
library_id => $branchcode
}
);
@ -3220,6 +3221,7 @@ sub AddIssuingCharge {
note => undef,
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
interface => C4::Context->interface,
type => 'rent',
item_id => $checkout->itemnumber,
issue_id => $checkout->issue_id,
@ -3810,7 +3812,13 @@ sub ProcessOfflinePayment {
my $patron = Koha::Patrons->find({ cardnumber => $operation->{cardnumber} });
$patron->account->pay({ amount => $operation->{amount}, library_id => $operation->{branchcode} });
$patron->account->pay(
{
amount => $operation->{amount},
library_id => $operation->{branchcode},
interface => 'koc'
}
);
return "Success.";
}

2
C4/Log.pm

@ -56,7 +56,7 @@ The functions in this module perform various functions in order to log all the o
=item logaction
&logaction($modulename, $actionname, $objectnumber, $infos);
&logaction($modulename, $actionname, $objectnumber, $infos, $interface);
Adds a record into action_logs table to report the different changes upon the database.
Each log entry includes the number of the user currently logged in. For batch

14
C4/Overdues.pm

@ -573,8 +573,15 @@ sub UpdateFine {
if ( $data ) {
if ( $data->{'amount'} != $amount ) {
my $accountline = Koha::Account::Lines->find( $data->{accountlines_id} );
$accountline->adjust({ amount => $amount, type => 'fine_update' });
my $accountline =
Koha::Account::Lines->find( $data->{accountlines_id} );
$accountline->adjust(
{
amount => $amount,
type => 'fine_update',
interface => C4::Context->interface
}
);
}
} else {
if ( $amount ) { # Don't add new fines with an amount of 0
@ -592,7 +599,8 @@ sub UpdateFine {
description => $desc,
note => undef,
user_id => undef,
library_id => undef,
interface => C4::Context->interface,
library_id => undef, #FIXME: Should we grab the checkout or circ-control branch here perhaps?
type => 'fine',
item_id => $itemnum,
issue_id => $issue_id,

1
C4/Reserves.pm

@ -575,6 +575,7 @@ sub ChargeReserveFee {
note => undef,
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
interface => C4::Context->interface,
sip => undef,
invoice_type => undef,
type => 'reserve',

16
C4/SIP/ILS/Transaction/FeePayment.pm

@ -65,10 +65,11 @@ sub pay {
if ( $fee ) {
$account->pay(
{
amount => $amt,
sip => $sip_type,
type => $type,
lines => [$fee],
amount => $amt,
sip => $sip_type,
type => $type,
lines => [$fee],
interface => C4::Context->interface
}
);
return 1;
@ -80,9 +81,10 @@ sub pay {
else {
$account->pay(
{
amount => $amt,
sip => $sip_type,
type => $type,
amount => $amt,
sip => $sip_type,
type => $type,
interface => C4::Context->interface
}
);
return 1;

4
C4/SIP/SIPServer.pm

@ -11,6 +11,7 @@ use IO::Socket::INET;
use Socket qw(:DEFAULT :crlf);
require UNIVERSAL::require;
use C4::Context;
use C4::SIP::Sip::Constants qw(:all);
use C4::SIP::Sip::Configuration;
use C4::SIP::Sip::Checksum qw(checksum verify_cksum);
@ -27,6 +28,9 @@ use constant LOG_SIP => "local6"; # Local alias for the logging facility
# A script with no MAIN namespace?
# A module that takes command line args?
# Set interface to 'sip'
C4::Context->interface('sip');
my %transports = (
RAW => \&raw_transport,
telnet => \&telnet_transport,

23
Koha/Account.pm

@ -86,6 +86,7 @@ sub pay {
my $patron = Koha::Patrons->find( $self->{patron_id} );
my $manager_id = $userenv ? $userenv->{number} : 0;
my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
my @fines_paid; # List of account lines paid on with this payment
@ -135,7 +136,8 @@ sub pay {
manager_id => $manager_id,
note => $note,
}
)
),
$interface
);
push( @fines_paid, $fine->id );
}
@ -185,7 +187,8 @@ sub pay {
manager_id => $manager_id,
note => $note,
}
)
),
$interface
);
push( @fines_paid, $fine->id );
}
@ -211,6 +214,7 @@ sub pay {
payment_type => $payment_type,
amountoutstanding => 0 - $balance_remaining,
manager_id => $manager_id,
interface => $interface,
branchcode => $library_id,
note => $note,
}
@ -244,7 +248,8 @@ sub pay {
accountlines_paid => \@fines_paid,
manager_id => $manager_id,
}
)
),
$interface
);
}
@ -289,6 +294,7 @@ my $credit_line = Koha::Account->new({ patron_id => $patron_id })->add_credit(
description => $description,
note => $note,
user_id => $user_id,
interface => $interface,
library_id => $library_id,
sip => $sip,
payment_type => $payment_type,
@ -315,6 +321,7 @@ sub add_credit {
my $description = $params->{description} // q{};
my $note = $params->{note} // q{};
my $user_id = $params->{user_id};
my $interface = $params->{interface};
my $library_id = $params->{library_id};
my $sip = $params->{sip};
my $payment_type = $params->{payment_type};
@ -344,6 +351,7 @@ sub add_credit {
payment_type => $payment_type,
note => $note,
manager_id => $user_id,
interface => $interface,
branchcode => $library_id,
itemnumber => $item_id,
}
@ -381,7 +389,8 @@ sub add_credit {
manager_id => $user_id,
branchcode => $library_id,
}
)
),
$interface
);
}
}
@ -400,6 +409,7 @@ my $debit_line = Koha::Account->new({ patron_id => $patron_id })->add_debit(
description => $description,
note => $note,
user_id => $user_id,
interface => $interface,
library_id => $library_id,
type => $debit_type,
item_id => $item_id,
@ -436,6 +446,7 @@ sub add_debit {
my $description = $params->{description} // q{};
my $note = $params->{note} // q{};
my $user_id = $params->{user_id};
my $interface = $params->{interface};
my $library_id = $params->{library_id};
my $type = $params->{type};
my $item_id = $params->{item_id};
@ -467,6 +478,7 @@ sub add_debit {
payment_type => undef,
note => $note,
manager_id => $user_id,
interface => $interface,
itemnumber => $item_id,
issue_id => $issue_id,
branchcode => $library_id,
@ -496,7 +508,8 @@ sub add_debit {
itemnumber => $item_id,
manager_id => $user_id,
}
)
),
$interface
);
}
}

7
Koha/Account/Line.pm

@ -229,8 +229,9 @@ This method allows updating a debit or credit on a patron's account
$account_line->adjust(
{
amount => $amount,
type => $update_type,
amount => $amount,
type => $update_type,
interface => $interface
}
);
@ -250,6 +251,7 @@ sub adjust {
my $amount = $params->{amount};
my $update_type = $params->{type};
my $interface = $params->{interface};
unless ( exists($Koha::Account::Line::allowed_update->{$update_type}) ) {
Koha::Exceptions::Account::UnrecognisedType->throw(
@ -286,6 +288,7 @@ sub adjust {
amount => $new_outstanding * -1,
description => 'Overpayment refund',
type => 'credit',
interface => $interface,
( $update_type eq 'fine_update' ? ( item_id => $self->itemnumber ) : ()),
}
);

9
Koha/Hold.pm

@ -369,11 +369,12 @@ sub cancel {
Koha::Account->new( { patron_id => $self->borrowernumber } );
$account->add_debit(
{
amount => $charge,
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
amount => $charge,
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
interface => C4::Context->interface,
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
type => 'hold_expired',
item_id => $self->itemnumber
type => 'hold_expired',
item_id => $self->itemnumber
}
);
}

7
Koha/Patron.pm

@ -849,10 +849,11 @@ sub add_enrolment_fee_if_needed {
if ( $enrolment_fee && $enrolment_fee > 0 ) {
$self->account->add_debit(
{
amount => $enrolment_fee,
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
amount => $enrolment_fee,
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
interface => C4::Context->interface,
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
type => 'account'
type => 'account'
}
);
}

1
Koha/REST/V1/Patrons/Account.pm

@ -114,6 +114,7 @@ sub add_credit {
description => $description,
note => $note,
user_id => $user->id,
interface => 'api',
library_id => $library_id
}
);

52
installer/data/mysql/atomicupdate/bug_22600.perl

@ -0,0 +1,52 @@
$DBversion = 'XXX'; # will be replaced by the RM
if ( CheckVersion($DBversion) ) {
if ( !column_exists( 'accountlines', 'interface' ) ) {
$dbh->do(
qq{
ALTER TABLE `accountlines`
ADD
`interface` varchar(16)
AFTER
`manager_id`;
}
);
}
$dbh->do(qq{
UPDATE
`accountlines`
SET
interface = 'opac'
WHERE
borrowernumber = manager_id;
});
$dbh->do(qq{
UPDATE
`accountlines`
SET
interface = 'cron'
WHERE
manager_id IS NULL
AND
branchcode IS NULL;
});
$dbh->do(qq{
UPDATE
`accountlines`
SET
interface = 'intranet'
WHERE
interface IS NULL;
});
$dbh->do(qq{
ALTER TABLE `accountlines`
MODIFY COLUMN `interface` varchar(16) NOT NULL;
});
SetVersion($DBversion);
print "Upgrade to $DBversion done (Bug 22600 - Add interface to accountlines)\n";
}

1
installer/data/mysql/kohastructure.sql

@ -2683,6 +2683,7 @@ CREATE TABLE `accountlines` (
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`note` MEDIUMTEXT NULL default NULL,
`manager_id` int(11) NULL DEFAULT NULL,
`interface` VARCHAR(16) NOT NULL,
`branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc.
PRIMARY KEY (`accountlines_id`),
KEY `acctsborridx` (`borrowernumber`),

3
members/mancredit.pl

@ -89,7 +89,8 @@ if ($add){
library_id => $library_id,
note => $note,
type => $type,
user_id => $logged_in_user->id
user_id => $logged_in_user->id,
interface => C4::Context->interface
});
if ( C4::Context->preference('AccountAutoReconcile') ) {

2
members/pay.pl

@ -113,6 +113,7 @@ elsif ( $input->param('confirm_writeoff') ) {
lines => [ scalar Koha::Account::Lines->find($accountlines_id) ],
type => 'writeoff',
note => $payment_note,
interface => C4::Context->interface,
library_id => $branch,
}
);
@ -216,6 +217,7 @@ sub writeoff_all {
lines => [ scalar Koha::Account::Lines->find($accountlines_id) ],
type => 'writeoff',
note => $payment_note,
interface => C4::Context->interface,
library_id => $branch,
}
);

3
members/paycollect.pl

@ -125,6 +125,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
amount => $total_paid,
library_id => $branch,
note => $payment_note,
interface => C4::Context->interface,
payment_type => $payment_type,
}
);
@ -157,6 +158,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
amount => $total_paid,
lines => \@lines,
note => $note,
interface => C4::Context->interface,
payment_type => $payment_type,
}
);
@ -168,6 +170,7 @@ if ( $total_paid and $total_paid ne '0.00' ) {
amount => $total_paid,
note => $note,
payment_type => $payment_type,
interface => C4::Context->interface
}
);
}

2
offline_circ/process_koc.pl

@ -371,7 +371,7 @@ sub kocMakePayment {
my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
Koha::Account->new( { patron_id => $patron->id } )
->pay( { amount => $amount } );
->pay( { amount => $amount, interface => C4::Context->interface } );
push @output,
{

3
opac/opac-account-pay-paypal-return.pl

@ -103,7 +103,8 @@ if ( $response->is_success ) {
{
amount => $amount,
lines => \@lines,
note => 'PayPal'
note => 'PayPal',
interface => C4::Context->interface
}
);
}

Loading…
Cancel
Save