From d1054383fa90478db0424f5dc255d5836bc494d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 26 Feb 2021 18:33:53 +0100 Subject: [PATCH] =?utf8?q?Artikelstamm:=20"Erneuert=20am"=20aus=20parts=5F?= =?utf8?q?price=5Fhistory=20holen=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … und in "Preisänderung am" umbenennen. Das ganze ist mit Rose gelöst und holt die Preise aus parts_price_history. Das hat den Nachteil, dass im Artikelbericht nicht nach der Preisanpassung sortiert werden kann und es wahrscheinlich nicht performant ist. Der aktuelle Trigger für parts.priceupdate funktionierte nicht, und hätte auch bei jeder Änderung eines Artikels das Datum angepasst. Dafür kann man auch mtime nehmen. Todo 1: Spalte priceupdate (und den Trigger) aus parts löschen (und alle Vorkommen finden). Todo 2: Query auf SQL umschreiben und soriteren wieder ermöglichen. Refs #254 (redmine) --- SL/DB/Part.pm | 6 ++++++ SL/IC.pm | 4 ++-- bin/mozilla/ic.pl | 7 +++++-- locale/de/all | 1 + locale/en/all | 1 + templates/webpages/ic/search.html | 2 +- templates/webpages/part/_basic_data.html | 4 ++-- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/SL/DB/Part.pm b/SL/DB/Part.pm index e98b0c4d7..0f855231e 100644 --- a/SL/DB/Part.pm +++ b/SL/DB/Part.pm @@ -76,6 +76,12 @@ __PACKAGE__->meta->add_relationships( column_map => { id => 'part_id' }, manager_args => { with_objects => [ 'shop' ] }, }, + last_price_update => { + type => 'one to one', + class => 'SL::DB::PartsPriceHistory', + column_map => { id => 'part_id' }, + manager_args => { sort_by => 'valid_from DESC', limit => 1 }, + }, ); __PACKAGE__->meta->initialize; diff --git a/SL/IC.pm b/SL/IC.pm index a09d740ea..5ddf2c862 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -481,7 +481,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 insertdate shop)); + my @sort_cols = (@simple_filters, qw(id onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate insertdate 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'); @@ -567,7 +567,7 @@ sub all_parts { qq|SELECT p.id, p.partnumber, p.description, a.qty AS onhand, p.unit, p.notes, p.itime::DATE as insertdate, p.sellprice, p.listprice, p.lastcost, - p.rop, p.weight, p.priceupdate, + p.rop, p.weight, p.image, p.drawing, p.microfiche, pfac.factor FROM parts p diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index f00ce0873..450d12439 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -188,7 +188,7 @@ sub generate_report { 'ordnumber' => { 'text' => $locale->text('Order Number'), }, 'partnumber' => { 'text' => $locale->text('Part Number'), }, 'partsgroup' => { 'text' => $locale->text('Partsgroup'), }, - 'priceupdate' => { 'text' => $locale->text('Updated'), }, + 'priceupdate' => { 'text' => $locale->text('Price updated'), }, 'quonumber' => { 'text' => $locale->text('Quotation'), }, 'rop' => { 'text' => $locale->text('ROP'), }, 'sellprice' => { 'text' => $locale->text('Sell Price'), }, @@ -435,7 +435,7 @@ sub generate_report { my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables); my @sort_full = qw(partnumber description onhand soldtotal deliverydate insertdate shop); - my @sort_no_revers = qw(partsgroup priceupdate invnumber ordnumber quonumber name image drawing serialnumber); + my @sort_no_revers = qw(partsgroup invnumber ordnumber quonumber name image drawing serialnumber); foreach my $col (@sort_full) { $column_defs{$col}->{link} = join '&', $callback, "sort=$col", map { "$_=" . E($form->{$_}) } qw(revers lastsort); @@ -582,6 +582,9 @@ sub generate_report { $row->{type_and_classific}{data} = SL::Presenter::Part::type_abbreviation($ref->{part_type}). SL::Presenter::Part::classification_abbreviation($ref->{classification_id}); + # last price update + $row->{priceupdate}{data} = SL::DB::Part->new(id => $ref->{id})->load->last_price_update->valid_from->to_kivitendo; + $report->add_data($row); my $next_ref = $form->{parts}[$idx + 1]; diff --git a/locale/de/all b/locale/de/all index ef2994be6..3f16ec327 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2501,6 +2501,7 @@ $self->{texts} = { 'Price sources deactivated in this client' => 'Preisquellen die in diesem Mandanten deaktiviert sind', 'Price type' => 'Preistyp', 'Price type explanation' => 'Preistyp Erklärung', + 'Price updated' => 'Preisänderung am', 'Pricegroup' => 'Preisgruppe', 'Pricegroups' => 'Preisgruppen', 'Prices' => 'Preise', diff --git a/locale/en/all b/locale/en/all index d79401c4b..f9d1c2c22 100644 --- a/locale/en/all +++ b/locale/en/all @@ -2501,6 +2501,7 @@ $self->{texts} = { 'Price sources deactivated in this client' => '', 'Price type' => '', 'Price type explanation' => '', + 'Price updated' => '', 'Pricegroup' => '', 'Pricegroups' => '', 'Prices' => '', diff --git a/templates/webpages/ic/search.html b/templates/webpages/ic/search.html index 42ec5fb86..91f665cee 100644 --- a/templates/webpages/ic/search.html +++ b/templates/webpages/ic/search.html @@ -192,7 +192,7 @@ - [%- L.checkbox_tag('l_priceupdate', label=LxERP.t8('Updated'), value='Y') %] + [%- L.checkbox_tag('l_priceupdate', label=LxERP.t8('Price updated'), value='Y') %] [%- L.checkbox_tag('l_deliverydate', label=LxERP.t8('Delivery Date'), value='Y') %] [%- L.checkbox_tag('l_rop', label=LxERP.t8('ROP'), value='Y') %] [%- L.checkbox_tag('l_weight', label=LxERP.t8('Weight'), value='Y') %] diff --git a/templates/webpages/part/_basic_data.html b/templates/webpages/part/_basic_data.html index 9e7fcee4d..90d5eeceb 100644 --- a/templates/webpages/part/_basic_data.html +++ b/templates/webpages/part/_basic_data.html @@ -84,9 +84,9 @@ - + -- 2.20.1
[% 'Updated' | $T8 %][% 'Price updated' | $T8 %] - [% SELF.part.priceupdate.to_kivitendo | html %] + [% SELF.part.last_price_update.valid_from.to_kivitendo | html %]