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

(-)a/acqui/edifactmsgs.pl (+24 lines)
Lines 45-50 if ( $cmd && $cmd eq 'delete' ) { Link Here
45
    $msg->update;
45
    $msg->update;
46
}
46
}
47
47
48
if ( $cmd && $cmd eq 'import' ) {
49
    my $id  = $q->param('message_id');
50
    my $invoice = $schema->resultset('EdifactMessage')->find($id);
51
52
    my $plugin_used = 0;
53
    if ( my $plugin_class = $invoice->edi_acct->plugin ) {
54
        my $plugin = $plugin_class->new();
55
        if ( $plugin->can('edifact_process_invoice') ) {
56
            $plugin_used = 1;
57
            Koha::Plugins::Handler->run(
58
                {
59
                    class  => $plugin_class,
60
                    method => 'edifact_process_invoice',
61
                    params => {
62
                        invoice => $invoice,
63
                    }
64
                }
65
            );
66
        }
67
    }
68
69
    process_invoice($invoice) unless $plugin_used;
70
}
71
48
my @msgs = $schema->resultset('EdifactMessage')->search(
72
my @msgs = $schema->resultset('EdifactMessage')->search(
49
    {
73
    {
50
        deleted => 0,
74
        deleted => 0,
(-)a/installer/data/mysql/atomicupdate/bug_23682.perl (+10 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if ( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{
4
        INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
5
        ('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice')
6
    });
7
8
    SetVersion( $DBversion );
9
    print "Upgrade to $DBversion done (Bug XXXXX - description)\n";
10
}
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 160-165 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
160
('DumpTemplateVarsIntranet',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',  'YesNo'),
160
('DumpTemplateVarsIntranet',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',  'YesNo'),
161
('DumpTemplateVarsOpac',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',  'YesNo'),
161
('DumpTemplateVarsOpac',  '0', NULL ,  'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',  'YesNo'),
162
('EasyAnalyticalRecords','0','','If on, display in the catalogue screens tools to easily setup analytical record relationships','YesNo'),
162
('EasyAnalyticalRecords','0','','If on, display in the catalogue screens tools to easily setup analytical record relationships','YesNo'),
163
('EdifactInvoiceImport', 'automatic', 'automatic|manual', "If on, don't auto-import EDI invoices, just keep them in the database with the status 'new'", 'Choice'),
163
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
164
('ElasticsearchIndexStatus_authorities', '0', 'Authorities index status', NULL, NULL),
164
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
165
('ElasticsearchIndexStatus_biblios', '0', 'Biblios index status', NULL, NULL),
165
('ElasticsearchMARCFormat', 'ISO2709', 'ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'),
166
('ElasticsearchMARCFormat', 'ISO2709', 'ISO2709|ARRAY', 'Elasticsearch MARC format. ISO2709 format is recommended as it is faster and takes less space, whereas array is searchable.', 'Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt (+3 lines)
Lines 71-76 Link Here
71
<td class="actions">
71
<td class="actions">
72
    <a class="btn btn-default btn-xs view_message" target="_blank" href="/cgi-bin/koha/acqui/edimsg.pl?id=[% msg.id | html %]"><i class="fa fa-search"></i> View message</a>
72
    <a class="btn btn-default btn-xs view_message" target="_blank" href="/cgi-bin/koha/acqui/edimsg.pl?id=[% msg.id | html %]"><i class="fa fa-search"></i> View message</a>
73
    <a class="btn btn-default btn-xs delete_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=delete&amp;message_id=[% msg.id | html %]"><i class="fa fa-trash"></i> Delete</a>
73
    <a class="btn btn-default btn-xs delete_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=delete&amp;message_id=[% msg.id | html %]"><i class="fa fa-trash"></i> Delete</a>
74
    [% IF msg.status == 'new' %]
75
        <a class="btn btn-default btn-xs import_msg" href="/cgi-bin/koha/acqui/edifactmsgs.pl?op=import&amp;message_id=[% msg.id | html %]"><i class="fa fa-cog"></i> Import</a>
76
    [% END %]
74
</td>
77
</td>
75
</tr>
78
</tr>
76
[% END %]
79
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref (+8 lines)
Lines 121-123 Acquisitions: Link Here
121
                  "pdfformat::layout3pagesfr": French 3-page
121
                  "pdfformat::layout3pagesfr": French 3-page
122
                  "pdfformat::layout2pagesde": German 2-page
122
                  "pdfformat::layout2pagesde": German 2-page
123
            - layout when printing basket groups.
123
            - layout when printing basket groups.
124
    EDIFACT:
125
        -
126
            - pref: EdifactInvoiceImport
127
              default: no
128
              choices:
129
                automatic: "Do"
130
                manual: "Don't"
131
            - " automatically import EDIFACT invoice message file when they are downloaded."
(-)a/misc/cronjobs/edi_cron.pl (-29 / +29 lines)
Lines 121-157 foreach my $quote_file (@downloaded_quotes) { Link Here
121
}
121
}
122
122
123
# process any downloaded invoices
123
# process any downloaded invoices
124
124
if ( C4::Context->preference('EdifactInvoiceImport') eq 'automatic' ) {
125
my @downloaded_invoices = $schema->resultset('EdifactMessage')->search(
125
    my @downloaded_invoices = $schema->resultset('EdifactMessage')->search(
126
    {
126
        {
127
        message_type => 'INVOICE',
127
            message_type => 'INVOICE',
128
        status       => 'new',
128
            status       => 'new',
129
    }
129
        }
130
)->all;
130
    )->all;
131
131
132
foreach my $invoice (@downloaded_invoices) {
132
    foreach my $invoice (@downloaded_invoices) {
133
    my $filename = $invoice->filename();
133
        my $filename = $invoice->filename();
134
    $logger->trace("Processing invoice $filename");
134
        $logger->trace("Processing invoice $filename");
135
135
136
    my $plugin_used = 0;
136
        my $plugin_used = 0;
137
    if ( my $plugin_class = $invoice->edi_acct->plugin ) {
137
        if ( my $plugin_class = $invoice->edi_acct->plugin ) {
138
        my $plugin = $plugin_class->new();
138
            my $plugin = $plugin_class->new();
139
        if ( $plugin->can('edifact_process_invoice') ) {
139
            if ( $plugin->can('edifact_process_invoice') ) {
140
            $plugin_used = 1;
140
                $plugin_used = 1;
141
            Koha::Plugins::Handler->run(
141
                Koha::Plugins::Handler->run(
142
                {
142
                    {
143
                    class  => $plugin_class,
143
                        class  => $plugin_class,
144
                    method => 'edifact_process_invoice',
144
                        method => 'edifact_process_invoice',
145
                    params => {
145
                        params => {
146
                        invoice => $invoice,
146
                            invoice => $invoice,
147
                        }
147
                    }
148
                    }
148
                }
149
                );
149
            );
150
            }
150
        }
151
        }
151
    }
152
152
153
    process_invoice($invoice) unless $plugin_used;
153
        process_invoice($invoice) unless $plugin_used;
154
}
154
    }
155
}   
155
156
156
my @downloaded_responses = $schema->resultset('EdifactMessage')->search(
157
my @downloaded_responses = $schema->resultset('EdifactMessage')->search(
157
    {
158
    {
158
- 

Return to bug 23682