package IC;
use Data::Dumper;
+use List::MoreUtils qw(all);
use YAML;
use SL::DBUtils;
my ($query, $sth);
+ my $priceupdate = ', priceupdate = current_date';
+
if ($form->{id}) {
# get old price
# 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) {
sellprice = ?,
lastcost = ?,
weight = ?,
- priceupdate = ?,
unit = ?,
notes = ?,
formel = ?,
microfiche = ?,
partsgroup_id = ?,
price_factor_id = ?
+ $priceupdate
WHERE id = ?|;
@values = ($form->{partnumber},
$form->{description},
$form->{sellprice},
$form->{lastcost},
$form->{weight},
- conv_date($form->{priceupdate}),
$form->{unit},
$form->{notes},
$form->{formel},