Revision b8277d1f
Von Werner Hahn vor mehr als 1 Jahr hinzugefügt
SL/Model/Record.pm | ||
---|---|---|
32 | 32 |
my $type_data_proxy = SL::DB::Helper::TypeDataProxy->new(ref $new_record, $subtype); |
33 | 33 |
$new_record->reqdate($type_data_proxy->defaults('reqdate')); |
34 | 34 |
|
35 |
# new_record: der neuerstellte objekt |
|
36 |
# flags: zusätzliche informationen zu der behanldung (soll ) |
|
37 |
|
|
38 |
# (aus add) neues record mit vorbereitenden sachen wie transdate/reqdate |
|
39 |
# |
|
40 |
# rückgabe: neues objekt |
|
41 |
# fehlerfall: exception |
|
42 | 35 |
return $new_record; |
43 | 36 |
} |
44 | 37 |
|
45 | 38 |
sub new_from_workflow { |
46 | 39 |
my ($class, $source_object, $target_subtype, %flags) = @_; |
47 | 40 |
|
48 |
# source: ein quellobjekt |
|
49 |
# target type: sollte ein subtype sein. wer das hier implementiert, sollte auch eine subtype registratur bauen in der man subtypes nachschlagen kann |
|
50 |
# flags: welche extra behandlungen sollen gemacht werden, z.B. record_links setzen |
|
51 |
|
|
52 |
# (muss prüfen ob diese umwandlung korrekt ist) |
|
53 |
# muss das entsprechende new_from in den objekten selber benutzen |
|
54 |
# und dann evtl nachbearbeitung machen (die bisher im controller stand) |
|
55 |
|
|
56 |
# new_from_workflow: (aus add_from_*) workflow umwandlung von bestehenden records |
|
57 |
|
|
58 |
# fehlerfall: exception aus unterliegendem code bubblen oder neue exception werfen |
|
59 |
# rückgabe: das neue objekt |
|
60 |
|
|
61 | 41 |
$flags{destination_type} = $target_subtype; |
62 | 42 |
my %defaults_flags = ( |
63 | 43 |
no_linked_records => 0, |
... | ... | |
90 | 70 |
|
91 | 71 |
sub new_from_workflow_multi { |
92 | 72 |
my ($class, $source_objects, $target_subtype, %flags) = @_; |
93 |
# source: ein arrayref von quellobjekten. |
|
94 |
# target type: sollte ein subtype sein. wer das hier implementiert, sollte auch eine subtype registratur bauen in der man subtypes nachschlagen kann |
|
95 |
# flags: welche extra behandlungen sollen gemacht werden, z.B. record_links setzen |
|
96 |
|
|
97 |
# muss prüfen ob diese umwandlung korrekt ist |
|
98 |
# muss das entsprechende new_from_multi in den objekten selber benutzen |
|
99 |
# und dann evtl nachbearbeitung machen (die bisher im controller stand) |
|
100 |
|
|
101 |
# new_from_workflow_multi: (aus action_edit_collective) workflow umwandlung von bestehenden records |
|
102 |
|
|
103 |
# fehlerfall: exception aus unterliegendem code bubblen oder neue exception werfen |
|
104 |
# rückgabe: das neue objekt |
|
105 | 73 |
|
106 | 74 |
my %subtype_to_type = ( |
107 | 75 |
# Order |
... | ... | |
117 | 85 |
return $target_object; |
118 | 86 |
} |
119 | 87 |
|
120 |
# im Moment nur bei Aufträgen |
|
121 | 88 |
sub increment_subversion { |
122 | 89 |
my ($class, $record, %flags) = @_; |
123 | 90 |
|
124 |
# erhöht die version des auftrags |
|
125 |
# setzt die neue auftragsnummer |
|
126 |
# legt OrderVersion objekt an |
|
127 |
# speichert |
|
128 |
# |
|
129 |
# return - nichts |
|
130 |
# fehlerfall: exception |
|
131 |
|
|
132 | 91 |
$record->increment_version_number if $record->type_data->features('subversions'); |
133 | 92 |
|
134 | 93 |
return; |
135 | 94 |
} |
136 | 95 |
|
137 | 96 |
sub delete { |
138 |
my ($class, $record, %params) = @_;
|
|
97 |
my ($class, $record, %flags) = @_;
|
|
139 | 98 |
|
140 | 99 |
my $errors = []; |
141 | 100 |
my $db = $record->db; |
... | ... | |
153 | 112 |
}) || push(@{$errors}, $db->error); |
154 | 113 |
|
155 | 114 |
die t8("Errors delete records:") . "\n" . join("\n", @{$errors}) . "\n" if scalar @{$errors}; |
156 |
# das hier sollte der code sein der in sub delete aus den controllern liegt |
|
157 |
# nicht nur record->delete, sondern auch andere elemente aufräumen |
|
158 |
# spool aufräumen |
|
159 |
# status aufräumen |
|
160 |
# history eintrag |
|
161 |
# |
|
162 |
# return: nichts |
|
163 |
# fehler: exception |
|
164 | 115 |
} |
165 | 116 |
|
166 | 117 |
sub _get_history_snumbers { |
... | ... | |
187 | 138 |
sub save { |
188 | 139 |
my ($class, $record, %params) = @_; |
189 | 140 |
|
190 |
# record: das zu speichernde objekt |
|
191 |
# params: |
|
192 |
# - with_validity_token -> scope |
|
193 |
# - delete custom shipto if empty |
|
194 |
# - item_ids_to_delete |
|
195 |
# - order version behandlung |
|
196 |
|
|
197 |
|
|
198 |
# muss linked_records aus converted_from_* erzeugen -> verschieben in after_save hooks |
|
199 |
# wenn aus quotation erstellt, muss beim speichern das angebot geschlossen werden |
|
200 |
# wenn aus lieferschein erstellt muss beim speichern delivered setzen (wenn in config aktiviert) |
|
201 |
# muss auch link requirement_specs machen (was tut das?) |
|
202 |
# set project in linked requirementspecs (nur aufträge -> flag) |
|
203 |
# |
|
204 |
# history einträge erstellen |
|
205 |
|
|
206 |
# rückgabe: nichts |
|
207 |
# fehler: exception |
|
208 |
|
|
209 | 141 |
$record->calculate_prices_and_taxes() if $record->type_data->features('price_tax'); |
210 | 142 |
|
211 | 143 |
foreach my $item (@{ $record->items }) { |
... | ... | |
400 | 332 |
|
401 | 333 |
Invoices are not supported as of now, but are planned for the future. |
402 | 334 |
|
335 |
The old deliveryorder C<sales_delivery_order> and C<purchase_delivery_order> must be implemented |
|
336 |
in the new DeliveryOrder Controller |
|
337 |
|
|
403 | 338 |
=head1 METHODS |
404 | 339 |
|
405 | 340 |
=over 4 |
406 | 341 |
|
342 |
=item C<update_after_new> |
|
343 |
|
|
344 |
Creates a new record_object by record_type and sub_type |
|
345 |
set reqdate and transdate if required by type_data |
|
346 |
|
|
347 |
Returns the record object. |
|
348 |
|
|
349 |
=item C<new_from_workflow> |
|
350 |
|
|
351 |
Expects source_object, target_object, can have flags. |
|
352 |
Creates a new record from source_subtype by target_type->new_from(source_record) |
|
353 |
Set default flag no_link_record to false and looks up the correct target_type |
|
354 |
|
|
355 |
Throws an error if target_type not exists. |
|
356 |
|
|
357 |
Returns the new record_object. |
|
358 |
|
|
359 |
=item C<new_from_workflow_multi> |
|
360 |
|
|
361 |
Expects an arrayref with source_objects and a target_object, can have flags. |
|
362 |
Creates a new record_objects from one or more source_objects. By now only for orders. |
|
363 |
Looks up the correct target_type throws an error if it doesn't exist. |
|
364 |
|
|
365 |
Return the new record_object. |
|
366 |
|
|
407 | 367 |
=item C<increment_subversion> |
408 | 368 |
|
369 |
Only orders. |
|
370 |
|
|
409 | 371 |
Increments the record's subversion number. |
410 | 372 |
|
373 |
TODO: check type data if this is allowed/supported for this record and trow exception or error |
|
374 |
|
|
411 | 375 |
=item C<delete> |
412 | 376 |
|
377 |
Expects a record to delete. |
|
413 | 378 |
Deletes the whole record and puts an entry in the history. |
379 |
Cleans up the spool directory. |
|
380 |
Dies and throws an error if dberror. |
|
381 |
|
|
382 |
TODO: check status order when old deliveryorder (do) will be implemented. |
|
383 |
|
|
384 |
=item C<save> |
|
385 |
|
|
386 |
Expects a record to save and params to handles stuff like validity_token, custom_shipto, |
|
387 |
items_to_delete, close objects, requirement_specs |
|
388 |
|
|
389 |
=over 2 |
|
390 |
|
|
391 |
=item * L<params:> |
|
392 |
|
|
393 |
=over 4 |
|
394 |
|
|
395 |
=item * C<with_validity_token -E<gt> scope> |
|
396 |
|
|
397 |
=item * C<delete custom shipto if empty> |
|
398 |
|
|
399 |
=item * C<items_to_delete> |
|
400 |
|
|
401 |
=item * C<objects_to_close> |
|
402 |
|
|
403 |
=item * C<link_requirement_specs_linking_to_created_from_objects> |
|
404 |
|
|
405 |
=item * C<set_project_in_linked_requirement_specs> |
|
406 |
|
|
407 |
=back |
|
408 |
|
|
409 |
Sets an entry in history |
|
410 |
|
|
411 |
Dies and throws error when error |
|
412 |
|
|
413 |
=back |
|
414 |
|
|
415 |
=back |
|
416 |
|
|
417 |
=over 4 |
|
418 |
|
|
419 |
=item C<clone_for_save_as_new> |
|
420 |
|
|
421 |
Expects the saved record and the record to change. |
|
422 |
|
|
423 |
Sets the actual employee. |
|
424 |
|
|
425 |
Sets also new transdate, new reqdate and an empty recordnumber if not allready changed in record to change. |
|
414 | 426 |
|
415 | 427 |
=item C<_save_history> |
416 | 428 |
|
417 |
Expects a record for id, addition for text (SAVED,...) |
|
429 |
Expects a record for id, addition for text (SAVED,DELETED,...) |
|
430 |
|
|
431 |
=item C<_get_history_snumbers> |
|
432 |
|
|
433 |
Expects a record returns snumber for history_entry |
|
418 | 434 |
|
419 | 435 |
=back |
420 | 436 |
|
Auch abrufbar als: Unified diff
S:M:R: POD