|
Lines 29-34
Invoice details
Link Here
|
| 29 |
use Modern::Perl; |
29 |
use Modern::Perl; |
| 30 |
|
30 |
|
| 31 |
use CGI qw ( -utf8 ); |
31 |
use CGI qw ( -utf8 ); |
|
|
32 |
use JSON; |
| 32 |
use C4::Auth; |
33 |
use C4::Auth; |
| 33 |
use C4::Output; |
34 |
use C4::Output; |
| 34 |
use C4::Acquisition; |
35 |
use C4::Acquisition; |
|
Lines 149-167
elsif ( $op && $op eq 'del_adj' ) {
Link Here
|
| 149 |
my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id ); |
150 |
my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id ); |
| 150 |
if ($del_adj) { |
151 |
if ($del_adj) { |
| 151 |
if (C4::Context->preference("AcqLog")) { |
152 |
if (C4::Context->preference("AcqLog")) { |
| 152 |
my $reason_length = length $del_adj->reason; |
153 |
my $infos = { |
| 153 |
my $reason_padded = ( ' ' x (80 - $reason_length) ) . $del_adj->reason; |
154 |
invoiceid => $del_adj->invoiceid, |
| 154 |
my $infos = |
155 |
budget_id => $del_adj->budget_id, |
| 155 |
sprintf("%010d", $del_adj->invoiceid) . |
156 |
encumber_open => $del_adj->encumber_open, |
| 156 |
sprintf("%010d", $del_adj->budget_id) . |
157 |
adjustment => $del_adj->adjustment, |
| 157 |
sprintf("%010d", $del_adj->encumber_open) . |
158 |
reason => $del_adj->reason |
| 158 |
sprintf("%010.2f", $del_adj->adjustment) . |
159 |
}; |
| 159 |
$reason_padded; |
|
|
| 160 |
logaction( |
160 |
logaction( |
| 161 |
'ACQUISITIONS', |
161 |
'ACQUISITIONS', |
| 162 |
'DELETE_INVOICE_ADJUSTMENT', |
162 |
'DELETE_INVOICE_ADJUSTMENT', |
| 163 |
$adjustment_id, |
163 |
$adjustment_id, |
| 164 |
$infos |
164 |
encode_json($infos) |
| 165 |
); |
165 |
); |
| 166 |
} |
166 |
} |
| 167 |
$del_adj->delete(); |
167 |
$del_adj->delete(); |
|
Lines 196-207
elsif ( $op && $op eq 'mod_adj' ) {
Link Here
|
| 196 |
$new_adj->store(); |
196 |
$new_adj->store(); |
| 197 |
# Log this addition |
197 |
# Log this addition |
| 198 |
if (C4::Context->preference("AcqLog")) { |
198 |
if (C4::Context->preference("AcqLog")) { |
| 199 |
my $infos = get_log_string($adj); |
|
|
| 200 |
logaction( |
199 |
logaction( |
| 201 |
'ACQUISITIONS', |
200 |
'ACQUISITIONS', |
| 202 |
'CREATE_INVOICE_ADJUSTMENT', |
201 |
'CREATE_INVOICE_ADJUSTMENT', |
| 203 |
$new_adj->adjustment_id, |
202 |
$new_adj->adjustment_id, |
| 204 |
$infos |
203 |
encode_json($adj) |
| 205 |
); |
204 |
); |
| 206 |
} |
205 |
} |
| 207 |
} |
206 |
} |
|
Lines 210-216
elsif ( $op && $op eq 'mod_adj' ) {
Link Here
|
| 210 |
unless ( $old_adj->adjustment == $adjustment[$i] && $old_adj->reason eq $reason[$i] && $old_adj->budget_id == $budget_id[$i] && $old_adj->encumber_open == $e_open{$adjustment_id[$i]} && $old_adj->note eq $note[$i] ){ |
209 |
unless ( $old_adj->adjustment == $adjustment[$i] && $old_adj->reason eq $reason[$i] && $old_adj->budget_id == $budget_id[$i] && $old_adj->encumber_open == $e_open{$adjustment_id[$i]} && $old_adj->note eq $note[$i] ){ |
| 211 |
# Log this modification |
210 |
# Log this modification |
| 212 |
if (C4::Context->preference("AcqLog")) { |
211 |
if (C4::Context->preference("AcqLog")) { |
| 213 |
my $infos = get_log_string({ |
212 |
my $infos = { |
| 214 |
adjustment => $adjustment[$i], |
213 |
adjustment => $adjustment[$i], |
| 215 |
reason => $reason[$i], |
214 |
reason => $reason[$i], |
| 216 |
budget_id => $budget_id[$i], |
215 |
budget_id => $budget_id[$i], |
|
Lines 219-230
elsif ( $op && $op eq 'mod_adj' ) {
Link Here
|
| 219 |
reason_old => $old_adj->reason, |
218 |
reason_old => $old_adj->reason, |
| 220 |
budget_id_old => $old_adj->budget_id, |
219 |
budget_id_old => $old_adj->budget_id, |
| 221 |
encumber_open_old => $old_adj->encumber_open |
220 |
encumber_open_old => $old_adj->encumber_open |
| 222 |
}); |
221 |
}; |
| 223 |
logaction( |
222 |
logaction( |
| 224 |
'ACQUISITIONS', |
223 |
'ACQUISITIONS', |
| 225 |
'UPDATE_INVOICE_ADJUSTMENT', |
224 |
'UPDATE_INVOICE_ADJUSTMENT', |
| 226 |
$adjustment_id[$i], |
225 |
$adjustment_id[$i], |
| 227 |
$infos |
226 |
encode_json($infos) |
| 228 |
); |
227 |
); |
| 229 |
} |
228 |
} |
| 230 |
$old_adj->timestamp(undef); |
229 |
$old_adj->timestamp(undef); |
|
Lines 351-385
sub get_infos {
Link Here
|
| 351 |
return \%line; |
350 |
return \%line; |
| 352 |
} |
351 |
} |
| 353 |
|
352 |
|
| 354 |
sub get_log_string { |
|
|
| 355 |
my ($data) = @_; |
| 356 |
|
| 357 |
# We specify the keys we're dealing for logging within an array in order |
| 358 |
# to preserve order, if we just iterate the hash keys, we could get |
| 359 |
# the values in any order |
| 360 |
my @keys = ( |
| 361 |
'budget_id', |
| 362 |
'encumber_open', |
| 363 |
'budget_id_old', |
| 364 |
'encumber_open_old' |
| 365 |
); |
| 366 |
# Adjustment amount |
| 367 |
my $return = sprintf("%010.2f", $data->{adjustment}); |
| 368 |
# Left pad "reason" to the maximum length of aqinvoice_adjustments.reason |
| 369 |
# (80 characters) |
| 370 |
my $reason_len = length $data->{reason}; |
| 371 |
$return .= ( ' ' x (80 - $reason_len) ) . $data->{reason}; |
| 372 |
# Append the remaining fields |
| 373 |
foreach my $key(@keys) { |
| 374 |
$return .= sprintf("%010d", $data->{$key}); |
| 375 |
} |
| 376 |
# Old adjustment amount |
| 377 |
$return .= sprintf("%010.2f", $data->{adjustment_old}); |
| 378 |
# Left pad "reason_old" to the maximum length of aqinvoice_adjustments.reason |
| 379 |
# (80 characters) |
| 380 |
my $reason_old_len = length $data->{reason_old}; |
| 381 |
$return .= ( ' ' x (80 - $reason_old_len) ) . $data->{reason_old}; |
| 382 |
return $return; |
| 383 |
} |
| 384 |
|
| 385 |
output_html_with_http_headers $input, $cookie, $template->output; |
353 |
output_html_with_http_headers $input, $cookie, $template->output; |