Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision de5824b8

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID de5824b8a7da56bbb94793eccd888fcc81ff3f86
  • Vorgänger 8c55046d
  • Nachfolger 7d7fa7a2

Model::Record: Anpassen nach Kunden/Lieferanten-Änderung

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
565 565
sub action_customer_vendor_changed {
566 566
  my ($self) = @_;
567 567

  
568
  setup_order_from_cv($self->order);
568
  $self->order(SL::Model::Record->update_after_customer_vendor_change($self->order));
569 569

  
570 570
  my $cv_method = $self->cv;
571 571

  
......
1375 1375
  my $cv_id_method = $self->cv . '_id';
1376 1376
  if (!$::form->{id} && $::form->{$cv_id_method}) {
1377 1377
    $order->$cv_id_method($::form->{$cv_id_method});
1378
    setup_order_from_cv($order);
1378
    $order = SL::Model::Record->update_after_customer_vendor_change($order);
1379 1379
  }
1380 1380

  
1381 1381
  my $form_orderitems                  = delete $::form->{order}->{orderitems};
......
1530 1530
  return $item;
1531 1531
}
1532 1532

  
1533
sub setup_order_from_cv {
1534
  my ($order) = @_;
1535

  
1536
  $order->$_($order->customervendor->$_) for (qw(taxzone_id payment_id delivery_term_id currency_id));
1537

  
1538
  $order->intnotes($order->customervendor->notes);
1539

  
1540
  if ($order->is_sales) {
1541
    $order->salesman_id($order->customer->salesman_id || SL::DB::Manager::Employee->current->id);
1542
    $order->taxincluded(defined($order->customer->taxincluded_checked)
1543
                        ? $order->customer->taxincluded_checked
1544
                        : $::myconfig{taxincluded_checked});
1545
  }
1546

  
1547
}
1548

  
1549 1533
# setup custom shipto from form
1550 1534
#
1551 1535
# The dialog returns form variables starting with 'shipto' and cvars starting
SL/Controller/Order.pm
937 937
sub action_customer_vendor_changed {
938 938
  my ($self) = @_;
939 939

  
940
  setup_order_from_cv($self->order);
940
  $self->order(SL::Model::Record->update_after_customer_vendor_change($self->order));
941

  
941 942
  $self->recalc();
942 943

  
943 944
  my $cv_method = $self->cv;
......
1860 1861
  my $cv_id_method = $self->cv . '_id';
1861 1862
  if (!$::form->{id} && $::form->{$cv_id_method}) {
1862 1863
    $order->$cv_id_method($::form->{$cv_id_method});
1863
    setup_order_from_cv($order);
1864
    $order = SL::Model::Record->update_after_customer_vendor_change($order);
1864 1865
  }
1865 1866

  
1866 1867
  my $form_orderitems                  = delete $::form->{order}->{orderitems};
......
1972 1973
  return $item;
1973 1974
}
1974 1975

  
1975
sub setup_order_from_cv {
1976
  my ($order) = @_;
1977

  
1978
  $order->$_($order->customervendor->$_) for (qw(taxzone_id payment_id delivery_term_id currency_id language_id));
1979

  
1980
  $order->intnotes($order->customervendor->notes);
1981

  
1982
  return if !$order->is_sales;
1983

  
1984
  $order->salesman_id($order->customer->salesman_id || SL::DB::Manager::Employee->current->id);
1985
  $order->taxincluded(defined($order->customer->taxincluded_checked)
1986
                      ? $order->customer->taxincluded_checked
1987
                      : $::myconfig{taxincluded_checked});
1988

  
1989
  my $address = $order->customer->default_billing_address;;
1990
  $order->billing_address_id($address ? $address->id : undef);
1991
}
1992

  
1993 1976
# setup custom shipto from form
1994 1977
#
1995 1978
# The dialog returns form variables starting with 'shipto' and cvars starting
SL/Controller/Reclamation.pm
666 666
sub action_customer_vendor_changed {
667 667
  my ($self) = @_;
668 668

  
669
  $self->reclamation(
670
    SL::Model::Record->update_after_customer_vendor_change($self->reclamation));
671

  
669 672
  $self->recalc();
670 673

  
671 674
  if ( $self->reclamation->customervendor->contacts
......
1471 1474
                   );
1472 1475
  }
1473 1476

  
1477
  my $cv_id_method = $self->cv . '_id';
1478
  if (!$::form->{id} && $::form->{$cv_id_method}) {
1479
    $reclamation->$cv_id_method($::form->{$cv_id_method});
1480
    $reclamation = SL::Model::Record->update_after_customer_vendor_change($reclamation);
1481
  }
1482

  
1474 1483
  my $form_reclamation_items = delete $::form->{reclamation}->{reclamation_items};
1475 1484

  
1476 1485
  $reclamation->assign_attributes(%{$::form->{reclamation}});
SL/Model/Record.pm
32 32
  return $new_record;
33 33
}
34 34

  
35
sub update_after_customer_vendor_change {
36
  my ($class, $record) = @_;
37
  my $new_customervendor = $record->customervendor;
38

  
39
  $record->$_($new_customervendor->$_) for (qw(
40
    taxzone_id payment_id delivery_term_id currency_id language_id
41
    ));
42

  
43
  $record->intnotes($new_customervendor->notes);
44

  
45
  return if !$record->is_sales;
46
  if ($record->is_sales) {
47
    my $new_customer = $new_customervendor;
48
    $record->salesman_id($new_customer->salesman_id
49
      || SL::DB::Manager::Employee->current->id);
50
    $record->taxincluded(defined($new_customer->taxincluded_checked)
51
      ? $new_customer->taxincluded_checked
52
      : $::myconfig{taxincluded_checked});
53
    if ($record->type_data->features('price_tax')) {
54
      my $address = $new_customer->default_billing_address;;
55
      $record->billing_address_id($address ? $address->id : undef);
56
    }
57
  }
58

  
59
  return $record;
60
}
61

  
35 62
sub new_from_workflow {
36 63
  my ($class, $source_object, $target_type, $target_subtype, %flags) = @_;
37 64

  
......
307 334

  
308 335
Returns the record object.
309 336

  
337
=item C<update_after_customer_vendor_change>
338

  
339
Updates a record_object corresponding to customer/vendor and type_data.
340
Sets taxzone_id, payment_id, delivery_term_id, currency_id, language_id and
341
intnotes to customer/vendor. For sales records salesman and taxincluded is set.
342
Also for sales record with the feature 'price_tax' the billing address is updated.
343

  
344
Returns the record object.
345

  
310 346
=item C<new_from_workflow>
311 347

  
312 348
Expects source_object, target_type, target_subtype and can have flags.
......
416 452

  
417 453
=item *
418 454

  
419
Handling of changed customer/vendor
420

  
421
=item *
422

  
423 455
sellprice changed handling
424 456

  
425 457
=back

Auch abrufbar als: Unified diff