Revision 7664f50f
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/DB/Order.pm | ||
---|---|---|
142 | 142 |
return $invoice; |
143 | 143 |
} |
144 | 144 |
|
145 |
sub convert_to_delivery_order { |
|
146 |
my ($self, %params) = @_; |
|
147 |
|
|
148 |
my ($delivery_order, $custom_shipto); |
|
149 |
if (!$self->db->do_transaction(sub { |
|
150 |
require SL::DB::DeliveryOrder; |
|
151 |
($delivery_order, $custom_shipto) = SL::DB::DeliveryOrder->new_from($self); |
|
152 |
$delivery_order->save; |
|
153 |
$custom_shipto->save if $custom_shipto; |
|
154 |
$self->link_to_record($delivery_order); |
|
155 |
# die; |
|
156 |
})) { |
|
157 |
return undef; |
|
158 |
} |
|
159 |
|
|
160 |
return wantarray ? ($delivery_order, $custom_shipto) : $delivery_order; |
|
161 |
} |
|
162 |
|
|
145 | 163 |
sub number { |
146 | 164 |
my $self = shift; |
147 | 165 |
|
... | ... | |
189 | 207 |
|
190 | 208 |
Returns true if the order is of the given type. |
191 | 209 |
|
210 |
=head2 C<convert_to_delivery_order %params> |
|
211 |
|
|
212 |
Creates a new delivery order with C<$self> as the basis by calling |
|
213 |
L<SL::DB::DeliveryOrder::new_from>. That delivery order is saved, and |
|
214 |
C<$self> is linked to the new invoice via L<SL::DB::RecordLink>. |
|
215 |
|
|
216 |
The arguments in C<%params> are passed to |
|
217 |
L<SL::DB::DeliveryOrder::new_from>. |
|
218 |
|
|
219 |
Returns C<undef> on failure. Otherwise the return value depends on the |
|
220 |
context. In list context the new delivery order and a shipto instance |
|
221 |
will be returned. In scalar instance only the delivery order instance |
|
222 |
is returned. |
|
223 |
|
|
224 |
Custom shipto addresses (the ones specific to the sales/purchase |
|
225 |
record and not to the customer/vendor) are only linked from C<shipto> |
|
226 |
to C<delivery_orders>. Meaning C<delivery_orders.shipto_id> will not |
|
227 |
be filled in that case. That's why a separate shipto object is created |
|
228 |
and returned. |
|
229 |
|
|
192 | 230 |
=head2 C<convert_to_invoice %params> |
193 | 231 |
|
194 | 232 |
Creates a new invoice with C<$self> as the basis by calling |
Auch abrufbar als: Unified diff
SL::DB::Order, DeliveryOrder: Funktionen zum Umwandeln von Order in DeliveryOrder