Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9e561023

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

Pflichtenheftaufträge: Pauschalpos. in Ang./Auftr. erstellen können

Pauschalpositionen haben die Menge 1, als Einheit die Einheit des
Artikels (und nicht »Stunden«) und als Preis den Gesamtpreis der
Aufwandsschätzung des dazugehörigen Abschnitts.

Unterschiede anzeigen:

SL/Controller/RequirementSpecOrder.pm
228 228
# helpers
229 229
#
230 230

  
231
sub cache_parts {
232
  my ($self, @ids) = @_;
233

  
234
  my $parts = !@ids ? [] : SL::DB::Manager::Part->get_all(
235
    where        => [ id => \@ids ],
236
    with_objects => [ qw(unit_obj) ],
237
  );
238

  
239
  $self->parts({ map { ($_->id => $_) } @{ $parts } });
240
}
241

  
231 242
sub do_update_sections {
232 243
  my ($self)           = @_;
233 244

  
......
235 246
  my $sections         = $self->requirement_spec->sections_sorted;
236 247
  my %orderitems_by_id = map { ($_->id => $_) } @{ $order->orderitems };
237 248
  my %sections_by_id   = map { ($_->id => $_) } @{ $sections };
238
  $self->{parts}       = { map { ($_->id => $_) } @{ SL::DB::Manager::Part->get_all(where => [ id => [ uniq map { $_->order_part_id } @{ $sections } ] ]) } };
239 249
  my $language_id      = $self->requirement_spec->customer->language_id;
240 250

  
251
  $self->cache_parts(uniq map { $_->order_part_id } @{ $sections });
252

  
241 253
  my %sections_seen;
242 254

  
243 255
  foreach my $attributes (@{ $::form->{orderitems} || [] }) {
......
262 274
  my $order         = $self->rs_order->order;
263 275
  my $add_parts     = $self->requirement_spec->parts_sorted;
264 276
  my %orderitems_by = map { (($_->parts_id . '-' . $_->description) => $_) } @{ $order->items };
265
  $self->{parts}    = { map { ($_->id => $_) } @{ SL::DB::Manager::Part->get_all(where => [ id => [ uniq map { $_->part_id } @{ $add_parts } ] ]) } };
266 277
  my $language_id   = $self->requirement_spec->customer->language_id;
267 278

  
279
  $self->cache_parts(uniq map { $_->part_id } @{ $add_parts });
280

  
268 281
  my %add_part_seen;
269 282
  my @new_orderitems;
270 283

  
......
289 302
  my $section         = $params{section};
290 303
  my $item            = $params{item} || SL::DB::OrderItem->new;
291 304
  my $part            = $self->parts->{ $section->order_part_id };
305
  my $is_time_based   = $part->unit_obj->is_time_based;
292 306
  my $translation     = $params{language_id} ? first { $params{language_id} == $_->language_id } @{ $part->translations } : {};
293 307
  my $description     = $section->{keep_description} ? $item->description : ($translation->{translation} || $part->description);
294 308
  my $longdescription = $translation->{longdescription} || $part->notes;
......
308 322
    parts_id        => $part->id,
309 323
    description     => $description,
310 324
    longdescription => $longdescription,
311
    qty             => $section->time_estimation * 1,
312
    unit            => $self->h_unit_name,
313
    sellprice       => $::form->round_amount($self->requirement_spec->hourly_rate, 2),
325
    qty             => $is_time_based ? $section->time_estimation * 1 : 1,
326
    unit            => $is_time_based ? $self->h_unit_name            : $part->unit,
327
    sellprice       => $::form->round_amount($self->requirement_spec->hourly_rate * ($is_time_based ? 1 : $section->time_estimation), 2),
314 328
    lastcost        => $part->lastcost,
315 329
    discount        => 0,
316 330
    project_id      => $self->requirement_spec->project_id,

Auch abrufbar als: Unified diff