Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 179e3c4c

Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt

  • ID 179e3c4c9270c013ad411cae843fe842a1af3ec8
  • Vorgänger e2db2d12
  • Nachfolger 6ad5169e

SL::DB::Part - neue Methode get_stock

um den aktuellen Lagerbestand eines Artikels in einem bestimmten
Lagerplatz oder in einem bestimmten Lager zu einem bestimmten Stichtag
in der Standardeinheit auszulesen.

Unterschiede anzeigen:

SL/DB/Part.pm
262 262
  return $charts->{$taxzone}->{$type};
263 263
}
264 264

  
265
sub get_stock {
266
  my ($self, %params) = @_;
267

  
268
  return undef unless $self->id;
269

  
270
  my $query = 'SELECT SUM(qty) FROM inventory WHERE parts_id = ?';
271
  my @values = ($self->id);
272

  
273
  if ( $params{bin_id} ) {
274
    $query .= ' AND bin_id = ?';
275
    push(@values, $params{bin_id});
276
  }
277

  
278
  if ( $params{warehouse_id} ) {
279
    $query .= ' AND warehouse_id = ?';
280
    push(@values, $params{warehouse_id});
281
  }
282

  
283
  if ( $params{shippingdate} ) {
284
    die unless ref($params{shippingdate}) eq 'DateTime';
285
    $query .= ' AND shippingdate <= ?';
286
    push(@values, $params{shippingdate});
287
  }
288

  
289
  my ($stock) = selectrow_query($::form, $self->db->dbh, $query, @values);
290

  
291
  return $stock || 0; # never return undef
292
};
293

  
294

  
265 295
# this is designed to ignore chargenumbers, expiration dates and just give a list of how much <-> where
266 296
sub get_simple_stock {
267 297
  my ($self, %params) = @_;
......
519 549

  
520 550
Non-recursive lastcost sum of all the assortment item lastcosts.
521 551

  
552
=item C<get_stock %params>
553

  
554
Fetches stock qty in the default unit for a part.
555

  
556
bin_id and warehouse_id may be passed as params. If only a bin_id is passed,
557
the stock qty for that bin is returned. If only a warehouse_id is passed, the
558
stock qty for all bins in that warehouse is returned.  If a shippingdate is
559
passed the stock qty for that date is returned.
560

  
561
Examples:
562
 my $qty = $part->get_stock(bin_id => 52);
563

  
564
 $part->get_stock(shippingdate => DateTime->today->add(days => -5));
565

  
522 566
=back
523 567

  
524 568
=head1 AUTHORS

Auch abrufbar als: Unified diff