Revision c37da034
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/DB/DeliveryOrder.pm | ||
---|---|---|
132 | 132 |
$args{shipto_id} = $source->shipto_id; |
133 | 133 |
} |
134 | 134 |
|
135 |
my $delivery_order = $class->new(%args, %params);
|
|
135 |
my $delivery_order = $class->new(%args, %{ $params{attributes} || {} });
|
|
136 | 136 |
|
137 | 137 |
my @items = map { |
138 | 138 |
my $source_item = $_; |
... | ... | |
146 | 146 |
|
147 | 147 |
} @{ $source->items_sorted }; |
148 | 148 |
|
149 |
@items = grep { $_->qty * 1 } @items if $params{skip_items_zero_qty}; |
|
150 |
|
|
149 | 151 |
$delivery_order->items(\@items); |
150 | 152 |
|
151 | 153 |
return ($delivery_order, $custom_shipto); |
... | ... | |
186 | 188 |
Returns the delivery order items sorted by their ID (same order they |
187 | 189 |
appear in the frontend delivery order masks). |
188 | 190 |
|
189 |
=item C<new_from $source> |
|
191 |
=item C<new_from $source, %params>
|
|
190 | 192 |
|
191 | 193 |
Creates a new C<SL::DB::DeliveryOrder> instance and copies as much |
192 | 194 |
information from C<$source> as possible. At the moment only instances |
... | ... | |
209 | 211 |
|
210 | 212 |
The objects returned are not saved. |
211 | 213 |
|
214 |
C<%params> can include the following options: |
|
215 |
|
|
216 |
=over 2 |
|
217 |
|
|
218 |
=item C<skip_items_zero_qty> |
|
219 |
|
|
220 |
If trueish then items with a quantity of 0 are skipped. |
|
221 |
|
|
222 |
=item C<attributes> |
|
223 |
|
|
224 |
An optional hash reference. If it exists then it is passed to C<new> |
|
225 |
allowing the caller to set certain attributes for the new delivery |
|
226 |
order. |
|
227 |
|
|
228 |
=back |
|
229 |
|
|
212 | 230 |
=item C<sales_order> |
213 | 231 |
|
214 | 232 |
TODO: Describe sales_order |
SL/DB/Order.pm | ||
---|---|---|
150 | 150 |
} |
151 | 151 |
|
152 | 152 |
sub convert_to_delivery_order { |
153 |
my ($self, %params) = @_;
|
|
153 |
my ($self, @args) = @_;
|
|
154 | 154 |
|
155 | 155 |
my ($delivery_order, $custom_shipto); |
156 | 156 |
if (!$self->db->with_transaction(sub { |
157 | 157 |
require SL::DB::DeliveryOrder; |
158 |
($delivery_order, $custom_shipto) = SL::DB::DeliveryOrder->new_from($self, %params);
|
|
158 |
($delivery_order, $custom_shipto) = SL::DB::DeliveryOrder->new_from($self, @args);
|
|
159 | 159 |
$delivery_order->save; |
160 | 160 |
$custom_shipto->save if $custom_shipto; |
161 | 161 |
$self->link_to_record($delivery_order); |
Auch abrufbar als: Unified diff
SL::DB::DeliveryOrder->new_from: Optionen zum Weglassen von Positionen mit Menge 0