__PACKAGE__->meta->add_relationship(orderitems => { type => 'one to many',
class => 'SL::DB::DeliveryOrderItem',
column_map => { id => 'delivery_order_id' },
- manager_args => { with_objects => [ 'parts' ] }
+ manager_args => { with_objects => [ 'part' ] }
},
);
# methods
-sub part {
- # canonial alias for parts.
- goto &parts;
-}
-
1;
class => 'SL::DB::InvoiceItem',
column_map => { id => 'trans_id' },
manager_args => {
- with_objects => [ 'parts' ]
+ with_objects => [ 'part' ]
}
},
);
# methods
-sub items { goto &invoiceitems; }
-sub payment_term { goto &payment; }
+sub items { goto &invoiceitems; }
sub is_sales {
# For compatibility with Order, DeliveryOrder
__PACKAGE__->meta->initialize;
-sub part {
- # canonial alias for parts.
- goto &parts;
-}
-
1;
key_columns => { delivery_order_id => 'id' },
},
- parts => {
+ part => {
class => 'SL::DB::Part',
key_columns => { parts_id => 'id' },
},
key_columns => { language_id => 'id' },
},
- payment => {
+ payment_terms => {
class => 'SL::DB::PaymentTerm',
key_columns => { payment_id => 'id' },
},
allow_inline_column_values => 1,
foreign_keys => [
- parts => {
+ part => {
class => 'SL::DB::Part',
key_columns => { parts_id => 'id' },
},
key_columns => { language_id => 'id' },
},
- payment => {
+ payment_terms => {
class => 'SL::DB::PaymentTerm',
key_columns => { payment_id => 'id' },
},
allow_inline_column_values => 1,
foreign_keys => [
- parts => {
+ part => {
class => 'SL::DB::Part',
key_columns => { parts_id => 'id' },
},
key_columns => { project_id => 'id' },
},
- trans => {
+ order => {
class => 'SL::DB::Order',
key_columns => { trans_id => 'id' },
},
key_columns => { language_id => 'id' },
},
- payment => {
+ payment_terms => {
class => 'SL::DB::PaymentTerm',
key_columns => { payment_id => 'id' },
},
class => 'SL::DB::OrderItem',
column_map => { id => 'trans_id' },
manager_args => {
- with_objects => [ 'parts' ]
+ with_objects => [ 'part' ]
}
},
periodic_invoices_config => {
# methods
-sub items { goto &orderitems; }
-sub payment_terms { goto &payment; }
+sub items { goto &orderitems; }
sub type {
my $self = shift;
return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi);
}
-sub part {
- # canonial alias for parts.
- goto &parts;
-}
-
-sub order {
- # canonial alias for trans.
- goto &trans;
-}
-
1;
__PACKAGE__->meta->initialize;
-sub items { goto &invoiceitems; }
-sub payment_term { goto &payment; }
+sub items { goto &invoiceitems; }
sub is_sales {
# For compatibility with Order, DeliveryOrder
my %config;
+our %foreign_key_name_map = (
+ oe => { payment => 'payment_terms', },
+ ar => { payment => 'payment_terms', },
+ ap => { payment => 'payment_terms', },
+
+ orderitems => { parts => 'part', trans => 'order', },
+ delivery_order_items => { parts => 'part' },
+ invoice => { parts => 'part' },
+);
+
sub setup {
SL::LxOfficeConf->read;
}
$definition =~ s/::AUTO::/::/g;
+
+ while (my ($auto_generated_name, $desired_name) = each %{ $foreign_key_name_map{$table} || {} }) {
+ $definition =~ s/( foreign_keys \s*=> \s*\[ .* ^\s+ ) ${auto_generated_name} \b/${1}${desired_name}/msx;
+ }
+
my $full_definition = <<CODE;
# This file has been auto-generated. Do not modify it; it will be overwritten
# by $::script automatically.