Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e9013716

Von Tamino Steinert vor mehr als 2 Jahren hinzugefügt

  • ID e9013716fffd65de9d3df3ae7608cbd6c5c99de8
  • Vorgänger 44212e4b
  • Nachfolger b2670cff

Workflow: sales_reclamation → credit_note

Unterschiede anzeigen:

SL/Controller/Reclamation.pm
70 70
                          workflow_save_and_sales_or_purchase_reclamation
71 71
                          save_and_order
72 72
                          save_and_delivery_order
73
                          save_and_credit_note
73 74
                       )]);
74 75

  
75 76
__PACKAGE__->run_before('get_unalterable_data',
......
79 80
                          workflow_save_and_sales_or_purchase_reclamation
80 81
                          save_and_order
81 82
                          save_and_delivery_order
83
                          save_and_credit_note
82 84
                        )]);
83 85

  
84 86
#
......
602 604
  );
603 605
}
604 606

  
607
# save the reclamation and redirect to the frontend subroutine for a new
608
# credit_note
609
sub action_save_and_credit_note {
610
  my ($self) = @_;
611

  
612
  # always save
613
  $self->save_with_render_error();
614

  
615
  if (!$self->reclamation->is_sales) {
616
    $self->js->flash('error', t8("Can't convert Purchase Reclamation to Credit Note"));
617
    return $self->js->render();
618
  }
619

  
620
  $self->save_and_redirect_to(
621
    controller => 'is.pl',
622
    action     => 'credit_note_from_reclamation',
623
    from_id    => $self->reclamation->id,
624
  );
625
}
626

  
605 627
# set form elements in respect to a changed customer or vendor
606 628
#
607 629
# This action is called on an change of the customer/vendor picker.
......
2233 2255
            $::instance_conf->get_reclamation_warn_no_reqdate,
2234 2256
          ],
2235 2257
        ],
2258
        action => [
2259
          t8('Save and Credit Note'),
2260
          call      => [
2261
            'kivi.Reclamation.save', 'save_and_credit_note',
2262
            $::instance_conf->get_reclamation_warn_duplicate_parts,
2263
            $::instance_conf->get_reclamation_warn_no_reqdate,
2264
          ],
2265
          only_if   => (any { $self->type eq $_ } (sales_reclamation_type())),
2266
        ],
2236 2267
      ], # end of combobox "Workflow"
2237 2268

  
2238 2269
      combobox => [
SL/DB/Helper/FlattenToForm.pm
74 74
  my $items_name = ref($self) eq 'SL::DB::Order'         ? 'orderitems'
75 75
                 : ref($self) eq 'SL::DB::DeliveryOrder' ? 'delivery_order_items'
76 76
                 : ref($self) eq 'SL::DB::Invoice'       ? 'invoice'
77
                 : ref($self) eq 'SL::DB::Reclamation'   ? 'reclamation_items'
77 78
                 : '';
78 79

  
79 80
  my %cvar_validity = _determine_cvar_validity($self, $vc);
SL/IS.pm
990 990
                                  dbh          => $dbh);
991 991
    }
992 992
    # link previous items with invoice items
993
    foreach (qw(delivery_order_items orderitems invoice)) {
993
    foreach (qw(delivery_order_items orderitems invoice reclamation_items)) {
994 994
      if (!$form->{useasnew} && $form->{"converted_from_${_}_id_$i"}) {
995 995
        RecordLinks->create_links('dbh'        => $dbh,
996 996
                                  'mode'       => 'ids',
......
1529 1529

  
1530 1530
  Common::webdav_folder($form);
1531 1531

  
1532
  if ($form->{convert_from_ar_ids}) {
1533
    RecordLinks->create_links('dbh'        => $dbh,
1534
                              'mode'       => 'ids',
1535
                              'from_table' => 'ar',
1536
                              'from_ids'   => $form->{convert_from_ar_ids},
1537
                              'to_table'   => 'ar',
1538
                              'to_id'      => $form->{id},
1539
    );
1540
    delete $form->{convert_from_ar_ids};
1541
  }
1542

  
1543 1532
  # Link this record to the records it was created from.
1544
  if ($form->{convert_from_oe_ids}) {
1545
    RecordLinks->create_links('dbh'        => $dbh,
1546
                              'mode'       => 'ids',
1547
                              'from_table' => 'oe',
1548
                              'from_ids'   => $form->{convert_from_oe_ids},
1549
                              'to_table'   => 'ar',
1550
                              'to_id'      => $form->{id},
1533
  foreach (qw(oe ar reclamations)) {
1534
    if ($form->{"convert_from_${_}_ids"}) {
1535
      RecordLinks->create_links('dbh'        => $dbh,
1536
                                'mode'       => 'ids',
1537
                                'from_table' => $_,
1538
                                'from_ids'   => $form->{"convert_from_${_}_ids"},
1539
                                'to_table'   => 'ar',
1540
                                'to_id'      => $form->{id},
1551 1541
      );
1552
    delete $form->{convert_from_oe_ids};
1542
      delete $form->{"convert_from_${_}_ids"};
1543
    }
1553 1544
  }
1554 1545

  
1555 1546
  my @convert_from_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{convert_from_do_ids};
bin/mozilla/io.pl
257 257
    my $record_item = $record->id && $record->items ? $record->items->[$i-1] : _make_record_item($i);
258 258

  
259 259
    # undo formatting
260
    $main::lxdebug->dump(0, "TST: before parse_amount", $form->{"sellprice_$i"});
260 261
    map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
261 262
      qw(qty discount sellprice lastcost price_new price_old)
262 263
        unless ($form->{simple_save});
264
    $main::lxdebug->dump(0, "TST: after parse_amount", $form->{"sellprice_$i"});
263 265

  
264 266
    if ($form->{"prices_$i"} && ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"})) {
265 267
      $form->{"sellprice_$i"} = $form->{"price_new_$i"};
......
474 476
      push @hidden_vars, qw(invoice_id converted_from_orderitems_id converted_from_delivery_order_items_id converted_from_invoice_id);
475 477
    }
476 478
    if ($::form->{type} =~ /credit_note/) {
477
      push @hidden_vars, qw(invoice_id converted_from_invoice_id);
479
      push @hidden_vars, qw(invoice_id converted_from_invoice_id converted_from_reclamation_items_id);
478 480
    }
479 481
   if ($is_delivery_order) {
480 482
      map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount lastcost);
......
831 833
                stock_out stock_in has_sernumber reqdate orderitems_id
832 834
                active_price_source active_discount_source delivery_order_items_id
833 835
                invoice_id converted_from_orderitems_id
834
                converted_from_delivery_order_items_id converted_from_invoice_id);
836
                converted_from_delivery_order_items_id converted_from_invoice_id
837
                converted_from_reclamation_items_id);
835 838

  
836 839
  my $ic_cvar_configs = CVar->get_configs(module => 'IC');
837 840
  push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
bin/mozilla/is.pl
649 649
    title creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
650 650
    max_dunning_level dunning_amount dunning_description
651 651
    taxaccounts cursor_fokus
652
    convert_from_do_ids convert_from_oe_ids convert_from_ar_ids useasnew
652
    convert_from_reclamations_ids convert_from_do_ids convert_from_oe_ids convert_from_ar_ids useasnew
653 653
    invoice_id
654 654
    show_details
655 655
  ), @custom_hiddens,
......
1434 1434
  $main::lxdebug->leave_sub();
1435 1435
}
1436 1436

  
1437
sub credit_note_from_reclamation {
1438
  $main::lxdebug->enter_sub();
1439

  
1440
  $main::auth->assert('invoice_edit');
1441

  
1442
  my $form     = $main::form;
1443
  my %myconfig = %main::myconfig;
1444
  my $locale   = $main::locale;
1445

  
1446

  
1447
  my $from_id = delete $form->{from_id};
1448
  my $reclamation = SL::DB::Reclamation->new(id => $from_id)->load;
1449

  
1450
  $reclamation->flatten_to_form($form, format_amounts => 1);
1451

  
1452
  # set new persistent ids for credit note and link previous reclamation id
1453
  $form->{convert_from_reclamations_ids} = $form->{id};
1454
  $form->{id}     = '';
1455

  
1456
  $form->{"converted_from_reclamation_items_id_$_"} = delete $form->{"reclamation_items_id_$_"} for 1 .. $form->{"rowcount"};
1457

  
1458
  $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1459
  $form->{duedate} =
1460
    $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1461

  
1462
  $form->{title}  = $locale->text('Add Credit Note');
1463
  $form->{script} = 'is.pl';
1464

  
1465
  # bo creates the id, reset it
1466
  map { delete $form->{$_} }
1467
    qw(id invnumber subject message cc bcc printed emailed queued);
1468
  $form->{ $form->{vc} } =~ s/--.*//g;
1469

  
1470
  $form->{type} = "credit_note";
1471

  
1472
  my $currency = $form->{currency};
1473
  &invoice_links;
1474
  $form->{currency}     = $currency;
1475
  $form->{forex}        = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{invdate}, 'buy');
1476
  $form->{exchangerate} = $form->{forex} || '';
1477

  
1478
  $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1479

  
1480
  &prepare_invoice;
1481

  
1482
  &display_form;
1483

  
1484
  $main::lxdebug->leave_sub();
1485
}
1486

  
1437 1487
sub display_form {
1438 1488
  $::lxdebug->enter_sub;
1439 1489

  

Auch abrufbar als: Unified diff