Revision 5bae603d
Von Tamino Steinert vor etwa 1 Jahr hinzugefügt
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 |
|
Auch abrufbar als: Unified diff
TypeData: nutzte Konstanten anstatt String für Typen