Fehler #130 » periodic_invoice_custom_shipto.diff
SL/BackgroundJob/CreatePeriodicInvoices.pm | ||
---|---|---|
$invoice->post(ar_id => $config->ar_chart_id) || die;
|
||
# like $form->add_shipto, but we don't need to check for a manual exception,
|
||
# because we can already assume this (otherwise no shipto_id from order)
|
||
if ($order->shipto_id) {
|
||
my $shipto_oe = SL::DB::Manager::Shipto->find_by(shipto_id => $order->shipto_id);
|
||
my $shipto_ar = $shipto_oe->clone_and_reset;
|
||
$shipto_ar->module('AR'); # alter module OE -> AR
|
||
$shipto_ar->trans_id($invoice->id); # alter trans_id -> new id from invoice
|
||
$shipto_ar->save;
|
||
# custom shipto
|
||
if (!$order->shipto_id && $order->id) {
|
||
my $shipto_oe = SL::DB::Manager::Shipto->find_by(trans_id => $order->id, module => 'OE');
|
||
if ($shipto_oe) {
|
||
my $shipto_ar = $shipto_oe->clone_and_reset;
|
||
$shipto_ar->module('AR');
|
||
$shipto_ar->trans_id($invoice->id);
|
||
$shipto_ar->save;
|
||
}
|
||
}
|
||
$order->link_to_record($invoice);
|
SL/Form.pm | ||
---|---|---|
}
|
||
# Load shipping address from database if shipto_id is set.
|
||
my $shipto;
|
||
if ($self->{shipto_id}) {
|
||
my $shipto = SL::DB::Shipto->new(shipto_id => $self->{shipto_id})->load;
|
||
$shipto = SL::DB::Shipto->new(shipto_id => $self->{shipto_id})->load;
|
||
} else {
|
||
# or try to find custom shipto in shiptos
|
||
my $module = ($self->{type} =~ /_delivery_order$/)? 'DO'
|
||
: ($self->{type} =~ /sales_order|sales_quotation|request_quotation|purchase_order/)? 'OE'
|
||
: ($self->{type} =~ /purchase_invoice/)? 'AP'
|
||
: 'AR';
|
||
$shipto = SL::DB::Manager::Shipto->find_by(trans_id => $self->{id}, module => $module);
|
||
}
|
||
if ($shipto) {
|
||
$self->{$_} = $shipto->$_ for grep { m{^shipto} } map { $_->name } @{ $shipto->meta->columns };
|
||
}
|
||