Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 28142a65

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID 28142a6541aa236a3f67dab418e68e0f1f55ed29
  • Vorgänger 9b8b347f
  • Nachfolger eecd5012

TypeData: nutzte Konstanten anstatt String für Typen

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
182 182
  # make new order from given orders
183 183
  my @multi_orders = map { SL::DB::DeliveryOrder->new(id => $_)->load } @multi_ids;
184 184
  $self->{converted_from_oe_id} = join ' ', map { $_->id } @multi_orders;
185
  my $target_type = "sales_delivery_order";
185
  my $target_type = SALES_DELIVERY_ORDER_TYPE();
186 186
  my $delivery_order = SL::Model::Record->new_from_workflow_multi(\@multi_orders, $target_type, sort_sources_by => 'transdate');
187 187
  $self->order($delivery_order);
188 188

  
SL/Controller/Order.pm
35 35
use SL::DB::Helper::RecordLink qw(set_record_link_conversions);
36 36
use SL::DB::Helper::TypeDataProxy;
37 37
use SL::Model::Record;
38
use SL::DB::Order::TypeData qw(:types);
39
use SL::DB::Reclamation::TypeData qw(:types);
38 40

  
39 41
use SL::Helper::CreatePDF qw(:all);
40 42
use SL::Helper::PrintOptions;
......
98 100

  
99 101
  my $reclamation = SL::DB::Reclamation->new(id => $::form->{from_id})->load;
100 102
  my %params;
101
  my $target_type = $reclamation->is_sales ? 'sales_order'
102
                                           : 'purchase_order';
103
  my $target_type = $reclamation->is_sales ? SALES_ORDER_TYPE()
104
                                           : PURCHASE_ORDER_TYPE();
103 105
  my $order = SL::Model::Record->new_from_workflow($reclamation, $target_type);
104 106
  $self->{converted_from_reclamation_id} = $::form->{from_id};
105 107

  
......
189 191
  my ($self) = @_;
190 192

  
191 193
  SL::Model::Record->delete($self->order);
192
  my $text = $self->type eq sales_order_type()       ? $::locale->text('The order has been deleted')
193
           : $self->type eq purchase_order_type()    ? $::locale->text('The order has been deleted')
194
           : $self->type eq sales_quotation_type()   ? $::locale->text('The quotation has been deleted')
195
           : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been deleted')
194
  my $text = $self->type eq SALES_ORDER_TYPE()       ? $::locale->text('The order has been deleted')
195
           : $self->type eq PURCHASE_ORDER_TYPE()    ? $::locale->text('The order has been deleted')
196
           : $self->type eq SALES_QUOTATION_TYPE()   ? $::locale->text('The quotation has been deleted')
197
           : $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text('The rfq has been deleted')
196 198
           : '';
197 199
  flash_later('info', $text);
198 200

  
......
210 212

  
211 213
  $self->save();
212 214

  
213
  my $text = $self->type eq sales_order_type()       ? $::locale->text('The order has been saved')
214
           : $self->type eq purchase_order_type()    ? $::locale->text('The order has been saved')
215
           : $self->type eq sales_quotation_type()   ? $::locale->text('The quotation has been saved')
216
           : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
215
  my $text = $self->type eq SALES_ORDER_TYPE()       ? $::locale->text('The order has been saved')
216
           : $self->type eq PURCHASE_ORDER_TYPE()    ? $::locale->text('The order has been saved')
217
           : $self->type eq SALES_QUOTATION_TYPE()   ? $::locale->text('The quotation has been saved')
218
           : $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text('The rfq has been saved')
217 219
           : '';
218 220
  flash_later('info', $text);
219 221

  
......
740 742
  $config  ||= SL::DB::Manager::PeriodicInvoicesConfig->find_by(oe_id => $::form->{id}) if $::form->{id};
741 743

  
742 744
  my $has_active_periodic_invoices =
743
       $self->type eq sales_order_type()
745
       $self->type eq SALES_ORDER_TYPE()
744 746
    && $config
745 747
    && $config->active
746 748
    && (!$config->end_date || ($config->end_date > DateTime->today_local))
......
784 786
  # can't use save_and_redirect_to, because id is set!
785 787
  $self->save();
786 788

  
787
  my $to_type = $self->order->is_sales ? 'sales_reclamation'
788
                                       : 'purchase_reclamation';
789
  my $to_type = $self->order->is_sales ? SALES_RECLAMATION_TYPE()
790
                                       : PURCHASE_RECLAMATION_TYPE();
789 791
  $self->redirect_to(
790 792
    controller => 'Reclamation',
791 793
    action     => 'add_from_order',
......
853 855
  my $destination_type = $::form->{to_type} ? $::form->{to_type} : '';
854 856

  
855 857
  my $from_side        = $self->order->is_sales ? 'sales' : 'purchase';
856
  my $to_side          = (any { $destination_type eq $_ } (sales_order_type(), sales_quotation_type())) ? 'sales' : 'purchase';
858
  my $to_side          = (any { $destination_type eq $_ } (SALES_ORDER_TYPE(), SALES_QUOTATION_TYPE())) ? 'sales' : 'purchase';
857 859

  
858 860
  # check for direct delivery
859 861
  # copy shipto in custom shipto (custom shipto will be copied by new_from() in case)
......
866 868
  $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type));
867 869

  
868 870
  # no linked records to quotations from the same side (sales -> sales or purchase -> purchase)
869
  if (    (any { $destination_type eq $_ } (sales_quotation_type(), request_quotation_type()))
871
  if (    (any { $destination_type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE()))
870 872
       && $from_side eq $to_side) {
871 873
    delete $::form->{id};
872 874
    delete $::form->{$_} for qw(converted_from_oe_id converted_from_orderitems_ids);
......
1618 1620
#
1619 1621

  
1620 1622
sub init_valid_types {
1621
  [ sales_order_type(), purchase_order_type(), sales_quotation_type(), request_quotation_type() ];
1623
  $_[0]->type_data->valid_types;
1622 1624
}
1623 1625

  
1624 1626
sub init_type {
......
1634 1636
sub init_cv {
1635 1637
  my ($self) = @_;
1636 1638

  
1637
  my $cv = (any { $self->type eq $_ } (sales_order_type(),    sales_quotation_type()))   ? 'customer'
1638
         : (any { $self->type eq $_ } (purchase_order_type(), request_quotation_type())) ? 'vendor'
1639
  my $cv = (any { $self->type eq $_ } (SALES_ORDER_TYPE(),    SALES_QUOTATION_TYPE()))   ? 'customer'
1640
         : (any { $self->type eq $_ } (PURCHASE_ORDER_TYPE(), REQUEST_QUOTATION_TYPE())) ? 'vendor'
1639 1641
         : die "Not a valid type for order";
1640 1642

  
1641 1643
  return $cv;
......
1855 1857
  my $order;
1856 1858
  $order   = SL::DB::Order->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id};
1857 1859
  $order ||= SL::DB::Order->new(orderitems  => [],
1858
                                quotation   => (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type())),
1860
                                quotation   => (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE())),
1859 1861
                                currency_id => $::instance_conf->get_currency_id(),);
1860 1862

  
1861 1863
  my $cv_id_method = $self->cv . '_id';
......
2169 2171
    $item->active_discount_source($price_source->discount_from_source($item->active_discount_source));
2170 2172
  }
2171 2173

  
2172
  if (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())) {
2174
  if (any { $self->type eq $_ } (SALES_ORDER_TYPE(), PURCHASE_ORDER_TYPE())) {
2173 2175
    # Calculate shipped qtys here to prevent calling calculate for every item via the items method.
2174 2176
    # Do not use write_to_objects to prevent order->delivered to be set, because this should be
2175 2177
    # the value from db, which can be set manually or is set when linked delivery orders are saved.
......
2188 2190
                                                } } @all_objects;
2189 2191
  }
2190 2192

  
2191
  if (   (any { $self->type eq $_ } (sales_quotation_type(), sales_order_type()))
2193
  if (   (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), SALES_ORDER_TYPE()))
2192 2194
      && $::instance_conf->get_transport_cost_reminder_article_number_id ) {
2193 2195
    $self->{template_args}->{transport_cost_reminder_article} = SL::DB::Part->new(id => $::instance_conf->get_transport_cost_reminder_article_number_id)->load;
2194 2196
  }
......
2206 2208
sub setup_edit_action_bar {
2207 2209
  my ($self, %params) = @_;
2208 2210

  
2209
  my $deletion_allowed = (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type()))
2210
                      || (($self->type eq sales_order_type())    && $::instance_conf->get_sales_order_show_delete)
2211
                      || (($self->type eq purchase_order_type()) && $::instance_conf->get_purchase_order_show_delete);
2211
  my $deletion_allowed = (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE()))
2212
                      || (($self->type eq SALES_ORDER_TYPE())    && $::instance_conf->get_sales_order_show_delete)
2213
                      || (($self->type eq PURCHASE_ORDER_TYPE()) && $::instance_conf->get_purchase_order_show_delete);
2212 2214

  
2213 2215
  my @req_trans_cost_art = qw(kivi.Order.check_transport_cost_article_presence) x!!$::instance_conf->get_transport_cost_reminder_article_number_id;
2214
  my @req_cusordnumber   = qw(kivi.Order.check_cusordnumber_presence)           x($self->type eq sales_order_type() && $::instance_conf->get_order_warn_no_cusordnumber);
2216
  my @req_cusordnumber   = qw(kivi.Order.check_cusordnumber_presence)           x($self->type eq SALES_ORDER_TYPE() && $::instance_conf->get_order_warn_no_cusordnumber);
2215 2217

  
2216 2218
  my $has_invoice_for_advance_payment;
2217
  if ($self->order->id && $self->type eq sales_order_type()) {
2219
  if ($self->order->id && $self->type eq SALES_ORDER_TYPE()) {
2218 2220
    my $lr = $self->order->linked_records(direction => 'to', to => ['Invoice']);
2219 2221
    $has_invoice_for_advance_payment = any {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$lr;
2220 2222
  }
2221 2223

  
2222 2224
  my $has_final_invoice;
2223
  if ($self->order->id && $self->type eq sales_order_type()) {
2225
  if ($self->order->id && $self->type eq SALES_ORDER_TYPE()) {
2224 2226
    my $lr = $self->order->linked_records(direction => 'to', to => ['Invoice']);
2225 2227
    $has_final_invoice               = any {'SL::DB::Invoice' eq ref $_ && "final_invoice" eq $_->type} @$lr;
2226 2228
  }
......
2288 2290
        ],
2289 2291
        action => [
2290 2292
          t8('Save and Quotation'),
2291
          call     => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => sales_quotation_type()), '#order_form' ],
2293
          call     => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => SALES_QUOTATION_TYPE()), '#order_form' ],
2292 2294
          checks   => [ @req_trans_cost_art, @req_cusordnumber ],
2293
          only_if  => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())),
2295
          only_if  => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), REQUEST_QUOTATION_TYPE())),
2294 2296
          disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2295 2297
        ],
2296 2298
        action => [
2297 2299
          t8('Save and RFQ'),
2298
          call     => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => request_quotation_type() } ],
2299
          only_if  => (any { $self->type eq $_ } (sales_order_type(), sales_quotation_type(), purchase_order_type())),
2300
          call     => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => REQUEST_QUOTATION_TYPE() } ],
2301
          only_if  => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), SALES_QUOTATION_TYPE(), PURCHASE_ORDER_TYPE())),
2300 2302
          disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2301 2303
        ],
2302 2304
        action => [
2303 2305
          t8('Save and Sales Order'),
2304
          call     => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => sales_order_type()), '#order_form' ],
2306
          call     => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => SALES_ORDER_TYPE()), '#order_form' ],
2305 2307
          checks   => [ @req_trans_cost_art ],
2306
          only_if  => (any { $self->type eq $_ } (sales_quotation_type(), request_quotation_type(), purchase_order_type())),
2308
          only_if  => (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE(), PURCHASE_ORDER_TYPE())),
2307 2309
          disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2308 2310
        ],
2309 2311
        action => [
2310 2312
          t8('Save and Purchase Order'),
2311
          call      => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => purchase_order_type() } ],
2313
          call      => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => PURCHASE_ORDER_TYPE() } ],
2312 2314
          checks    => [ @req_trans_cost_art, @req_cusordnumber ],
2313
          only_if   => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())),
2315
          only_if   => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), REQUEST_QUOTATION_TYPE())),
2314 2316
          disabled  => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2315 2317
        ],
2316 2318
        action => [
......
2322 2324
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices',
2323 2325
                         @req_trans_cost_art, @req_cusordnumber,
2324 2326
          ],
2325
          only_if   => (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())),
2327
          only_if   => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), PURCHASE_ORDER_TYPE())),
2326 2328
          disabled  => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2327 2329
        ],
2328 2330
        action => [
......
2345 2347
          checks    => [ 'kivi.Order.check_save_active_periodic_invoices',
2346 2348
                         @req_trans_cost_art, @req_cusordnumber,
2347 2349
          ],
2348
          only_if   => (any { $self->type eq $_ } (purchase_order_type())),
2350
          only_if   => (any { $self->type eq $_ } (PURCHASE_ORDER_TYPE())),
2349 2351
          disabled  => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
2350 2352
        ],
2351 2353
        action => [
......
2353 2355
          call      => [ 'kivi.Order.save', { action             => 'save_and_reclamation',
2354 2356
                                              warn_on_duplicates => $::instance_conf->get_order_warn_duplicate_parts },
2355 2357
          ],
2356
          only_if   => (any { $self->type eq $_ } (sales_order_type(), purchase_order_type()))
2358
          only_if   => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), PURCHASE_ORDER_TYPE()))
2357 2359
        ],
2358 2360
        action => [
2359 2361
          t8('Save and Invoice'),
......
2376 2378
          disabled  => !$may_edit_create  ? t8('You do not have the permissions to access this function.')
2377 2379
                     : $has_final_invoice ? t8('This order has already a final invoice.')
2378 2380
                     :                      undef,
2379
          only_if   => (any { $self->type eq $_ } (sales_order_type())),
2381
          only_if   => (any { $self->type eq $_ } (SALES_ORDER_TYPE())),
2380 2382
        ],
2381 2383
        action => [
2382 2384
          t8('Save and Final Invoice'),
......
2389 2391
          disabled  => !$may_edit_create  ? t8('You do not have the permissions to access this function.')
2390 2392
                     : $has_final_invoice ? t8('This order has already a final invoice.')
2391 2393
                     :                      undef,
2392
          only_if   => (any { $self->type eq $_ } (sales_order_type())) && $has_invoice_for_advance_payment,
2394
          only_if   => (any { $self->type eq $_ } (SALES_ORDER_TYPE())) && $has_invoice_for_advance_payment,
2393 2395
        ],
2394 2396
        action => [
2395 2397
          t8('Save and AP Transaction'),
2396 2398
          call      => [ 'kivi.Order.save', { action             => 'save_and_ap_transaction',
2397 2399
                                              warn_on_duplicates => $::instance_conf->get_order_warn_duplicate_parts },
2398 2400
          ],
2399
          only_if   => (any { $self->type eq $_ } (purchase_order_type())),
2401
          only_if   => (any { $self->type eq $_ } (PURCHASE_ORDER_TYPE())),
2400 2402
          disabled  => !$may_edit_create  ? t8('You do not have the permissions to access this function.') : undef,
2401 2403
        ],
2402 2404

  
......
2586 2588
sub get_periodic_invoices_status {
2587 2589
  my ($self, $config) = @_;
2588 2590

  
2589
  return                      if $self->type ne sales_order_type();
2591
  return                      if $self->type ne SALES_ORDER_TYPE();
2590 2592
  return t8('not configured') if !$config;
2591 2593

  
2592 2594
  my $active = ('HASH' eq ref $config)                           ? $config->{active}
......
2612 2614
  # $::locale->text("Edit Request for Quotation");
2613 2615

  
2614 2616
  $action = ucfirst(lc($action));
2615
  return $self->type eq sales_order_type()       ? $::locale->text("$action Sales Order")
2616
       : $self->type eq purchase_order_type()    ? $::locale->text("$action Purchase Order")
2617
       : $self->type eq sales_quotation_type()   ? $::locale->text("$action Quotation")
2618
       : $self->type eq request_quotation_type() ? $::locale->text("$action Request for Quotation")
2617
  return $self->type eq SALES_ORDER_TYPE()       ? $::locale->text("$action Sales Order")
2618
       : $self->type eq PURCHASE_ORDER_TYPE()    ? $::locale->text("$action Purchase Order")
2619
       : $self->type eq SALES_QUOTATION_TYPE()   ? $::locale->text("$action Quotation")
2620
       : $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text("$action Request for Quotation")
2619 2621
       : '';
2620 2622
}
2621 2623

  
......
2693 2695
  return ($price_src, $discount_src);
2694 2696
}
2695 2697

  
2696
sub sales_order_type {
2697
  'sales_order';
2698
}
2699

  
2700
sub purchase_order_type {
2701
  'purchase_order';
2702
}
2703

  
2704
sub sales_quotation_type {
2705
  'sales_quotation';
2706
}
2707

  
2708
sub request_quotation_type {
2709
  'request_quotation';
2710
}
2711

  
2712 2698
sub nr_key {
2713
  return $_[0]->type eq sales_order_type()       ? 'ordnumber'
2714
       : $_[0]->type eq purchase_order_type()    ? 'ordnumber'
2715
       : $_[0]->type eq sales_quotation_type()   ? 'quonumber'
2716
       : $_[0]->type eq request_quotation_type() ? 'quonumber'
2699
  return $_[0]->type eq SALES_ORDER_TYPE()       ? 'ordnumber'
2700
       : $_[0]->type eq PURCHASE_ORDER_TYPE()    ? 'ordnumber'
2701
       : $_[0]->type eq SALES_QUOTATION_TYPE()   ? 'quonumber'
2702
       : $_[0]->type eq REQUEST_QUOTATION_TYPE() ? 'quonumber'
2717 2703
       : '';
2718 2704
}
2719 2705

  
......
2722 2708

  
2723 2709
  $self->save();
2724 2710

  
2725
  my $text = $self->type eq sales_order_type()       ? $::locale->text('The order has been saved')
2726
           : $self->type eq purchase_order_type()    ? $::locale->text('The order has been saved')
2727
           : $self->type eq sales_quotation_type()   ? $::locale->text('The quotation has been saved')
2728
           : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
2711
  my $text = $self->type eq SALES_ORDER_TYPE()       ? $::locale->text('The order has been saved')
2712
           : $self->type eq PURCHASE_ORDER_TYPE()    ? $::locale->text('The order has been saved')
2713
           : $self->type eq SALES_QUOTATION_TYPE()   ? $::locale->text('The quotation has been saved')
2714
           : $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text('The rfq has been saved')
2729 2715
           : '';
2730 2716
  flash_later('info', $text);
2731 2717

  
SL/Controller/Reclamation.pm
39 39
use SL::DB::DeliveryOrder;
40 40
use SL::DB::Invoice;
41 41
use SL::Model::Record;
42
use SL::DB::Order::TypeData qw(:types);
43
use SL::DB::Reclamation::TypeData qw(:types);
42 44

  
43 45
use List::Util qw(first sum0);
44 46
use List::UtilsBy qw(sort_by uniq_by);
......
123 125
  }
124 126

  
125 127
  my $order = SL::DB::Order->new(id => $::form->{from_id})->load;
126
  my $target_type = $order->is_sales ? 'sales_reclamation'
127
                                     : 'purchase_reclamation';
128
  my $target_type = $order->is_sales ? SALES_RECLAMATION_TYPE()
129
                                     : PURCHASE_RECLAMATION_TYPE();
128 130
  my $reclamation = SL::Model::Record->new_from_workflow($order, $target_type);
129 131

  
130 132
  $self->reclamation($reclamation);
......
151 153
  }
152 154

  
153 155
  my $delivery_order = SL::DB::DeliveryOrder->new(id => $::form->{from_id})->load;
154
  my $target_type = $delivery_order->is_sales ? 'sales_reclamation'
155
                                              : 'purchase_reclamation';
156
  my $target_type = $delivery_order->is_sales ? SALES_RECLAMATION_TYPE()
157
                                              : PURCHASE_RECLAMATION_TYPE();
156 158
  my $reclamation = SL::Model::Record->new_from_workflow($delivery_order, $target_type);
157 159

  
158 160
  $self->reclamation($reclamation);
......
179 181
  }
180 182

  
181 183
  my $invoice = SL::DB::Invoice->new(id => $::form->{from_id})->load;
182
  my $target_type = 'sales_reclamation';
184
  my $target_type = SALES_RECLAMATION_TYPE();
183 185
  my $reclamation = SL::Model::Record->new_from_workflow($invoice, $target_type);
184 186

  
185 187
  $self->reclamation($reclamation);
......
208 210
  require SL::DB::PurchaseInvoice;
209 211
  my $invoice = SL::DB::PurchaseInvoice->new(id => $::form->{from_id})->load;
210 212
  $invoice->{type} = $invoice->invoice_type; #can't add type → invoice_type in SL/DB/PurchaseInvoice
211
  my $target_type = 'purchase_reclamation';
213
  my $target_type = PURCHASE_RECLAMATION_TYPE();
212 214
  my $reclamation = SL::Model::Record->new_from_workflow($invoice, $target_type);
213 215

  
214 216
  $self->reclamation($reclamation);
......
583 585
sub action_save_and_order {
584 586
  my ($self) = @_;
585 587

  
586
  my $to_type = $self->reclamation->is_sales ? 'sales_order'
587
                                             : 'purchase_order';
588
  my $to_type = $self->reclamation->is_sales ? SALES_ORDER_TYPE()
589
                                             : PURCHASE_ORDER_TYPE();
588 590

  
589 591
  $self->save_with_render_error();
590 592
  flash_later('info', t8('The reclamation has been saved'));
......
606 608
    controller => 'Reclamation',
607 609
    action     => 'add_from_reclamation',
608 610
    from_id => $self->reclamation->id,
609
    type => sales_reclamation_type(),
611
    type => SALES_RECLAMATION_TYPE(),
610 612
  );
611 613
}
612 614

  
......
620 622
    controller => 'Reclamation',
621 623
    action     => 'add_from_reclamation',
622 624
    from_id => $self->reclamation->id,
623
    type => purchase_reclamation_type(),
625
    type => PURCHASE_RECLAMATION_TYPE(),
624 626
  );
625 627
}
626 628

  
......
1213 1215
#
1214 1216

  
1215 1217
sub init_valid_types {
1216
  [ sales_reclamation_type(), purchase_reclamation_type() ];
1218
  $_[0]->type_data->valid_types;
1217 1219
}
1218 1220

  
1219 1221
sub init_type {
......
1229 1231
sub init_cv {
1230 1232
  my ($self) = @_;
1231 1233

  
1232
  my $cv = (any { $self->type eq $_ } (sales_reclamation_type()))   ? 'customer'
1233
         : (any { $self->type eq $_ } (purchase_reclamation_type())) ? 'vendor'
1234
  my $cv = (any { $self->type eq $_ } (SALES_RECLAMATION_TYPE()))   ? 'customer'
1235
         : (any { $self->type eq $_ } (PURCHASE_RECLAMATION_TYPE())) ? 'vendor'
1234 1236
         : die "Not a valid type for reclamation";
1235 1237

  
1236 1238
  return $cv;
......
1273 1275
      language_id             => t8('Language'),
1274 1276
      department_id           => t8('Department'),
1275 1277
      globalproject_id        => t8('Project Number'),
1276
      cv_record_number        => ($self->type eq 'sales_reclamation' ? t8('Customer Record Number') : t8('Vendor Record Number')),
1278
      cv_record_number        => ($self->type eq SALES_RECLAMATION_TYPE() ? t8('Customer Record Number') : t8('Vendor Record Number')),
1277 1279
      transaction_description => t8('Description'),
1278 1280
      notes                   => t8('Notes'),
1279 1281
      intnotes                => t8('Internal Notes'),
......
1319 1321

  
1320 1322
sub init_part_picker_classification_ids {
1321 1323
  my ($self)    = @_;
1322
  my $attribute = 'used_for_' . ($self->type eq sales_reclamation_type() ? 'sale' : 'purchase');
1324
  my $attribute = 'used_for_' . ($self->type eq SALES_RECLAMATION_TYPE() ? 'sale' : 'purchase');
1323 1325

  
1324 1326
  return [ map { $_->id } @{ SL::DB::Manager::PartClassification->get_all(where => [ $attribute => 1 ]) } ];
1325 1327
}
......
1767 1769

  
1768 1770
  # check for direct delivery
1769 1771
  # copy shipto in custom shipto (custom shipto will be copied by new_from() in case)
1770
  if ($::form->{type} eq purchase_reclamation_type()) {
1772
  if ($::form->{type} eq PURCHASE_RECLAMATION_TYPE()) {
1771 1773
    if ($::form->{use_shipto}) {
1772 1774
      my $custom_shipto = $source_reclamation->shipto->clone('SL::DB::Reclamation');
1773 1775
      $self->reclamation->custom_shipto($custom_shipto) if $custom_shipto;
......
2059 2061
      sub      => sub { $_[0]->closed ? t8('Yes') : t8('No') },
2060 2062
    },
2061 2063
  );
2062
  if ($self->type eq sales_reclamation_type()) {
2064
  if ($self->type eq SALES_RECLAMATION_TYPE()) {
2063 2065
    $column_defs{customer_id} = ({
2064 2066
      raw_data => sub { $_[0]->customervendor->presenter->customer(display => 'table-cell', callback => $callback) },
2065 2067
      sub      => sub { $_[0]->customervendor->name },
......
2074 2076
      },
2075 2077
      sub      => sub { $_[0]->contact ? $_[0]->contact->cp_name : '' },
2076 2078
    });
2077
  } elsif ($self->type eq purchase_reclamation_type()) {
2079
  } elsif ($self->type eq PURCHASE_RECLAMATION_TYPE()) {
2078 2080
    $column_defs{vendor_id} = ({
2079 2081
      raw_data => sub { $_[0]->customervendor->presenter->vendor(display => 'table-cell', callback => $callback) },
2080 2082
      sub      => sub { $_[0]->customervendor->name },
......
2135 2137
     { output => 0 },
2136 2138
     models => $self->models
2137 2139
    ),
2138
    title                 => $self->type eq sales_reclamation_type() ? t8('Sales Reclamations') : t8('Purchase Reclamations'),
2140
    title                 => $self->type eq SALES_RECLAMATION_TYPE() ? t8('Sales Reclamations') : t8('Purchase Reclamations'),
2139 2141
    allow_pdf_export      => 1,
2140 2142
    allow_csv_export      => 1,
2141 2143
  );
......
2150 2152
sub _setup_edit_action_bar {
2151 2153
  my ($self, %params) = @_;
2152 2154

  
2153
  my $deletion_allowed = ($self->type eq sales_reclamation_type()
2155
  my $deletion_allowed = ($self->type eq SALES_RECLAMATION_TYPE()
2154 2156
                          && $::instance_conf->get_sales_reclamation_show_delete)
2155
                      || ($self->type eq purchase_reclamation_type()
2157
                      || ($self->type eq PURCHASE_RECLAMATION_TYPE()
2156 2158
                          && $::instance_conf->get_purchase_reclamation_show_delete);
2157 2159

  
2158 2160
  for my $bar ($::request->layout->get('actionbar')) {
......
2190 2192
            $::instance_conf->get_reclamation_warn_duplicate_parts,
2191 2193
            $::instance_conf->get_reclamation_warn_no_reqdate,
2192 2194
          ],
2193
          only_if  => (any { $self->type eq $_ } (purchase_reclamation_type())),
2195
          only_if  => (any { $self->type eq $_ } (PURCHASE_RECLAMATION_TYPE())),
2194 2196
        ],
2195 2197
        action => [
2196 2198
          t8('Save and Purchase Reclamation'),
2197 2199
          call      => [ 'kivi.Reclamation.purchase_reclamation_check_for_direct_delivery' ],
2198
          only_if   => (any { $self->type eq $_ } (sales_reclamation_type())),
2200
          only_if   => (any { $self->type eq $_ } (SALES_RECLAMATION_TYPE())),
2199 2201
        ],
2200 2202
        action => [
2201 2203
          t8('Save and Order'),
......
2212 2214
            $::instance_conf->get_reclamation_warn_duplicate_parts,
2213 2215
            $::instance_conf->get_reclamation_warn_no_reqdate,
2214 2216
          ],
2215
          only_if   => (any { $self->type eq $_ } (sales_reclamation_type())),
2217
          only_if   => (any { $self->type eq $_ } (SALES_RECLAMATION_TYPE())),
2216 2218
        ],
2217 2219
        action => [
2218 2220
          t8('Save and Supplier Delivery Order'),
......
2221 2223
            $::instance_conf->get_reclamation_warn_duplicate_parts,
2222 2224
            $::instance_conf->get_reclamation_warn_no_reqdate,
2223 2225
          ],
2224
          only_if   => (any { $self->type eq $_ } (purchase_reclamation_type())),
2226
          only_if   => (any { $self->type eq $_ } (PURCHASE_RECLAMATION_TYPE())),
2225 2227
        ],
2226 2228
        action => [
2227 2229
          t8('Save and Credit Note'),
......
2230 2232
            $::instance_conf->get_reclamation_warn_duplicate_parts,
2231 2233
            $::instance_conf->get_reclamation_warn_no_reqdate,
2232 2234
          ],
2233
          only_if   => (any { $self->type eq $_ } (sales_reclamation_type())),
2235
          only_if   => (any { $self->type eq $_ } (SALES_RECLAMATION_TYPE())),
2234 2236
        ],
2235 2237
      ], # end of combobox "Workflow"
2236 2238

  
......
2445 2447
  # t8("Edit Purchase Reclamation");
2446 2448

  
2447 2449
  $action = ucfirst(lc($action));
2448
  return $self->type eq sales_reclamation_type()    ? t8("$action Sales Reclamation")
2449
       : $self->type eq purchase_reclamation_type() ? t8("$action Purchase Reclamation")
2450
  return $self->type eq SALES_RECLAMATION_TYPE()    ? t8("$action Sales Reclamation")
2451
       : $self->type eq PURCHASE_RECLAMATION_TYPE() ? t8("$action Purchase Reclamation")
2450 2452
       : '';
2451 2453
}
2452 2454

  
......
2489 2491
  return $texts;
2490 2492
}
2491 2493

  
2492
sub sales_reclamation_type {
2493
  'sales_reclamation';
2494
}
2495

  
2496
sub purchase_reclamation_type {
2497
  'purchase_reclamation';
2498
}
2499

  
2500 2494
sub save_history {
2501 2495
  my ($self, $addition) = @_;
2502 2496

  
......
2550 2544
}
2551 2545

  
2552 2546
sub init_type_data {
2553
  SL::DB::Helper::TypeDataProxy->new('SL::DB::Reclamation', $_[0]->type);
2547
  SL::DB::Helper::TypeDataProxy->new('SL::DB::Reclamation', $::form->{type});
2554 2548
}
2555 2549

  
2556 2550
1;
SL/DB/DeliveryOrder.pm
20 20
use SL::DB::Unit;
21 21

  
22 22
use SL::DB::DeliveryOrder::TypeData qw(:types);
23
use SL::DB::Reclamation::TypeData qw(:types);
23 24

  
24 25
use SL::Helper::Number qw(_format_total _round_total);
25 26

  
......
93 94
    ],
94 95
  );
95 96

  
96
  return first { $_->is_type('sales_order') } @{ $orders };
97
  return first { $_->is_type(SALES_ORDER_TYPE()) } @{ $orders };
97 98
}
98 99

  
99 100
sub type {
......
107 108
sub displayable_type {
108 109
  my $type = shift->type;
109 110

  
110
  return $::locale->text('Sales Delivery Order')    if $type eq 'sales_delivery_order';
111
  return $::locale->text('Purchase Delivery Order') if $type eq 'purchase_delivery_order';
111
  return $::locale->text('Sales Delivery Order')    if $type eq SALES_DELIVERY_ORDER_TYPE();
112
  return $::locale->text('Purchase Delivery Order') if $type eq PURCHASE_DELIVERY_ORDER_TYPE();
112 113

  
113 114
  die 'invalid type';
114 115
}
......
145 146
sub convert_to_reclamation {
146 147
  my ($self, %params) = @_;
147 148

  
148
  $params{destination_type} = $self->is_sales ? 'sales_reclamation'
149
                                              : 'purchase_reclamation';
149
  $params{destination_type} = $self->is_sales ? SALES_RECLAMATION_TYPE()
150
                                              : PURCHASE_RECLAMATION_TYPE();
150 151

  
151 152
  my $reclamation = SL::DB::Reclamation->new_from($self, %params);
152 153

  
......
238 239
  }
239 240

  
240 241
  # infer type from legacy fields if not given
241
  $record_args{order_type} //= $source->customer_id ? 'sales_delivery_order'
242
                      : $source->vendor_id   ? 'purchase_delivery_order'
243
                      : $source->is_sales    ? 'sales_delivery_order'
242
  $record_args{order_type} //= $source->customer_id ? SALES_DELIVERY_ORDER_TYPE()
243
                      : $source->vendor_id   ? PURCHASE_DELIVERY_ORDER_TYPE()
244
                      : $source->is_sales    ? SALES_DELIVERY_ORDER_TYPE()
244 245
                      : croak "need some way to set delivery order type from source";
245 246

  
246 247
  my $delivery_order = $class->new(%record_args);
247 248
  $delivery_order->assign_attributes(%{ $params{attributes} }) if $params{attributes};
248 249

  
249 250
  my $items = delete($params{items}) || $source->items_sorted;
250
  my @items = ( $delivery_order->is_type(SUPPLIER_DELIVERY_ORDER_TYPE) && ref($source) ne 'SL::DB::Reclamation' ) ?
251
  my @items = ( $delivery_order->is_type(SUPPLIER_DELIVERY_ORDER_TYPE()) && ref($source) ne 'SL::DB::Reclamation' ) ?
251 252
                ()
252 253
              : map { SL::DB::DeliveryOrderItem->new_from($_, %params) } @{ $items };
253 254

  
SL/DB/Order.pm
26 26
use SL::RecordLinks;
27 27
use Rose::DB::Object::Helpers qw(as_tree strip);
28 28

  
29
use SL::DB::Order::TypeData qw(:types);
30
use SL::DB::Reclamation::TypeData qw(:types);
31

  
29 32
__PACKAGE__->meta->add_relationship(
30 33
  orderitems => {
31 34
    type         => 'one to many',
......
99 102
  my ($self) = @_;
100 103

  
101 104
  # force new project, if not set yet
102
  if ($::instance_conf->get_order_always_project && !$self->globalproject_id && ($self->type eq 'sales_order')) {
105
  if ($::instance_conf->get_order_always_project && !$self->globalproject_id && ($self->type eq SALES_ORDER_TYPE())) {
103 106

  
104 107
    die t8("Error while creating project with project number of new order number, project number #1 already exists!", $self->ordnumber)
105 108
      if SL::DB::Manager::Project->find_by(projectnumber => $self->ordnumber);
......
161 164
sub type {
162 165
  my $self = shift;
163 166

  
164
  return 'sales_order'       if $self->customer_id && ! $self->quotation;
165
  return 'purchase_order'    if $self->vendor_id   && ! $self->quotation;
166
  return 'sales_quotation'   if $self->customer_id &&   $self->quotation;
167
  return 'request_quotation' if $self->vendor_id   &&   $self->quotation;
167
  return SALES_ORDER_TYPE()       if $self->customer_id && ! $self->quotation;
168
  return PURCHASE_ORDER_TYPE()    if $self->vendor_id   && ! $self->quotation;
169
  return SALES_QUOTATION_TYPE()   if $self->customer_id &&   $self->quotation;
170
  return REQUEST_QUOTATION_TYPE() if $self->vendor_id   &&   $self->quotation;
168 171

  
169 172
  return;
170 173
}
......
178 181
  # But this has a different meaning for sales quotations.
179 182
  # deliverydate can be used to determine tax if tax_point isn't set.
180 183

  
181
  return $_[0]->reqdate if $_[0]->type ne 'sales_quotation';
184
  return $_[0]->reqdate if $_[0]->type ne SALES_QUOTATION_TYPE();
182 185
}
183 186

  
184 187
sub effective_tax_point {
......
190 193
sub displayable_type {
191 194
  my $type = shift->type;
192 195

  
193
  return $::locale->text('Sales quotation')   if $type eq 'sales_quotation';
194
  return $::locale->text('Request quotation') if $type eq 'request_quotation';
195
  return $::locale->text('Sales Order')       if $type eq 'sales_order';
196
  return $::locale->text('Purchase Order')    if $type eq 'purchase_order';
196
  return $::locale->text('Sales quotation')   if $type eq SALES_QUOTATION_TYPE();
197
  return $::locale->text('Request quotation') if $type eq REQUEST_QUOTATION_TYPE();
198
  return $::locale->text('Sales Order')       if $type eq SALES_ORDER_TYPE();
199
  return $::locale->text('Purchase Order')    if $type eq PURCHASE_ORDER_TYPE();
197 200

  
198 201
  die 'invalid type';
199 202
}
......
212 215

  
213 216
  return 1 if $self->currency_id == $::instance_conf->get_currency_id;
214 217

  
215
  my $rate = (any { $self->is_type($_) } qw(sales_quotation sales_order))      ? 'buy'
216
           : (any { $self->is_type($_) } qw(request_quotation purchase_order)) ? 'sell'
218
  my $rate = (any { $self->is_type($_) } (SALES_QUOTATION_TYPE(), SALES_ORDER_TYPE()))      ? 'buy'
219
           : (any { $self->is_type($_) } (REQUEST_QUOTATION_TYPE(), PURCHASE_ORDER_TYPE())) ? 'sell'
217 220
           : undef;
218 221
  return if !$rate;
219 222

  
......
303 306

  
304 307
sub convert_to_reclamation {
305 308
  my ($self, %params) = @_;
306
  $params{destination_type} = $self->is_sales ? 'sales_reclamation'
307
                                              : 'purchase_reclamation';
309
  $params{destination_type} = $self->is_sales ? SALES_RECLAMATION_TYPE()
310
                                              : PURCHASE_RECLAMATION_TYPE();
308 311

  
309 312
  require SL::DB::Reclamation;
310 313
  my $reclamation = SL::DB::Reclamation->new_from($self, %params);
......
335 338
  my $destination_type  = delete $params{destination_type};
336 339

  
337 340
  my @from_tos = (
338
    { from => 'sales_quotation',   to => 'sales_order',       abbr => 'sqso' },
339
    { from => 'request_quotation', to => 'purchase_order',    abbr => 'rqpo' },
340
    { from => 'sales_quotation',   to => 'sales_quotation',   abbr => 'sqsq' },
341
    { from => 'sales_order',       to => 'sales_order',       abbr => 'soso' },
342
    { from => 'request_quotation', to => 'request_quotation', abbr => 'rqrq' },
343
    { from => 'purchase_order',    to => 'purchase_order',    abbr => 'popo' },
344
    { from => 'sales_order',       to => 'purchase_order',    abbr => 'sopo' },
345
    { from => 'purchase_order',    to => 'sales_order',       abbr => 'poso' },
346
    { from => 'sales_order',       to => 'sales_quotation',   abbr => 'sosq' },
347
    { from => 'purchase_order',    to => 'request_quotation', abbr => 'porq' },
348
    { from => 'request_quotation', to => 'sales_quotation',   abbr => 'rqsq' },
349
    { from => 'request_quotation', to => 'sales_order',       abbr => 'rqso' },
350
    { from => 'sales_quotation',   to => 'request_quotation', abbr => 'sqrq' },
351
    { from => 'sales_order',       to => 'request_quotation', abbr => 'sorq' },
352
    { from => 'sales_reclamation', to => 'sales_order',       abbr => 'srso' },
353
    { from => 'purchase_reclamation', to => 'purchase_order', abbr => 'prpo' },
341
    { from => SALES_QUOTATION_TYPE(),      to => SALES_ORDER_TYPE(),       abbr => 'sqso' },
342
    { from => REQUEST_QUOTATION_TYPE(),    to => PURCHASE_ORDER_TYPE(),    abbr => 'rqpo' },
343
    { from => SALES_QUOTATION_TYPE(),      to => SALES_QUOTATION_TYPE(),   abbr => 'sqsq' },
344
    { from => SALES_ORDER_TYPE(),          to => SALES_ORDER_TYPE(),       abbr => 'soso' },
345
    { from => REQUEST_QUOTATION_TYPE(),    to => REQUEST_QUOTATION_TYPE(), abbr => 'rqrq' },
346
    { from => PURCHASE_ORDER_TYPE(),       to => PURCHASE_ORDER_TYPE(),    abbr => 'popo' },
347
    { from => SALES_ORDER_TYPE(),          to => PURCHASE_ORDER_TYPE(),    abbr => 'sopo' },
348
    { from => PURCHASE_ORDER_TYPE(),       to => SALES_ORDER_TYPE(),       abbr => 'poso' },
349
    { from => SALES_ORDER_TYPE(),          to => SALES_QUOTATION_TYPE(),   abbr => 'sosq' },
350
    { from => PURCHASE_ORDER_TYPE(),       to => REQUEST_QUOTATION_TYPE(), abbr => 'porq' },
351
    { from => REQUEST_QUOTATION_TYPE(),    to => SALES_QUOTATION_TYPE(),   abbr => 'rqsq' },
352
    { from => REQUEST_QUOTATION_TYPE(),    to => SALES_ORDER_TYPE(),       abbr => 'rqso' },
353
    { from => SALES_QUOTATION_TYPE(),      to => REQUEST_QUOTATION_TYPE(), abbr => 'sqrq' },
354
    { from => SALES_ORDER_TYPE(),          to => REQUEST_QUOTATION_TYPE(), abbr => 'sorq' },
355
    { from => SALES_RECLAMATION_TYPE(),    to => SALES_ORDER_TYPE(),       abbr => 'srso' },
356
    { from => PURCHASE_RECLAMATION_TYPE(), to => PURCHASE_ORDER_TYPE(),    abbr => 'prpo' },
354 357
  );
355 358
  my $from_to = (grep { $_->{from} eq $source->type && $_->{to} eq $destination_type} @from_tos)[0];
356 359
  croak("Cannot convert from '" . $source->type . "' to '" . $destination_type . "'") if !$from_to;
......
571 574
  push @items, @{$_->items_sorted} for @$sources;
572 575
  # make order from first source and all items
573 576
  my $order = $class->new_from($sources->[0],
574
                               destination_type => 'sales_order',
577
                               destination_type => SALES_ORDER_TYPE(),
575 578
                               attributes       => \%attributes,
576 579
                               items            => \@items,
577 580
                               %params);
......
585 588
  return if !$self->type;
586 589

  
587 590
  my %number_method = (
588
    sales_order       => 'ordnumber',
589
    sales_quotation   => 'quonumber',
590
    purchase_order    => 'ordnumber',
591
    request_quotation => 'quonumber',
591
    SALES_ORDER_TYPE()       => 'ordnumber',
592
    SALES_QUOTATION_TYPE()   => 'quonumber',
593
    PURCHASE_ORDER_TYPE()    => 'ordnumber',
594
    REQUEST_QUOTATION_TYPE() => 'quonumber',
592 595
  );
593 596

  
594 597
  return $self->${ \ $number_method{$self->type} }(@_);
SL/DB/Reclamation.pm
8 8
use List::Util qw(max sum0);
9 9
use List::MoreUtils qw(any);
10 10

  
11
use SL::DB::DeliveryOrder::TypeData qw(:types);
12
use SL::DB::Reclamation::TypeData qw(:types);
11 13
use SL::DB::MetaSetup::Reclamation;
12 14
use SL::DB::Manager::Reclamation;
13 15
use SL::DB::Helper::Attr;
......
107 109
sub type {
108 110
  my ($self) = @_;
109 111

  
110
  return 'sales_reclamation'    if $self->customer_id;
111
  return 'purchase_reclamation' if $self->vendor_id;
112
  return SALES_RECLAMATION_TYPE()    if $self->customer_id;
113
  return PURCHASE_RECLAMATION_TYPE() if $self->vendor_id;
112 114

  
113 115
  return;
114 116
}
......
127 129
sub displayable_type {
128 130
  my $type = shift->type;
129 131

  
130
  return $::locale->text('Sales Reclamation')    if $type eq 'sales_reclamation';
131
  return $::locale->text('Purchase Reclamation') if $type eq 'purchase_reclamation';
132
  return $::locale->text('Sales Reclamation')    if $type eq SALES_RECLAMATION_TYPE();
133
  return $::locale->text('Purchase Reclamation') if $type eq PURCHASE_RECLAMATION_TYPE();
132 134

  
133 135
  die 'invalid type';
134 136
}
......
147 149

  
148 150
  return 1 if $self->currency_id == $::instance_conf->get_currency_id;
149 151

  
150
  my $rate = (any { $self->is_type($_) } qw(sales_reclamation))    ? 'buy'
151
           : (any { $self->is_type($_) } qw(purchase_reclamation)) ? 'sell'
152
  my $rate = (any { $self->is_type($_) } (SALES_RECLAMATION_TYPE()))    ? 'buy'
153
           : (any { $self->is_type($_) } (PURCHASE_RECLAMATION_TYPE())) ? 'sell'
152 154
           : undef;
153 155
  return if !$rate;
154 156

  
......
201 203
  my ($self, %params) = @_;
202 204

  
203 205
  my $order;
204
  $params{destination_type} = $self->is_sales ? 'sales_order'
205
                                              : 'purchase_order';
206
  $params{destination_type} = $self->is_sales ? SALES_ORDER_TYPE()
207
                                              : PURCHASE_ORDER_TYPE();
206 208
  if (!$self->db->with_transaction(sub {
207 209
    require SL::DB::Order;
208 210
    $order = SL::DB::Order->new_from($self, %params);
......
253 255

  
254 256
  my @from_tos = (
255 257
    #Reclamation
256
    { from => 'sales_reclamation',       to => 'sales_reclamation',    abbr => 'srsr', },
257
    { from => 'purchase_reclamation',    to => 'purchase_reclamation', abbr => 'prpr', },
258
    { from => 'sales_reclamation',       to => 'purchase_reclamation', abbr => 'srpr', },
259
    { from => 'purchase_reclamation',    to => 'sales_reclamation',    abbr => 'prsr', },
258
    { from => SALES_RECLAMATION_TYPE(),       to => SALES_RECLAMATION_TYPE(),    abbr => 'srsr', },
259
    { from => PURCHASE_RECLAMATION_TYPE(),    to => PURCHASE_RECLAMATION_TYPE(), abbr => 'prpr', },
260
    { from => SALES_RECLAMATION_TYPE(),       to => PURCHASE_RECLAMATION_TYPE(), abbr => 'srpr', },
261
    { from => PURCHASE_RECLAMATION_TYPE(),    to => SALES_RECLAMATION_TYPE(),    abbr => 'prsr', },
260 262
    #Order
261
    { from => 'sales_order',             to => 'sales_reclamation',    abbr => 'sosr', },
262
    { from => 'purchase_order',          to => 'purchase_reclamation', abbr => 'popr', },
263
    { from => SALES_ORDER_TYPE(),             to => SALES_RECLAMATION_TYPE(),    abbr => 'sosr', },
264
    { from => PURCHASE_ORDER_TYPE(),          to => PURCHASE_RECLAMATION_TYPE(), abbr => 'popr', },
263 265
    #Delivery Order
264
    { from => 'sales_delivery_order',    to => 'sales_reclamation',    abbr => 'sdsr', },
265
    { from => 'purchase_delivery_order', to => 'purchase_reclamation', abbr => 'pdpr', },
266
    { from => SALES_DELIVERY_ORDER_TYPE(),    to => SALES_RECLAMATION_TYPE(),    abbr => 'sdsr', },
267
    { from => PURCHASE_DELIVERY_ORDER_TYPE(), to => PURCHASE_RECLAMATION_TYPE(), abbr => 'pdpr', },
266 268
    #Invoice
267
    { from => 'invoice',                 to => 'sales_reclamation',    abbr => 'sisr', },
268
    { from => 'purchase_invoice',        to => 'purchase_reclamation', abbr => 'pipr', },
269
    { from => 'invoice',                 to => SALES_RECLAMATION_TYPE(),    abbr => 'sisr', },
270
    { from => 'purchase_invoice',        to => PURCHASE_RECLAMATION_TYPE(), abbr => 'pipr', },
269 271
  );
270 272
  my $from_to = (grep { $_->{from} eq $source->type && $_->{to} eq $destination_type} @from_tos)[0];
271 273
  if (!$from_to) {
SL/Model/Record.pm
14 14
use SL::DB::Status;
15 15
use SL::DB::ValidityToken;
16 16
use SL::DB::Helper::TypeDataProxy;
17
use SL::DB::Order::TypeData qw(:types);
18
use SL::DB::DeliveryOrder::TypeData qw(:types);
19
use SL::DB::Reclamation::TypeData qw(:types);
17 20

  
18 21
use SL::Util qw(trim);
19 22
use SL::Locale::String qw(t8);
......
63 66

  
64 67
  my %subtype_to_type = (
65 68
    # Order
66
    "request_quotation" => "SL::DB::Order",
67
    "purchase_order"    => "SL::DB::Order",
68
    "sales_quotation"   => "SL::DB::Order",
69
    "sales_order"       => "SL::DB::Order",
69
    REQUEST_QUOTATION_TYPE() => "SL::DB::Order",
70
    PURCHASE_ORDER_TYPE()    => "SL::DB::Order",
71
    SALES_QUOTATION_TYPE()   => "SL::DB::Order",
72
    SALES_ORDER_TYPE()       => "SL::DB::Order",
70 73
    # DeliveryOrder
71
    "sales_delivery_order"    => "SL::DB::DeliveryOrder",
72
    "purchase_delivery_order" => "SL::DB::DeliveryOrder",
73
    "rma_delivery_order"      => "SL::DB::DeliveryOrder",
74
    "supplier_delivery_order" => "SL::DB::DeliveryOrder",
74
    SALES_DELIVERY_ORDER_TYPE()    => "SL::DB::DeliveryOrder",
75
    PURCHASE_DELIVERY_ORDER_TYPE() => "SL::DB::DeliveryOrder",
76
    RMA_DELIVERY_ORDER_TYPE()      => "SL::DB::DeliveryOrder",
77
    SUPPLIER_DELIVERY_ORDER_TYPE() => "SL::DB::DeliveryOrder",
75 78
    # Reclamation
76
    "sales_reclamation"    => "SL::DB::Reclamation",
77
    "purchase_reclamation" => "SL::DB::Reclamation",
79
    SALES_RECLAMATION_TYPE()    => "SL::DB::Reclamation",
80
    PURCHASE_RECLAMATION_TYPE() => "SL::DB::Reclamation",
78 81
  );
79 82
  my $target_type = $subtype_to_type{$target_subtype};
80 83
  unless ($target_type) {
......
102 105

  
103 106
  my %subtype_to_type = (
104 107
    # Order
105
    "sales_order" => "SL::DB::Order",
108
    SALES_ORDER_TYPE() => "SL::DB::Order",
106 109
  );
107 110
  my $target_type = $subtype_to_type{$target_subtype};
108 111
  unless ($target_type) {

Auch abrufbar als: Unified diff