X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/284470c116a0f1a73f82797160b0170e55a58652..7664f50fac4a789932317d0e0d35e15bc2d7d1c4:/SL/DB/Order.pm?ds=inline diff --git a/SL/DB/Order.pm b/SL/DB/Order.pm index 194431dcd..a3c9de0f5 100644 --- a/SL/DB/Order.pm +++ b/SL/DB/Order.pm @@ -142,6 +142,24 @@ sub convert_to_invoice { return $invoice; } +sub convert_to_delivery_order { + my ($self, %params) = @_; + + my ($delivery_order, $custom_shipto); + if (!$self->db->do_transaction(sub { + require SL::DB::DeliveryOrder; + ($delivery_order, $custom_shipto) = SL::DB::DeliveryOrder->new_from($self); + $delivery_order->save; + $custom_shipto->save if $custom_shipto; + $self->link_to_record($delivery_order); + # die; + })) { + return undef; + } + + return wantarray ? ($delivery_order, $custom_shipto) : $delivery_order; +} + sub number { my $self = shift; @@ -189,6 +207,26 @@ Returns one of the following string types: Returns true if the order is of the given type. +=head2 C + +Creates a new delivery order with C<$self> as the basis by calling +L. That delivery order is saved, and +C<$self> is linked to the new invoice via L. + +The arguments in C<%params> are passed to +L. + +Returns C on failure. Otherwise the return value depends on the +context. In list context the new delivery order and a shipto instance +will be returned. In scalar instance only the delivery order instance +is returned. + +Custom shipto addresses (the ones specific to the sales/purchase +record and not to the customer/vendor) are only linked from C +to C. Meaning C will not +be filled in that case. That's why a separate shipto object is created +and returned. + =head2 C Creates a new invoice with C<$self> as the basis by calling