|
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 144-162
elsif ( $op && $op eq 'del_adj' ) {
Link Here
|
| 144 |
my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id ); |
145 |
my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id ); |
| 145 |
if ($del_adj) { |
146 |
if ($del_adj) { |
| 146 |
if (C4::Context->preference("AcqLog")) { |
147 |
if (C4::Context->preference("AcqLog")) { |
| 147 |
my $reason_length = length $del_adj->reason; |
148 |
my $infos = { |
| 148 |
my $reason_padded = ( ' ' x (80 - $reason_length) ) . $del_adj->reason; |
149 |
invoiceid => $del_adj->invoiceid, |
| 149 |
my $infos = |
150 |
budget_id => $del_adj->budget_id, |
| 150 |
sprintf("%010d", $del_adj->invoiceid) . |
151 |
encumber_open => $del_adj->encumber_open, |
| 151 |
sprintf("%010d", $del_adj->budget_id) . |
152 |
adjustment => $del_adj->adjustment, |
| 152 |
sprintf("%010d", $del_adj->encumber_open) . |
153 |
reason => $del_adj->reason |
| 153 |
sprintf("%010.2f", $del_adj->adjustment) . |
154 |
}; |
| 154 |
$reason_padded; |
|
|
| 155 |
logaction( |
155 |
logaction( |
| 156 |
'ACQUISITIONS', |
156 |
'ACQUISITIONS', |
| 157 |
'DELETE_INVOICE_ADJUSTMENT', |
157 |
'DELETE_INVOICE_ADJUSTMENT', |
| 158 |
$adjustment_id, |
158 |
$adjustment_id, |
| 159 |
$infos |
159 |
encode_json($infos) |
| 160 |
); |
160 |
); |
| 161 |
} |
161 |
} |
| 162 |
$del_adj->delete(); |
162 |
$del_adj->delete(); |
|
Lines 191-202
elsif ( $op && $op eq 'mod_adj' ) {
Link Here
|
| 191 |
$new_adj->store(); |
191 |
$new_adj->store(); |
| 192 |
# Log this addition |
192 |
# Log this addition |
| 193 |
if (C4::Context->preference("AcqLog")) { |
193 |
if (C4::Context->preference("AcqLog")) { |
| 194 |
my $infos = get_log_string($adj); |
|
|
| 195 |
logaction( |
194 |
logaction( |
| 196 |
'ACQUISITIONS', |
195 |
'ACQUISITIONS', |
| 197 |
'CREATE_INVOICE_ADJUSTMENT', |
196 |
'CREATE_INVOICE_ADJUSTMENT', |
| 198 |
$new_adj->adjustment_id, |
197 |
$new_adj->adjustment_id, |
| 199 |
$infos |
198 |
encode_json($adj) |
| 200 |
); |
199 |
); |
| 201 |
} |
200 |
} |
| 202 |
} |
201 |
} |
|
Lines 205-211
elsif ( $op && $op eq 'mod_adj' ) {
Link Here
|
| 205 |
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] ){ |
204 |
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] ){ |
| 206 |
# Log this modification |
205 |
# Log this modification |
| 207 |
if (C4::Context->preference("AcqLog")) { |
206 |
if (C4::Context->preference("AcqLog")) { |
| 208 |
my $infos = get_log_string({ |
207 |
my $infos = { |
| 209 |
adjustment => $adjustment[$i], |
208 |
adjustment => $adjustment[$i], |
| 210 |
reason => $reason[$i], |
209 |
reason => $reason[$i], |
| 211 |
budget_id => $budget_id[$i], |
210 |
budget_id => $budget_id[$i], |
|
Lines 214-225
elsif ( $op && $op eq 'mod_adj' ) {
Link Here
|
| 214 |
reason_old => $old_adj->reason, |
213 |
reason_old => $old_adj->reason, |
| 215 |
budget_id_old => $old_adj->budget_id, |
214 |
budget_id_old => $old_adj->budget_id, |
| 216 |
encumber_open_old => $old_adj->encumber_open |
215 |
encumber_open_old => $old_adj->encumber_open |
| 217 |
}); |
216 |
}; |
| 218 |
logaction( |
217 |
logaction( |
| 219 |
'ACQUISITIONS', |
218 |
'ACQUISITIONS', |
| 220 |
'UPDATE_INVOICE_ADJUSTMENT', |
219 |
'UPDATE_INVOICE_ADJUSTMENT', |
| 221 |
$adjustment_id[$i], |
220 |
$adjustment_id[$i], |
| 222 |
$infos |
221 |
encode_json($infos) |
| 223 |
); |
222 |
); |
| 224 |
} |
223 |
} |
| 225 |
$old_adj->timestamp(undef); |
224 |
$old_adj->timestamp(undef); |
|
Lines 346-380
sub get_infos {
Link Here
|
| 346 |
return \%line; |
345 |
return \%line; |
| 347 |
} |
346 |
} |
| 348 |
|
347 |
|
| 349 |
sub get_log_string { |
|
|
| 350 |
my ($data) = @_; |
| 351 |
|
| 352 |
# We specify the keys we're dealing for logging within an array in order |
| 353 |
# to preserve order, if we just iterate the hash keys, we could get |
| 354 |
# the values in any order |
| 355 |
my @keys = ( |
| 356 |
'budget_id', |
| 357 |
'encumber_open', |
| 358 |
'budget_id_old', |
| 359 |
'encumber_open_old' |
| 360 |
); |
| 361 |
# Adjustment amount |
| 362 |
my $return = sprintf("%010.2f", $data->{adjustment}); |
| 363 |
# Left pad "reason" to the maximum length of aqinvoice_adjustments.reason |
| 364 |
# (80 characters) |
| 365 |
my $reason_len = length $data->{reason}; |
| 366 |
$return .= ( ' ' x (80 - $reason_len) ) . $data->{reason}; |
| 367 |
# Append the remaining fields |
| 368 |
foreach my $key(@keys) { |
| 369 |
$return .= sprintf("%010d", $data->{$key}); |
| 370 |
} |
| 371 |
# Old adjustment amount |
| 372 |
$return .= sprintf("%010.2f", $data->{adjustment_old}); |
| 373 |
# Left pad "reason_old" to the maximum length of aqinvoice_adjustments.reason |
| 374 |
# (80 characters) |
| 375 |
my $reason_old_len = length $data->{reason_old}; |
| 376 |
$return .= ( ' ' x (80 - $reason_old_len) ) . $data->{reason_old}; |
| 377 |
return $return; |
| 378 |
} |
| 379 |
|
| 380 |
output_html_with_http_headers $input, $cookie, $template->output; |
348 |
output_html_with_http_headers $input, $cookie, $template->output; |