Lines 63-114
sub void {
Link Here
|
63 |
return unless $self->accounttype =~ /^Pay/; |
63 |
return unless $self->accounttype =~ /^Pay/; |
64 |
|
64 |
|
65 |
my @account_offsets = |
65 |
my @account_offsets = |
66 |
Koha::Account::Offsets->search( { credit_id => $self->id, type => 'Payment' } ); |
66 |
Koha::Account::Offsets->search( |
67 |
|
67 |
{ credit_id => $self->id, type => 'Payment' } ); |
68 |
foreach my $account_offset (@account_offsets) { |
68 |
|
69 |
my $fee_paid = Koha::Account::Lines->find( $account_offset->debit_id ); |
69 |
$self->_result->result_source->schema->txn_do( |
70 |
|
70 |
sub { |
71 |
next unless $fee_paid; |
71 |
foreach my $account_offset (@account_offsets) { |
72 |
|
72 |
my $fee_paid = |
73 |
my $amount_paid = $account_offset->amount * -1; # amount paid is stored as a negative amount |
73 |
Koha::Account::Lines->find( $account_offset->debit_id ); |
74 |
my $new_amount = $fee_paid->amountoutstanding + $amount_paid; |
74 |
|
75 |
$fee_paid->amountoutstanding($new_amount); |
75 |
next unless $fee_paid; |
76 |
$fee_paid->store(); |
76 |
|
|
|
77 |
my $amount_paid = $account_offset->amount * |
78 |
-1; # amount paid is stored as a negative amount |
79 |
my $new_amount = $fee_paid->amountoutstanding + $amount_paid; |
80 |
$fee_paid->amountoutstanding($new_amount); |
81 |
$fee_paid->store(); |
82 |
|
83 |
Koha::Account::Offset->new( |
84 |
{ |
85 |
credit_id => $self->id, |
86 |
debit_id => $fee_paid->id, |
87 |
amount => $amount_paid, |
88 |
type => 'Void Payment', |
89 |
} |
90 |
)->store(); |
91 |
} |
77 |
|
92 |
|
78 |
Koha::Account::Offset->new( |
93 |
if ( C4::Context->preference("FinesLog") ) { |
79 |
{ |
94 |
logaction( |
80 |
credit_id => $self->id, |
95 |
"FINES", 'VOID', |
81 |
debit_id => $fee_paid->id, |
96 |
$self->borrowernumber, |
82 |
amount => $amount_paid, |
97 |
Dumper( |
83 |
type => 'Void Payment', |
98 |
{ |
|
|
99 |
action => 'void_payment', |
100 |
borrowernumber => $self->borrowernumber, |
101 |
, |
102 |
amount => $self->amount, |
103 |
amountoutstanding => $self->amountoutstanding, |
104 |
description => $self->description, |
105 |
accounttype => $self->accounttype, |
106 |
payment_type => $self->payment_type, |
107 |
note => $self->note, |
108 |
itemnumber => $self->itemnumber, |
109 |
manager_id => $self->manager_id, |
110 |
offsets => |
111 |
[ map { $_->unblessed } @account_offsets ], |
112 |
} |
113 |
) |
114 |
); |
84 |
} |
115 |
} |
85 |
)->store(); |
116 |
|
86 |
} |
117 |
$self->set( |
87 |
|
118 |
{ |
88 |
if ( C4::Context->preference("FinesLog") ) { |
119 |
accounttype => 'VOID', |
89 |
logaction("FINES", 'VOID', $self->borrowernumber, Dumper({ |
120 |
amountoutstanding => 0, |
90 |
action => 'void_payment', |
121 |
amount => 0, |
91 |
borrowernumber => $self->borrowernumber,, |
122 |
} |
92 |
amount => $self->amount, |
123 |
); |
93 |
amountoutstanding => $self->amountoutstanding, |
124 |
$self->store(); |
94 |
description => $self->description, |
|
|
95 |
accounttype => $self->accounttype, |
96 |
payment_type => $self->payment_type, |
97 |
note => $self->note, |
98 |
itemnumber => $self->itemnumber, |
99 |
manager_id => $self->manager_id, |
100 |
offsets => [ map { $_->unblessed } @account_offsets ], |
101 |
})); |
102 |
} |
103 |
|
104 |
$self->set( |
105 |
{ |
106 |
accounttype => 'VOID', |
107 |
amountoutstanding => 0, |
108 |
amount => 0, |
109 |
} |
125 |
} |
110 |
); |
126 |
); |
111 |
$self->store(); |
127 |
|
112 |
} |
128 |
} |
113 |
|
129 |
|
114 |
=head3 _type |
130 |
=head3 _type |
115 |
- |
|
|