You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
310 lines
5.3 KiB
310 lines
5.3 KiB
package NGCP::Schema::Result::customers;
|
|
use Scalar::Util qw(blessed);
|
|
use parent 'DBIx::Class::Core';
|
|
|
|
our $VERSION = '2.007';
|
|
|
|
__PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON");
|
|
|
|
__PACKAGE__->table("billing.customers");
|
|
|
|
__PACKAGE__->add_columns(
|
|
"id",
|
|
{
|
|
data_type => "integer",
|
|
extra => { unsigned => 1 },
|
|
is_auto_increment => 1,
|
|
is_nullable => 0,
|
|
},
|
|
"reseller_id",
|
|
{
|
|
data_type => "integer",
|
|
extra => { unsigned => 1 },
|
|
is_foreign_key => 1,
|
|
is_nullable => 1,
|
|
},
|
|
"shopuser",
|
|
{ data_type => "varchar", is_nullable => 1, size => 31 },
|
|
"shoppass",
|
|
{ data_type => "varchar", is_nullable => 1, size => 31 },
|
|
"business",
|
|
{ data_type => "tinyint", default_value => 0, is_nullable => 0 },
|
|
"contact_id",
|
|
{
|
|
data_type => "integer",
|
|
extra => { unsigned => 1 },
|
|
is_foreign_key => 1,
|
|
is_nullable => 1,
|
|
},
|
|
"tech_contact_id",
|
|
{
|
|
data_type => "integer",
|
|
extra => { unsigned => 1 },
|
|
is_foreign_key => 1,
|
|
is_nullable => 1,
|
|
},
|
|
"comm_contact_id",
|
|
{
|
|
data_type => "integer",
|
|
extra => { unsigned => 1 },
|
|
is_foreign_key => 1,
|
|
is_nullable => 1,
|
|
},
|
|
"external_id",
|
|
{ data_type => "varchar", is_nullable => 1, size => 255 },
|
|
"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,
|
|
},
|
|
);
|
|
|
|
__PACKAGE__->set_primary_key("id");
|
|
|
|
__PACKAGE__->add_unique_constraint("reseller_id", ["reseller_id", "shopuser"]);
|
|
|
|
__PACKAGE__->belongs_to(
|
|
"comm_contact",
|
|
"NGCP::Schema::Result::contacts",
|
|
{ id => "comm_contact_id" },
|
|
{
|
|
is_deferrable => 1,
|
|
join_type => "LEFT",
|
|
on_delete => "RESTRICT",
|
|
on_update => "CASCADE",
|
|
},
|
|
);
|
|
|
|
__PACKAGE__->belongs_to(
|
|
"contact",
|
|
"NGCP::Schema::Result::contacts",
|
|
{ id => "contact_id" },
|
|
{
|
|
is_deferrable => 1,
|
|
join_type => "LEFT",
|
|
on_delete => "RESTRICT",
|
|
on_update => "CASCADE",
|
|
},
|
|
);
|
|
|
|
__PACKAGE__->has_many(
|
|
"contracts",
|
|
"NGCP::Schema::Result::contracts",
|
|
{ "foreign.customer_id" => "self.id" },
|
|
{ cascade_copy => 0, cascade_delete => 0 },
|
|
);
|
|
|
|
__PACKAGE__->has_many(
|
|
"customer_registers",
|
|
"NGCP::Schema::Result::customer_registers",
|
|
{ "foreign.customer_id" => "self.id" },
|
|
{ cascade_copy => 0, cascade_delete => 0 },
|
|
);
|
|
|
|
__PACKAGE__->has_many(
|
|
"orders",
|
|
"NGCP::Schema::Result::orders",
|
|
{ "foreign.customer_id" => "self.id" },
|
|
{ cascade_copy => 0, cascade_delete => 0 },
|
|
);
|
|
|
|
__PACKAGE__->belongs_to(
|
|
"reseller",
|
|
"NGCP::Schema::Result::resellers",
|
|
{ id => "reseller_id" },
|
|
{
|
|
is_deferrable => 1,
|
|
join_type => "LEFT",
|
|
on_delete => "RESTRICT",
|
|
on_update => "CASCADE",
|
|
},
|
|
);
|
|
|
|
__PACKAGE__->belongs_to(
|
|
"tech_contact",
|
|
"NGCP::Schema::Result::contacts",
|
|
{ id => "tech_contact_id" },
|
|
{
|
|
is_deferrable => 1,
|
|
join_type => "LEFT",
|
|
on_delete => "RESTRICT",
|
|
on_update => "CASCADE",
|
|
},
|
|
);
|
|
|
|
sub TO_JSON {
|
|
my ($self) = @_;
|
|
return {
|
|
map { blessed($_) && $_->isa('DateTime') ? $_->datetime : $_ } %{ $self->next::method }
|
|
};
|
|
}
|
|
|
|
1;
|
|
__END__
|
|
|
|
=encoding UTF-8
|
|
|
|
=head1 NAME
|
|
|
|
NGCP::Schema::Result::customers
|
|
|
|
=head1 COMPONENTS LOADED
|
|
|
|
=over 4
|
|
|
|
=item * L<DBIx::Class::InflateColumn::DateTime>
|
|
|
|
=item * L<DBIx::Class::Helper::Row::ToJSON>
|
|
|
|
=back
|
|
|
|
=head1 TABLE: C<billing.customers>
|
|
|
|
=head1 ACCESSORS
|
|
|
|
=head2 id
|
|
|
|
data_type: 'integer'
|
|
extra: {unsigned => 1}
|
|
is_auto_increment: 1
|
|
is_nullable: 0
|
|
|
|
=head2 reseller_id
|
|
|
|
data_type: 'integer'
|
|
extra: {unsigned => 1}
|
|
is_foreign_key: 1
|
|
is_nullable: 1
|
|
|
|
=head2 shopuser
|
|
|
|
data_type: 'varchar'
|
|
is_nullable: 1
|
|
size: 31
|
|
|
|
=head2 shoppass
|
|
|
|
data_type: 'varchar'
|
|
is_nullable: 1
|
|
size: 31
|
|
|
|
=head2 business
|
|
|
|
data_type: 'tinyint'
|
|
default_value: 0
|
|
is_nullable: 0
|
|
|
|
=head2 contact_id
|
|
|
|
data_type: 'integer'
|
|
extra: {unsigned => 1}
|
|
is_foreign_key: 1
|
|
is_nullable: 1
|
|
|
|
=head2 tech_contact_id
|
|
|
|
data_type: 'integer'
|
|
extra: {unsigned => 1}
|
|
is_foreign_key: 1
|
|
is_nullable: 1
|
|
|
|
=head2 comm_contact_id
|
|
|
|
data_type: 'integer'
|
|
extra: {unsigned => 1}
|
|
is_foreign_key: 1
|
|
is_nullable: 1
|
|
|
|
=head2 external_id
|
|
|
|
data_type: 'varchar'
|
|
is_nullable: 1
|
|
size: 255
|
|
|
|
=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
|
|
|
|
=head1 PRIMARY KEY
|
|
|
|
=over 4
|
|
|
|
=item * L</id>
|
|
|
|
=back
|
|
|
|
=head1 UNIQUE CONSTRAINTS
|
|
|
|
=head2 C<reseller_id>
|
|
|
|
=over 4
|
|
|
|
=item * L</reseller_id>
|
|
|
|
=item * L</shopuser>
|
|
|
|
=back
|
|
|
|
=head1 RELATIONS
|
|
|
|
=head2 comm_contact
|
|
|
|
Type: belongs_to
|
|
|
|
Related object: L<NGCP::Schema::Result::contacts>
|
|
|
|
=head2 contact
|
|
|
|
Type: belongs_to
|
|
|
|
Related object: L<NGCP::Schema::Result::contacts>
|
|
|
|
=head2 contracts
|
|
|
|
Type: has_many
|
|
|
|
Related object: L<NGCP::Schema::Result::contracts>
|
|
|
|
=head2 customer_registers
|
|
|
|
Type: has_many
|
|
|
|
Related object: L<NGCP::Schema::Result::customer_registers>
|
|
|
|
=head2 orders
|
|
|
|
Type: has_many
|
|
|
|
Related object: L<NGCP::Schema::Result::orders>
|
|
|
|
=head2 reseller
|
|
|
|
Type: belongs_to
|
|
|
|
Related object: L<NGCP::Schema::Result::resellers>
|
|
|
|
=head2 tech_contact
|
|
|
|
Type: belongs_to
|
|
|
|
Related object: L<NGCP::Schema::Result::contacts>
|