Revision fd82e4e7
Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
47 | 47 |
use File::Spec; |
48 | 48 |
use Cwd; |
49 | 49 |
use Sort::Naturally; |
50 |
use Try::Tiny; |
|
51 | 50 |
|
52 | 51 |
use Rose::Object::MakeMethods::Generic |
53 | 52 |
( |
... | ... | |
223 | 222 |
sub action_add_subversion { |
224 | 223 |
my ($self) = @_; |
225 | 224 |
|
226 |
try { |
|
227 |
my $current_version_number = $self->order->current_version_number; |
|
228 |
my $new_version_number = $current_version_number + 1; |
|
229 |
|
|
230 |
if ($self->type eq sales_quotation_type() || $self->type eq request_quotation_type()) { |
|
231 |
my $new_quonumber = $self->order->quonumber; |
|
232 |
$new_quonumber =~ s/-$current_version_number$//; |
|
233 |
$self->order->quonumber($new_quonumber . '-' . $new_version_number); |
|
234 |
} elsif ($self->type eq sales_order_type()|| $self->type eq purchase_order_type()) { |
|
235 |
my $new_ordnumber = $self->order->ordnumber; |
|
236 |
$new_ordnumber =~ s/-$current_version_number$//; |
|
237 |
$self->order->ordnumber($new_ordnumber . '-' . $new_version_number); |
|
238 |
} else { die "Invalid Call for Sub-Version. Need Order or Quotation."; } |
|
239 |
|
|
240 |
SL::DB::OrderVersion->new(oe_id => $self->order->id, |
|
241 |
version => $new_version_number, |
|
242 |
)->save; |
|
243 |
|
|
244 |
} catch { die "Could not create sub-version for record with id:" . $self->order->id . " Reason: $_" }; |
|
225 |
my $current_version_number = $self->order->current_version_number; |
|
226 |
my $new_version_number = $current_version_number + 1; |
|
227 |
|
|
228 |
my $new_number = $self->order->number; |
|
229 |
$new_number =~ s/-$current_version_number$//; |
|
230 |
$self->order->number($new_number . '-' . $new_version_number); |
|
231 |
|
|
232 |
SL::DB::OrderVersion->new(oe_id => $self->order->id, |
|
233 |
version => $new_version_number, |
|
234 |
)->save; |
|
245 | 235 |
|
246 | 236 |
# call the save action |
247 | 237 |
$self->action_save(); |
Auch abrufbar als: Unified diff
Unterversionen: Controller: Code zum Erzeugen der neuen Belegnummer vereinfacht
- number-Accessor nehmen, dann kann die Fallunterscheidung weg
- der Controller stellt schon sicher, dass es nur valide Belegtypen
gibt
- try/catch kann weg, da das save selber eine Ausnahme werden kann