Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f65440cb

Von Moritz Bunkus vor fast 4 Jahren hinzugefügt

  • ID f65440cb9d28d4862facc50858bd25fa138cb211
  • Vorgänger cd274d3f
  • Nachfolger 92f6fae1

Order-Controller: Workflow Verkaufsauftrag → Verkaufsangebot

Unterschiede anzeigen:

SL/Controller/Order.pm
598 598
  );
599 599
}
600 600

  
601
# workflow from sales order to sales quotation
602
sub action_sales_quotation {
603
  $_[0]->workflow_sales_quotation();
604
}
605

  
601 606
# workflow from sales quotation to sales order
602 607
sub action_sales_order {
603 608
  $_[0]->workflow_sales_or_purchase_order();
......
1580 1585
  return $errors;
1581 1586
}
1582 1587

  
1588
sub workflow_sales_quotation {
1589
  my ($self) = @_;
1590

  
1591
  # always save
1592
  my $errors = $self->save();
1593

  
1594
  if (scalar @{ $errors }) {
1595
    $self->js->flash('error', $_) for @{ $errors };
1596
    return $self->js->render();
1597
  }
1598

  
1599
  my $destination_type = sales_quotation_type();
1600

  
1601
  $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type));
1602
  $self->{converted_from_oe_id} = delete $::form->{id};
1603

  
1604
  # set item ids to new fake id, to identify them as new items
1605
  foreach my $item (@{$self->order->items_sorted}) {
1606
    $item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
1607
  }
1608

  
1609
  # change form type
1610
  $::form->{type} = $destination_type;
1611
  $self->type($self->init_type);
1612
  $self->cv  ($self->init_cv);
1613
  $self->check_auth;
1614

  
1615
  $self->recalc();
1616
  $self->get_unalterable_data();
1617
  $self->pre_render();
1618

  
1619
  # trigger rendering values for second row as hidden, because they
1620
  # are loaded only on demand. So we need to keep the values from the
1621
  # source.
1622
  $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
1623

  
1624
  $self->render(
1625
    'order/form',
1626
    title => $self->get_title_for('edit'),
1627
    %{$self->{template_args}}
1628
  );
1629
}
1630

  
1583 1631
sub workflow_sales_or_purchase_order {
1584 1632
  my ($self) = @_;
1585 1633

  
......
1738 1786
        action => [
1739 1787
          t8('Workflow'),
1740 1788
        ],
1789
        action => [
1790
          t8('Save and Quotation'),
1791
          submit   => [ '#order_form', { action => "Order/sales_quotation" } ],
1792
          only_if  => (any { $self->type eq $_ } (sales_order_type())),
1793
        ],
1741 1794
        action => [
1742 1795
          t8('Save and Sales Order'),
1743 1796
          submit   => [ '#order_form', { action => "Order/sales_order" } ],
......
2150 2203

  
2151 2204
=item * credit limit
2152 2205

  
2153
=item * more workflows (quotation, rfq)
2206
=item * more workflows (rfq)
2154 2207

  
2155 2208
=item * price sources: little symbols showing better price / better discount
2156 2209

  
SL/DB/Order.pm
310 310
    { from => 'purchase_order',    to => 'purchase_order',    abbr => 'popo' },
311 311
    { from => 'sales_order',       to => 'purchase_order',    abbr => 'sopo' },
312 312
    { from => 'purchase_order',    to => 'sales_order',       abbr => 'poso' },
313
    { from => 'sales_order',       to => 'sales_quotation',   abbr => 'sosq' },
313 314
  );
314 315
  my $from_to = (grep { $_->{from} eq $source->type && $_->{to} eq $destination_type} @from_tos)[0];
315 316
  croak("Cannot convert from '" . $source->type . "' to '" . $destination_type . "'") if !$from_to;
......
354 355
  if ( $is_abbr_any->(qw(soso)) ) {
355 356
    $args{periodic_invoices_config} = $source->periodic_invoices_config->clone_and_reset if $source->periodic_invoices_config;
356 357
  }
358
  if ( $is_abbr_any->(qw(sosq)) ) {
359
    $args{ordnumber} = undef;
360
    $args{quonumber} = undef;
361
    $args{reqdate}   = DateTime->today_local->next_workday();
362
  }
357 363

  
358 364
  # Custom shipto addresses (the ones specific to the sales/purchase
359 365
  # record and not to the customer/vendor) are only linked from

Auch abrufbar als: Unified diff