View | Details | Raw Unified | Return to bug 24190
Collapse All | Expand All

(-)a/C4/Budgets.pm (-14 / +17 lines)
Lines 18-23 package C4::Budgets; Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use JSON;
21
use C4::Context;
22
use C4::Context;
22
use Koha::Database;
23
use Koha::Database;
23
use Koha::Patrons;
24
use Koha::Patrons;
Lines 645-659 sub AddBudget { Link Here
645
646
646
    # Log the addition
647
    # Log the addition
647
    if (C4::Context->preference("AcqLog")) {
648
    if (C4::Context->preference("AcqLog")) {
648
        my $infos =
649
        my $infos = {
649
            sprintf("%010d", $budget->{budget_amount}) .
650
            budget_amount => $budget->{budget_amount},
650
            sprintf("%010d", $budget->{budget_encumb}) .
651
            budget_encumb => $budget->{budget_encumb},
651
            sprintf("%010d", $budget->{budget_expend});
652
            budget_expend => $budget->{budget_expend}
653
        };
652
        logaction(
654
        logaction(
653
            'ACQUISITIONS',
655
            'ACQUISITIONS',
654
            'CREATE_FUND',
656
            'CREATE_FUND',
655
            $id,
657
            $id,
656
            $infos
658
            encode_json($infos)
657
        );
659
        );
658
    }
660
    }
659
    return $id;
661
    return $id;
Lines 668-686 sub ModBudget { Link Here
668
670
669
    # Log this modification
671
    # Log this modification
670
    if (C4::Context->preference("AcqLog")) {
672
    if (C4::Context->preference("AcqLog")) {
671
        my $infos =
673
        my $infos = {
672
            sprintf("%010d", $budget->{budget_amount}) .
674
            budget_amount_new    => $budget->{budget_amount},
673
            sprintf("%010d", $budget->{budget_encumb}) .
675
            budget_encumb_new    => $budget->{budget_encumb},
674
            sprintf("%010d", $budget->{budget_expend}) .
676
            budget_expend_new    => $budget->{budget_expend},
675
            sprintf("%010d", $result->budget_amount) .
677
            budget_amount_old    => $result->budget_amount,
676
            sprintf("%010d", $result->budget_encumb) .
678
            budget_encumb_old    => $result->budget_encumb,
677
            sprintf("%010d", $result->budget_expend) .
679
            budget_expend_old    => $result->budget_expend,
678
            sprintf("%010d", 0 - ($result->budget_amount - $budget->{budget_amount}));
680
            budget_amount_change => 0 - ($result->budget_amount - $budget->{budget_amount})
681
        };
679
        logaction(
682
        logaction(
680
            'ACQUISITIONS',
683
            'ACQUISITIONS',
681
            'MODIFY_FUND',
684
            'MODIFY_FUND',
682
            $budget->{budget_id},
685
            $budget->{budget_id},
683
            $infos
686
            encode_json($infos)
684
        );
687
        );
685
    }
688
    }
686
689
(-)a/acqui/addorder.pl (-7 / +7 lines)
Lines 119-125 if it is an order from an existing suggestion : the id of this suggestion. Link Here
119
119
120
use Modern::Perl;
120
use Modern::Perl;
121
use CGI qw ( -utf8 );
121
use CGI qw ( -utf8 );
122
use JSON qw( to_json );
122
use JSON qw ( to_json encode_json );
123
use C4::Auth qw( get_template_and_user );
123
use C4::Auth qw( get_template_and_user );
124
use C4::Acquisition qw( FillWithDefaultValues populate_order_with_prices ModOrder ModOrderUsers );
124
use C4::Acquisition qw( FillWithDefaultValues populate_order_with_prices ModOrder ModOrderUsers );
125
use C4::Suggestions qw( ModSuggestion );
125
use C4::Suggestions qw( ModSuggestion );
Lines 320-334 if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { Link Here
320
        ModOrder($orderinfo);
320
        ModOrder($orderinfo);
321
        # Log the order modification
321
        # Log the order modification
322
        if (C4::Context->preference("AcqLog")) {
322
        if (C4::Context->preference("AcqLog")) {
323
            my $infos = '';
323
            my $infos = {};
324
            foreach my $field(@log_order_fields) {
324
            foreach my $field(@log_order_fields) {
325
                $infos .= sprintf("%010d", $orderinfo->{$field});
325
                $infos->{$field} = $orderinfo->{$field};
326
            }
326
            }
327
            logaction(
327
            logaction(
328
                'ACQUISITIONS',
328
                'ACQUISITIONS',
329
                'MODIFY_ORDER',
329
                'MODIFY_ORDER',
330
                $orderinfo->{ordernumber},
330
                $orderinfo->{ordernumber},
331
                $infos
331
                encode_json($infos)
332
            );
332
            );
333
        }
333
        }
334
    }
334
    }
Lines 336-350 if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { Link Here
336
        $order->store;
336
        $order->store;
337
        # Log the order creation
337
        # Log the order creation
338
        if (C4::Context->preference("AcqLog")) {
338
        if (C4::Context->preference("AcqLog")) {
339
            my $infos = '';
339
            my $infos = {};
340
            foreach my $field(@log_order_fields) {
340
            foreach my $field(@log_order_fields) {
341
                $infos .= sprintf("%010d", $orderinfo->{$field});
341
                $infos->{$field} = $orderinfo->{$field};
342
            }
342
            }
343
            logaction(
343
            logaction(
344
                'ACQUISITIONS',
344
                'ACQUISITIONS',
345
                'CREATE_ORDER',
345
                'CREATE_ORDER',
346
                $order->ordernumber,
346
                $order->ordernumber,
347
                $infos
347
                encode_json($infos)
348
            );
348
            );
349
        }
349
        }
350
    }
350
    }
(-)a/acqui/finishreceive.pl (-7 / +9 lines)
Lines 23-28 Link Here
23
use Modern::Perl;
23
use Modern::Perl;
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use C4::Auth qw( checkauth );
25
use C4::Auth qw( checkauth );
26
use JSON qw( encode_json );
26
use C4::Output;
27
use C4::Output;
27
use C4::Context;
28
use C4::Context;
28
use C4::Acquisition qw( GetInvoice GetOrder populate_order_with_prices ModReceiveOrder );
29
use C4::Acquisition qw( GetInvoice GetOrder populate_order_with_prices ModReceiveOrder );
Lines 192-209 if ($suggestion_id) { Link Here
192
193
193
# Log the receipt
194
# Log the receipt
194
if (C4::Context->preference("AcqLog")) {
195
if (C4::Context->preference("AcqLog")) {
195
    my $infos =
196
    my $infos = {
196
        sprintf("%010d", $quantityrec) .
197
        quantityrec      => $quantityrec,
197
        sprintf("%010d", $bookfund) .
198
        bookfund         => $bookfund,
198
        sprintf("%010.2f", $input->param("tax_rate")) .
199
        tax_rate         => $input->param("tax_rate"),
199
        sprintf("%010.2f", $replacementprice) .
200
        replacementprice => $replacementprice,
200
        sprintf("%010.2f", $unitprice);
201
        unitprice        => $unitprice
202
    };
201
203
202
    logaction(
204
    logaction(
203
        'ACQUISITIONS',
205
        'ACQUISITIONS',
204
        'RECEIVE_ORDER',
206
        'RECEIVE_ORDER',
205
        $ordernumber,
207
        $ordernumber,
206
        $infos
208
        encode_json($infos)
207
    );
209
    );
208
}
210
}
209
211
(-)a/acqui/invoice.pl (-45 / +13 lines)
Lines 33-38 use C4::Auth qw( get_template_and_user ); Link Here
33
use C4::Output qw( output_and_exit output_html_with_http_headers );
33
use C4::Output qw( output_and_exit output_html_with_http_headers );
34
use C4::Acquisition qw( CloseInvoice ReopenInvoice ModInvoice MergeInvoices DelInvoice GetInvoice GetInvoiceDetails get_rounded_price );
34
use C4::Acquisition qw( CloseInvoice ReopenInvoice ModInvoice MergeInvoices DelInvoice GetInvoice GetInvoiceDetails get_rounded_price );
35
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
35
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
36
use JSON qw( encode_json );
36
use C4::Log qw(logaction);
37
use C4::Log qw(logaction);
37
38
38
use Koha::Acquisition::Booksellers;
39
use Koha::Acquisition::Booksellers;
Lines 148-166 elsif ( $op && $op eq 'del_adj' ) { Link Here
148
    my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id );
149
    my $del_adj = Koha::Acquisition::Invoice::Adjustments->find( $adjustment_id );
149
    if ($del_adj) {
150
    if ($del_adj) {
150
        if (C4::Context->preference("AcqLog")) {
151
        if (C4::Context->preference("AcqLog")) {
151
            my $reason_length = length $del_adj->reason;
152
            my $infos = {
152
            my $reason_padded = ( ' ' x (80 - $reason_length) ) . $del_adj->reason;
153
                invoiceid     => $del_adj->invoiceid,
153
            my $infos =
154
                budget_id     => $del_adj->budget_id,
154
                sprintf("%010d", $del_adj->invoiceid) .
155
                encumber_open => $del_adj->encumber_open,
155
                sprintf("%010d", $del_adj->budget_id) .
156
                adjustment    => $del_adj->adjustment,
156
                sprintf("%010d", $del_adj->encumber_open) .
157
                reason        => $del_adj->reason
157
                sprintf("%010.2f", $del_adj->adjustment) .
158
            };
158
                $reason_padded;
159
            logaction(
159
            logaction(
160
                'ACQUISITIONS',
160
                'ACQUISITIONS',
161
                'DELETE_INVOICE_ADJUSTMENT',
161
                'DELETE_INVOICE_ADJUSTMENT',
162
                $adjustment_id,
162
                $adjustment_id,
163
                $infos
163
                encode_json($infos)
164
            );
164
            );
165
        }
165
        }
166
        $del_adj->delete();
166
        $del_adj->delete();
Lines 195-206 elsif ( $op && $op eq 'mod_adj' ) { Link Here
195
            $new_adj->store();
195
            $new_adj->store();
196
            # Log this addition
196
            # Log this addition
197
            if (C4::Context->preference("AcqLog")) {
197
            if (C4::Context->preference("AcqLog")) {
198
                my $infos = get_log_string($adj);
199
                logaction(
198
                logaction(
200
                    'ACQUISITIONS',
199
                    'ACQUISITIONS',
201
                    'CREATE_INVOICE_ADJUSTMENT',
200
                    'CREATE_INVOICE_ADJUSTMENT',
202
                    $new_adj->adjustment_id,
201
                    $new_adj->adjustment_id,
203
                    $infos
202
                    encode_json($adj)
204
                );
203
                );
205
            }
204
            }
206
        }
205
        }
Lines 209-215 elsif ( $op && $op eq 'mod_adj' ) { Link Here
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] ){
208
            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] ){
210
                # Log this modification
209
                # Log this modification
211
                if (C4::Context->preference("AcqLog")) {
210
                if (C4::Context->preference("AcqLog")) {
212
                    my $infos = get_log_string({
211
                    my $infos = {
213
                        adjustment        => $adjustment[$i],
212
                        adjustment        => $adjustment[$i],
214
                        reason            => $reason[$i],
213
                        reason            => $reason[$i],
215
                        budget_id         => $budget_id[$i],
214
                        budget_id         => $budget_id[$i],
Lines 218-229 elsif ( $op && $op eq 'mod_adj' ) { Link Here
218
                        reason_old        => $old_adj->reason,
217
                        reason_old        => $old_adj->reason,
219
                        budget_id_old     => $old_adj->budget_id,
218
                        budget_id_old     => $old_adj->budget_id,
220
                        encumber_open_old => $old_adj->encumber_open
219
                        encumber_open_old => $old_adj->encumber_open
221
                    });
220
                    };
222
                    logaction(
221
                    logaction(
223
                        'ACQUISITIONS',
222
                        'ACQUISITIONS',
224
                        'UPDATE_INVOICE_ADJUSTMENT',
223
                        'UPDATE_INVOICE_ADJUSTMENT',
225
                        $adjustment_id[$i],
224
                        $adjustment_id[$i],
226
                        $infos
225
                        encode_json($infos)
227
                    );
226
                    );
228
                }
227
                }
229
                $old_adj->timestamp(undef);
228
                $old_adj->timestamp(undef);
Lines 350-384 sub get_infos { Link Here
350
    return \%line;
349
    return \%line;
351
}
350
}
352
351
353
sub get_log_string {
354
    my ($data) = @_;
355
356
    # We specify the keys we're dealing for logging within an array in order
357
    # to preserve order, if we just iterate the hash keys, we could get
358
    # the values in any order
359
    my @keys = (
360
        'budget_id',
361
        'encumber_open',
362
        'budget_id_old',
363
        'encumber_open_old'
364
    );
365
    # Adjustment amount
366
    my $return = sprintf("%010.2f", $data->{adjustment});
367
    # Left pad "reason" to the maximum length of aqinvoice_adjustments.reason
368
    # (80 characters)
369
    my $reason_len = length $data->{reason};
370
    $return .= ( ' ' x (80 - $reason_len) ) . $data->{reason};
371
    # Append the remaining fields
372
    foreach my $key(@keys) {
373
        $return .= sprintf("%010d", $data->{$key});
374
    }
375
    # Old adjustment amount
376
    $return .= sprintf("%010.2f", $data->{adjustment_old});
377
    # Left pad "reason_old" to the maximum length of aqinvoice_adjustments.reason
378
    # (80 characters)
379
    my $reason_old_len = length $data->{reason_old};
380
    $return .= ( ' ' x (80 - $reason_old_len) ) . $data->{reason_old};
381
    return $return;
382
}
383
384
output_html_with_http_headers $input, $cookie, $template->output;
352
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/admin/aqbudgetperiods.pl (-10 / +11 lines)
Lines 48-53 use Modern::Perl; Link Here
48
48
49
use CGI qw ( -utf8 );
49
use CGI qw ( -utf8 );
50
use Koha::DateUtils qw( dt_from_string );
50
use Koha::DateUtils qw( dt_from_string );
51
use JSON qw( encode_json );
51
use Koha::Database;
52
use Koha::Database;
52
use C4::Koha;
53
use C4::Koha;
53
use C4::Context;
54
use C4::Context;
Lines 121-139 elsif ( $op eq 'add_validate' ) { Link Here
121
        # Log the budget modification
122
        # Log the budget modification
122
        if (C4::Context->preference("AcqLog")) {
123
        if (C4::Context->preference("AcqLog")) {
123
            my $diff = 0 - ($budgetperiod_old->{budget_period_total} - $budget_period_hashref->{budget_period_total});
124
            my $diff = 0 - ($budgetperiod_old->{budget_period_total} - $budget_period_hashref->{budget_period_total});
124
            my $infos =
125
            my $infos = {
125
                eval { output_pref({ dt => dt_from_string( $input->param('budget_period_startdate') ), dateformat => 'iso', dateonly => 1 } ); } .
126
                budget_period_startdate     => $input->param('budget_period_startdate'),
126
                eval { output_pref({ dt => dt_from_string( $input->param('budget_period_enddate') ), dateformat => 'iso', dateonly => 1 } ); } .
127
                budget_period_enddate       => $input->param('budget_period_enddate'),
127
                sprintf("%010d", $budget_period_hashref->{budget_period_total}) .
128
                budget_period_total         => $budget_period_hashref->{budget_period_total},
128
                eval { output_pref({ dt => dt_from_string( $budgetperiod_old->{budget_period_startdate} ), dateformat => 'iso', dateonly => 1 } ); } .
129
                budget_period_startdate_old => $budgetperiod_old->{budget_period_startdate},
129
                eval { output_pref({ dt => dt_from_string( $budgetperiod_old->{budget_period_enddate} ), dateformat => 'iso', dateonly => 1 } ); } .
130
                budget_period_enddate_old   => $budgetperiod_old->{budget_period_enddate},
130
                sprintf("%010d", $budgetperiod_old->{budget_period_total}) .
131
                budget_period_total_old     => $budgetperiod_old->{budget_period_total},
131
                sprintf("%010d", $diff);
132
                budget_period_total_change  => $diff
133
            };
132
            logaction(
134
            logaction(
133
                'ACQUISITIONS',
135
                'ACQUISITIONS',
134
                'MODIFY_BUDGET',
136
                'MODIFY_BUDGET',
135
                $budget_period_id,
137
                $budget_period_id,
136
                $infos
138
                encode_json($infos)
137
            );
139
            );
138
        }
140
        }
139
    }
141
    }
140
- 

Return to bug 24190