use utf8;
package CLMApp::Schema::Result::Bpmigration;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME

CLMApp::Schema::Result::Bpmigration

=cut

use strict;
use warnings;

use base 'DBIx::Class::Core';

=head1 COMPONENTS LOADED

=over 4

=item * L<DBIx::Class::InflateColumn::DateTime>

=back

=cut

__PACKAGE__->load_components("InflateColumn::DateTime");

=head1 TABLE: C<BPMigration>

=cut

__PACKAGE__->table("BPMigration");

=head1 ACCESSORS

=head2 bpmigrationid

  data_type: 'integer'
  is_auto_increment: 1
  is_nullable: 0

=head2 chaingroupid

  data_type: 'integer'
  default_value: 0
  is_nullable: 1

=head2 chainconceptid

  data_type: 'integer'
  default_value: 0
  is_nullable: 1

=head2 distributorwarehouseid

  data_type: 'integer'
  default_value: 0
  is_nullable: 1

=head2 systemid

  data_type: 'integer'
  default_value: 0
  is_nullable: 1

=head2 active

  data_type: 'integer'
  default_value: 1
  is_nullable: 1

=head2 distributorcompanyid

  data_type: 'integer'
  default_value: 0
  is_nullable: 1

=cut

__PACKAGE__->add_columns(
  "bpmigrationid",
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
  "chaingroupid",
  { data_type => "integer", default_value => 0, is_nullable => 1 },
  "chainconceptid",
  { data_type => "integer", default_value => 0, is_nullable => 1 },
  "distributorwarehouseid",
  { data_type => "integer", default_value => 0, is_nullable => 1 },
  "systemid",
  { data_type => "integer", default_value => 0, is_nullable => 1 },
  "active",
  { data_type => "integer", default_value => 1, is_nullable => 1 },
  "distributorcompanyid",
  { data_type => "integer", default_value => 0, is_nullable => 1 },
);

=head1 PRIMARY KEY

=over 4

=item * L</bpmigrationid>

=back

=cut

__PACKAGE__->set_primary_key("bpmigrationid");


__PACKAGE__->belongs_to(
  "chaingrp",
  "CLMApp::Schema::Result::ChainGroup",
  { "foreign.chaingroupid" => "self.chaingroupid" },
  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION", join_type => 'LEFT' },
);

__PACKAGE__->belongs_to(
  "concept",
  "CLMApp::Schema::Result::ChainConcept",
  { "foreign.chainconceptid" => "self.chainconceptid" },
  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION", join_type => 'LEFT' },
);

__PACKAGE__->belongs_to(
  "warehouse",
  "CLMApp::Schema::Result::DistributorWarehouse",
  { "foreign.distributorwarehouseid" => "self.distributorwarehouseid" },
  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION", join_type => 'LEFT' },
);

__PACKAGE__->belongs_to(
  "distributor",
  "CLMApp::Schema::Result::DistributorCompany",
  { "foreign.distributorcompanyid" => "self.distributorcompanyid" },
  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION", join_type => 'LEFT' },
);
__PACKAGE__->belongs_to(
  "backoffice",
  "CLMApp::Schema::Result::BackOfficeSystem",
  { "foreign.systemid" => "self.systemid" },
  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION", join_type => 'LEFT' },
);

# Created by DBIx::Class::Schema::Loader v0.07039 @ 2018-03-07 09:34:05
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FFH3MGCD9449ZRzFwynrmw


__PACKAGE__->has_many(
  "emailnotifications",
  "CLMApp::Schema::Result::EmailNotification",
   sub {
      my $args = shift;

      return {
        "-or" =>
          [
            {"$args->{foreign_alias}.chainconceptid" => { -ident => "$args->{self_alias}.chainconceptid" } },
            {"$args->{foreign_alias}.chainconceptid" => { '=' => 0 } }
          ],
        "$args->{foreign_alias}.chaingroupid" => { -ident => "$args->{self_alias}.chaingroupid" },
        "$args->{foreign_alias}.distributorcompanyid" => { -ident => "$args->{self_alias}.distributorcompanyid" },
        "$args->{foreign_alias}.active"   => { '=' => 1 },
      };
    },
  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION", join_type => 'LEFT' },
);



# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
