Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 632f0308

Von Sven Schöling vor fast 3 Jahren hinzugefügt

  • ID 632f0308562656fd01b8bcf75839f2ce5490c03b
  • Vorgänger 711f432a
  • Nachfolger 9cec711d

DeliveryOrder: types im objekt richtig setzen

Unterschiede anzeigen:

SL/DB/DeliveryOrder.pm
17 17
use SL::DB::Part;
18 18
use SL::DB::Unit;
19 19

  
20
use SL::Controller::DeliveryOrder::TypeData;
21

  
20 22
use SL::Helper::Number qw(_format_total _round_total);
21 23

  
22 24
use List::Util qw(first);
......
77 79
}
78 80

  
79 81
sub type {
80
  return shift->customer_id ? 'sales_delivery_order' : 'purchase_delivery_order';
82
  goto &order_type;
81 83
}
82 84

  
83 85
sub displayable_type {
......
150 152
    $args{shipto_id} = $source->shipto_id;
151 153
  }
152 154

  
155
  # infer type from legacy fields if not given
156
  $params{order_type} //= $source->customer_id ? 'sales_delivery_order'
157
                        : $source->vendor_id   ? 'purchase_delivery_order'
158
                        : undef;
159

  
160
  # overwrite legacy is_sales from type_data
161
  $args{is_sales} = SL::Controller::DeliveryOrder::TypeData::get3($params{order_type}, "properties", "is_customer");
162

  
153 163
  my $delivery_order = $class->new(%args);
154 164
  $delivery_order->assign_attributes(%{ $params{attributes} }) if $params{attributes};
155 165
  my $items          = delete($params{items}) || $source->items_sorted;
......
291 301
  } else {
292 302
    my %args = (
293 303
      is_sales    => 1,
304
      order_type  => 'sales_delivery_order',
294 305
      delivered   => 0,
295 306
      customer_id => $sources->[0]->customer_id,
296 307
      taxzone_id  => $sources->[0]->customer->taxzone_id,
......
306 317
  return $delivery_order;
307 318
}
308 319

  
320
# legacy for compatibility
321
# use type_data cusomtervendor and transfer direction instead
322
sub is_sales {
323
  SL::Controller::DeliveryOrder::TypeData::get3($_[0]->order_type, "properties", "is_customer");
324
}
325

  
309 326
sub customervendor {
310
  $_[0]->is_sales ? $_[0]->customer : $_[0]->vendor;
327
  SL::Controller::DeliveryOrder::TypeData::get3($_[0]->order_type, "properties", "is_customer") ? $_[0]->customer : $_[0]->vendor;
311 328
}
312 329

  
313 330
sub convert_to_invoice {

Auch abrufbar als: Unified diff