Revision 569d24f3
Von Tamino Steinert vor etwa 1 Jahr hinzugefügt
SL/Controller/CsvImport/DeliveryOrder.pm | ||
---|---|---|
218 | 218 |
{ name => 'language', description => $::locale->text('Language (name)') }, |
219 | 219 |
{ name => 'language_id', description => $::locale->text('Language (database ID)') }, |
220 | 220 |
{ name => 'notes', description => $::locale->text('Notes') }, |
221 |
{ name => 'order_type', description => $::locale->text('Delivery Order Type') },
|
|
221 |
{ name => 'record_type', description => $::locale->text('Delivery Order Type') },
|
|
222 | 222 |
{ name => 'ordnumber', description => $::locale->text('Order Number') }, |
223 | 223 |
{ name => 'payment', description => $::locale->text('Payment terms (name)') }, |
224 | 224 |
{ name => 'payment_id', description => $::locale->text('Payment terms (database ID)') }, |
... | ... | |
664 | 664 |
parts_id => $item_obj->parts_id, |
665 | 665 |
warehouse_id => $object->warehouse_id, |
666 | 666 |
bin_id => $object->bin_id, |
667 |
trans_type_id => $trans_type_id,
|
|
667 |
PURCHASE_DELIVERY_ORDER_TYPE() => $trans_type_id,
|
|
668 | 668 |
qty => $qty, |
669 | 669 |
chargenumber => $object->chargenumber, |
670 | 670 |
employee_id => $order_obj->employee_id, |
... | ... | |
681 | 681 |
sub handle_type { |
682 | 682 |
my ($self, $entry) = @_; |
683 | 683 |
|
684 |
if (!exists $entry->{raw_data}->{order_type}) {
|
|
684 |
if (!exists $entry->{raw_data}->{record_type}) {
|
|
685 | 685 |
# if no type is present - set to sales delivery order or purchase delivery |
686 | 686 |
# order depending on is_sales or customer/vendor |
687 | 687 |
|
688 |
$entry->{object}->order_type(
|
|
688 |
$entry->{object}->record_type(
|
|
689 | 689 |
$entry->{object}->customer_id ? SALES_DELIVERY_ORDER_TYPE : |
690 | 690 |
$entry->{object}->vendor_id ? PURCHASE_DELIVERY_ORDER_TYPE : |
691 | 691 |
$entry->{raw_data}->{is_sales} ? SALES_DELIVERY_ORDER_TYPE : |
SL/DB/DeliveryOrder.pm | ||
---|---|---|
169 | 169 |
employee => SL::DB::Manager::Employee->current, |
170 | 170 |
closed => 0, |
171 | 171 |
delivered => 0, |
172 |
order_type => $params{destination_type},
|
|
172 |
record_type => $params{destination_type},
|
|
173 | 173 |
transdate => DateTime->today_local, |
174 | 174 |
); |
175 | 175 |
|
... | ... | |
238 | 238 |
} |
239 | 239 |
|
240 | 240 |
# infer type from legacy fields if not given |
241 |
$record_args{order_type} //= $source->customer_id ? SALES_DELIVERY_ORDER_TYPE()
|
|
242 |
: $source->vendor_id ? PURCHASE_DELIVERY_ORDER_TYPE() |
|
243 |
: $source->is_sales ? SALES_DELIVERY_ORDER_TYPE() |
|
244 |
: croak "need some way to set delivery order type from source"; |
|
241 |
$record_args{record_type} //= $source->customer_id ? SALES_DELIVERY_ORDER_TYPE()
|
|
242 |
: $source->vendor_id ? PURCHASE_DELIVERY_ORDER_TYPE()
|
|
243 |
: $source->is_sales ? SALES_DELIVERY_ORDER_TYPE()
|
|
244 |
: croak "need some way to set delivery order type from source";
|
|
245 | 245 |
|
246 | 246 |
my $delivery_order = $class->new(%record_args); |
247 | 247 |
$delivery_order->assign_attributes(%{ $params{attributes} }) if $params{attributes}; |
... | ... | |
372 | 372 |
|
373 | 373 |
} else { |
374 | 374 |
my %args = ( |
375 |
order_type => SALES_DELIVERY_ORDER_TYPE,
|
|
375 |
record_type => SALES_DELIVERY_ORDER_TYPE,
|
|
376 | 376 |
delivered => 0, |
377 | 377 |
customer_id => $sources->[0]->customer_id, |
378 | 378 |
taxzone_id => $sources->[0]->customer->taxzone_id, |
... | ... | |
391 | 391 |
# legacy for compatibility |
392 | 392 |
# use type_data cusomtervendor and transfer direction instead |
393 | 393 |
sub is_sales { |
394 |
if ($_[0]->order_type) {
|
|
395 |
return SL::DB::DeliveryOrder::TypeData::get3($_[0]->order_type, "properties", "is_customer");
|
|
394 |
if ($_[0]->record_type) {
|
|
395 |
return SL::DB::DeliveryOrder::TypeData::get3($_[0]->record_type, "properties", "is_customer");
|
|
396 | 396 |
} |
397 | 397 |
return $_[0]{is_sales}; |
398 | 398 |
} |
399 | 399 |
|
400 | 400 |
sub customervendor { |
401 |
SL::DB::DeliveryOrder::TypeData::get3($_[0]->order_type, "properties", "is_customer") ? $_[0]->customer : $_[0]->vendor;
|
|
401 |
SL::DB::DeliveryOrder::TypeData::get3($_[0]->record_type, "properties", "is_customer") ? $_[0]->customer : $_[0]->vendor;
|
|
402 | 402 |
} |
403 | 403 |
|
404 | 404 |
sub convert_to_invoice { |
SL/DB/Manager/DeliveryOrder.pm | ||
---|---|---|
30 | 30 |
my $type = lc(shift || ''); |
31 | 31 |
my $prefix = shift // ''; |
32 | 32 |
|
33 |
return "${prefix}order_type" => validate_type($type);
|
|
33 |
return "${prefix}record_type" => validate_type($type);
|
|
34 | 34 |
} |
35 | 35 |
|
36 | 36 |
sub _sort_spec { |
SL/Dev/Record.pm | ||
---|---|---|
174 | 174 |
die "illegal customer" unless ref($customer) eq 'SL::DB::Customer'; |
175 | 175 |
|
176 | 176 |
my $delivery_order = SL::DB::DeliveryOrder->new( |
177 |
order_type => SALES_DELIVERY_ORDER_TYPE,
|
|
177 |
record_type => SALES_DELIVERY_ORDER_TYPE,
|
|
178 | 178 |
'closed' => undef, |
179 | 179 |
customer_id => $customer->id, |
180 | 180 |
taxzone_id => $customer->taxzone_id, |
... | ... | |
202 | 202 |
die "illegal vendor" unless ref($vendor) eq 'SL::DB::Vendor'; |
203 | 203 |
|
204 | 204 |
my $delivery_order = SL::DB::DeliveryOrder->new( |
205 |
order_type => PURCHASE_DELIVERY_ORDER_TYPE,
|
|
205 |
record_type => PURCHASE_DELIVERY_ORDER_TYPE,
|
|
206 | 206 |
'closed' => undef, |
207 | 207 |
vendor_id => $vendor->id, |
208 | 208 |
taxzone_id => $vendor->taxzone_id, |
t/workflow/delivery_order_reclamation.t | ||
---|---|---|
241 | 241 |
# clean different values |
242 | 242 |
foreach (qw( |
243 | 243 |
customer_id vendor_id |
244 |
id order_type
|
|
244 |
id record_type
|
|
245 | 245 |
donumber salesman_id |
246 | 246 |
transaction_description |
247 | 247 |
itime mtime |
... | ... | |
279 | 279 |
## converted should be nearly the same |
280 | 280 |
my @different_record_values = qw( |
281 | 281 |
id employee_id itime mtime reqdate |
282 |
order_type ordnumber oreqnumber
|
|
282 |
ordnumber oreqnumber |
|
283 | 283 |
amount exchangerate netamount |
284 |
order_type record_type
|
|
284 |
record_type |
|
285 | 285 |
cp_id contact_id |
286 | 286 |
cusordnumber cv_record_number |
287 | 287 |
donumber record_number |
Auch abrufbar als: Unified diff
DB::DeliveryOrder: Nutze record_type