Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 45ea642b

Von Sven Schöling vor etwa 3 Jahren hinzugefügt

  • ID 45ea642b37fc269a9dc9795f5fec420aa42883c3
  • Vorgänger 013fdb49
  • Nachfolger f1632521

do: neue Nummerkreise für supplier und rma Lieferscheine

Unterschiede anzeigen:

SL/TransNumber.pm
9 9
use SL::DBUtils;
10 10
use SL::PrefixedNumber;
11 11
use SL::DB;
12
use SL::DB::DeliveryOrder::TypeData;
12 13

  
13 14
use Rose::Object::MakeMethods::Generic
14 15
(
15 16
 scalar => [ qw(type id number save dbh dbh_provided business_id) ],
16 17
);
17 18

  
18
my @SUPPORTED_TYPES = qw(invoice credit_note customer vendor sales_delivery_order purchase_delivery_order sales_order purchase_order sales_quotation request_quotation part service assembly assortment letter);
19
my @SUPPORTED_TYPES = (
20
  qw(invoice credit_note customer vendor sales_order purchase_order sales_quotation request_quotation part service assembly assortment letter),
21
  @{ SL::DB::DeliveryOrder::TypeData::valid_types() },
22
);
19 23

  
20 24
sub new {
21 25
  my $class = shift;
......
47 51
    $filters{numberfield}   = "${type}number";
48 52
    $filters{table}         = $type;
49 53

  
50
  } elsif ($type =~ /_delivery_order$/) {
51
    $filters{trans_number}  = "donumber";
52
    $filters{numberfield}   = $type eq 'sales_delivery_order' ? "sdonumber" : "pdonumber";
54
  } elsif ($type =~ /_delivery_order$/ && SL::DB::DeliveryOrder::TypeData::is_valid_type($type)) {
55
    $filters{trans_number}  = SL::DB::DeliveryOrder::TypeData::get3($type, 'properties', 'nr_key'),
56
    $filters{numberfield}   = SL::DB::DeliveryOrder::TypeData::get3($type, 'properties', 'transnumber'),
53 57
    $filters{table}         = "delivery_orders";
54
    $filters{where}         = $type =~ /^sales/ ? '(customer_id IS NOT NULL)' : '(vendor_id IS NOT NULL)';
58
    $filters{where}         = "order_type = ?";
59
    $filters{values}        = [ $::form->{type} ];
55 60

  
56 61
  } elsif ($type =~ /_order$/) {
57 62
    $filters{trans_number}  = "ordnumber";
......
96 101
  my @values = ($self->number);
97 102

  
98 103
  push @where, $filters{where} if $filters{where};
104
  push @values, @{ $filters{values} } if $filters{values};
99 105

  
100 106
  if ($self->id) {
101 107
    push @where,  qq|id <> ?|;
......
131 137
SQL
132 138

  
133 139
    do_query($form, $self->dbh, "LOCK TABLE " . $filters{table}) || die $self->dbh->errstr;
134
    my %numbers_in_use = selectall_as_map($form, $self->dbh, $query, $filters{trans_number}, 'in_use');
140
    my %numbers_in_use = selectall_as_map($form, $self->dbh, $query, $filters{trans_number}, 'in_use', @{ $filters{values} // [] });
135 141

  
136 142
    my $business_number;
137 143
    ($business_number) = selectfirst_array_query($form, $self->dbh, qq|SELECT customernumberinit FROM business WHERE id = ? FOR UPDATE|, $self->business_id) if $self->business_id;

Auch abrufbar als: Unified diff