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

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

=head1 NAME

CLMApp::Schema::Result::CustomerSystem

=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<CustomerSystem>

=cut

__PACKAGE__->table("CustomerSystem");

=head1 ACCESSORS

=head2 customersystemid

  data_type: 'integer'
  is_auto_increment: 1
  is_nullable: 0

=head2 customerid

  data_type: 'integer'
  is_nullable: 0

=head2 systemtype

  data_type: 'varchar'
  is_nullable: 1
  size: 256

=head2 systemid

  data_type: 'integer'
  default_value: 0
  is_nullable: 1

=head2 systemfiles

  data_type: 'text'
  is_nullable: 1

=head2 marketid

  data_type: 'integer'
  default_value: 0
  is_nullable: 1

=head2 accountingcode

  data_type: 'varchar'
  is_nullable: 1
  size: 256

=head2 filecode

  data_type: 'varchar'
  is_nullable: 1
  size: 256

=head2 active

  data_type: 'integer'
  default_value: 1
  is_nullable: 1

=head2 deleted

  data_type: 'tinyint'
  default_value: 0
  is_nullable: 1

=head2 created

  data_type: 'datetime'
  datetime_undef_if_invalid: 1
  default_value: '0000-00-00 00:00:00'
  is_nullable: 0

=head2 createdby

  data_type: 'integer'
  default_value: 0
  is_nullable: 0

=head2 updated

  data_type: 'datetime'
  datetime_undef_if_invalid: 1
  default_value: '0000-00-00 00:00:00'
  is_nullable: 0

=head2 updatedby

  data_type: 'integer'
  default_value: 0
  is_nullable: 0

=cut

__PACKAGE__->add_columns(
  "customersystemid",
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
  "customerid",
  { data_type => "integer", is_nullable => 0 },
  "systemtype",
  { data_type => "varchar", is_nullable => 1, size => 256 },
  "systemid",
  { data_type => "integer", default_value => 0, is_nullable => 1 },
  "systemfiles",
  { data_type => "text", is_nullable => 1 },
  "marketid",
  { data_type => "integer", default_value => 0, is_nullable => 1 },
  "accountingcode",
  { data_type => "varchar", is_nullable => 1, size => 256 },
  "filecode",
  { data_type => "varchar", is_nullable => 1, size => 256 },
  "active",
  { data_type => "integer", default_value => 1, is_nullable => 1 },
  "deleted",
  { data_type => "tinyint", default_value => 0, is_nullable => 1 },
  "created",
  {
    data_type => "datetime",
    datetime_undef_if_invalid => 1,
    default_value => "0000-00-00 00:00:00",
    is_nullable => 0,
  },
  "createdby",
  { data_type => "integer", default_value => 0, is_nullable => 0 },
  "updated",
  {
    data_type => "datetime",
    datetime_undef_if_invalid => 1,
    default_value => "0000-00-00 00:00:00",
    is_nullable => 0,
  },
  "updatedby",
  { data_type => "integer", default_value => 0, is_nullable => 0 },
);

=head1 PRIMARY KEY

=over 4

=item * L</customersystemid>

=back

=cut

__PACKAGE__->set_primary_key("customersystemid");


# Created by DBIx::Class::Schema::Loader v0.07049 @ 2024-04-25 17:17:42
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nwSlD7todhEybIHyqEq0bQ

__PACKAGE__->belongs_to(
  "systems_customer",
  "CLMApp::Schema::Result::Customer",
  { "foreign.customerid" => "self.customerid" },
  { cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->belongs_to(
  "ordersystems",
  "CLMApp::Schema::Result::OrderInvoiceSystem",
   sub {
      my $args = shift;

      return {
        "$args->{foreign_alias}.ordersystem" =>  { '=' => 1},
        "$args->{foreign_alias}.id" => { -ident => "$args->{self_alias}.systemid" },
        "$args->{foreign_alias}.deleted"   => { '=' => 0 },
      };
    },
  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION", join_type => 'LEFT' },
);

__PACKAGE__->belongs_to(
  "invoicesystems",
  "CLMApp::Schema::Result::OrderInvoiceSystem",
   sub {
      my $args = shift;

      return {
        "$args->{foreign_alias}.invoicesystem" =>  { '=' => 1},
        "$args->{foreign_alias}.id" => { -ident => "$args->{self_alias}.systemid" },
        "$args->{foreign_alias}.deleted"   => { '=' => 0 },
      };
    },
  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION", join_type => 'LEFT' },
);

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

__PACKAGE__->belongs_to(
  "market",
  "CLMApp::Schema::Result::Market",
  { "foreign.marketid" => "self.marketid" },
  { 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;
