Revision a2a95b63
Von Bernd Bleßmann vor 10 Monaten hinzugefügt
SL/DB/Part.pm | ||
---|---|---|
143 | 143 |
# changed when saving |
144 | 144 |
|
145 | 145 |
return join(' ', sort map { $_->part->id } @{$self->items}); |
146 |
};
|
|
146 |
} |
|
147 | 147 |
|
148 | 148 |
sub validate { |
149 | 149 |
my ($self) = @_; |
... | ... | |
162 | 162 |
|
163 | 163 |
unless ( $self->id ) { |
164 | 164 |
push @errors, $::locale->text('The partnumber already exists.') if SL::DB::Manager::Part->get_all_count(where => [ partnumber => $self->partnumber ]); |
165 |
};
|
|
165 |
} |
|
166 | 166 |
|
167 | 167 |
if ($self->is_assortment && $self->orphaned && scalar @{$self->assortment_items} == 0) { |
168 | 168 |
# when assortment isn't orphaned form doesn't contain any items |
... | ... | |
226 | 226 |
sub last_modification { |
227 | 227 |
my ($self) = @_; |
228 | 228 |
return $self->mtime // $self->itime; |
229 |
};
|
|
229 |
} |
|
230 | 230 |
|
231 | 231 |
sub used_in_record { |
232 | 232 |
my ($self) = @_; |
... | ... | |
246 | 246 |
} |
247 | 247 |
return 0; |
248 | 248 |
} |
249 |
|
|
249 | 250 |
sub orphaned { |
250 | 251 |
my ($self) = @_; |
251 | 252 |
die 'not an accessor' if @_ > 1; |
... | ... | |
371 | 372 |
my ($stock) = selectrow_query($::form, $self->db->dbh, $query, @values); |
372 | 373 |
|
373 | 374 |
return $stock || 0; # never return undef |
374 |
};
|
|
375 |
} |
|
375 | 376 |
|
376 | 377 |
|
377 | 378 |
# this is designed to ignore chargenumbers, expiration dates and just give a list of how much <-> where |
... | ... | |
458 | 459 |
SQL |
459 | 460 |
|
460 | 461 |
my $objs = SL::DB::Manager::Inventory->get_all( |
461 |
query => [ id => [ \"$query" ] ], # make emacs happy " |
|
462 |
query => [ id => [ \"$query" ] ], # make emacs happy "]]
|
|
462 | 463 |
with_objects => [ 'parts', 'trans_type', 'bin', 'bin.warehouse' ], # prevent lazy loading in template |
463 | 464 |
sort_by => 'itime DESC', |
464 | 465 |
); |
... | ... | |
490 | 491 |
# use clone rather than reset_and_clone because the unique constraint would also remove parts_id |
491 | 492 |
$clone->assortment_items( map { $_->clone } @{$self->assortment_items} ); |
492 | 493 |
$_->assortment_id(undef) foreach @{ $clone->assortment_items } |
493 |
};
|
|
494 |
} |
|
494 | 495 |
|
495 | 496 |
if ( $self->is_assembly ) { |
496 | 497 |
$clone->assemblies( map { $_->clone_and_reset } @{$self->assemblies}); |
497 |
};
|
|
498 |
} |
|
498 | 499 |
|
499 | 500 |
if ( $self->prices ) { |
500 | 501 |
$clone->prices( map { $_->clone } @{$self->prices}); # pricegroup_id gets reset here because it is part of a unique contraint |
... | ... | |
502 | 503 |
foreach my $price ( @{$clone->prices} ) { |
503 | 504 |
$price->id(undef); |
504 | 505 |
$price->parts_id(undef); |
505 |
};
|
|
506 |
};
|
|
507 |
};
|
|
506 |
} |
|
507 |
} |
|
508 |
} |
|
508 | 509 |
|
509 | 510 |
return $clone; |
510 | 511 |
} |
... | ... | |
529 | 530 |
@removals = grep { !exists( $comparison{$_} ) } @self_part_ids if @self_part_ids; |
530 | 531 |
|
531 | 532 |
return \@additions, \@removals; |
532 |
};
|
|
533 |
} |
|
533 | 534 |
|
534 | 535 |
sub items_sellprice_sum { |
535 | 536 |
my ($self, %params) = @_; |
... | ... | |
550 | 551 |
return unless $self->is_assortment or $self->is_assembly; |
551 | 552 |
return unless $self->items; |
552 | 553 |
sum map { $_->linetotal_lastcost } @{$self->items}; |
553 |
};
|
|
554 |
} |
|
554 | 555 |
|
555 | 556 |
sub items_weight_sum { |
556 | 557 |
my ($self) = @_; |
... | ... | |
558 | 559 |
return unless $self->is_assembly; |
559 | 560 |
return unless $self->items; |
560 | 561 |
sum map { $_->linetotal_weight} @{$self->items}; |
561 |
};
|
|
562 |
} |
|
562 | 563 |
|
563 | 564 |
sub set_lastcost_assemblies_and_assortiments { |
564 | 565 |
my ($self) = @_; |
Auch abrufbar als: Unified diff
S:D:Part: Kosmetik: kein Semikolon nach Kontrollstrukturen, …
… und emacs noch glücklicher machen ;)