Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8453789b

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

  • ID 8453789b42c168bbaec52a87527191a25d9b2080
  • Vorgänger 27fe7b11
  • Nachfolger 0820aac0

Erzeugnisse zerlegen über eindeutige trans_id

Durch 639c7f18be0 ist die Hilfstabelle für die Zerlegung
von Erzeugnissen nicht mehr notwendig und das Verfahren
kann entsprechend simpler implementiert werden.

Unterschiede anzeigen:

SL/WH.pm
530 530
     };
531 531

  
532 532
  $form->{l_classification_id}  = 'Y';
533
  $form->{l_id}                 = 'Y';
533
  $form->{l_trans_id}           = 'Y';
534 534
  $form->{l_part_type}          = 'Y';
535 535
  $form->{l_itime}              = 'Y';
536 536
  $form->{l_invoice_id} = $form->{l_oe_id} if $form->{l_oe_id};
......
1346 1346

  
1347 1347
  There has to be at least one data set in the table assembly referenced to this assembly_id.
1348 1348

  
1349
=item Assembly cannot be destroyed or disassembled
1349
=item Assembly can be disassembled
1350 1350

  
1351 1351
  Assemblies are like cakes. You cannot disassemble it. NEVER.
1352
  No negative nor zero qty's are valid inputs.
1352
  But if your assembly is a mechanical cake you may unscrew it.
1353
  Assemblies are created in one transaction therefore you can
1354
  safely rely on the trans_id in inventory to disassemble the
1355
  created assemblies (see action disassemble_assembly in wh.pl).
1353 1356

  
1354 1357
=item The assembly item(s) have to be in the same warehouse
1355 1358

  
bin/mozilla/wh.pl
51 51
use SL::Presenter::Tag qw(checkbox_tag);
52 52
use SL::Presenter::Part;
53 53

  
54
use SL::DB::AssemblyInventoryPart;
55 54
use SL::DB::Part;
56 55

  
57 56
use Data::Dumper;
......
560 559

  
561 560
  croak("No assembly ids") unless scalar @{ $form->{ids}} > 0;
562 561

  
563
  # fail safe, only allow disassemble in certain intervals
564
  my $undo_date  = DateTime->today->subtract(days => $::instance_conf->get_undo_transfer_interval);
565

  
566
  foreach my $assembly_id (@{ $::form->{ids}} )  {
567
    my $assembly_parts;
568
    $assembly_parts  = SL::DB::Manager::AssemblyInventoryPart->get_all(where => [ inventory_assembly_id => $assembly_id ]);
569
    $form->show_generic_error(t8('No relations found for #1', $assembly_id)) unless $assembly_parts;
570
    # check first entry for insertdate
571
    # everything in one transaction
572
    my $db = SL::DB::Inventory->new->db;
573
    $db->with_transaction(sub {
574
      my ($assembly_entry, $part_entry);
575
      foreach my $assembly_part (@{ $assembly_parts }) {
576
        die("No valid entry found") unless (ref($assembly_part)  eq 'SL::DB::AssemblyInventoryPart');
577
        # fail safe undo date
578
        die("Invalid time interval") unless DateTime->compare($assembly_part->itime, $undo_date);
579

  
580
        $assembly_entry //= $assembly_part->assembly;
581
        $part_entry       = $assembly_part->part;
582
        $assembly_part->delete;
583
        $part_entry->delete;
584
      }
585
      flash_later('info', t8("Disassembly successful for #1",  $assembly_entry->part->partnumber));
562
  # everything in one transaction
563
  my $db = SL::DB::Inventory->new->db;
564
  $db->with_transaction(sub {
586 565

  
587
      $assembly_entry->delete;
588

  
589
      1;
566
    foreach my $trans_id (@{ $::form->{ids}} )  {
567
      SL::DB::Manager::Inventory->delete_all(where => [ trans_id => $trans_id ]);
568
      flash_later('info', t8("Disassembly successful for trans_id #1",  $trans_id));
569
    }
590 570

  
591
    }) || die t8('error while disassembling assembly #1 : #2', $assembly_id)  . $db->error . "\n";
571
    1;
572
  }) || die t8('error while disassembling for trans_ids #1 : #2', $form->{ids})  . $db->error . "\n";
592 573

  
593
  }
594 574
  $main::lxdebug->leave_sub();
595 575
  $form->redirect;
596 576
}
......
670 650
    $last_nr        = $pages->{per_page};
671 651
  }
672 652

  
653
  my $old_l_trans_id = $form->{l_trans_id};
673 654
  my @contents  = WH->get_warehouse_journal(%filter);
655
  $form->{l_trans_id} = $old_l_trans_id;
656

  
674 657
  # get maxcount
675 658
  if (!$form->{maxrows}) {
676 659
    $form->{maxrows} = scalar @contents ;
......
752 735
                  );
753 736

  
754 737
  my $idx       = 0;
755

  
738
  my $undo_date  = DateTime->today->subtract(days => $::instance_conf->get_undo_transfer_interval);
756 739
  foreach my $entry (@contents) {
757 740
    $entry->{type_and_classific} = SL::Presenter::Part::type_abbreviation($entry->{part_type}) .
758 741
                                   SL::Presenter::Part::classification_abbreviation($entry->{classification_id});
......
768 751
      };
769 752
    }
770 753

  
771
    $row->{ids}->{raw_data} = checkbox_tag("ids[]", value => $entry->{id}, "data-checkall" => 1) if $entry->{assembled};
772

  
754
    if ($entry->{assembled}) {
755
      my $insertdate = DateTime->from_kivitendo($entry->{shippingdate});
756
      if (ref $undo_date eq 'DateTime' && ref $insertdate eq 'DateTime') {
757
        my $undo_assembly = DateTime->compare($insertdate, $undo_date) == 1 ? 1 : 0;
758
        $row->{ids}->{raw_data} = checkbox_tag("ids[]", value => $entry->{trans_id}, "data-checkall" => 1) if $undo_assembly;
759
      }
760
    }
773 761
    $row->{trans_type}->{raw_data} = $entry->{trans_type};
774 762
    if ($form->{l_oe_id}) {
775 763
      $row->{oe_id}->{data} = '';

Auch abrufbar als: Unified diff