Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 45073f4d

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID 45073f4d6742b8fc9399e3eabf5259cbff71536f
  • Vorgänger 4d32ba10
  • Nachfolger 05d7e914

Belegvorlagen + Dialogbuchung: Workflow von EmailJournal aus umgesetzt

Unterschiede anzeigen:

SL/AP.pm
1106 1106
    )->load;
1107 1107
    $email_journal->link_to_record_with_attachment(
1108 1108
      $ap_transaction_storno,
1109
      delete $::form->{email_attachment_id}
1109
      delete $::form->{workflow_email_attachment_id}
1110 1110
    );
1111 1111
  }
1112 1112

  
SL/AR.pm
989 989
    )->load;
990 990
    $email_journal->link_to_record_with_attachment(
991 991
      $ar_transaction_storno,
992
      delete $::form->{email_attachment_id}
992
      delete $::form->{workflow_email_attachment_id}
993 993
    );
994 994
  }
995 995

  
SL/Controller/EmailJournal.pm
52 52
    class      => 'Reclamation',
53 53
    types => SL::DB::Reclamation::TypeData->valid_types(),
54 54
  },
55
  GlTransaction => {
56
    controller => 'gl.pl',
57
    class      => 'GLTransaction',
58
    types => [
59
      'gl_transaction',
60
    ],
61
  },
55 62
  ArTransaction => {
56 63
    controller => 'ar.pl',
57 64
    class      => 'Invoice',
......
87 94
      'purchase_credit_note',
88 95
    ],
89 96
  },
90
  RecordTemplate => {
91
    controller => '',
97
  GlRecordTemplate => {
98
    controller => 'gl.pl',
92 99
    class      => 'RecordTemplate',
93 100
    types => [
94 101
      'gl_transaction_template',
102
    ],
103
  },
104
  ArRecordTemplate => {
105
    controller => 'ar.pl',
106
    class      => 'RecordTemplate',
107
    types => [
95 108
      'ar_transaction_template',
109
    ],
110
  },
111
  ApRecordTemplate => {
112
    controller => 'ap.pl',
113
    class      => 'RecordTemplate',
114
    types => [
96 115
      'ap_transaction_template',
97 116
    ],
98
  }
117
  },
99 118
);
100 119
my %RECORD_TYPE_TO_CONTROLLER =
101 120
  map {
......
121 140
      $_ => 'invnumber';
122 141
    } elsif (any {$model eq $_} qw(SL::DB::RecordTemplate)) {
123 142
      $_ => 'template_name';
143
    } elsif (any {$model eq $_} qw(SL::DB::GLTransaction)) {
144
      $_ => 'reference';
124 145
    } else {
125 146
      my $type_data = SL::DB::Helper::TypeDataProxy->new($model, $_);
126 147
      $_ => $type_data->properties('nr_key');
......
161 182
    { record_type => 'purchase_invoice',      customervendor => 'vendor', workflow_needed => 0, can_workflow => 1, text => t8('Purchase Invoice')},
162 183
    { record_type => 'purchase_credit_note',  customervendor => 'vendor', workflow_needed => 0, can_workflow => 1, text => t8('Purchase Credit Note')},
163 184
    # transactions
164
    # TODO: create gl_transaction with email
165
    # { record_type => 'gl_transaction', customervendor => 'customer', workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
166
    # { record_type => 'gl_transaction', customervendor => 'vendor',   workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
185
    # gl_transaction can be for vendor and customer
186
    { record_type => 'gl_transaction', customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('GL Transaction')},
187
    { record_type => 'gl_transaction', customervendor => 'vendor',   workflow_needed => 0, can_workflow => 1, text => t8('GL Transaction')},
167 188
    { record_type => 'ar_transaction', customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('AR Transaction')},
168 189
    { record_type => 'ap_transaction', customervendor => 'vendor',   workflow_needed => 0, can_workflow => 1, text => t8('AP Transaction')},
169 190
    # templates
......
179 200
  my ($self, $customer_vendor_type, $action) = @_;
180 201
  return [
181 202
    map { $_->{record_type} }
203
    grep {
204
      # No gl_transaction in standard workflows
205
      # They can't be filtered by customer/vendor or open/closed and polute the list
206
      ($_->{record_type} ne 'gl_transaction')
207
    }
182 208
    grep {
183 209
      ($_->{customervendor} eq $customer_vendor_type)
184 210
      && ($action eq 'workflow_record' ? $_->{can_workflow} : 1)
......
270 296
      $additional_where{$nr_key} = { ilike => "%$record_number%" };
271 297
    }
272 298
    unless ($with_closed) {
273
      if (any {$_ eq 'closed' } $model->meta->columns) {
299
      if (any {$_ eq 'closed'} $model->meta->columns) {
274 300
        $additional_where{closed} = 0;
275
      } elsif (any {$_ eq 'paid' } $model->meta->columns) {
301
      } elsif (any {$_ eq 'paid'} $model->meta->columns) {
276 302
        $additional_where{amount} = { gt => \'paid' };
277 303
      }
278 304
    }
......
367 393
  my $action             = $::form->{action_selection};
368 394
  my $record_id          = $::form->{"record_id"};
369 395
  my $record_type        = $::form->{"record_type"};
370
     $record_type      ||= $::form->{"${customer_vendor}_record_type_selection"};
396
     $record_type      ||= $::form->{"${customer_vendor}_${action}_type_selection"};
371 397

  
372
  die t8("No record is selected.")               unless $record_id || $action eq 'create_new';
398
  die t8("No record is selected.")               unless $record_id || $action eq 'new_record';
373 399
  die t8("No record type is selected.")          unless $record_type;
374 400
  die "no 'email_journal_id' was given"          unless $email_journal_id;
375 401
  die "no 'customer_vendor_selection' was given" unless $customer_vendor;
......
385 411
  }
386 412

  
387 413
  my %additional_params = ();
388
  if ($action eq 'create_new') {
414
  if ($action eq 'new_record') {
389 415
    $additional_params{action} = 'add_from_email_journal';
390 416
    $additional_params{"${customer_vendor}_id"} = $customer_vendor_id;
391
  } else {
417
  } elsif ($action eq 'template_record') {
418
    $additional_params{action} = 'load_record_template_from_email_journal';
419
    $additional_params{id} = $record_id;
420
    $additional_params{form_defaults} = {
421
      email_journal_id => $email_journal_id,
422
      email_attachment_id => $attachment_id,
423
    };
424
  } else { # workflow_record
392 425
    $additional_params{action} = 'edit_with_email_journal_workflow';
393 426
    $additional_params{id} = $record_id;
394 427
  }
SL/DB/EmailJournalAttachment.pm
20 20
    # TODO: file and webdav use different types
21 21
    $record_type = 'accounts_payable' if $record_type eq 'ap_transaction';
22 22
    $record_type = 'general_ledger'   if $record_type eq 'ar_transaction';
23
    $record_type = 'general_ledger'   if $record_type eq 'gl_transaction';
23 24
    $record_type = 'invoice'          if $record_type eq 'invoice_storno';
24 25
    my $webdav = SL::Webdav->new(
25 26
      type     => $record_type,
SL/DB/GLTransaction.pm
4 4

  
5 5
use SL::DB::Helper::LinkedRecords;
6 6
use SL::DB::MetaSetup::GLTransaction;
7
use SL::DB::Manager::GLTransaction;
7 8
use SL::Locale::String qw(t8);
8 9
use List::Util qw(sum);
9 10
use SL::DATEV;
10 11
use Carp;
11 12
use Data::Dumper;
12 13

  
13
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
14
__PACKAGE__->meta->make_manager_class;
15

  
16 14
__PACKAGE__->meta->add_relationship(
17 15
  transactions   => {
18 16
    type         => 'one to many',
......
27 25

  
28 26
__PACKAGE__->meta->initialize;
29 27

  
28
sub record_type {return 'gl_transaction';}
29
sub record_number {goto &id;}
30
sub displayable_name {goto &oneline_summary;}
31

  
30 32
sub abbreviation {
31 33
  my $self = shift;
32 34

  
SL/DB/Manager/GLTransaction.pm
1
package SL::DB::Manager::GLTransaction;
2

  
3
use strict;
4

  
5
use parent qw(SL::DB::Helper::Manager);
6

  
7

  
8
sub object_class { 'SL::DB::GLTransaction' }
9

  
10
__PACKAGE__->make_manager_methods;
11

  
12
sub type_filter {
13
  my $class = shift;
14
  my $type  = lc(shift || '');
15

  
16
  return if $type eq 'gl_transaction';
17

  
18
  die "Unknown type $type";
19
}
20

  
21
1;
SL/GL.pm
47 47
use SL::DB::Chart;
48 48
use SL::DB::Draft;
49 49
use SL::DB::ValidityToken;
50
use SL::DB::GLTransaction;
50 51
use SL::Util qw(trim);
51 52
use SL::DB;
52 53

  
......
797 798
    do_query($form, $dbh, $query, (values %$row));
798 799
  }
799 800

  
801
  if ($form->{workflow_email_journal_id}) {
802
    my $ar_transaction_storno = SL::DB::GLTransaction->new(id => $new_id)->load;
803
    my $email_journal = SL::DB::EmailJournal->new(
804
      id => delete $form->{workflow_email_journal_id}
805
    )->load;
806
    $email_journal->link_to_record_with_attachment(
807
      $ar_transaction_storno,
808
      delete $::form->{workflow_email_attachment_id}
809
    );
810
  }
800 811
  return 1;
801 812
}
802 813

  
bin/mozilla/ap.pl
1455 1455
  &add;
1456 1456
}
1457 1457

  
1458
sub load_record_template_from_email_journal {
1459
  die "No 'email_journal_id' was given." unless ($::form->{email_journal_id});
1460
  &load_record_template;
1461
}
1462

  
1458 1463
sub edit_with_email_journal_workflow {
1459 1464
  my ($self) = @_;
1460 1465
  die "No 'email_journal_id' was given." unless ($::form->{email_journal_id});
bin/mozilla/ar.pl
287 287
  &add;
288 288
}
289 289

  
290
sub load_record_template_from_email_journal {
291
  die "No 'email_journal_id' was given." unless ($::form->{email_journal_id});
292
  &load_record_template;
293
}
294

  
290 295
sub edit_with_email_journal_workflow {
291 296
  my ($self) = @_;
292 297
  die "No 'email_journal_id' was given." unless ($::form->{email_journal_id});
bin/mozilla/gl.pl
44 44
use SL::DB::BankTransactionAccTrans;
45 45
use SL::DB::Tax;
46 46
use SL::DB::ValidityToken;
47
use SL::DB::GLTransaction;
47 48
use SL::FU;
48 49
use SL::GL;
49 50
use SL::Helper::Flash qw(flash flash_later);
......
252 253

  
253 254
}
254 255

  
256
sub add_from_email_journal {
257
  die "No 'email_journal_id' was given." unless ($::form->{email_journal_id});
258
  &add;
259
}
260

  
261
sub load_record_template_from_email_journal {
262
  die "No 'email_journal_id' was given." unless ($::form->{email_journal_id});
263
  &load_record_template;
264
}
265

  
266
sub edit_with_email_journal_workflow {
267
  my ($self) = @_;
268
  die "No 'email_journal_id' was given." unless ($::form->{email_journal_id});
269
  $::form->{workflow_email_journal_id}    = delete $::form->{email_journal_id};
270
  $::form->{workflow_email_attachment_id} = delete $::form->{email_attachment_id};
271

  
272
  &edit;
273
}
274

  
255 275
sub prepare_transaction {
256 276
  $main::lxdebug->enter_sub();
257 277

  
......
1472 1492
                   )->webdav_path;
1473 1493
  }
1474 1494

  
1495
  if ($form->{email_journal_id} && $form->{id} ne "") {
1496
    my $ar_transaction = SL::DB::GLTransaction->new(id => $form->{id})->load;
1497
    my $email_journal = SL::DB::EmailJournal->new(
1498
      id => delete $form->{email_journal_id}
1499
    )->load;
1500
    $email_journal->link_to_record_with_attachment($ar_transaction, delete $::form->{email_attachment_id});
1501
  }
1502

  
1475 1503
  my $msg = $::locale->text("General ledger transaction '#1' posted (ID: #2)", $form->{reference}, $form->{id});
1476 1504
  if ($form->{callback} =~ /BankTransaction/ && $form->{bt_id}) {
1477 1505
    SL::Helper::Flash::flash_later('info', $msg) if $msg;
css/design40/email_journal.css
2 2
input.record_button {
3 3
  color: var(--color-dark);
4 4
  background-color: var(--color-lighter);
5
  width: 200px;
5
  width: 300px;
6 6
  padding: 5px;
7 7
  margin: 5px;
8 8
  float: left;
locale/de/all
914 914
  'Create customers and vendors. Edit all vendors. Edit only customers where salesman equals employee (login)' => 'Kunden und Lieferanten erfassen. Alle Lieferanten bearbeiten. Nur Kunden bearbeiten bei denen der Verkäufer gleich Bearbeiter (login) ist',
915 915
  'Create delivery order'       => 'Lieferschein erstellen',
916 916
  'Create first invoice on'     => 'Erste Rechnung erzeugen am',
917
  'Create from Record Template' => 'Mit Belegvorlage erstellen',
917
  'Create from Record Template' => 'Neu erfassen mit Belegvorlage',
918 918
  'Create from Workflow'        => 'Workflow weiterführen von',
919 919
  'Create invoice'              => 'Buchung erstellen',
920 920
  'Create invoice?'             => 'Rechnung erstellen?',
templates/design40_webpages/ar/form_header.html
55 55

  
56 56
<div id="ui-tabs-basic-data">
57 57

  
58
[% IF email_attachment_id || workflow_email_attachment_id%]
58
[% IF email_attachment_id || workflow_email_attachment_id %]
59 59
  <div class="wrapper" id="email_attachment_wrapper">
60 60
    [%
61 61
      BLOCK panel_1;
templates/design40_webpages/email_journal/show.html
257 257
        </div><!-- /.record_toggle -->
258 258
      </div><!-- record_div -->
259 259
    </div><!-- record_selection_div -->
260
    <div id="create_new_div" class="input-panel" style="display:none;min-width:0;margin:0">
260
    <div id="new_record_div" class="input-panel" style="display:none;min-width:0;margin:0">
261 261
        [% L.button_tag('kivi.EmailJournal.apply_action_with_attachment();',
262 262
          LxERP.t8('Apply with Attachment')) %]
263 263
    </div>
templates/design40_webpages/gl/form_header.html
2 2
[% USE LxERP %]
3 3
[% USE T8 %]
4 4
[% USE L %]
5
<h1>[% title | html %]</h1>
5
[% USE P %]
6

  
7
<h1>
8
  [% IF workflow_email_journal_id; LxERP.t8("Email Journal Workflow") _ " - "; END; %]
9
  [% title | html %]
10
</h1>
6 11

  
7 12
<script type="text/javascript">
8 13
  <!--
......
27 32
[% IF !id %]
28 33
[%   L.hidden_tag('form_validity_token', form_validity_token) %]
29 34
[% END %]
35
[% L.hidden_tag('email_journal_id',             email_journal_id) %]
36
[% L.hidden_tag('email_attachment_id',          email_attachment_id) %]
37
[% L.hidden_tag('workflow_email_journal_id',    workflow_email_journal_id) %]
38
[% L.hidden_tag('workflow_email_attachment_id', workflow_email_attachment_id) %]
30 39

  
31 40
<input type=hidden name=title value="[% hide_title | html %]">
32 41

  
......
39 48

  
40 49
<ul>
41 50
  <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
51
  [% IF email_attachment_id || workflow_email_attachment_id %]
52
    <li><a href="controller.pl?action=EmailJournal/attachment_preview&attachment_id=[% HTML.url(email_attachment_id || workflow_email_attachment_id) %]">[% 'Email Attachment Preview' | $T8 %]</a></li>
53
  [% END %]
42 54
  [% IF INSTANCE_CONF.get_webdav %]
43 55
    <li><a href="#ui-tabs-webdav">[% 'WebDAV' | $T8 %]</a></li>
44 56
  [% END %]
......
66 78

  
67 79
</div><!-- /.wrapper -->
68 80

  
81
[% IF email_attachment_id || workflow_email_attachment_id %]
82
  <div class="wrapper" id="email_attachment_wrapper">
83
    [%
84
      BLOCK panel_1;
85
        P.email_journal.attachment_preview(
86
             email_attachment_id || workflow_email_attachment_id,
87
             style="height:600px"
88
             );
89
      END;
90
      INCLUDE 'common/toggle_panel.html'
91
        block_name='panel_1'
92
        button_closed  = LxERP.t8('Show Attachment')
93
        button_open    = LxERP.t8('Hide Attachment')
94
        ;
95
    %]
96
  </div>
97
[% END %]
98

  
69 99
<div class="wrapper">
70 100

  
71 101
<table class="tbl-horizontal">

Auch abrufbar als: Unified diff