Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 166e72f1

Von Tamino Steinert vor mehr als 2 Jahren hinzugefügt

  • ID 166e72f1115dec2ec1c965cc09164dcbbf283a61
  • Vorgänger e4c53ed5
  • Nachfolger 4578cdff

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
645 645
    title creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
646 646
    max_dunning_level dunning_amount dunning_description
647 647
    taxaccounts cursor_fokus
648
    convert_from_do_ids convert_from_oe_ids convert_from_ar_ids useasnew
648
    convert_from_reclamations_ids convert_from_do_ids convert_from_oe_ids convert_from_ar_ids useasnew
649 649
    invoice_id
650 650
    show_details
651 651
  ), @custom_hiddens,
......
1412 1412
  $main::lxdebug->leave_sub();
1413 1413
}
1414 1414

  
1415
sub credit_note_from_reclamation {
1416
  $main::lxdebug->enter_sub();
1417

  
1418
  $main::auth->assert('invoice_edit');
1419

  
1420
  my $form     = $main::form;
1421
  my %myconfig = %main::myconfig;
1422
  my $locale   = $main::locale;
1423

  
1424

  
1425
  my $from_id = delete $form->{from_id};
1426
  my $reclamation = SL::DB::Reclamation->new(id => $from_id)->load;
1427

  
1428
  $reclamation->flatten_to_form($form, format_amounts => 1);
1429

  
1430
  # set new persistent ids for credit note and link previous reclamation id
1431
  $form->{convert_from_reclamations_ids} = $form->{id};
1432
  $form->{id}     = '';
1433

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

  
1436
  $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1437
  $form->{duedate} =
1438
    $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1439

  
1440
  $form->{title}  = $locale->text('Add Credit Note');
1441
  $form->{script} = 'is.pl';
1442

  
1443
  # bo creates the id, reset it
1444
  map { delete $form->{$_} }
1445
    qw(id invnumber subject message cc bcc printed emailed queued);
1446
  $form->{ $form->{vc} } =~ s/--.*//g;
1447

  
1448
  $form->{type} = "credit_note";
1449

  
1450
  my $currency = $form->{currency};
1451
  &invoice_links;
1452
  $form->{currency}     = $currency;
1453
  $form->{forex}        = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{invdate}, 'buy');
1454
  $form->{exchangerate} = $form->{forex} || '';
1455

  
1456
  $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1457

  
1458
  &prepare_invoice;
1459

  
1460
  &display_form;
1461

  
1462
  $main::lxdebug->leave_sub();
1463
}
1464

  
1415 1465
sub display_form {
1416 1466
  $::lxdebug->enter_sub;
1417 1467

  

Auch abrufbar als: Unified diff