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} = '';
|
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.