From: Niclas Zimmermann
Date: Mon, 3 Jun 2013 11:49:40 +0000 (+0200)
Subject: Merge branch 'gewicht'
X-Git-Tag: release-3.1.0beta1~388
X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/commitdiff_plain/c6b2257945060625bcb86fa7e2efd27c737480ff?hp=9be2155c4e7ee8ea2c000b8fb20110d5e9bd97cc
Merge branch 'gewicht'
Conflicts:
SL/Controller/ClientConfig.pm
SL/DB/MetaSetup/Default.pm
---
diff --git a/SL/Controller/ClientConfig.pm b/SL/Controller/ClientConfig.pm
index 1bfa615ac..148054e4e 100644
--- a/SL/Controller/ClientConfig.pm
+++ b/SL/Controller/ClientConfig.pm
@@ -55,6 +55,9 @@ sub action_edit {
$self->{warehouse_id} ||= $self->{WAREHOUSES}->[$max -1]->{id};
$self->{bin_id} ||= $self->{WAREHOUSES}->[$max -1]->{BINS}->[0]->{id};
}
+
+ $self->{show_weight} = SL::DB::Default->get->show_weight;
+
$self->render('client_config/form', title => $::locale->text('Client Configuration'));
}
@@ -76,12 +79,16 @@ sub action_save {
map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(sales_order_show_delete purchase_order_show_delete sales_delivery_order_show_delete purchase_delivery_order_show_delete);
+<<<<<<< HEAD
# undef warehouse_id if the empty value is selected
if ( ($::form->{warehouse_id} == 0) && ($::form->{bin_id} == 0) ) {
undef $::form->{warehouse_id};
undef $::form->{bin_id};
}
map { SL::DB::Default->get->update_attributes($_ => $::form->{$_}); } qw(warehouse_id bin_id);
+=======
+ SL::DB::Default->get->update_attributes('show_weight' => $::form->{show_weight});
+>>>>>>> gewicht
flash_later('info', $::locale->text('Client Configuration saved!'));
diff --git a/SL/DB/Helper/FlattenToForm.pm b/SL/DB/Helper/FlattenToForm.pm
index c2d8a5fe9..9754d2bb3 100644
--- a/SL/DB/Helper/FlattenToForm.pm
+++ b/SL/DB/Helper/FlattenToForm.pm
@@ -59,6 +59,7 @@ sub flatten_to_form {
$form->{"id_${idx}"} = $item->parts_id;
$form->{"partnumber_${idx}"} = $item->part->partnumber;
+ $form->{"weight_${idx}"} = $item->part->weight;
_copy($item, $form, '', "_${idx}", 0, qw(description project_id ship serialnumber pricegroup_id ordnumber cusordnumber unit
subtotal longdescription price_factor_id marge_price_factor approved_sellprice reqdate transdate));
_copy($item, $form, '', "_${idx}", $format_amounts, qw(qty sellprice marge_total marge_percent lastcost));
diff --git a/SL/DB/MetaSetup/Default.pm b/SL/DB/MetaSetup/Default.pm
index d6b6b8458..6c1e5ecfb 100644
--- a/SL/DB/MetaSetup/Default.pm
+++ b/SL/DB/MetaSetup/Default.pm
@@ -70,6 +70,7 @@ __PACKAGE__->meta->setup(
warehouse_id => { type => 'integer' },
bin_id => { type => 'integer' },
currency_id => { type => 'integer', not_null => 1 },
+ show_weight => { type => 'boolean', default => 'false', not_null => 1 },
],
primary_key_columns => [ 'id' ],
diff --git a/SL/DO.pm b/SL/DO.pm
index 04d5e84dd..a4677bbd9 100644
--- a/SL/DO.pm
+++ b/SL/DO.pm
@@ -810,7 +810,7 @@ sub order_details {
qw(runningnumber number description longdescription qty unit
partnotes serialnumber reqdate projectnumber projectdescription
si_runningnumber si_number si_description
- si_warehouse si_bin si_chargenumber si_bestbefore si_qty si_unit);
+ si_warehouse si_bin si_chargenumber si_bestbefore si_qty si_unit weight lineweight);
map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays);
@@ -819,6 +819,7 @@ sub order_details {
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
+ my $totalweight = 0;
my $sameitem = "";
foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
$i = $item->[0];
@@ -854,6 +855,13 @@ sub order_details {
push @{ $form->{TEMPLATE_ARRAYS}{projectdescription} },
$projectdescriptions{$form->{"project_id_$i"}};
+ my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"};
+ $totalweight += $lineweight;
+ push @{ $form->{TEMPLATE_ARRAYS}->{weight} }, $form->format_amount($myconfig, $form->{"weight_$i"}, 3);
+ push @{ $form->{TEMPLATE_ARRAYS}->{weight_nofmt} }, $form->{"weight_$i"};
+ push @{ $form->{TEMPLATE_ARRAYS}->{lineweight} }, $form->format_amount($myconfig, $lineweight, 3);
+ push @{ $form->{TEMPLATE_ARRAYS}->{lineweight_nofmt} }, $lineweight;
+
if ($form->{"assembly_$i"}) {
$sameitem = "";
@@ -907,6 +915,11 @@ sub order_details {
for @{ $ic_cvar_configs };
}
+ $form->{totalweight} = $form->format_amount($myconfig, $totalweight, 3);
+ $form->{totalweight_nofmt} = $totalweight;
+ my $defaults = AM->get_defaults();
+ $form->{weightunit} = $defaults->{weightunit};
+
$h_pg->finish();
$h_bin_wh->finish();
diff --git a/SL/IS.pm b/SL/IS.pm
index 8f91a2360..1dc1eff60 100644
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -154,7 +154,7 @@ sub invoice_details {
partnotes serialnumber reqdate sellprice listprice netprice
discount p_discount discount_sub nodiscount_sub
linetotal nodiscount_linetotal tax_rate projectnumber projectdescription
- price_factor price_factor_name partsgroup);
+ price_factor price_factor_name partsgroup weight lineweight);
push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
@@ -164,6 +164,7 @@ sub invoice_details {
map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays, @tax_arrays, @payment_arrays);
+ my $totalweight = 0;
foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
$i = $item->[0];
@@ -280,6 +281,13 @@ sub invoice_details {
push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
push(@{ $form->{TEMPLATE_ARRAYS}->{projectdescription} }, $projectdescriptions{$form->{"project_id_$i"}});
+ my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"};
+ $totalweight += $lineweight;
+ push @{ $form->{TEMPLATE_ARRAYS}->{weight} }, $form->format_amount($myconfig, $form->{"weight_$i"}, 3);
+ push @{ $form->{TEMPLATE_ARRAYS}->{weight_nofmt} }, $form->{"weight_$i"};
+ push @{ $form->{TEMPLATE_ARRAYS}->{lineweight} }, $form->format_amount($myconfig, $lineweight, 3);
+ push @{ $form->{TEMPLATE_ARRAYS}->{lineweight_nofmt} }, $lineweight;
+
@taxaccounts = split(/ /, $form->{"taxaccounts_$i"});
$taxrate = 0;
$taxdiff = 0;
@@ -366,6 +374,11 @@ sub invoice_details {
}
}
+ $form->{totalweight} = $form->format_amount($myconfig, $totalweight, 3);
+ $form->{totalweight_nofmt} = $totalweight;
+ my $defaults = AM->get_defaults();
+ $form->{weightunit} = $defaults->{weightunit};
+
foreach my $item (sort keys %taxaccounts) {
$tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
@@ -1941,7 +1954,7 @@ sub retrieve_item {
p.unit, p.assembly, p.onhand,
p.notes AS partnotes, p.notes AS longdescription,
p.not_discountable, p.formel, p.payment_id AS part_payment_id,
- p.price_factor_id,
+ p.price_factor_id, p.weight,
pfac.factor AS price_factor,
diff --git a/SL/OE.pm b/SL/OE.pm
index f18cb0651..0c0b76796 100644
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -1116,7 +1116,7 @@ sub order_details {
partnotes serialnumber reqdate sellprice listprice netprice
discount p_discount discount_sub nodiscount_sub
linetotal nodiscount_linetotal tax_rate projectnumber projectdescription
- price_factor price_factor_name partsgroup);
+ price_factor price_factor_name partsgroup weight lineweight);
push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
@@ -1124,6 +1124,7 @@ sub order_details {
map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays, @tax_arrays);
+ my $totalweight = 0;
my $sameitem = "";
foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) {
$i = $item->[0];
@@ -1238,6 +1239,13 @@ sub order_details {
push(@{ $form->{TEMPLATE_ARRAYS}->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
push(@{ $form->{TEMPLATE_ARRAYS}->{projectdescription} }, $projectdescriptions{$form->{"project_id_$i"}});
+ my $lineweight = $form->{"qty_$i"} * $form->{"weight_$i"};
+ $totalweight += $lineweight;
+ push @{ $form->{TEMPLATE_ARRAYS}->{weight} }, $form->format_amount($myconfig, $form->{"weight_$i"}, 3);
+ push @{ $form->{TEMPLATE_ARRAYS}->{weight_nofmt} }, $form->{"weight_$i"};
+ push @{ $form->{TEMPLATE_ARRAYS}->{lineweight} }, $form->format_amount($myconfig, $lineweight, 3);
+ push @{ $form->{TEMPLATE_ARRAYS}->{lineweight_nofmt} }, $lineweight;
+
my ($taxamount, $taxbase);
my $taxrate = 0;
@@ -1304,6 +1312,11 @@ sub order_details {
}
}
+ $form->{totalweight} = $form->format_amount($myconfig, $totalweight, 3);
+ $form->{totalweight_nofmt} = $totalweight;
+ my $defaults = AM->get_defaults();
+ $form->{weightunit} = $defaults->{weightunit};
+
my $tax = 0;
foreach $item (sort keys %taxaccounts) {
$tax += $taxamount = $form->round_amount($taxaccounts{$item}, 2);
diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl
index 4db8256c2..99b61f31e 100644
--- a/bin/mozilla/io.pl
+++ b/bin/mozilla/io.pl
@@ -123,6 +123,10 @@ sub display_row {
my ($stock_in_out, $stock_in_out_title);
+ my $defaults = AM->get_defaults();
+ $form->{show_weight} = $defaults->{show_weight};
+ $form->{weightunit} = $defaults->{weightunit};
+
my $is_purchase = (first { $_ eq $form->{type} } qw(request_quotation purchase_order purchase_delivery_order)) || ($form->{script} eq 'ir.pl');
my $show_min_order_qty = first { $_ eq $form->{type} } qw(request_quotation purchase_order);
my $is_delivery_order = $form->{type} =~ /_delivery_order$/;
@@ -141,7 +145,7 @@ sub display_row {
}
# column_index
- my @header_sort = qw(runningnumber partnumber description ship qty unit sellprice_pg sellprice discount linetotal);
+ my @header_sort = qw(runningnumber partnumber description ship qty unit weight sellprice_pg sellprice discount linetotal);
my @HEADER = (
{ id => 'runningnumber', width => 5, value => $locale->text('No.'), display => 1, },
{ id => 'partnumber', width => 8, value => $locale->text('Number'), display => 1, },
@@ -150,6 +154,7 @@ sub display_row {
{ id => 'qty', width => 5, value => $locale->text('Qty'), display => 1, },
{ id => 'price_factor', width => 5, value => $locale->text('Price Factor'), display => !$is_delivery_order, },
{ id => 'unit', width => 5, value => $locale->text('Unit'), display => 1, },
+ { id => 'weight', width => 5, value => $locale->text('Weight'), display => $defaults->{show_weight}, },
{ id => 'serialnr', width => 10, value => $locale->text('Serial No.'), display => 0, },
{ id => 'projectnr', width => 10, value => $locale->text('Project'), display => 0, },
{ id => 'sellprice', width => 15, value => $locale->text('Price'), display => !$is_delivery_order, },
@@ -187,12 +192,13 @@ sub display_row {
my $deliverydate = $locale->text('Required by');
# special alignings
- my %align = map { $_ => 'right' } qw(qty ship right sellprice_pg discount linetotal stock_in_out);
+ my %align = map { $_ => 'right' } qw(qty ship right sellprice_pg discount linetotal stock_in_out weight);
my %nowrap = map { $_ => 1 } qw(description unit);
$form->{marge_total} = 0;
$form->{sellprice_total} = 0;
$form->{lastcost_total} = 0;
+ $form->{totalweight} = 0;
my %projectnumber_labels = ();
my @projectnumber_values = ("");
@@ -205,6 +211,8 @@ sub display_row {
_update_ship() if ($is_s_p_order);
_update_custom_variables();
+ my $totalweight = 0;
+
# rows
my @ROWS;
@@ -246,6 +254,7 @@ sub display_row {
} else {
$column_data{price_factor} = ' ';
}
+ $form->{"weight_$i"} *= AM->convert_unit($form->{"selected_unit_$i"}, $form->{"partunit_$i"}, $all_units) || 1;
$column_data{"unit"} = AM->unit_select_html($all_units, "unit_$i", $this_unit, $form->{"id_$i"} ? $form->{"unit_$i"} : undef);
# / unit ending
@@ -325,6 +334,8 @@ sub display_row {
$column_data{linetotal} = $form->format_amount(\%myconfig, $linetotal, 2);
$column_data{bin} = $form->{"bin_$i"};
+ $column_data{weight} = $form->format_amount(\%myconfig, $form->{"qty_$i"} * $form->{"weight_$i"}, 3) . ' ' . $defaults->{weightunit} if $defaults->{show_weight};
+
if ($is_delivery_order) {
$column_data{stock_in_out} = calculate_stock_in_out($i);
}
@@ -389,6 +400,9 @@ sub display_row {
if $form->{"id_$i"} && ($form->{type} =~ /^sales_/ || $form->{type} =~ /invoice/) ;
# / marge calculations ending
+# Calculate total weight
+ $totalweight += ($form->{"qty_$i"} * $form->{"weight_$i"});
+
# calculate onhand
if ($form->{"id_$i"}) {
my $part = IC->get_basic_part_info(id => $form->{"id_$i"});
@@ -416,7 +430,7 @@ sub display_row {
map { ($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } map { $_."_$i" }
(qw(orderitems_id bo pricegroup_old price_old id inventory_accno bin partsgroup partnotes
income_accno expense_accno listprice assembly taxaccounts ordnumber transdate cusordnumber
- longdescription basefactor marge_absolut marge_percent marge_price_factor), @hidden_vars)
+ longdescription basefactor marge_absolut marge_percent marge_price_factor weight), @hidden_vars)
);
map { $form->{"${_}_base"} += $linetotal } (split(/ /, $form->{"taxaccounts_$i"}));
@@ -429,6 +443,8 @@ sub display_row {
push @ROWS, { ROW1 => \@ROW1, ROW2 => \@ROW2, HIDDENS => \@HIDDENS, colspan => $colspan, error => $form->{"row_error_$i"}, };
}
+ $form->{totalweight} = $totalweight;
+
print $form->parse_html_template('oe/sales_order', { ROWS => \@ROWS,
HEADER => \@HEADER,
});
@@ -1789,6 +1805,7 @@ sub _update_part_information {
my $info = $form->{PART_INFORMATION}->{$form->{"id_${i}"}} || { };
$form->{"partunit_${i}"} = $info->{unit};
+ $form->{"weight_$i"} = $info->{weight};
}
$main::lxdebug->leave_sub();
diff --git a/locale/de/all b/locale/de/all
index c416d452e..5136a93f7 100755
--- a/locale/de/all
+++ b/locale/de/all
@@ -1822,6 +1822,8 @@ $self->{texts} = {
'Show old dunnings' => 'Alte Mahnungen anzeigen',
'Show overdue sales quotations and requests for quotations...' => 'Ãberfällige Angebote und Preisanfragen anzeigen...',
'Show settings' => 'Einstellungen anzeigen',
+ 'Show the weights of articles and the total weight in orders, invoices and delivery notes?' => 'Sollen Warengewichte und Gesamtgewicht in Aufträgen, Rechnungen und Lieferscheinen angezeigt werden?',
+ 'Show weights' => 'Gewichte anzeigen',
'Show your TODO list after loggin in' => 'Aufgabenliste nach dem Anmelden anzeigen',
'Signature' => 'Unterschrift',
'Since bin is not enforced in the parts data, please specify a bin where goods without a specified bin will be put.' => 'Da Lagerplätze kein Pflichtfeld sind, geben Sie bitte einen Lagerplatz an, in dem Waren ohne spezifizierten Lagerplatz eingelagert werden sollen.',
@@ -2202,6 +2204,7 @@ $self->{texts} = {
'Total Fees' => 'Kumulierte Gebühren',
'Total stock value' => 'Gesamter Bestandswert',
'Total sum' => 'Gesamtsumme',
+ 'Total weight' => 'Gesamtgewicht',
'Totals' => 'Summen',
'Trade Discount' => 'Rabatt',
'Trans Id' => 'Trans-ID',
diff --git a/sql/Pg-upgrade2/gewichte.sql b/sql/Pg-upgrade2/gewichte.sql
new file mode 100644
index 000000000..b8d03efd2
--- /dev/null
+++ b/sql/Pg-upgrade2/gewichte.sql
@@ -0,0 +1,6 @@
+-- @tag: gewichte
+-- @description: Je nach Mandantenkonfiguration können Warengewichte in Angeboten/Aufträgen/Lieferscheinen/Rechnungen angezeigt werden oder nicht.
+-- @depends: release_3_0_0
+-- @charset: utf-8
+
+ALTER TABLE defaults ADD show_weight BOOLEAN NOT NULL DEFAULT FALSE;
diff --git a/templates/webpages/client_config/form.html b/templates/webpages/client_config/form.html
index dd9856353..bcbf845be 100644
--- a/templates/webpages/client_config/form.html
+++ b/templates/webpages/client_config/form.html
@@ -198,6 +198,18 @@
+
+ | [% 'Weight' | $T8 %] |
+
+
+ | [% 'Show weights' | $T8 %] |
+
+ [% L.yes_no_tag('show_weight', SELF.show_weight) %]
+ |
+
+ [% 'Show the weights of articles and the total weight in orders, invoices and delivery notes?' | $T8 %]
+ |
+
diff --git a/templates/webpages/do/form_footer.html b/templates/webpages/do/form_footer.html
index 78ad35a41..d87b156ca 100644
--- a/templates/webpages/do/form_footer.html
+++ b/templates/webpages/do/form_footer.html
@@ -20,6 +20,26 @@
+[%- IF show_weight %]
+
+
+
+
+
+
+
+ | [% 'Total weight' | $T8 %] |
+
+ [% LxERP.format_amount(totalweight, 3) %] [% HTML.escape(weightunit) %]
+ |
+
+
+ |
+
+
+ |
+
+[%- END %]
diff --git a/templates/webpages/ir/form_footer.html b/templates/webpages/ir/form_footer.html
index 8538fd42d..66758003d 100644
--- a/templates/webpages/ir/form_footer.html
+++ b/templates/webpages/ir/form_footer.html
@@ -33,6 +33,18 @@
[%- END %]
+[%- IF show_weight %]
+
+
+
+ | [% 'Total weight' | $T8 %] |
+
+ [% LxERP.format_amount(totalweight) %] [% HTML.escape(weightunit) %]
+ |
+
+
+ |
+[%- END %]
[%- IF taxaccounts %]
diff --git a/templates/webpages/is/form_footer.html b/templates/webpages/is/form_footer.html
index 52179c295..28fafaa09 100644
--- a/templates/webpages/is/form_footer.html
+++ b/templates/webpages/is/form_footer.html
@@ -43,6 +43,18 @@
[%- END %]
|
+[%- IF show_weight %]
+
+
+
+ | [% 'Total weight' | $T8 %] |
+
+ [% LxERP.format_amount(totalweight) %] [% HTML.escape(weightunit) %]
+ |
+
+
+ |
+[%- END %]
diff --git a/templates/webpages/oe/form_footer.html b/templates/webpages/oe/form_footer.html
index c9078ef98..87c1993a7 100644
--- a/templates/webpages/oe/form_footer.html
+++ b/templates/webpages/oe/form_footer.html
@@ -47,6 +47,18 @@
[%- END %]
|
+ [%- IF show_weight %]
+
+
+
+ | [% 'Total weight' | $T8 %] |
+
+ [% LxERP.format_amount(totalweight, 3) %] [% HTML.escape(weightunit) %]
+ |
+
+
+ |
+ [%- END %]
[%- IF is_sales %]
|