Revision 4cdf2968
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
SL/Controller/Order.pm | ||
---|---|---|
my $order;
|
||
$order = SL::DB::Order->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id};
|
||
$order ||= SL::DB::Order->new(orderitems => [],
|
||
record_type => $self->type,
|
||
quotation => (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE(), PURCHASE_QUOTATION_INTAKE_TYPE())),
|
||
intake => (any { $self->type eq $_ } (SALES_ORDER_INTAKE_TYPE(), PURCHASE_QUOTATION_INTAKE_TYPE())),
|
||
currency_id => $::instance_conf->get_currency_id(),);
|
SL/Controller/RequirementSpecOrder.pm | ||
---|---|---|
|
||
use SL::DB::Customer;
|
||
use SL::DB::Order;
|
||
use SL::DB::Order::TypeData qw(:types);
|
||
use SL::DB::Part;
|
||
use SL::DB::RequirementSpec;
|
||
use SL::DB::RequirementSpecOrder;
|
||
... | ... | |
my $reqdate = !$::form->{quotation} ? undef
|
||
: $customer->payment_id ? $customer->payment->calc_date
|
||
: DateTime->today_local->next_workday(extra_days => $::instance_conf->get_reqdate_interval)->to_kivitendo;
|
||
my $record_type = $::form->{quotation} ? SALES_QUOTATION_TYPE() : SALES_ORDER_TYPE();
|
||
my $order = SL::DB::Order->new(
|
||
record_type => $record_type,
|
||
globalproject_id => $self->requirement_spec->project_id,
|
||
transdate => DateTime->today_local,
|
||
reqdate => $reqdate,
|
SL/DB/Order.pm | ||
---|---|---|
|
||
sub type {
|
||
my $self = shift;
|
||
|
||
return SALES_ORDER_INTAKE_TYPE() if $self->customer_id && $self->intake;
|
||
return SALES_ORDER_TYPE() if $self->customer_id && ! $self->quotation;
|
||
return PURCHASE_ORDER_TYPE() if $self->vendor_id && ! $self->quotation;
|
||
return SALES_QUOTATION_TYPE() if $self->customer_id && $self->quotation;
|
||
return REQUEST_QUOTATION_TYPE() if $self->vendor_id && $self->quotation && ! $self->intake;
|
||
return PURCHASE_QUOTATION_INTAKE_TYPE() if $self->vendor_id && $self->quotation && $self->intake;
|
||
|
||
return;
|
||
die "invalid type: " . $self->record_type if (!any { $self->record_type eq $_ } (
|
||
SALES_ORDER_INTAKE_TYPE(),
|
||
SALES_ORDER_TYPE(),
|
||
PURCHASE_ORDER_TYPE(),
|
||
REQUEST_QUOTATION_TYPE(),
|
||
SALES_QUOTATION_TYPE(),
|
||
PURCHASE_QUOTATION_INTAKE_TYPE(),
|
||
));
|
||
return $self->record_type;
|
||
}
|
||
|
||
sub is_type {
|
||
... | ... | |
$args{shipto_id} = $source->shipto_id;
|
||
}
|
||
|
||
$args{record_type} = $destination_type;
|
||
|
||
my $order = $class->new(%args);
|
||
$order->assign_attributes(%{ $params{attributes} }) if $params{attributes};
|
||
my $items = delete($params{items}) || $source->items_sorted;
|
SL/DB/ShopOrder.pm | ||
---|---|---|
: @{ $self->shop_order_items };
|
||
|
||
require SL::DB::Order;
|
||
use SL::DB::Order::TypeData qw(:types);
|
||
require SL::DB::OrderItem;
|
||
require SL::DB::Part;
|
||
require SL::DB::Shipto;
|
||
... | ... | |
currency_id => $customer->currency_id,
|
||
transaction_description => $shop->transaction_description,
|
||
transdate => $transdate,
|
||
record_type => SALES_ORDER_TYPE(),
|
||
);
|
||
return $order;
|
||
}else{
|
SL/Dev/Record.pm | ||
---|---|---|
|
||
use SL::DB::Invoice;
|
||
use SL::DB::InvoiceItem;
|
||
use SL::DB::Order;
|
||
use SL::DB::Order::TypeData qw(:types);
|
||
use SL::DB::DeliveryOrder::TypeData qw(:types);
|
||
use SL::DB::Employee;
|
||
use SL::Dev::Part qw(new_part);
|
||
... | ... | |
credit_note => 'SL::DB::InvoiceItem',
|
||
sales_order => 'SL::DB::OrderItem',
|
||
sales_quotation => 'SL::DB::OrderItem',
|
||
purchase_quotation => 'SL::DB::OrderItem',
|
||
request_quotation => 'SL::DB::OrderItem',
|
||
purchase_order => 'SL::DB::OrderItem',
|
||
sales_delivery_order => 'SL::DB::DeliveryOrderItem',
|
||
purchase_delivery_order => 'SL::DB::DeliveryOrderItem',
|
||
... | ... | |
|
||
sub create_sales_quotation {
|
||
my (%params) = @_;
|
||
$params{type} = 'sales_quotation';
|
||
$params{type} = SALES_QUOTATION_TYPE();
|
||
_create_sales_order_or_quotation(%params);
|
||
}
|
||
|
||
sub create_sales_order {
|
||
my (%params) = @_;
|
||
$params{type} = 'sales_order';
|
||
$params{type} = SALES_ORDER_TYPE();
|
||
_create_sales_order_or_quotation(%params);
|
||
}
|
||
|
||
sub create_purchase_quotation {
|
||
my (%params) = @_;
|
||
$params{type} = 'purchase_quotation';
|
||
$params{type} = REQUEST_QUOTATION_TYPE();
|
||
# TODO: set a with reqdate
|
||
_create_purchase_order_or_quotation(%params);
|
||
}
|
||
|
||
sub create_purchase_order {
|
||
my (%params) = @_;
|
||
$params{type} = 'purchase_order';
|
||
$params{type} = PURCHASE_ORDER_TYPE();
|
||
_create_purchase_order_or_quotation(%params);
|
||
}
|
||
|
||
... | ... | |
my (%params) = @_;
|
||
|
||
my $record_type = $params{type};
|
||
die "illegal type" unless $record_type eq 'sales_order' or $record_type eq 'sales_quotation';
|
||
die "illegal type" unless $record_type eq SALES_ORDER_TYPE() or $record_type eq SALES_QUOTATION_TYPE();
|
||
|
||
my $orderitems = delete $params{orderitems} // _create_two_items($record_type);
|
||
_check_items($orderitems, $record_type);
|
||
... | ... | |
die "illegal customer" unless ref($customer) eq 'SL::DB::Customer';
|
||
|
||
my $record = SL::DB::Order->new(
|
||
record_type => delete $params{type},
|
||
customer_id => delete $params{customer_id} // $customer->id,
|
||
taxzone_id => delete $params{taxzone_id} // $customer->taxzone->id,
|
||
currency_id => delete $params{currency_id} // $::instance_conf->get_currency_id,
|
||
... | ... | |
my (%params) = @_;
|
||
|
||
my $record_type = $params{type};
|
||
die "illegal type" unless $record_type eq 'purchase_order' or $record_type eq 'purchase_quotation';
|
||
die "illegal type" unless $record_type eq PURCHASE_ORDER_TYPE() or $record_type eq REQUEST_QUOTATION_TYPE();
|
||
my $orderitems = delete $params{orderitems} // _create_two_items($record_type);
|
||
_check_items($orderitems, $record_type);
|
||
|
||
... | ... | |
die "illegal vendor" unless ref($vendor) eq 'SL::DB::Vendor';
|
||
|
||
my $record = SL::DB::Order->new(
|
||
record_type => delete $params{type},
|
||
vendor_id => delete $params{vendor_id} // $vendor->id,
|
||
taxzone_id => delete $params{taxzone_id} // $vendor->taxzone->id,
|
||
currency_id => delete $params{currency_id} // $::instance_conf->get_currency_id,
|
||
taxincluded => delete $params{taxincluded} // 0,
|
||
transdate => delete $params{transdate} // DateTime->today,
|
||
'closed' => undef,
|
||
quotation => $record_type eq 'purchase_quotation' ? 1 : 0,
|
||
quotation => $record_type eq REQUEST_QUOTATION_TYPE() ? 1 : 0,
|
||
orderitems => $orderitems,
|
||
);
|
||
$record->assign_attributes(%params) if %params;
|
t/db_helper/record_links.t | ||
---|---|---|
use SL::DB::Employee;
|
||
use SL::DB::Invoice;
|
||
use SL::DB::Order;
|
||
use SL::DB::Order::TypeData qw(:types);
|
||
use SL::DB::DeliveryOrder;
|
||
use SL::DB::DeliveryOrder::TypeData qw(:types);
|
||
use SL::DB::Part;
|
||
... | ... | |
my %params = @_;
|
||
|
||
return SL::DB::Order->new(
|
||
record_type => SALES_ORDER_TYPE(),
|
||
customer_id => $customer->id,
|
||
currency_id => $currency_id,
|
||
employee_id => $employee->id,
|
Auch abrufbar als: Unified diff
Order: nutze Record-Type