is_customer => 1,
nr_key => "donumber",
transfer => 'out',
+ transnumber => 'sdonumber',
},
part_classification_query => [ "used_for_sale" => 1 ],
right => "sales_delivery_order_edit",
is_customer => 0,
nr_key => "donumber",
transfer => 'in',
+ transnumber => 'pdonumber',
},
part_classification_query => [ "used_for_purchase" => 1 ],
right => "purchase_delivery_order_edit",
is_customer => 0,
nr_key => "donumber",
transfer => 'out',
+ transnumber => 'sudonumber',
},
part_classification_query => [ "used_for_purchase" => 1 ],
right => "purchase_delivery_order_edit",
is_customer => 0,
nr_key => "donumber",
transfer => 'in',
+ transnumber => 'rdonumber',
},
part_classification_query => [ "used_for_sale" => 1 ],
right => "sales_delivery_order_edit",
purchase_order => { number_column => 'ordnumber', number_range_column => 'ponumber', scoping => \&oe_scoping, },
sales_delivery_order => { number_column => 'donumber', number_range_column => 'sdonumber', scoping => \&do_scoping, },
purchase_delivery_order => { number_column => 'donumber', number_range_column => 'pdonumber', scoping => \&do_scoping, },
+ supplier_delivery_order => { number_column => 'donumber', number_range_column => 'sudonumber', scoping => \&do_scoping, },
+ rma_delivery_order => { number_column => 'donumber', number_range_column => 'rdonumber', scoping => \&do_scoping, },
customer => { number_column => 'customernumber', number_range_column => 'customernumber', },
vendor => { number_column => 'vendornumber', number_range_column => 'vendornumber', },
part => { number_column => 'partnumber', number_range_column => 'articlenumber', scoping => \&parts_scoping, },
use SL::DB::Helper::Sorted;
use SL::DB::Helper::Filtered;
+use SL::DB::DeliveryOrder::TypeData qw(validate_type);
+
sub object_class { 'SL::DB::DeliveryOrder' }
__PACKAGE__->make_manager_methods;
my $class = shift;
my $type = lc(shift || '');
- return ('!customer_id' => undef) if $type eq 'sales_delivery_order';
- return ('!vendor_id' => undef) if $type eq 'purchase_delivery_order';
-
- die "Unknown type $type";
+ return type => validate_type($type);
}
sub _sort_spec {
purchase_delivery_order_show_delete => { type => 'boolean', default => 'true' },
purchase_order_show_delete => { type => 'boolean', default => 'true' },
quick_search_modules => { type => 'array' },
+ rdonumber => { type => 'text' },
reqdate_interval => { type => 'integer', default => '0' },
reqdate_on => { type => 'boolean', default => 'true' },
require_transaction_description_ps => { type => 'boolean', default => 'false', not_null => 1 },
stocktaking_cutoff_date => { type => 'date' },
stocktaking_qty_threshold => { type => 'numeric', default => '0', precision => 25, scale => 5 },
stocktaking_warehouse_id => { type => 'integer' },
+ sudonumber => { type => 'text' },
taxnumber => { type => 'text' },
templates => { type => 'text' },
transfer_default => { type => 'boolean', default => 'true' },
use SL::DBUtils;
use SL::PrefixedNumber;
use SL::DB;
+use SL::DB::DeliveryOrder::TypeData;
use Rose::Object::MakeMethods::Generic
(
scalar => [ qw(type id number save dbh dbh_provided business_id) ],
);
-my @SUPPORTED_TYPES = qw(invoice invoice_for_advance_payment final_invoice credit_note customer vendor sales_delivery_order purchase_delivery_order sales_order purchase_order sales_quotation request_quotation part service assembly assortment letter);
+my @SUPPORTED_TYPES = qw(invoice invoice_for_advance_payment final_invoice credit_note customer vendor sales_delivery_order purchase_delivery_order sales_order purchase_order sales_quotation request_quotation part service assembly assortment letter),
+ @{ SL::DB::DeliveryOrder::TypeData::valid_types() },
+);
sub new {
my $class = shift;
$filters{numberfield} = "${type}number";
$filters{table} = $type;
- } elsif ($type =~ /_delivery_order$/) {
- $filters{trans_number} = "donumber";
- $filters{numberfield} = $type eq 'sales_delivery_order' ? "sdonumber" : "pdonumber";
+ } elsif ($type =~ /_delivery_order$/ && SL::DB::DeliveryOrder::TypeData::is_valid_type($type)) {
+ $filters{trans_number} = SL::DB::DeliveryOrder::TypeData::get3($type, 'properties', 'nr_key'),
+ $filters{numberfield} = SL::DB::DeliveryOrder::TypeData::get3($type, 'properties', 'transnumber'),
$filters{table} = "delivery_orders";
- $filters{where} = $type =~ /^sales/ ? '(customer_id IS NOT NULL)' : '(vendor_id IS NOT NULL)';
+ $filters{where} = "order_type = ?";
+ $filters{values} = [ $::form->{type} ];
} elsif ($type =~ /_order$/) {
$filters{trans_number} = "ordnumber";
my @values = ($self->number);
push @where, $filters{where} if $filters{where};
+ push @values, @{ $filters{values} } if $filters{values};
if ($self->id) {
push @where, qq|id <> ?|;
SQL
do_query($form, $self->dbh, "LOCK TABLE " . $filters{table}) || die $self->dbh->errstr;
- my %numbers_in_use = selectall_as_map($form, $self->dbh, $query, $filters{trans_number}, 'in_use');
+ my %numbers_in_use = selectall_as_map($form, $self->dbh, $query, $filters{trans_number}, 'in_use', @{ $filters{values} // [] });
my $business_number;
($business_number) = selectfirst_array_query($form, $self->dbh, qq|SELECT customernumberinit FROM business WHERE id = ? FOR UPDATE|, $self->business_id) if $self->business_id;
--- /dev/null
+-- @tag: deliveryorder_transnumbers
+-- @description: Nummernkreise für neue lieferscheintypen
+-- @depends: release_3_5_8
+
+ALTER TABLE defaults ADD COLUMN sudonumber TEXT;
+ALTER TABLE defaults ADD COLUMN rdonumber TEXT;
+
+UPDATE defaults SET
+ sudonumber = '0',
+ rdonumber = '0';
+