sub action_save_and_delivery_order {
my ($self) = @_;
- my $errors = $self->save();
-
- if (scalar @{ $errors }) {
- $self->js->flash('error', $_) foreach @{ $errors };
- return $self->js->render();
- }
-
- my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
- : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
- : '';
- flash_later('info', $text);
-
- my @redirect_params = (
+ $self->save_and_redirect_to(
controller => 'oe.pl',
action => 'oe_delivery_order_from_order',
- id => $self->order->id,
);
-
- $self->redirect_to(@redirect_params);
}
# save the order and redirect to the frontend subroutine for a new
sub action_save_and_invoice {
my ($self) = @_;
- my $errors = $self->save();
-
- if (scalar @{ $errors }) {
- $self->js->flash('error', $_) foreach @{ $errors };
- return $self->js->render();
- }
-
- my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
- : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
- : '';
- flash_later('info', $text);
-
- my @redirect_params = (
+ $self->save_and_redirect_to(
controller => 'oe.pl',
action => 'oe_invoice_from_order',
- id => $self->order->id,
);
-
- $self->redirect_to(@redirect_params);
}
# workflow from sales quotation to sales order
sub action_save_and_ap_transaction {
my ($self) = @_;
- my $errors = $self->save();
-
- if (scalar @{ $errors }) {
- $self->js->flash('error', $_) foreach @{ $errors };
- return $self->js->render();
- }
-
- my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
- : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
- : '';
- flash_later('info', $text);
-
- my @redirect_params = (
+ $self->save_and_redirect_to(
controller => 'ap.pl',
action => 'add_from_purchase_order',
- id => $self->order->id,
);
-
- $self->redirect_to(@redirect_params);
}
# set form elements in respect to a changed customer or vendor
: '';
}
+sub save_and_redirect_to {
+ my ($self, %params) = @_;
+
+ my $errors = $self->save();
+
+ if (scalar @{ $errors }) {
+ $self->js->flash('error', $_) foreach @{ $errors };
+ return $self->js->render();
+ }
+
+ my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
+ : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
+ : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
+ : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
+ : '';
+ flash_later('info', $text);
+
+ $self->redirect_to(%params, id => $self->order->id);
+}
+
1;
__END__
$main::lxdebug->leave_sub();
}
-sub oe_delivery_order_from_order {
-
+sub oe_prepare_xyz_from_order {
return if !$::form->{id};
my $order = SL::DB::Order->new(id => $::form->{id})->load;
$::form->{rowcount}++;
_update_ship();
+}
+
+sub oe_delivery_order_from_order {
+ oe_prepare_xyz_from_order();
delivery_order();
}
sub oe_invoice_from_order {
-
- return if !$::form->{id};
-
- my $order = SL::DB::Order->new(id => $::form->{id})->load;
- $order->flatten_to_form($::form, format_amounts => 1);
-
- # hack: add partsgroup for first row if it does not exists,
- # because _remove_billed_or_delivered_rows and _remove_full_delivered_rows
- # determine fields to handled by existing fields for the first row. If partsgroup
- # is missing there, for deleted rows the partsgroup_field is not emptied and in
- # update_delivery_order it will not considered an empty row ...
- $::form->{partsgroup_1} = '' if !exists $::form->{partsgroup_1};
-
- # fake last empty row
- $::form->{rowcount}++;
-
- _update_ship();
+ oe_prepare_xyz_from_order();
invoice();
}