Revision 77a69e5e
Von Bernd Bleßmann vor etwa 1 Jahr hinzugefügt
SL/Model/Record.pm | ||
---|---|---|
10 | 10 |
use SL::DB::History; |
11 | 11 |
use SL::DB::Invoice; |
12 | 12 |
use SL::DB::Status; |
13 |
use SL::DB::ValidityToken; |
|
13 | 14 |
|
14 | 15 |
use SL::Locale::String qw(t8); |
15 | 16 |
|
... | ... | |
181 | 182 |
|
182 | 183 |
# rückgabe: nichts |
183 | 184 |
# fehler: exception |
185 |
|
|
186 |
$record->calculate_prices_and_taxes() if $params{calculate_prices_and_taxes}; # flag or type data? |
|
187 |
|
|
188 |
foreach my $item (@{ $record->items }) { |
|
189 |
# autovivify all cvars that are not in the form (cvars_by_config can do it). |
|
190 |
# workaround to pre-parse number-cvars (parse_custom_variable_values does not parse number values). |
|
191 |
foreach my $var (@{ $item->cvars_by_config }) { |
|
192 |
$var->unparsed_value($::form->parse_amount(\%::myconfig, $var->{__unparsed_value})) if ($var->config->type eq 'number' && exists($var->{__unparsed_value})); |
|
193 |
} |
|
194 |
$item->parse_custom_variable_values; |
|
195 |
} |
|
196 |
|
|
197 |
SL::DB->client->with_transaction(sub { |
|
198 |
# validity token |
|
199 |
my $validity_token; |
|
200 |
if (my $validity_token_specs = $params{with_validity_token}) { |
|
201 |
if (!defined $validity_token_specs->{scope} || !defined $validity_token_specs->{token}) { |
|
202 |
croak ('you must provide a hash ref "with_validity_token" with the keys "scope" and "token" if you want the token to be handled'); |
|
203 |
} |
|
204 |
|
|
205 |
if (!$record->id) { |
|
206 |
$validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token( |
|
207 |
scope => $validity_token_specs->{scope}, |
|
208 |
token => $validity_token_specs->{token}, |
|
209 |
); |
|
210 |
|
|
211 |
die $::locale->text('The form is not valid anymore.') if !$validity_token; |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
# delete custom shipto if it is to be deleted or if it is empty |
|
216 |
if ($params{delete_custom_shipto}) { # flag? |
|
217 |
if ($record->custom_shipto) { |
|
218 |
$record->custom_shipto->delete if $record->custom_shipto->shipto_id; |
|
219 |
$record->custom_shipto(undef); |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
$_->delete for @{ $params{items_to_delete} || [] }; |
|
224 |
|
|
225 |
$record->save(cascade => 1); |
|
226 |
|
|
227 |
# # link records |
|
228 |
# if (@converted_from_oe_ids) { |
|
229 |
# $self->link_requirement_specs_linking_to_created_from_objects(@converted_from_oe_ids); |
|
230 |
# } |
|
231 |
|
|
232 |
# $self->set_project_in_linked_requirement_specs if $self->order->globalproject_id; |
|
233 |
|
|
234 |
_save_history($record, 'SAVED', %{$params{history}}); |
|
235 |
|
|
236 |
$validity_token->delete if $validity_token; |
|
237 |
|
|
238 |
1; |
|
239 |
}); |
|
184 | 240 |
} |
185 | 241 |
|
186 | 242 |
sub update_for_save_as_new { |
Auch abrufbar als: Unified diff
Model::Record: save implementiert