projects
/
kivitendo-erp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
45eb876
)
S/D/Shipto: Methode is_empty, um auf leere Lieferadresse zu prüfen
author
Bernd Bleßmann
<bernd@kivitendo-premium.de>
Tue, 25 Aug 2020 13:26:36 +0000
(15:26 +0200)
committer
Bernd Bleßmann
<bernd@kivitendo-premium.de>
Tue, 25 Aug 2020 14:17:06 +0000
(16:17 +0200)
SL/DB/Shipto.pm
patch
|
blob
|
history
diff --git
a/SL/DB/Shipto.pm
b/SL/DB/Shipto.pm
index
99a4036
..
6cfcba6
100644
(file)
--- a/
SL/DB/Shipto.pm
+++ b/
SL/DB/Shipto.pm
@@
-3,6
+3,9
@@
package SL::DB::Shipto;
use strict;
use Carp;
use strict;
use Carp;
+use List::MoreUtils qw(all);
+
+use SL::Util qw(trim);
use SL::DB::MetaSetup::Shipto;
use SL::DB::Manager::Shipto;
use SL::DB::MetaSetup::Shipto;
use SL::DB::Manager::Shipto;
@@
-16,6
+19,7
@@
our @SHIPTO_VARIABLES = qw(shiptoname shiptostreet shiptozipcode shiptocity ship
__PACKAGE__->meta->initialize;
__PACKAGE__->meta->initialize;
+
sub displayable_id {
my $self = shift;
my $text = join('; ', grep { $_ } (map({ $self->$_ } qw(shiptoname shiptostreet)),
sub displayable_id {
my $self = shift;
my $text = join('; ', grep { $_ } (map({ $self->$_ } qw(shiptoname shiptostreet)),
@@
-40,6
+44,15
@@
sub used {
|| SL::DB::Manager::DeliveryOrder->get_all_count(query => [ shipto_id => $self->shipto_id ]);
}
|| SL::DB::Manager::DeliveryOrder->get_all_count(query => [ shipto_id => $self->shipto_id ]);
}
+sub is_empty {
+ my ($self) = @_;
+
+ # todo: consider cvars
+ my @fields_to_consider = grep { !m{^ (?: itime | mtime | shipto_id | trans_id | shiptocp_gender | module ) $}x } map {$_->name} $self->meta->columns;
+
+ return all { trim($self->$_) eq '' } @fields_to_consider;
+}
+
sub detach {
$_[0]->trans_id(undef);
$_[0];
sub detach {
$_[0]->trans_id(undef);
$_[0];
@@
-90,6
+103,18
@@
SL::DB::Shipto - Database model for shipping addresses
=over 4
=over 4
+=item C<is_empty>
+
+Returns truish if all fields to consider are empty, falsish if not.
+Fields are trimmed before the test is performed.
+C<shiptocp_gender> is not considered because in forms this is usually
+a selection with 'm' as default value.
+CVar fields are not considered by now.
+
+=back
+
+=over 4
+
=item C<clone $target>
Creates and returns a clone of the current object. The mandatory
=item C<clone $target>
Creates and returns a clone of the current object. The mandatory