Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1bbcb32c

Von Bernd Bleßmann vor mehr als 6 Jahren hinzugefügt

  • ID 1bbcb32cff12865da20d6f2dabc85d7683dca31e
  • Vorgänger 421ed1f7
  • Nachfolger 51072516

Inventur: Inventurzählungen mit Lagerbewegungen im Backend SL::WH speichern können

Unterschiede anzeigen:

SL/WH.pm
80 80
  my $db = SL::DB::Inventory->new->db;
81 81
  $db->with_transaction(sub{
82 82
    while (my $transfer = shift @args) {
83
      my ($trans_id) = selectrow_query($::form, $::form->get_standard_dbh, qq|SELECT nextval('id')|);
83
      my $trans_id;
84
      ($trans_id) = selectrow_query($::form, $::form->get_standard_dbh, qq|SELECT nextval('id')|) if $transfer->{qty};
84 85

  
85 86
      my $part          = $objectify->($transfer, 'parts',         'SL::DB::Part');
86 87
      my $unit          = $objectify->($transfer, 'unit',          'SL::DB::Unit',         name => $transfer->{unit});
......
101 102
      my $transfer_type = $objectify->($transfer, 'transfer_type', 'SL::DB::TransferType', direction   => $directions[$direction],
102 103
                                                                                           description => $transfer->{transfer_type});
103 104

  
105
      my $stocktaking_qty = $transfer->{stocktaking_qty};
106

  
104 107
      my %params = (
105 108
          part             => $part,
106 109
          employee         => $employee,
......
113 116
      );
114 117

  
115 118
      if ($unit) {
116
        $qty = $unit->convert_to($qty, $part->unit_obj);
119
        $qty             = $unit->convert_to($qty,             $part->unit_obj);
120
        $stocktaking_qty = $unit->convert_to($stocktaking_qty, $part->unit_obj);
117 121
      }
118 122

  
119 123
      $params{chargenumber} ||= '';
120 124

  
121
      if ($direction & 1) {
122
        SL::DB::Inventory->new(
125
      my @inventories;
126
      if ($qty && $direction & 1) {
127
        push @inventories, SL::DB::Inventory->new(
123 128
          %params,
124 129
          warehouse => $src_wh,
125 130
          bin       => $src_bin,
......
127 132
        )->save;
128 133
      }
129 134

  
130
      if ($direction & 2) {
131
        SL::DB::Inventory->new(
135
      if ($qty && $direction & 2) {
136
        push @inventories, SL::DB::Inventory->new(
132 137
          %params,
133 138
          warehouse => $dst_wh->id,
134 139
          bin       => $dst_bin->id,
......
140 145
        }
141 146
      }
142 147

  
148
      # Record stocktaking if requested.
149
      # This is only possible if transfer was a stock in or stock out,
150
      # but not both (transfer).
151
      if ($transfer->{record_stocktaking}) {
152
        die 'Stocktaking can only be recorded for stock in or stock out, but not on a transfer.' if scalar @inventories > 1;
153

  
154
        my $inventory_id;
155
        $inventory_id = $inventories[0]->id if $inventories[0];
156

  
157
        SL::DB::Stocktaking->new(
158
          inventory_id => $inventory_id,
159
          warehouse    => $src_wh  || $dst_wh,
160
          bin          => $src_bin || $dst_bin,
161
          parts_id     => $part->id,
162
          employee_id  => $employee->id,
163
          qty          => $stocktaking_qty,
164
          comment      => $transfer->{comment},
165
          cutoff_date  => $transfer->{stocktaking_cutoff_date},
166
          chargenumber => $transfer->{chargenumber},
167
          bestbefore   => $transfer->{bestbefore},
168
        )->save;
169

  
170
      }
171

  
143 172
      push @trans_ids, $trans_id;
144 173
    }
145 174

  
......
1133 1162
more than one is supplied, it is guaranteed, that all are processed in the same
1134 1163
transaction.
1135 1164

  
1165
It is possible to record stocktakings within this transaction as well.
1166
This is useful if the transfer is the result of stocktaking (see also
1167
C<SL::Controller::Inventory>). To do so the parameters C<record_stocktaking>,
1168
C<stocktaking_qty> and C<stocktaking_cutoff_date> hava to be given.
1169
If stocktaking should be saved, then the transfer quantity can be zero. In this
1170
case no entry in inventory will be made, but only the stocktaking entry.
1171

  
1136 1172
Here is a full list of parameters. All "_id" parameters except oe and
1137 1173
orderitems can be called without id with RDB objects as well.
1138 1174

  
......
1199 1235

  
1200 1236
An expiration date. Note that this is not by default used by C<warehouse_report>.
1201 1237

  
1238
=item record_stocktaking
1239

  
1240
A boolean flag to indicate that a stocktaking entry should be saved.
1241

  
1242
=item stocktaking_qty
1243

  
1244
The quantity for the stocktaking entry.
1245

  
1246
=item stocktaking_cutoff_date
1247

  
1248
The cutoff date for the stocktaking entry.
1249

  
1202 1250
=back
1203 1251

  
1204 1252
=head2 create_assembly \%PARAMS, [ \%PARAMS, ... ]

Auch abrufbar als: Unified diff