use SL::DB::Tax;
use SL::DBUtils;
use SL::IC;
+use SL::TransNumber;
use strict;
my $ml = ($form->{type} eq 'sales_order') ? 1 : -1;
+ my $number_field = $form->{type} =~ m{order} ? 'ordnumber' : 'quonumber';
+ my $trans_number = SL::TransNumber->new(type => $form->{type}, dbh => $dbh, number => $form->{$number_field}, id => $form->{id});
+ $form->{$number_field} ||= $trans_number->create_unique;
+
if ($form->{id}) {
$query = qq|DELETE FROM custom_variables
WHERE (config_id IN (SELECT id FROM custom_variable_configs WHERE module = 'IC'))
}
- # get new number in sequence if no number is given or if saveasnew was requested
- if (!$form->{$ordnumber} || $form->{saveasnew}) {
- $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
- }
+ # get new number in sequence if saveasnew was requested
+ delete $form->{$ordnumber} if $form->{saveasnew};
relink_accounts();
}
- # value of $ordnumber is ordnumber or quonumber
- $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
- unless $form->{$ordnumber};
-
relink_accounts();
OE->save(\%myconfig, \%$form);