Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f3842deb

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID f3842debb17a887b210cd16ae6311d0270ef25a8
  • Vorgänger 48243bb3
  • Nachfolger 7ec7edbc

TypeData: nutzte Konstanten anstatt String für Typen

Unterschiede anzeigen:

SL/DB/Reclamation.pm
8 8
use List::Util qw(max sum0);
9 9
use List::MoreUtils qw(any);
10 10

  
11
use SL::DB::DeliveryOrder::TypeData qw(:types);
12
use SL::DB::Reclamation::TypeData qw(:types);
11 13
use SL::DB::MetaSetup::Reclamation;
12 14
use SL::DB::Manager::Reclamation;
13 15
use SL::DB::Helper::Attr;
......
107 109
sub type {
108 110
  my ($self) = @_;
109 111

  
110
  return 'sales_reclamation'    if $self->customer_id;
111
  return 'purchase_reclamation' if $self->vendor_id;
112
  return SALES_RECLAMATION_TYPE()    if $self->customer_id;
113
  return PURCHASE_RECLAMATION_TYPE() if $self->vendor_id;
112 114

  
113 115
  return;
114 116
}
......
127 129
sub displayable_type {
128 130
  my $type = shift->type;
129 131

  
130
  return $::locale->text('Sales Reclamation')    if $type eq 'sales_reclamation';
131
  return $::locale->text('Purchase Reclamation') if $type eq 'purchase_reclamation';
132
  return $::locale->text('Sales Reclamation')    if $type eq SALES_RECLAMATION_TYPE();
133
  return $::locale->text('Purchase Reclamation') if $type eq PURCHASE_RECLAMATION_TYPE();
132 134

  
133 135
  die 'invalid type';
134 136
}
......
147 149

  
148 150
  return 1 if $self->currency_id == $::instance_conf->get_currency_id;
149 151

  
150
  my $rate = (any { $self->is_type($_) } qw(sales_reclamation))    ? 'buy'
151
           : (any { $self->is_type($_) } qw(purchase_reclamation)) ? 'sell'
152
  my $rate = (any { $self->is_type($_) } (SALES_RECLAMATION_TYPE()))    ? 'buy'
153
           : (any { $self->is_type($_) } (PURCHASE_RECLAMATION_TYPE())) ? 'sell'
152 154
           : undef;
153 155
  return if !$rate;
154 156

  
......
201 203
  my ($self, %params) = @_;
202 204

  
203 205
  my $order;
204
  $params{destination_type} = $self->is_sales ? 'sales_order'
205
                                              : 'purchase_order';
206
  $params{destination_type} = $self->is_sales ? SALES_ORDER_TYPE()
207
                                              : PURCHASE_ORDER_TYPE();
206 208
  if (!$self->db->with_transaction(sub {
207 209
    require SL::DB::Order;
208 210
    $order = SL::DB::Order->new_from($self, %params);
......
253 255

  
254 256
  my @from_tos = (
255 257
    #Reclamation
256
    { from => 'sales_reclamation',       to => 'sales_reclamation',    abbr => 'srsr', },
257
    { from => 'purchase_reclamation',    to => 'purchase_reclamation', abbr => 'prpr', },
258
    { from => 'sales_reclamation',       to => 'purchase_reclamation', abbr => 'srpr', },
259
    { from => 'purchase_reclamation',    to => 'sales_reclamation',    abbr => 'prsr', },
258
    { from => SALES_RECLAMATION_TYPE(),       to => SALES_RECLAMATION_TYPE(),    abbr => 'srsr', },
259
    { from => PURCHASE_RECLAMATION_TYPE(),    to => PURCHASE_RECLAMATION_TYPE(), abbr => 'prpr', },
260
    { from => SALES_RECLAMATION_TYPE(),       to => PURCHASE_RECLAMATION_TYPE(), abbr => 'srpr', },
261
    { from => PURCHASE_RECLAMATION_TYPE(),    to => SALES_RECLAMATION_TYPE(),    abbr => 'prsr', },
260 262
    #Order
261
    { from => 'sales_order',             to => 'sales_reclamation',    abbr => 'sosr', },
262
    { from => 'purchase_order',          to => 'purchase_reclamation', abbr => 'popr', },
263
    { from => SALES_ORDER_TYPE(),             to => SALES_RECLAMATION_TYPE(),    abbr => 'sosr', },
264
    { from => PURCHASE_ORDER_TYPE(),          to => PURCHASE_RECLAMATION_TYPE(), abbr => 'popr', },
263 265
    #Delivery Order
264
    { from => 'sales_delivery_order',    to => 'sales_reclamation',    abbr => 'sdsr', },
265
    { from => 'purchase_delivery_order', to => 'purchase_reclamation', abbr => 'pdpr', },
266
    { from => SALES_DELIVERY_ORDER_TYPE(),    to => SALES_RECLAMATION_TYPE(),    abbr => 'sdsr', },
267
    { from => PURCHASE_DELIVERY_ORDER_TYPE(), to => PURCHASE_RECLAMATION_TYPE(), abbr => 'pdpr', },
266 268
    #Invoice
267
    { from => 'invoice',                 to => 'sales_reclamation',    abbr => 'sisr', },
268
    { from => 'purchase_invoice',        to => 'purchase_reclamation', abbr => 'pipr', },
269
    { from => 'invoice',                 to => SALES_RECLAMATION_TYPE(),    abbr => 'sisr', },
270
    { from => 'purchase_invoice',        to => PURCHASE_RECLAMATION_TYPE(), abbr => 'pipr', },
269 271
  );
270 272
  my $from_to = (grep { $_->{from} eq $source->type && $_->{to} eq $destination_type} @from_tos)[0];
271 273
  if (!$from_to) {

Auch abrufbar als: Unified diff