Revision 34035b33
Von Martin Helmling martin.helmling@octosoft.eu vor etwa 8 Jahren hinzugefügt
bin/mozilla/wh.pl | ||
---|---|---|
674 | 674 |
$form->{title} = $locale->text("WHJournal"); |
675 | 675 |
$form->{sort} ||= 'date'; |
676 | 676 |
|
677 |
$form->{report_generator_output_format} = 'HTML' if !$form->{report_generator_output_format}; |
|
678 |
|
|
677 | 679 |
my %filter; |
678 | 680 |
my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber bestbefore trans_type comment qty employee oe_id projectnumber); |
679 | 681 |
|
... | ... | |
709 | 711 |
'chargenumber' => { 'text' => $locale->text('Charge Number'), }, |
710 | 712 |
'bestbefore' => { 'text' => $locale->text('Best Before'), }, |
711 | 713 |
'qty' => { 'text' => $locale->text('Qty'), }, |
714 |
'unit' => { 'text' => $locale->text('Part Unit'), }, |
|
715 |
'partunit' => { 'text' => $locale->text('Unit'), }, |
|
712 | 716 |
'employee' => { 'text' => $locale->text('Employee'), }, |
713 | 717 |
'projectnumber' => { 'text' => $locale->text('Project Number'), }, |
714 | 718 |
'oe_id' => { 'text' => $locale->text('Document'), }, |
715 | 719 |
); |
716 | 720 |
|
717 | 721 |
my $href = build_std_url('action=generate_journal', grep { $form->{$_} } @hidden_variables); |
718 |
map { $column_defs{$_}->{link} = $href . "&sort=${_}&order=" . Q($_ eq $form->{sort} ? 1 - $form->{order} : $form->{order}) } @columns; |
|
722 |
my $page = $::form->{page} || 1; |
|
723 |
map { $column_defs{$_}->{link} = $href ."&page=".$page. "&sort=${_}&order=" . Q($_ eq $form->{sort} ? 1 - $form->{order} : $form->{order}) } @columns; |
|
719 | 724 |
|
720 | 725 |
my %column_alignment = map { $_ => 'right' } qw(qty); |
721 | 726 |
|
... | ... | |
747 | 752 |
'purchase_invoice' => { script => 'ir', title => $locale->text('Purchase Invoice') }, |
748 | 753 |
); |
749 | 754 |
|
755 |
my $allrows = 0; |
|
756 |
$allrows = 1 if $form->{report_generator_output_format} ne 'HTML' ; |
|
757 |
|
|
758 |
# manual paginating |
|
759 |
my $pages = {}; |
|
760 |
$pages->{per_page} = $::form->{per_page} || 15; |
|
761 |
my $first_nr = ($page - 1) * $pages->{per_page}; |
|
762 |
my $last_nr = $first_nr + $pages->{per_page}; |
|
763 |
my $idx = 0; |
|
764 |
|
|
750 | 765 |
foreach my $entry (@contents) { |
751 | 766 |
$entry->{qty} = $form->format_amount_units('amount' => $entry->{qty}, |
752 | 767 |
'part_unit' => $entry->{partunit}, |
... | ... | |
774 | 789 |
} |
775 | 790 |
} |
776 | 791 |
|
777 |
$report->add_data($row); |
|
792 |
if ( $allrows || ($idx >= $first_nr && $idx < $last_nr )) { |
|
793 |
$report->add_data($row); |
|
794 |
} |
|
795 |
$idx++; |
|
778 | 796 |
} |
779 | 797 |
|
798 |
if ( ! $allrows ) { |
|
799 |
$pages->{max} = SL::DB::Helper::Paginated::ceil($idx, $pages->{per_page}) || 1; |
|
800 |
$pages->{page} = $page < 1 ? 1: $page > $pages->{max} ? $pages->{max}: $page; |
|
801 |
$pages->{common} = [ grep { $_->{visible} } @{ SL::DB::Helper::Paginated::make_common_pages($pages->{page}, $pages->{max}) } ]; |
|
802 |
|
|
803 |
$report->set_options('raw_bottom_info_text' => $form->parse_html_template('common/paginate', |
|
804 |
{ 'pages' => $pages , 'base_url' => $href}) ); |
|
805 |
} |
|
780 | 806 |
$report->generate_with_headers(); |
781 | 807 |
|
782 | 808 |
$main::lxdebug->leave_sub(); |
... | ... | |
822 | 848 |
|
823 | 849 |
$form->{title} = $locale->text("Report about warehouse contents"); |
824 | 850 |
$form->{sort} ||= 'partnumber'; |
851 |
$form->{sort} ||= 'partunit'; |
|
825 | 852 |
my $sort_col = $form->{sort}; |
826 | 853 |
|
827 | 854 |
my %filter; |
828 | 855 |
my @columns = qw(warehousedescription bindescription partnumber partdescription chargenumber bestbefore qty stock_value); |
829 | 856 |
|
830 | 857 |
# filter stuff |
831 |
map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber bestbefore date include_invalid_warehouses); |
|
858 |
map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partstypes_id partnumber description chargenumber bestbefore date include_invalid_warehouses);
|
|
832 | 859 |
|
833 | 860 |
# show filter stuff also in report |
834 | 861 |
my @options; |
... | ... | |
862 | 889 |
|
863 | 890 |
$form->{subtotal} = '' if (!first { $_ eq $sort_col } qw(partnumber partdescription)); |
864 | 891 |
|
892 |
$form->{report_generator_output_format} = 'HTML' if !$form->{report_generator_output_format}; |
|
865 | 893 |
my $report = SL::ReportGenerator->new(\%myconfig, $form); |
866 | 894 |
|
867 | 895 |
my @hidden_variables = map { "l_${_}" } @columns; |
868 |
push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber bestbefore qty_op qty qty_unit l_warehousedescription l_bindescription);
|
|
896 |
push @hidden_variables, qw(warehouse_id bin_id partnumber partstypes_id description chargenumber bestbefore qty_op qty qty_unit partunit l_warehousedescription l_bindescription);
|
|
869 | 897 |
push @hidden_variables, qw(include_empty_bins subtotal include_invalid_warehouses date); |
870 | 898 |
|
871 | 899 |
my %column_defs = ( |
... | ... | |
876 | 904 |
'chargenumber' => { 'text' => $locale->text('Charge Number'), }, |
877 | 905 |
'bestbefore' => { 'text' => $locale->text('Best Before'), }, |
878 | 906 |
'qty' => { 'text' => $locale->text('Qty'), }, |
907 |
'partunit' => { 'text' => $locale->text('Unit'), }, |
|
879 | 908 |
'stock_value' => { 'text' => $locale->text('Stock value'), }, |
880 | 909 |
); |
881 | 910 |
|
882 | 911 |
my $href = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables); |
883 |
map { $column_defs{$_}->{link} = $href . "&sort=${_}&order=" . Q($_ eq $sort_col ? 1 - $form->{order} : $form->{order}) } @columns; |
|
912 |
my $page = $::form->{page} || 1; |
|
913 |
map { $column_defs{$_}->{link} = $href . "&page=".$page."&sort=${_}&order=" . Q($_ eq $sort_col ? 1 - $form->{order} : $form->{order}) } @columns; |
|
884 | 914 |
|
885 | 915 |
my %column_alignment = map { $_ => 'right' } qw(qty stock_value); |
886 | 916 |
|
... | ... | |
910 | 940 |
|
911 | 941 |
my $total_stock_value = 0; |
912 | 942 |
|
943 |
my $allrows = 0; |
|
944 |
$allrows = 1 if $form->{report_generator_output_format} ne 'HTML' ; |
|
945 |
|
|
946 |
# manual paginating |
|
947 |
my $pages = {}; |
|
948 |
$pages->{per_page} = $::form->{per_page} || 20; |
|
949 |
my $first_nr = ($page - 1) * $pages->{per_page}; |
|
950 |
my $last_nr = $first_nr + $pages->{per_page}; |
|
951 |
|
|
913 | 952 |
foreach my $entry (@contents) { |
914 | 953 |
map { $subtotals{$_} += $entry->{$_} } @subtotals_columns; |
915 | 954 |
$total_stock_value += $entry->{stock_value} * 1; |
916 |
|
|
917 |
$entry->{qty} = $form->format_amount_units('amount' => $entry->{qty}, |
|
918 |
'part_unit' => $entry->{partunit}, |
|
919 |
'conv_units' => 'convertible'); |
|
955 |
$entry->{qty} = $form->format_amount(\%myconfig, $entry->{qty}); |
|
956 |
# $entry->{qty} = $form->format_amount_units('amount' => $entry->{qty},
|
|
957 |
# 'part_unit' => $entry->{partunit},
|
|
958 |
# 'conv_units' => 'convertible');
|
|
920 | 959 |
$entry->{stock_value} = $form->format_amount(\%myconfig, $entry->{stock_value} * 1, 2); |
921 | 960 |
|
922 | 961 |
my $row_set = [ { map { $_ => { 'data' => $entry->{$_}, 'align' => $column_alignment{$_} } } @columns } ]; |
... | ... | |
926 | 965 |
|| ($entry->{$sort_col} ne $contents[$idx + 1]->{$sort_col}))) { |
927 | 966 |
|
928 | 967 |
my $row = { map { $_ => { 'data' => '', 'class' => 'listsubtotal', 'align' => $column_alignment{$_}, } } @columns }; |
929 |
$row->{qty}->{data} = $form->format_amount_units('amount' => $subtotals{qty} * 1, |
|
930 |
'part_unit' => $entry->{partunit}, |
|
931 |
'conv_units' => 'convertible'); |
|
968 |
$row->{qty}->{data} = $form->format_amount(\%myconfig, $subtotals{qty}); |
|
969 |
# $row->{qty}->{data} = $form->format_amount_units('amount' => $subtotals{qty} * 1, |
|
970 |
# 'part_unit' => $entry->{partunit}, |
|
971 |
# 'conv_units' => 'convertible'); |
|
932 | 972 |
$row->{stock_value}->{data} = $form->format_amount(\%myconfig, $subtotals{stock_value} * 1, 2); |
933 | 973 |
|
934 | 974 |
%subtotals = map { $_ => 0 } @subtotals_columns; |
... | ... | |
936 | 976 |
push @{ $row_set }, $row; |
937 | 977 |
} |
938 | 978 |
|
939 |
$report->add_data($row_set); |
|
940 |
|
|
979 |
if ( $allrows || ($idx >= $first_nr && $idx < $last_nr )) { |
|
980 |
$report->add_data($row_set); |
|
981 |
} |
|
941 | 982 |
$idx++; |
942 | 983 |
} |
943 | 984 |
|
Auch abrufbar als: Unified diff
Verbrauchsbericht: Lager->Berichte->Lagerentnahme
Ein Bericht über jährliche/quartalsweise/monatliche Lagerentnahme
Anforderungen waren:
1. Zahlen im Bericht einheitlich Formatieren (mit Tausender-Trennpunkt)
2. Spaltenüberschrift:
- "Lagerverbrauch" (Letzte zwei Spalten)
> "Entnommen (ohne Korrekturen)"
"Verbrauch monatlich" (vorletzte Spalte)> "Im Zeitraum"
"Ø Verbr." (letzte Spalte -> "Ø mtl."3. In der Suchmaske unter "Vorgewählte Zeiträume" sollte das aktuelle Jahr vorgegeben sein.
4. Filter "Freier Zeitraum" funktioniert nicht: "Es wurden keine Daten gefunden."
Bei der Berechnung des "Ø mtl." wird Folgendes beachtet:
Falls ein Zeitraum angegeben ist mit einem Enddatum in der Zukunft (z.B. auch bei "Jährlich" oder "Quartal")
muss der Bezugszeitraum mit dem aktuellen Datum (heute) begrenzt werden, ansonsten wird der Durchschnitt falsch berechnet!
Bei Zeitraum kleiner einem Monat, wird Durchschnitt des Entnommenen über einen Monat berechnet
Bei PDF/CSV Export müssen alle Werte berechnet werden
Wegen PDF-Erzeugung ausserhalb Papier X-Rand default reduziert auf 0,8 cm