Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision dfd16cc1

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID dfd16cc1326fd9cde1c7f09b0b1b9c925a1766c7
  • Vorgänger 06ec5141

Bug: Fehler beim Holen von custom_shipto

Hallo zusammen, ich habe habe ein Problem und vielleicht könnt ihr mir
weiter Helfen. Ich bin dabei die Lieferadresse von den Reklamationen
durchsuchbar zu machen. Da für wird eine DB-Abfrage über Rose generiert.
Das Problem tritt auf, wenn bei der Abfrage `with_objects => [ ...
'custom_shipto']` hinzugefügt wird.

In `SL::DB::Reclamation` wird die Relation wie folgt hinzugefügt:
```perl
custom_shipto => {
type => 'one to one',
class => 'SL::DB::Shipto',
column_map => { id => 'trans_id' },
query_args => [ module => 'Reclamation' ],
},
```
Wenn die Abfrage in sql übersetzt wird kommt folgendes raus:
```
LEFT OUTER JOIN shipto t15 ON (t1.id = t15.trans_id)
WHERE
t15.module = 'Reclamation'
```
Nun ist das Problem, dass alle Reklamationen ohne `custom_shipto` durch
die where-Klausel herausgefiltert werden. Ich habe schon versucht an den
`query_args`, am `type` und `with_objects` was zu verändern, aber das
alles hat nicht funktioniert. Was kann ich machen, dass auch die
Reklamationen ohne `custom_shipto` zurückgegeben werden?

Unterschiede anzeigen:

SL/Controller/Reclamation.pm
1938 1938

  
1939 1939
  $self->{report} = $report;
1940 1940

  
1941
  # TODO(Tamino): shipto_id is not linked to custom_shipto
1942 1941
  my @columns_order = qw(
1943 1942
    id
1944 1943
    record_number
......
1956 1955
    intnotes
1957 1956
    shippingpoint
1958 1957
    shipvia
1958
    shipto_name
1959
    shipto_department
1960
    shipto_street
1961
    shipto_zipcode
1962
    shipto_city
1963
    shipto_country
1959 1964
    amount
1960 1965
    netamount
1961 1966
    delivery_term
......
2038 2043
    shipvia => {
2039 2044
      sub      => sub { $_[0]->shipvia },
2040 2045
    },
2041
    # TODO(Tamino): custom ship to is not safed in reclamation
2042
    #shipto_id => {
2043
    #  sub      => sub { $_[0]->shipto ? $_[0]->shipto->shiptoname : '' },
2044
    #},
2046
    shipto_name => {
2047
      sub      => sub {
2048
        $_[0]->custom_shipto ? $_[0]->custom_shipto->shiptoname :
2049
        $_[0]->shipto        ? $_[0]->shipto->shiptoname        :
2050
        '';
2051
      },
2052
    },
2053
    shipto_department => {
2054
      sub      => sub {
2055
        $_[0]->custom_shipto ? join "\n" , ($_[0]->custom_shipto->shiptodepartment_1, $_[0]->custom_shipto->shiptodepartment_2):
2056
        $_[0]->shipto ?        $_[0]->shipto->shiptodepartment_1 . $_[0]->shipto->shiptodepartment_2:
2057
        '';
2058
      },
2059
    },
2060
    shipto_street => {
2061
      sub      => sub {
2062
        $_[0]->custom_shipto ? $_[0]->custom_shipto->shiptostreet :
2063
        $_[0]->shipto ?        $_[0]->shipto->shiptostreet :
2064
        '';
2065
      },
2066
    },
2067
    shipto_zipcode => {
2068
      sub      => sub {
2069
        $_[0]->custom_shipto ? $_[0]->custom_shipto->shiptozipcode :
2070
        $_[0]->shipto ?        $_[0]->shipto->shiptozipcode :
2071
        '';
2072
      },
2073
    },
2074
    shipto_city => {
2075
      sub      => sub {
2076
        $_[0]->custom_shipto ? $_[0]->custom_shipto->shiptocity :
2077
        $_[0]->shipto ?        $_[0]->shipto->shiptocity :
2078
        '';
2079
      },
2080
    },
2081
    shipto_country => {
2082
      sub      => sub {
2083
        $_[0]->custom_shipto ? $_[0]->custom_shipto->shiptocountry :
2084
        $_[0]->shipto ?        $_[0]->shipto->shiptocountry :
2085
        '';
2086
      },
2087
    },
2045 2088
    amount  => {
2046 2089
      sub      => sub { $_[0]->amount_as_number },
2047 2090
    },
SL/DB/Manager/Reclamation.pm
17 17
    my ($key, $value, $prefix) = @_;
18 18
    return __PACKAGE__->type_filter($value, $prefix);
19 19
  },
20
  # todo when is this used?
21
  #all => sub {
22
  #  my ($key, $value, $prefix) = @_;
23
  #  return or => [ map { $prefix . $_ => $value } qw(record_number customer.name vendor.name transaction_description) ]
24
  #}
20
  shipto_name => sub {
21
    return __PACKAGE__->shipto_filter(@_);
22
  },
23
  shipto_department => sub {
24
    my ($key, $value, $prefix) = @_;
25
    return __PACKAGE__->shipto_filter(['shipto_department_1','shipto_department_2'], $value, $prefix);
26
  },
27
  shipto_street => sub {
28
    return __PACKAGE__->shipto_filter(@_);
29
  },
30
  shipto_zipcode => sub {
31
    return __PACKAGE__->shipto_filter(@_);
32
  },
33
  shipto_city => sub {
34
    return __PACKAGE__->shipto_filter(@_);
35
  },
36
  shipto_country => sub {
37
    return __PACKAGE__->shipto_filter(@_);
38
  },
25 39
);
26 40

  
27 41
sub type_filter {
......
35 49
  die "Unknown type $type";
36 50
}
37 51

  
52
sub shipto_filter {
53
  my ($class, $key, $value, $prefix) = @_;
54

  
55
  my $keys;
56
  if (ref $keys ne 'ARRAY') {
57
    $keys = [$key];
58
  }
59

  
60
  my @or = ();
61
  for my $key (@$keys) {
62
    $key =~ s/^shipto_//;
63
    push @or, $prefix . 'shipto.shipto' . $key       , $value;
64
    push @or, $prefix . 'custom_shipto.shipto' . $key, $value;
65
  }
66

  
67
  return or => \@or, ['shipto', 'custom_shipto'];
68
}
69

  
38 70
sub _sort_spec {
39 71
  return (
40 72
    default                   => [ 'transdate', 1 ],
SL/DB/Reclamation.pm
37 37
    class                  => 'SL::DB::Shipto',
38 38
    column_map             => { id => 'trans_id' },
39 39
    query_args             => [ module => 'Reclamation' ],
40
    # query_args             => [ module => [ 'Reclamation', undef ] ],
40 41
  },
41 42
  exchangerate_obj         => {
42 43
    type                   => 'one to one',
SL/Presenter/ReclamationFilter.pm
198 198
      'report_id' => 'shipvia',
199 199
      'active' => 1,
200 200
    },
201
    # 'shipto_block'{
202
      'shipto_name' => {
203
        'position' => 18.1,
204
        'text' => t8("Name"),
205
        'input_type' => 'input_tag',
206
        'input_name' => 'filter.shipto_name:substr::ilike',
207
        'input_default' => $filter->{'shipto_name:substr::ilike'},
208
        'report_id' => 'shipto_name',
209
        'active' => 1,
210
      },
211
      'shipto_department' => {
212
        'position' => 18.2,
213
        'text' => t8("Department"),
214
        'input_type' => 'input_tag',
215
        'input_name' => 'filter.shipto_department:substr::ilike',
216
        'input_default' => $filter->{'shipto_department:substr::ilike'},
217
        'report_id' => 'shipto_department',
218
        'active' => 1,
219
      },
220
      'shipto_street' => {
221
        'position' => 18.3,
222
        'text' => t8("Street"),
223
        'input_type' => 'input_tag',
224
        'input_name' => 'filter.shipto_street:substr::ilike',
225
        'input_default' => $filter->{'shipto_street:substr::ilike'},
226
        'report_id' => 'shipto_street',
227
        'active' => 1,
228
      },
229
      'shipto_zipcode' => {
230
        'position' => 18.4,
231
        'text' => t8("Zipcode"),
232
        'input_type' => 'input_tag',
233
        'input_name' => 'filter.shipto_zipcode:substr::ilike',
234
        'input_default' => $filter->{'shipto_zipcode:substr::ilike'},
235
        'report_id' => 'shipto_zipcode',
236
        'active' => 1,
237
      },
238
      'shipto_city' => {
239
        'position' => 18.5,
240
        'text' => t8("City"),
241
        'input_type' => 'input_tag',
242
        'input_name' => 'filter.shipto_city:substr::ilike',
243
        'input_default' => $filter->{'shipto_city:substr::ilike'},
244
        'report_id' => 'shipto_city',
245
        'active' => 1,
246
      },
247
      'shipto_country' => {
248
        'position' => 18.6,
249
        'text' => t8("Country"),
250
        'input_type' => 'input_tag',
251
        'input_name' => 'filter.shipto_country:substr::ilike',
252
        'input_default' => $filter->{'shipto_country:substr::ilike'},
253
        'report_id' => 'shipto_country',
254
        'active' => 1,
255
      },
256
    # }
201 257
    'amount' => {
202 258
      'position' => 19,
203 259
      'text' => t8("Total"),

Auch abrufbar als: Unified diff