X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/ccde19fe1c1eb5ea7f0d6cb2d9d2f6b522d6ca01..d6369b1f946980f0e22fc18da3fc54a14501b3c5:/SL/IC.pm diff --git a/SL/IC.pm b/SL/IC.pm index 784366582..5314d4b8e 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -35,6 +35,7 @@ package IC; use Data::Dumper; +use List::MoreUtils qw(all); use YAML; use SL::DBUtils; @@ -80,10 +81,11 @@ sub get_part { $query = qq|SELECT p.id, p.partnumber, p.description, p.sellprice, p.lastcost, p.weight, a.qty, a.bom, p.unit, - pg.partsgroup + pg.partsgroup, p.price_factor_id, pfac.factor AS price_factor FROM parts p JOIN assembly a ON (a.parts_id = p.id) LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) + LEFT JOIN price_factors pfac ON pfac.id = p.price_factor_id WHERE (a.id = ?) ORDER BY $oid{$myconfig->{dbdriver}}|; $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); @@ -307,6 +309,8 @@ sub save { my ($query, $sth); + my $priceupdate = ', priceupdate = current_date'; + if ($form->{id}) { # get old price @@ -337,6 +341,11 @@ sub save { # delete translations do_query($form, $dbh, qq|DELETE FROM translation WHERE parts_id = ?|, conv_i($form->{id})); + # Check whether or not the prices have changed. If they haven't + # then 'priceupdate' should not be updated. + my $previous_values = selectfirst_hashref_query($form, $dbh, qq|SELECT * FROM parts WHERE id = ?|, conv_i($form->{id})) || {}; + $priceupdate = '' if (all { $previous_values->{$_} == $form->{$_} } qw(sellprice lastcost listprice)); + } else { my ($count) = selectrow_query($form, $dbh, qq|SELECT COUNT(*) FROM parts WHERE partnumber = ?|, $form->{partnumber}); if ($count) { @@ -392,7 +401,6 @@ sub save { sellprice = ?, lastcost = ?, weight = ?, - priceupdate = ?, unit = ?, notes = ?, formel = ?, @@ -414,6 +422,7 @@ sub save { microfiche = ?, partsgroup_id = ?, price_factor_id = ? + $priceupdate WHERE id = ?|; @values = ($form->{partnumber}, $form->{description}, @@ -423,7 +432,6 @@ sub save { $form->{sellprice}, $form->{lastcost}, $form->{weight}, - conv_date($form->{priceupdate}), $form->{unit}, $form->{notes}, $form->{formel},