Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision fe3e0ed3

Von Tamino Steinert vor fast 2 Jahren hinzugefügt

  • ID fe3e0ed3b2b549abc16fb207c5668530bb2c8b46
  • Vorgänger 8522a85e
  • Nachfolger 5398bba1

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
1013 1013
                                  dbh          => $dbh);
1014 1014
    }
1015 1015
    # link previous items with invoice items
1016
    foreach (qw(delivery_order_items orderitems invoice)) {
1016
    foreach (qw(delivery_order_items orderitems invoice reclamation_items)) {
1017 1017
      if (!$form->{useasnew} && $form->{"converted_from_${_}_id_$i"}) {
1018 1018
        RecordLinks->create_links('dbh'        => $dbh,
1019 1019
                                  'mode'       => 'ids',
......
1578 1578

  
1579 1579
  Common::webdav_folder($form);
1580 1580

  
1581
  if ($form->{convert_from_ar_ids}) {
1582
    RecordLinks->create_links('dbh'        => $dbh,
1583
                              'mode'       => 'ids',
1584
                              'from_table' => 'ar',
1585
                              'from_ids'   => $form->{convert_from_ar_ids},
1586
                              'to_table'   => 'ar',
1587
                              'to_id'      => $form->{id},
1588
    );
1589
    delete $form->{convert_from_ar_ids};
1590
  }
1591

  
1592 1581
  # Link this record to the records it was created from.
1593
  if ($form->{convert_from_oe_ids}) {
1594
    RecordLinks->create_links('dbh'        => $dbh,
1595
                              'mode'       => 'ids',
1596
                              'from_table' => 'oe',
1597
                              'from_ids'   => $form->{convert_from_oe_ids},
1598
                              'to_table'   => 'ar',
1599
                              'to_id'      => $form->{id},
1582
  foreach (qw(oe ar reclamations)) {
1583
    if ($form->{"convert_from_${_}_ids"}) {
1584
      RecordLinks->create_links('dbh'        => $dbh,
1585
                                'mode'       => 'ids',
1586
                                'from_table' => $_,
1587
                                'from_ids'   => $form->{"convert_from_${_}_ids"},
1588
                                'to_table'   => 'ar',
1589
                                'to_id'      => $form->{id},
1600 1590
      );
1601
    delete $form->{convert_from_oe_ids};
1591
      delete $form->{"convert_from_${_}_ids"};
1592
    }
1602 1593
  }
1603 1594

  
1604 1595
  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
660 660
    title creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
661 661
    max_dunning_level dunning_amount dunning_description
662 662
    taxaccounts cursor_fokus
663
    convert_from_do_ids convert_from_oe_ids convert_from_ar_ids useasnew
663
    convert_from_reclamations_ids convert_from_do_ids convert_from_oe_ids convert_from_ar_ids useasnew
664 664
    invoice_id
665 665
    show_details
666 666
  ), @custom_hiddens,
......
1444 1444
  $main::lxdebug->leave_sub();
1445 1445
}
1446 1446

  
1447
sub credit_note_from_reclamation {
1448
  $main::lxdebug->enter_sub();
1449

  
1450
  $main::auth->assert('invoice_edit');
1451

  
1452
  my $form     = $main::form;
1453
  my %myconfig = %main::myconfig;
1454
  my $locale   = $main::locale;
1455

  
1456

  
1457
  my $from_id = delete $form->{from_id};
1458
  my $reclamation = SL::DB::Reclamation->new(id => $from_id)->load;
1459

  
1460
  $reclamation->flatten_to_form($form, format_amounts => 1);
1461

  
1462
  # set new persistent ids for credit note and link previous reclamation id
1463
  $form->{convert_from_reclamations_ids} = $form->{id};
1464
  $form->{id}     = '';
1465

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

  
1468
  $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1469
  $form->{duedate} =
1470
    $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1471

  
1472
  $form->{title}  = $locale->text('Add Credit Note');
1473
  $form->{script} = 'is.pl';
1474

  
1475
  # bo creates the id, reset it
1476
  map { delete $form->{$_} }
1477
    qw(id invnumber subject message cc bcc printed emailed queued);
1478
  $form->{ $form->{vc} } =~ s/--.*//g;
1479

  
1480
  $form->{type} = "credit_note";
1481

  
1482
  my $currency = $form->{currency};
1483
  &invoice_links;
1484
  $form->{currency}     = $currency;
1485
  $form->{forex}        = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{invdate}, 'buy');
1486
  $form->{exchangerate} = $form->{forex} || '';
1487

  
1488
  $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1489

  
1490
  &prepare_invoice;
1491

  
1492
  &display_form;
1493

  
1494
  $main::lxdebug->leave_sub();
1495
}
1496

  
1447 1497
sub display_form {
1448 1498
  $::lxdebug->enter_sub;
1449 1499

  

Auch abrufbar als: Unified diff