Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0845c4b7

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 0845c4b7d7a969d68cd55a15780c0af2fbe4d2db
  • Vorgänger 026e601d
  • Nachfolger aa8fc8ca

Rose: Fremdschlüsselbenennung fixen

Die von Rose erzeugten Fremdschlüsselaccessoren heißen wie die
Spaltennamen, also z.B. in Perl 'trans' zu Spalte 'trans_id'. Das ist
unintuitiv und muss an vielen Stellen (z.B. bei den manager_args,
with_objects etc.) auch als 'trans' angegeben werden.

Also im Generatorscript gewisse Namen auf sinnvollere Namen mappen.

Unterschiede anzeigen:

SL/DB/DeliveryOrder.pm
15 15
__PACKAGE__->meta->add_relationship(orderitems => { type         => 'one to many',
16 16
                                                    class        => 'SL::DB::DeliveryOrderItem',
17 17
                                                    column_map   => { id => 'delivery_order_id' },
18
                                                    manager_args => { with_objects => [ 'parts' ] }
18
                                                    manager_args => { with_objects => [ 'part' ] }
19 19
                                                  },
20 20
                                   );
21 21

  
SL/DB/DeliveryOrderItem.pm
24 24

  
25 25
# methods
26 26

  
27
sub part {
28
  # canonial alias for parts.
29
  goto &parts;
30
}
31

  
32 27
1;
SL/DB/Invoice.pm
25 25
    class        => 'SL::DB::InvoiceItem',
26 26
    column_map   => { id => 'trans_id' },
27 27
    manager_args => {
28
      with_objects => [ 'parts' ]
28
      with_objects => [ 'part' ]
29 29
    }
30 30
  },
31 31
);
......
34 34

  
35 35
# methods
36 36

  
37
sub items        { goto &invoiceitems; }
38
sub payment_term { goto &payment;      }
37
sub items { goto &invoiceitems; }
39 38

  
40 39
sub is_sales {
41 40
  # For compatibility with Order, DeliveryOrder
SL/DB/InvoiceItem.pm
24 24

  
25 25
__PACKAGE__->meta->initialize;
26 26

  
27
sub part {
28
  # canonial alias for parts.
29
  goto &parts;
30
}
31

  
32 27
1;
SL/DB/MetaSetup/DeliveryOrderItem.pm
45 45
      key_columns => { delivery_order_id => 'id' },
46 46
    },
47 47

  
48
    parts => {
48
    part => {
49 49
      class       => 'SL::DB::Part',
50 50
      key_columns => { parts_id => 'id' },
51 51
    },
SL/DB/MetaSetup/Invoice.pm
99 99
      key_columns => { language_id => 'id' },
100 100
    },
101 101

  
102
    payment => {
102
    payment_terms => {
103 103
      class       => 'SL::DB::PaymentTerm',
104 104
      key_columns => { payment_id => 'id' },
105 105
    },
SL/DB/MetaSetup/InvoiceItem.pm
46 46
  allow_inline_column_values => 1,
47 47

  
48 48
  foreign_keys => [
49
    parts => {
49
    part => {
50 50
      class       => 'SL::DB::Part',
51 51
      key_columns => { parts_id => 'id' },
52 52
    },
SL/DB/MetaSetup/Order.pm
93 93
      key_columns => { language_id => 'id' },
94 94
    },
95 95

  
96
    payment => {
96
    payment_terms => {
97 97
      class       => 'SL::DB::PaymentTerm',
98 98
      key_columns => { payment_id => 'id' },
99 99
    },
SL/DB/MetaSetup/OrderItem.pm
44 44
  allow_inline_column_values => 1,
45 45

  
46 46
  foreign_keys => [
47
    parts => {
47
    part => {
48 48
      class       => 'SL::DB::Part',
49 49
      key_columns => { parts_id => 'id' },
50 50
    },
......
64 64
      key_columns => { project_id => 'id' },
65 65
    },
66 66

  
67
    trans => {
67
    order => {
68 68
      class       => 'SL::DB::Order',
69 69
      key_columns => { trans_id => 'id' },
70 70
    },
SL/DB/MetaSetup/PurchaseInvoice.pm
75 75
      key_columns => { language_id => 'id' },
76 76
    },
77 77

  
78
    payment => {
78
    payment_terms => {
79 79
      class       => 'SL::DB::PaymentTerm',
80 80
      key_columns => { payment_id => 'id' },
81 81
    },
SL/DB/Order.pm
23 23
    class        => 'SL::DB::OrderItem',
24 24
    column_map   => { id => 'trans_id' },
25 25
    manager_args => {
26
      with_objects => [ 'parts' ]
26
      with_objects => [ 'part' ]
27 27
    }
28 28
  },
29 29
  periodic_invoices_config => {
......
37 37

  
38 38
# methods
39 39

  
40
sub items         { goto &orderitems; }
41
sub payment_terms { goto &payment;    }
40
sub items { goto &orderitems; }
42 41

  
43 42
sub type {
44 43
  my $self = shift;
SL/DB/OrderItem.pm
39 39
  return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi);
40 40
}
41 41

  
42
sub part {
43
  # canonial alias for parts.
44
  goto &parts;
45
}
46

  
47
sub order {
48
  # canonial alias for trans.
49
  goto &trans;
50
}
51

  
52 42
1;
SL/DB/PurchaseInvoice.pm
19 19

  
20 20
__PACKAGE__->meta->initialize;
21 21

  
22
sub items        { goto &invoiceitems; }
23
sub payment_term { goto &payment;      }
22
sub items { goto &invoiceitems; }
24 23

  
25 24
sub is_sales {
26 25
  # For compatibility with Order, DeliveryOrder
scripts/rose_auto_create_model.pl
44 44

  
45 45
my %config;
46 46

  
47
our %foreign_key_name_map = (
48
  oe                   => { payment => 'payment_terms', },
49
  ar                   => { payment => 'payment_terms', },
50
  ap                   => { payment => 'payment_terms', },
51

  
52
  orderitems           => { parts => 'part', trans => 'order', },
53
  delivery_order_items => { parts => 'part' },
54
  invoice              => { parts => 'part' },
55
);
56

  
47 57
sub setup {
48 58

  
49 59
  SL::LxOfficeConf->read;
......
103 113
  }
104 114

  
105 115
  $definition =~ s/::AUTO::/::/g;
116

  
117
  while (my ($auto_generated_name, $desired_name) = each %{ $foreign_key_name_map{$table} || {} }) {
118
    $definition =~ s/( foreign_keys \s*=> \s*\[ .* ^\s+ ) ${auto_generated_name} \b/${1}${desired_name}/msx;
119
  }
120

  
106 121
  my $full_definition = <<CODE;
107 122
# This file has been auto-generated. Do not modify it; it will be overwritten
108 123
# by $::script automatically.

Auch abrufbar als: Unified diff