From b712efcdd4ada1fa83e6d84038f1ec39fbad0a30 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Thu, 6 Nov 2014 16:08:15 +0100 Subject: [PATCH] MT#8645 - add billing_profiles status, create_timestamp, modify_timestamp, terminate_timestamp add billing_mappings contract_active "belongs_to" relation --- lib/NGCP/Schema/Result/billing_mappings.pm | 19 ++++++++ lib/NGCP/Schema/Result/billing_profiles.pm | 54 ++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/lib/NGCP/Schema/Result/billing_mappings.pm b/lib/NGCP/Schema/Result/billing_mappings.pm index a15422c5..4c701e8a 100644 --- a/lib/NGCP/Schema/Result/billing_mappings.pm +++ b/lib/NGCP/Schema/Result/billing_mappings.pm @@ -72,6 +72,19 @@ __PACKAGE__->belongs_to( { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); +__PACKAGE__->belongs_to( + "contract_active", + "NGCP::Schema::Result::contracts", + sub { + my $args = shift; + return { + "$args->{foreign_alias}.id" => { -ident => "$args->{self_alias}.contract_id" } , + "$args->{foreign_alias}.status" => { '!=' => 'terminated' }, + }; + }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + __PACKAGE__->belongs_to( "product", "NGCP::Schema::Result::products", @@ -176,6 +189,12 @@ Type: belongs_to Related object: L +=head2 contract_active + +Type: belongs_to + +Related object: L + =head2 product Type: belongs_to diff --git a/lib/NGCP/Schema/Result/billing_profiles.pm b/lib/NGCP/Schema/Result/billing_profiles.pm index 122acd06..47201407 100644 --- a/lib/NGCP/Schema/Result/billing_profiles.pm +++ b/lib/NGCP/Schema/Result/billing_profiles.pm @@ -63,6 +63,33 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 255 }, "currency", { data_type => "varchar", is_nullable => 1, size => 31 }, + "status", + { + data_type => "enum", + default_value => "active", + extra => { list => ["active", "terminated"] }, + is_nullable => 0, + }, + "modify_timestamp", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + default_value => \"current_timestamp", + is_nullable => 0, + }, + "create_timestamp", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + default_value => "0000-00-00 00:00:00", + is_nullable => 0, + }, + "terminate_timestamp", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + is_nullable => 1, + }, ); __PACKAGE__->set_primary_key("id"); @@ -273,6 +300,33 @@ NGCP::Schema::Result::billing_profiles default_value: 1 is_nullable: 0 +head2 status + + data_type: 'enum' + default_value: 'active' + extra: {list => ["pending","active","locked","terminated"]} + is_nullable: 0 + +=head2 modify_timestamp + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: current_timestamp + is_nullable: 0 + +=head2 create_timestamp + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: '0000-00-00 00:00:00' + is_nullable: 0 + +=head2 terminate_timestamp + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + is_nullable: 1 + =head1 PRIMARY KEY =over 4