Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5e9f19cb

Von Tamino Steinert vor 12 Monaten hinzugefügt

  • ID 5e9f19cb649be0d7d87a26c71f176c10d7ad3653
  • Vorgänger 6088e247
  • Nachfolger 6dc75be3

EmailJournal: Belegvorlage zum Workflow hinzugefügt

Unterschiede anzeigen:

SL/Controller/EmailJournal.pm
87 87
      'purchase_credit_note',
88 88
    ],
89 89
  },
90
  RecordTemplate => {
91
    controller => '',
92
    class      => 'RecordTemplate',
93
    types => [
94
      'gl_transaction_template',
95
      'ar_transaction_template',
96
      'ap_transaction_template',
97
    ],
98
  }
90 99
);
91 100
my %RECORD_TYPE_TO_CONTROLLER =
92 101
  map {
......
110 119
    my $model = $RECORD_TYPE_TO_MODEL{$_};
111 120
    if (any {$model eq $_} qw(SL::DB::Invoice SL::DB::PurchaseInvoice)) {
112 121
      $_ => 'invnumber';
122
    } elsif (any {$model eq $_} qw(SL::DB::RecordTemplate)) {
123
      $_ => 'template_name';
113 124
    } else {
114 125
      my $type_data = SL::DB::Helper::TypeDataProxy->new($model, $_);
115 126
      $_ => $type_data->properties('nr_key');
......
121 132
  # TODO: what record types can be created, which are only available in workflows?
122 133
  my @record_types_with_info = ();
123 134
  for my $record_class ('SL::DB::Order', 'SL::DB::DeliveryOrder', 'SL::DB::Reclamation') {
124
    my $valid_types = "${record_class}::TypeData"->valid_types();
135
    my $type_data = "${record_class}::TypeData";
136
    my $valid_types = $type_data->valid_types();
125 137
    for my $type (@$valid_types) {
126

  
127
      my $type_data = SL::DB::Helper::TypeDataProxy->new($record_class, $type);
128 138
      push @record_types_with_info, {
129
        record_type    => $type,
130
        customervendor => $type_data->properties('customervendor'),
131
        text           => $type_data->text('type'),
139
        record_type     => $type,
140
        text            => $type_data->can('get3')->($type, 'text', 'type'),
141
        customervendor  => $type_data->can('get3')->($type, 'properties', 'customervendor'),
142
        workflow_needed => $type_data->can('get3')->($type, 'properties', 'worflow_needed'),
143
        can_workflow    => (
144
          any {
145
            $_ ne 'delete' && $type_data->can('get3')->($type, 'show_menu', $_)
146
          } keys %{$type_data->can('get')->($type, 'show_menu')}
147
        ),
132 148
      };
133 149
    }
134 150
  }
135 151
  push @record_types_with_info, (
136 152
    # invoice
137
    { record_type => 'invoice',                             customervendor => 'customer',  text => t8('Invoice') },
138
    { record_type => 'invoice_for_advance_payment',         customervendor => 'customer',  text => t8('Invoice for Advance Payment')},
139
    { record_type => 'invoice_for_advance_payment_storno',  customervendor => 'customer',  text => t8('Storno Invoice for Advance Payment')},
140
    { record_type => 'final_invoice',                       customervendor => 'customer',  text => t8('Final Invoice')},
141
    { record_type => 'invoice_storno',                      customervendor => 'customer',  text => t8('Storno Invoice')},
142
    { record_type => 'credit_note',                         customervendor => 'customer',  text => t8('Credit Note')},
143
    { record_type => 'credit_note_storno',                  customervendor => 'customer',  text => t8('Storno Credit Note')},
144
    { record_type => 'ar_transaction',                      customervendor => 'customer',  text => t8('AR Transaction')},
153
    { record_type => 'invoice',                            customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('Invoice') },
154
    { record_type => 'invoice_for_advance_payment',        customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('Invoice for Advance Payment')},
155
    { record_type => 'invoice_for_advance_payment_storno', customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Storno Invoice for Advance Payment')},
156
    { record_type => 'final_invoice',                      customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Final Invoice')},
157
    { record_type => 'invoice_storno',                     customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Storno Invoice')},
158
    { record_type => 'credit_note',                        customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('Credit Note')},
159
    { record_type => 'credit_note_storno',                 customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Storno Credit Note')},
145 160
    # purchase invoice
146
    { record_type => 'purchase_invoice',      customervendor => 'vendor',  text => t8('Purchase Invoice')},
147
    { record_type => 'purchase_credit_note',  customervendor => 'vendor',  text => t8('Purchase Credit Note')},
148
    { record_type => 'ap_transaction',        customervendor => 'vendor',  text => t8('AP Transaction')},
161
    { record_type => 'purchase_invoice',      customervendor => 'vendor', workflow_needed => 0, can_workflow => 1, text => t8('Purchase Invoice')},
162
    { record_type => 'purchase_credit_note',  customervendor => 'vendor', workflow_needed => 0, can_workflow => 1, text => t8('Purchase Credit Note')},
163
    # 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')},
167
    { record_type => 'ar_transaction', customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('AR Transaction')},
168
    { record_type => 'ap_transaction', customervendor => 'vendor',   workflow_needed => 0, can_workflow => 1, text => t8('AP Transaction')},
169
    # templates
170
    { record_type => 'gl_transaction_template', is_template => 1, customervendor => 'customer', workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
171
    { record_type => 'gl_transaction_template', is_template => 1, customervendor => 'vendor',   workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
172
    { record_type => 'ar_transaction_template', is_template => 1, customervendor => 'customer', workflow_needed => 0, can_workflow => 0, text => t8('AR Transaction')},
173
    { record_type => 'ap_transaction_template', is_template => 1, customervendor => 'vendor',   workflow_needed => 0, can_workflow => 0, text => t8('AP Transaction')},
149 174
  );
150 175
  return @record_types_with_info;
151 176
}
152 177

  
153
sub record_types_for_customer_vendor_type {
154
  my ($self, $customer_vendor_type) = @_;
155
  return [ map { $_->{record_type} } grep { $_->{customervendor} eq $customer_vendor_type } $self->get_record_types_with_info ];
178
sub record_types_for_customer_vendor_type_and_action {
179
  my ($self, $customer_vendor_type, $action) = @_;
180
  return [
181
    map { $_->{record_type} }
182
    grep {
183
      ($_->{customervendor} eq $customer_vendor_type)
184
      && ($action eq 'workflow_record' ? $_->{can_workflow} : 1)
185
      && ($action eq 'create_new'      ? $_->{workflow_needed} : 1)
186
      && ($action eq 'linking_record'  ? $_->{record_type} !~ /_template$/ : 1)
187
      && ($action eq 'template_record' ? $_->{record_type} =~ /_template$/ : 1)
188
    }
189
    $self->get_record_types_with_info()
190
  ];
156 191
}
157 192

  
158 193
#
......
192 227
  my $customer_vendor = $self->find_customer_vendor_from_email($self->entry);
193 228
  my $cv_type = $customer_vendor && $customer_vendor->is_vendor ? 'vendor' : 'customer';
194 229

  
195
  my $record_types = $self->record_types_for_customer_vendor_type($cv_type);
230
  my $record_types = $self->record_types_for_customer_vendor_type_and_action($cv_type, 'workflow_record');
196 231
  my @records = $self->get_records_for_types(
197 232
    $record_types,
198 233
    customer_vendor_type => $cv_type,
......
227 262
    my $manager = $RECORD_TYPE_TO_MANAGER{$record_type};
228 263
    my $model = $RECORD_TYPE_TO_MODEL{$record_type};
229 264
    my %additional_where = ();
230
    if ($cv_type && $cv_id) {
265
    if ($cv_type && $cv_id && $record_type !~ /^gl_transaction/) {
231 266
      $additional_where{"${cv_type}_id"} = $cv_id;
232 267
    }
233 268
    if ($record_number) {
......
392 427
  $::auth->assert('email_journal');
393 428
  my $customer_vendor_type = $::form->{customer_vendor_selection};
394 429
  my $customer_vendor_id   = $::form->{"${customer_vendor_type}_id"};
395
  my $record_type          = $::form->{"${customer_vendor_type}_record_type_selection"};
430
  my $action               = $::form->{action_selection};
431
  my $record_type          = $::form->{"${customer_vendor_type}_${action}_type_selection"};
396 432
  my $record_number        = $::form->{record_number};
397 433
  my $with_closed          = $::form->{with_closed};
398 434

  
399
  $record_type ||= $self->record_types_for_customer_vendor_type($customer_vendor_type);
435
  $record_type ||= $self->record_types_for_customer_vendor_type_and_action($customer_vendor_type, $action);
400 436

  
401 437
  my @records = $self->get_records_for_types(
402 438
    $record_type,
......
423 459
    id => 'record_list',
424 460
  );
425 461

  
426

  
427 462
  $self->js->replaceWith('#record_list', $new_div);
428 463
  $self->js->hide('#record_toggle_closed') if scalar @records < 20;
429 464
  $self->js->show('#record_toggle_open')   if scalar @records < 20;

Auch abrufbar als: Unified diff