]> wagnertech.de Git - mfinanz.git/blobdiff - SL/IC.pm
Merge branch 'master' of github.com:kivitendo/kivitendo-erp
[mfinanz.git] / SL / IC.pm
index 810e226fac194758e20ea143ffa27388f8261ae4..2455d9e0e11260c2d838ed4b400d264848be537e 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -243,7 +243,7 @@ sub save {
   map { $form->{$_} = $form->parse_amount($myconfig, $form->{$_}) }
     qw(rop weight listprice sellprice gv lastcost);
 
-  my $makemodel = (($form->{make_1}) || ($form->{model_1})) ? 1 : 0;
+  my $makemodel = ($form->{make_1} || $form->{model_1} || ($form->{makemodel_rows} > 1)) ? 1 : 0;
 
   $form->{assembly} = ($form->{item} eq 'assembly') ? 1 : 0;
 
@@ -419,10 +419,9 @@ sub save {
   $query = qq|INSERT INTO prices (parts_id, pricegroup_id, price) VALUES(?, ?, ?)|;
   $sth   = prepare_query($form, $dbh, $query);
 
-  # insert price records only if different to sellprice
   for my $i (1 .. $form->{price_rows}) {
     my $price = $form->parse_amount($myconfig, $form->{"price_$i"});
-    next unless $price && ($price != $form->{sellprice});
+    next unless $price;
 
     @values = (conv_i($form->{id}), conv_i($form->{"pricegroup_id_$i"}), $price);
     do_statement($form, $sth, $query, @values);
@@ -731,7 +730,7 @@ sub all_parts {
   my @apoe_filters         = qw(transdate);
   my @like_filters         = (@simple_filters, @invoice_oi_filters);
   my @all_columns          = (@simple_filters, @makemodel_filters, @apoe_filters, @project_filters, qw(serialnumber));
-  my @simple_l_switches    = (@all_columns, qw(notes listprice sellprice lastcost priceupdate weight unit rop image));
+  my @simple_l_switches    = (@all_columns, qw(notes listprice sellprice lastcost priceupdate weight unit rop image shop));
   my @oe_flags             = qw(bought sold onorder ordered rfq quoted);
   my @qsooqr_flags         = qw(invnumber ordnumber quonumber trans_id name module qty);
   my @deliverydate_flags   = qw(deliverydate);
@@ -857,6 +856,16 @@ sub all_parts {
     push @bind_vars, $form->{"partsgroup_id"};
   }
 
+  if ($form->{shop} ne '') {
+    $form->{l_shop} = '1'; # show the column
+    if ($form->{shop} eq '0' || $form->{shop} eq 'f') {
+      push @where_tokens, 'NOT p.shop';
+      $form->{shop} = 'f';
+    } else {
+      push @where_tokens, 'p.shop';
+    }
+  }
+
   foreach (@like_filters) {
     next unless $form->{$_};
     $form->{"l_$_"} = '1'; # show the column
@@ -974,7 +983,7 @@ sub all_parts {
 
   my $token_builder = $make_token_builder->(\%joins_needed);
 
-  my @sort_cols    = (@simple_filters, qw(id priceupdate onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate));
+  my @sort_cols    = (@simple_filters, qw(id priceupdate onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate shop));
      $form->{sort} = 'id' unless grep { $form->{"l_$_"} } grep { $form->{sort} eq $_ } @sort_cols; # sort by id if unknown or invisible column
   my $sort_order   = ($form->{revers} ? ' DESC' : ' ASC');
   my $order_clause = " ORDER BY " . $token_builder->($form->{sort}) . ($form->{revers} ? ' DESC' : ' ASC');
@@ -1081,7 +1090,7 @@ SQL
 
   $main::lxdebug->leave_sub();
 
-  return wantarray ? @{ $form->{parts} } : $form->{parts};
+  return @{ $form->{parts} };
 }
 
 sub _create_filter_for_priceupdate {
@@ -1552,9 +1561,9 @@ sub retrieve_accounts {
     LEFT JOIN chart c1 ON bg.inventory_accno_id = c1.id
     LEFT JOIN chart c2 ON tc.income_accno_id = c2.id
     LEFT JOIN chart c3 ON tc.expense_accno_id = c3.id
-    WHERE 
-    tc.taxzone_id = '$form->{taxzone_id}' 
-    and 
+    WHERE
+    tc.taxzone_id = '$form->{taxzone_id}'
+    and
     p.id IN ($in)
 SQL