Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 01f65005

Von Jan Büren vor mehr als 3 Jahren hinzugefügt

  • ID 01f6500562203f8b7e0ed13d6b969c1ac47f51e0
  • Vorgänger a96b6e95
  • Nachfolger 79b75e07

Erzeugnis fertigen -> Zustand in Hilfstabelle dokumentieren

Unterschiede anzeigen:

SL/DB/Helper/Mappings.pm
99 99
  ar                             => 'invoice',
100 100
  ap                             => 'purchase_invoice',
101 101
  assembly                       => 'assembly',
102
  assembly_inventory_part        => 'assembly_inventory_part',
102 103
  assortment_items               => 'assortment_item',
103 104
  background_jobs                => 'background_job',
104 105
  background_job_histories       => 'background_job_history',
SL/DB/MetaSetup/AssemblyInventoryPart.pm
1
# This file has been auto-generated. Do not modify it; it will be overwritten
2
# by rose_auto_create_model.pl automatically.
3
package SL::DB::AssemblyInventoryPart;
4

  
5
use strict;
6

  
7
use parent qw(SL::DB::Object);
8

  
9
__PACKAGE__->meta->table('assembly_inventory_part');
10

  
11
__PACKAGE__->meta->columns(
12
  inventory_assembly_id => { type => 'integer', not_null => 1 },
13
  inventory_part_id     => { type => 'integer', not_null => 1 },
14
  itime                 => { type => 'timestamp', default => 'now()' },
15
  mtime                 => { type => 'timestamp' },
16
);
17

  
18
__PACKAGE__->meta->primary_key_columns([ 'inventory_assembly_id', 'inventory_part_id' ]);
19

  
20
__PACKAGE__->meta->unique_keys([ 'inventory_part_id', 'inventory_assembly_id' ]);
21

  
22
__PACKAGE__->meta->allow_inline_column_values(1);
23

  
24
__PACKAGE__->meta->foreign_keys(
25
  inventory_assembly => {
26
    class       => 'SL::DB::Inventory',
27
    key_columns => { inventory_assembly_id => 'id' },
28
  },
29

  
30
  inventory_part => {
31
    class       => 'SL::DB::Inventory',
32
    key_columns => { inventory_part_id => 'id' },
33
  },
34
);
35

  
36
1;
37
;
SL/WH.pm
198 198
  my %params   = @_;
199 199
  Common::check_params(\%params, qw(assembly_id dst_warehouse_id login qty unit dst_bin_id chargenumber bestbefore comment));
200 200

  
201
#  my $maxcreate=WH->check_assembly_max_create(assembly_id =>$params{'assembly_id'}, dbh => $my_dbh);
202

  
203 201
  my $myconfig = \%main::myconfig;
204 202
  my $form     = $main::form;
205 203
  my $kannNichtFertigen ="";  # Falls leer dann erfolgreich
......
234 232

  
235 233
    my $sth_part_qty_assembly = prepare_execute_query($form, $dbh, $query, $params{assembly_id});
236 234

  
235
    my @trans_ids;
236
    my $query_trans_id      = qq|SELECT nextval('inventory_id_seq')|;
237
    my $query_trans_ids     = qq|INSERT INTO assembly_inventory_part (inventory_assembly_id, inventory_part_id) VALUES (?, ?)|;
238
    my $sth_query_trans_ids = prepare_query($form, $dbh, $query_trans_ids);
239

  
237 240
    # Hier wird das prepared Statement für die Schleife über alle Lagerplätze vorbereitet
238 241
    my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore, comment, employee_id, qty,
239
                             trans_id, trans_type_id, shippingdate)
240
                             VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
242
                             trans_id, id, trans_type_id, shippingdate)
243
                             VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), ?,
241 244
                             (SELECT id FROM transfer_type WHERE direction = 'out' AND description = 'used'),
242 245
                             (SELECT current_date))|;
243 246
    my $sthTransferPartSQL   = prepare_query($form, $dbh, $transferPartSQL);
......
278 281
        my $temppart_bestbefore   = localtime();
279 282
        my $temppart_qty          = $partsQTY * -1;
280 283

  
284
        my ($trans_id)     = selectrow_query($form, $dbh, $query_trans_id);
285
        push @trans_ids, $trans_id;
281 286
        do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $currentPart_WH_ID,
282 287
                       $temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' .
283
                       $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty);
288
                       $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty,
289
                       $trans_id);
284 290
        next;
285 291
      }
286 292
      # Überprüfen, ob diese Anzahl gefertigt werden kann
......
325 331
                                              # wenn * -1 als berechnung in der parameter-übergabe angegeben wird.
326 332
                                              # Dieser Wert IST und BLEIBT positiv!! Hilfe.
327 333
                                              # Liegt das daran, dass dieser Wert aus einem SQL-Statement stammt?
334
          my ($trans_id)     = selectrow_query($form, $dbh, $query_trans_id);
335
          push @trans_ids, $trans_id;
328 336
          do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $currentPart_WH_ID,
329 337
                       $temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' .
330
                       $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty);
338
                       $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty, $trans_id);
331 339

  
332 340
          # hier ist noch ein fehler am besten mit definierten erzeugnissen debuggen 02/2009 jb
333 341
          # idee: ausbuch algorithmus mit rekursion lösen und an- und abschaltbar machen
......
335 343
          # auf jeden fall war der internal-server-error nach aktivierung von strict und warnings plus ein paar my-definitionen weg
336 344
        } else { # okay, wir haben weniger oder gleich Waren die wir wegbuchen müssen, wir können also aufhören
337 345
          $tmpPartsQTY *=-1;
346
          my ($trans_id)     = selectrow_query($form, $dbh, $query_trans_id);
347
          push @trans_ids, $trans_id;
338 348
          do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $currentPart_WH_ID,
339 349
                       $temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' .
340
                       $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $tmpPartsQTY);
350
                       $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $tmpPartsQTY, $trans_id);
341 351
          last; # beendet die schleife (springt zum letzten element)
342 352
        }
343 353
      }  # ende while SELECT SUM(qty), bin_id, chargenumber, bestbefore   FROM inventory  WHERE warehouse_id
......
354 364

  
355 365
    # soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ...
356 366
    my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore,
357
                                                        comment, employee_id, qty, trans_id, trans_type_id, shippingdate)
358
                                 VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
367
                                                        comment, employee_id, qty, trans_id, id, trans_type_id, shippingdate)
368
                                 VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), ?,
359 369
                                 (SELECT id FROM transfer_type WHERE direction = 'in' AND description = 'assembled'),
360 370
                                 (select current_date))|;
361 371
    my $sthTransferAssemblySQL   = prepare_query($form, $dbh, $transferAssemblySQL);
372
    my ($assembly_trans_id)      = selectrow_query($form, $dbh, $query_trans_id);
362 373
    do_statement($form, $sthTransferAssemblySQL, $transferAssemblySQL, $params{assembly_id}, $params{dst_warehouse_id},
363
                 $params{dst_bin_id}, $params{chargenumber}, conv_date($params{bestbefore}), $params{comment}, $params{login}, $params{qty});
374
                 $params{dst_bin_id}, $params{chargenumber}, conv_date($params{bestbefore}), $params{comment}, $params{login}, $params{qty}, $assembly_trans_id);
375

  
376
    # save inventory transactions for this assembly
377
    for my $part_id (@trans_ids) {
378
      do_statement($form, $sth_query_trans_ids, $query_trans_ids, $assembly_trans_id, $part_id);
379
    }
380

  
364 381
    1;
365 382
  }) or do { return $kannNichtFertigen };
366 383

  
sql/Pg-upgrade2/assembly_inventory_part.sql
1
-- @tag: assembly_inventory_part
2
-- @description: Tabelle für die wirklich verbauten Einzelteile eines Erzeugnis
3
-- @depends: warehouse release_3_5_6_1
4

  
5

  
6
CREATE TABLE assembly_inventory_part (
7
       inventory_part_id        INTEGER        REFERENCES inventory(id),
8
       inventory_assembly_id    INTEGER        REFERENCES inventory(id),
9
       itime                    TIMESTAMP      DEFAULT now(),
10
       mtime                    TIMESTAMP,
11

  
12
       PRIMARY KEY (inventory_assembly_id, inventory_part_id)
13
);
14

  
15
CREATE TRIGGER mtime_assembly_inventory_part BEFORE UPDATE ON assembly_inventory_part FOR EACH ROW EXECUTE PROCEDURE set_mtime();

Auch abrufbar als: Unified diff