Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6efd78c7

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID 6efd78c76b85aae8d7aba456d857927bc9a7aea0
  • Vorgänger bcdd2d47
  • Nachfolger d031045e

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
925 925
sub action_customer_vendor_changed {
926 926
  my ($self) = @_;
927 927

  
928
  setup_order_from_cv($self->order);
928
  $self->order(SL::Model::Record->update_after_customer_vendor_change($self->order));
929

  
929 930
  $self->recalc();
930 931

  
931 932
  my $cv_method = $self->cv;
......
1848 1849
  my $cv_id_method = $self->cv . '_id';
1849 1850
  if (!$::form->{id} && $::form->{$cv_id_method}) {
1850 1851
    $order->$cv_id_method($::form->{$cv_id_method});
1851
    setup_order_from_cv($order);
1852
    $order = SL::Model::Record->update_after_customer_vendor_change($order);
1852 1853
  }
1853 1854

  
1854 1855
  my $form_orderitems                  = delete $::form->{order}->{orderitems};
......
1960 1961
  return $item;
1961 1962
}
1962 1963

  
1963
sub setup_order_from_cv {
1964
  my ($order) = @_;
1965

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

  
1968
  $order->intnotes($order->customervendor->notes);
1969

  
1970
  return if !$order->is_sales;
1971

  
1972
  $order->salesman_id($order->customer->salesman_id || SL::DB::Manager::Employee->current->id);
1973
  $order->taxincluded(defined($order->customer->taxincluded_checked)
1974
                      ? $order->customer->taxincluded_checked
1975
                      : $::myconfig{taxincluded_checked});
1976

  
1977
  my $address = $order->customer->default_billing_address;;
1978
  $order->billing_address_id($address ? $address->id : undef);
1979
}
1980

  
1981 1964
# setup custom shipto from form
1982 1965
#
1983 1966
# 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
......
1465 1468
                   );
1466 1469
  }
1467 1470

  
1471
  my $cv_id_method = $self->cv . '_id';
1472
  if (!$::form->{id} && $::form->{$cv_id_method}) {
1473
    $reclamation->$cv_id_method($::form->{$cv_id_method});
1474
    $reclamation = SL::Model::Record->update_after_customer_vendor_change($reclamation);
1475
  }
1476

  
1468 1477
  my $form_reclamation_items = delete $::form->{reclamation}->{reclamation_items};
1469 1478

  
1470 1479
  $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