Fehler #130 » periodic_invoice_custom_shipto.diff
SL/BackgroundJob/CreatePeriodicInvoices.pm | ||
---|---|---|
213 | 213 | |
214 | 214 |
$invoice->post(ar_id => $config->ar_chart_id) || die; |
215 | 215 | |
216 |
# like $form->add_shipto, but we don't need to check for a manual exception, |
|
217 |
# because we can already assume this (otherwise no shipto_id from order) |
|
218 |
if ($order->shipto_id) { |
|
219 | ||
220 |
my $shipto_oe = SL::DB::Manager::Shipto->find_by(shipto_id => $order->shipto_id); |
|
221 |
my $shipto_ar = $shipto_oe->clone_and_reset; |
|
222 | ||
223 |
$shipto_ar->module('AR'); # alter module OE -> AR |
|
224 |
$shipto_ar->trans_id($invoice->id); # alter trans_id -> new id from invoice |
|
225 |
$shipto_ar->save; |
|
216 |
# custom shipto |
|
217 |
if (!$order->shipto_id && $order->id) { |
|
218 |
my $shipto_oe = SL::DB::Manager::Shipto->find_by(trans_id => $order->id, module => 'OE'); |
|
219 |
if ($shipto_oe) { |
|
220 |
my $shipto_ar = $shipto_oe->clone_and_reset; |
|
221 |
$shipto_ar->module('AR'); |
|
222 |
$shipto_ar->trans_id($invoice->id); |
|
223 |
$shipto_ar->save; |
|
224 |
} |
|
226 | 225 |
} |
227 | 226 | |
228 | 227 |
$order->link_to_record($invoice); |
SL/Form.pm | ||
---|---|---|
3368 | 3368 |
} |
3369 | 3369 | |
3370 | 3370 |
# Load shipping address from database if shipto_id is set. |
3371 |
my $shipto; |
|
3371 | 3372 |
if ($self->{shipto_id}) { |
3372 |
my $shipto = SL::DB::Shipto->new(shipto_id => $self->{shipto_id})->load; |
|
3373 |
$shipto = SL::DB::Shipto->new(shipto_id => $self->{shipto_id})->load; |
|
3374 |
} else { |
|
3375 |
# or try to find custom shipto in shiptos |
|
3376 |
my $module = ($self->{type} =~ /_delivery_order$/)? 'DO' |
|
3377 |
: ($self->{type} =~ /sales_order|sales_quotation|request_quotation|purchase_order/)? 'OE' |
|
3378 |
: ($self->{type} =~ /purchase_invoice/)? 'AP' |
|
3379 |
: 'AR'; |
|
3380 |
$shipto = SL::DB::Manager::Shipto->find_by(trans_id => $self->{id}, module => $module); |
|
3381 |
} |
|
3382 |
if ($shipto) { |
|
3373 | 3383 |
$self->{$_} = $shipto->$_ for grep { m{^shipto} } map { $_->name } @{ $shipto->meta->columns }; |
3374 | 3384 |
} |
3375 | 3385 |