Revision 3f0ed511
Von Moritz Bunkus vor fast 9 Jahren hinzugefügt
SL/DB/Shipto.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
use Carp; |
|
6 |
|
|
5 | 7 |
use SL::DB::MetaSetup::Shipto; |
6 | 8 |
use SL::DB::Manager::Shipto; |
7 | 9 |
use SL::DB::Helper::CustomVariables ( |
... | ... | |
43 | 45 |
$_[0]; |
44 | 46 |
} |
45 | 47 |
|
48 |
sub clone { |
|
49 |
my ($self, $target) = @_; |
|
50 |
|
|
51 |
my $type = ref($target) || $target; |
|
52 |
my $module = $type =~ m{::Order$} ? 'OE' |
|
53 |
: $type =~ m{::DeliveryOrder$} ? 'DO' |
|
54 |
: $type =~ m{::Invoice$} ? 'AR' |
|
55 |
: $type =~ m{::(?:Customer|Vendor)$} ? 'CT' |
|
56 |
: croak "Unsupported target class '$type'"; |
|
57 |
|
|
58 |
my $new_shipto = SL::DB::Shipto->new( |
|
59 |
(map { +($_ => $self->$_) } |
|
60 |
grep { !m{^ (?: itime | mtime | shipto_id | trans_id ) $}x } |
|
61 |
map { $_->name } |
|
62 |
@{ $self->meta->columns }), |
|
63 |
module => $module, |
|
64 |
); |
|
65 |
|
|
66 |
return $new_shipto; |
|
67 |
} |
|
68 |
|
|
46 | 69 |
1; |
70 |
|
|
71 |
__END__ |
|
72 |
|
|
73 |
=pod |
|
74 |
|
|
75 |
=encoding utf8 |
|
76 |
|
|
77 |
=head1 NAME |
|
78 |
|
|
79 |
SL::DB::Shipto - Database model for shipping addresses |
|
80 |
|
|
81 |
=head1 SYNOPSIS |
|
82 |
|
|
83 |
my $order = SL::DB::Order->new(id => …)->load; |
|
84 |
if ($order->custom_shipto) { |
|
85 |
my $cloned_shipto = $order->custom_shipto->clone('SL::DB::Invoice'); |
|
86 |
} |
|
87 |
|
|
88 |
=head1 FUNCTIONS |
|
89 |
|
|
90 |
=over 4 |
|
91 |
|
|
92 |
=item C<clone $target> |
|
93 |
|
|
94 |
Creates and returns a clone of the current object. The mandatory |
|
95 |
parameter C<$target> must be either an instance of a Rose DB class or |
|
96 |
the name of one. It's used for setting the new instance's C<module> |
|
97 |
attribute to the correct value. |
|
98 |
|
|
99 |
Currently the following classes are supported: |
|
100 |
|
|
101 |
=over 2 |
|
102 |
|
|
103 |
=item C<SL::DB::Order> |
|
104 |
|
|
105 |
=item C<SL::DB::DeliveryOrder> |
|
106 |
|
|
107 |
=item C<SL::DB::Invoice> |
|
108 |
|
|
109 |
=item C<SL::DB::Customer> |
|
110 |
|
|
111 |
=item C<SL::DB::Vendor> |
|
112 |
|
|
113 |
=back |
|
114 |
|
|
115 |
=back |
|
116 |
|
|
117 |
=head1 BUGS |
|
118 |
|
|
119 |
Nothing here yet. |
|
120 |
|
|
121 |
=head1 AUTHOR |
|
122 |
|
|
123 |
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt> |
|
124 |
|
|
125 |
=cut |
Auch abrufbar als: Unified diff
Shipto: Methode zum Clonen in SL::DB::Shipto und nicht in DeliveryOrder->new_from