Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5c03b316

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

  • ID 5c03b316c349b081a165f0c8b45348b70e712565
  • Vorgänger 94e5f462
  • Nachfolger c9847742

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 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);
19
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),
20
  @{ SL::DB::DeliveryOrder::TypeData::valid_types() },
21
);
19 22

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

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

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

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

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

  
133 138
    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');
139
    my %numbers_in_use = selectall_as_map($form, $self->dbh, $query, $filters{trans_number}, 'in_use', @{ $filters{values} // [] });
135 140

  
136 141
    my $business_number;
137 142
    ($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