}
sub pay_fee {
- my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type,
- $pay_type, $fee_id, $trans_id, $currency) = @_;
+ my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type, $pay_type, $fee_id, $trans_id, $currency) = @_;
my $trans;
$trans = C4::SIP::ILS::Transaction::FeePayment->new();
-
$trans->transaction_id($trans_id);
my $patron;
$trans->patron($patron = C4::SIP::ILS::Patron->new($patron_id));
$trans->screen_msg('Invalid patron barcode.');
return $trans;
}
- $trans->pay($patron->{borrowernumber},$fee_amt, $pay_type);
- $trans->ok(1);
+ my $ok =$trans->pay($patron->{borrowernumber},$fee_amt, $pay_type, $fee_id);
+ $trans->ok($ok);
return $trans;
}
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Koha::Account;
-use parent qw(C4::SIP::ILS::Transaction);
+use Koha::Account::Lines;
+use parent qw(C4::SIP::ILS::Transaction);
-our $debug = 0;
+our $debug = 0;
my %fields = ();
my $borrowernumber = shift;
my $amt = shift;
my $type = shift;
+ my $fee_id = shift;
+
warn("RECORD:$borrowernumber::$amt");
- Koha::Account->new( { patron_id => $borrowernumber } )->pay( { amount => $amt, sip => $type } );
+
+ my $account = Koha::Account->new( { patron_id => $borrowernumber } );
+
+ if ($fee_id) {
+ my $fee = Koha::Account::Lines->find($fee_id);
+ if ( $fee && $fee->amountoutstanding == $amt ) {
+ $account->pay( { amount => $amt, sip => $type, lines => [$fee] } );
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+ else {
+ $account->pay( { amount => $amt, sip => $type } );
+ return 1;
+ }
}
#sub DESTROY {