From 9a255c41b5c888dedb9473f14209e3eb3b61eeb7 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Thu, 5 Jun 2014 12:10:00 +0200 Subject: [PATCH] MT#5879 Cleanup invoice tables and add gpp contact Drop unnecessary invoice template tables. Provide proper columns in invoice and invoice templates table. Add general purpose columns to contacts. --- lib/NGCP/Schema/Result/contacts.pm | 22 ++++ .../Result/invoice_template_resource.pm | 97 --------------- .../Result/invoice_template_resources.pm | 97 --------------- lib/NGCP/Schema/Result/invoice_templates.pm | 116 +---------------- lib/NGCP/Schema/Result/invoices.pm | 117 ++---------------- 5 files changed, 37 insertions(+), 412 deletions(-) delete mode 100644 lib/NGCP/Schema/Result/invoice_template_resource.pm delete mode 100644 lib/NGCP/Schema/Result/invoice_template_resources.pm diff --git a/lib/NGCP/Schema/Result/contacts.pm b/lib/NGCP/Schema/Result/contacts.pm index def5c1c9..9d93e6b2 100644 --- a/lib/NGCP/Schema/Result/contacts.pm +++ b/lib/NGCP/Schema/Result/contacts.pm @@ -75,6 +75,28 @@ __PACKAGE__->add_columns( { data_type => "varchar", is_nullable => 1, size => 11 }, "vatnum", { data_type => "varchar", is_nullable => 1, size => 127 }, + "bankname", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp0", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp1", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp2", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp3", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp4", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp5", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp6", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp7", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp8", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "gpp9", + { data_type => "varchar", is_nullable => 1, size => 255 }, ); __PACKAGE__->set_primary_key("id"); diff --git a/lib/NGCP/Schema/Result/invoice_template_resource.pm b/lib/NGCP/Schema/Result/invoice_template_resource.pm deleted file mode 100644 index dd526c61..00000000 --- a/lib/NGCP/Schema/Result/invoice_template_resource.pm +++ /dev/null @@ -1,97 +0,0 @@ -package NGCP::Schema::Result::invoice_template_resource; -use Scalar::Util qw(blessed); -use parent 'DBIx::Class::Core'; - -our $VERSION = '2.010'; - -__PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON"); - - -__PACKAGE__->table("invoice_template_resource"); - - -__PACKAGE__->add_columns( - "invoice_template_id", - { - data_type => "integer", - extra => { unsigned => 1 }, - is_foreign_key => 1, - is_nullable => 0, - }, - "is_active", - { data_type => "tinyint", default_value => 0, is_nullable => 0 }, - "type", - { data_type => "enum", extra => { list => ["css"] }, is_nullable => 1 }, - "base64", - { data_type => "mediumblob", is_nullable => 1 }, -); - - -__PACKAGE__->belongs_to( - "invoice_template", - "NGCP::Schema::Result::invoice_template", - { id => "invoice_template_id" }, - { is_deferrable => 1, on_delete => "CASCADE", 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::invoice_template_resource - -=head1 COMPONENTS LOADED - -=over 4 - -=item * L - -=item * L - -=back - -=head1 TABLE: C - -=head1 ACCESSORS - -=head2 invoice_template_id - - data_type: 'integer' - extra: {unsigned => 1} - is_foreign_key: 1 - is_nullable: 0 - -=head2 is_active - - data_type: 'tinyint' - default_value: 0 - is_nullable: 0 - -=head2 type - - data_type: 'enum' - extra: {list => ["css"]} - is_nullable: 1 - -=head2 base64 - - data_type: 'mediumblob' - is_nullable: 1 - -=head1 RELATIONS - -=head2 invoice_template - -Type: belongs_to - -Related object: L - -=cut diff --git a/lib/NGCP/Schema/Result/invoice_template_resources.pm b/lib/NGCP/Schema/Result/invoice_template_resources.pm deleted file mode 100644 index ab86d27d..00000000 --- a/lib/NGCP/Schema/Result/invoice_template_resources.pm +++ /dev/null @@ -1,97 +0,0 @@ -package NGCP::Schema::Result::invoice_template_resources; -use Scalar::Util qw(blessed); -use parent 'DBIx::Class::Core'; - -our $VERSION = '2.010'; - -__PACKAGE__->load_components("InflateColumn::DateTime", "Helper::Row::ToJSON"); - - -__PACKAGE__->table("invoice_template_resources"); - - -__PACKAGE__->add_columns( - "invoice_template_id", - { - data_type => "integer", - extra => { unsigned => 1 }, - is_foreign_key => 1, - is_nullable => 0, - }, - "is_active", - { data_type => "tinyint", default_value => 0, is_nullable => 0 }, - "type", - { data_type => "enum", extra => { list => ["css"] }, is_nullable => 1 }, - "base64", - { data_type => "mediumblob", is_nullable => 1 }, -); - - -__PACKAGE__->belongs_to( - "invoice_template", - "NGCP::Schema::Result::invoice_template", - { id => "invoice_template_id" }, - { is_deferrable => 1, on_delete => "CASCADE", 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::invoice_template_resources - -=head1 COMPONENTS LOADED - -=over 4 - -=item * L - -=item * L - -=back - -=head1 TABLE: C - -=head1 ACCESSORS - -=head2 invoice_template_id - - data_type: 'integer' - extra: {unsigned => 1} - is_foreign_key: 1 - is_nullable: 0 - -=head2 is_active - - data_type: 'tinyint' - default_value: 0 - is_nullable: 0 - -=head2 type - - data_type: 'enum' - extra: {list => ["css"]} - is_nullable: 1 - -=head2 base64 - - data_type: 'mediumblob' - is_nullable: 1 - -=head1 RELATIONS - -=head2 invoice_template - -Type: belongs_to - -Related object: L - -=cut diff --git a/lib/NGCP/Schema/Result/invoice_templates.pm b/lib/NGCP/Schema/Result/invoice_templates.pm index 3b58e4b4..1d455dec 100644 --- a/lib/NGCP/Schema/Result/invoice_templates.pm +++ b/lib/NGCP/Schema/Result/invoice_templates.pm @@ -25,6 +25,8 @@ __PACKAGE__->add_columns( is_foreign_key => 1, is_nullable => 0, }, + "name", + { data_type => "varchar", is_nullable => 0, size => 255 }, "type", { data_type => "enum", @@ -34,135 +36,25 @@ __PACKAGE__->add_columns( }, "is_active", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, - "base64_saved", - { data_type => "mediumblob", is_nullable => 1 }, - "base64_previewed", + "data", { data_type => "mediumblob", is_nullable => 1 }, - "name", - { data_type => "varchar", is_nullable => 0, size => 255 }, - "x_title", - { data_type => "mediumint", default_value => 0, is_nullable => 0 }, - "y_title", - { data_type => "mediumint", default_value => 0, is_nullable => 0 }, - "rows_title", - { data_type => "mediumint", default_value => 0, is_nullable => 0 }, - "x_mid", - { data_type => "mediumint", default_value => 0, is_nullable => 0 }, - "y_mid", - { data_type => "mediumint", default_value => 0, is_nullable => 0 }, - "rows_mid", - { data_type => "mediumint", default_value => 0, is_nullable => 0 }, - "x_last", - { data_type => "mediumint", default_value => 0, is_nullable => 0 }, - "y_last", - { data_type => "mediumint", default_value => 0, is_nullable => 0 }, - "rows_last", - { data_type => "mediumint", default_value => 0, is_nullable => 0 }, ); __PACKAGE__->set_primary_key("id"); - -__PACKAGE__->has_many( - "invoice_template_resources", - "NGCP::Schema::billing::Result::invoice_template_resources", - { "foreign.invoice_template_id" => "self.id" }, - { cascade_copy => 0, cascade_delete => 0 }, -); - - __PACKAGE__->belongs_to( "reseller", "NGCP::Schema::Result::resellers", { id => "reseller_id" }, { is_deferrable => 1, on_delete => "CASCADE", 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::invoice_templates - -=head1 COMPONENTS LOADED - -=over 4 - -=item * L - -=item * L - -=back - -=head1 TABLE: C - -=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: 0 - -=head2 type - - data_type: 'enum' - default_value: 'svg' - extra: {list => ["svg","html"]} - is_nullable: 0 - -=head2 is_active - - data_type: 'tinyint' - default_value: 0 - is_nullable: 0 - -=head2 base64_saved - - data_type: 'mediumblob' - is_nullable: 1 - -=head2 base64_previewed - - data_type: 'mediumblob' - is_nullable: 1 - -=head1 PRIMARY KEY - -=over 4 - -=item * L - -=back - -=head1 RELATIONS - -=head2 reseller - -Type: belongs_to - -Related object: L - -=cut - -# You can replace this text with custom code or comments, and it will be preserved on regeneration -__PACKAGE__->meta->make_immutable; 1; diff --git a/lib/NGCP/Schema/Result/invoices.pm b/lib/NGCP/Schema/Result/invoices.pm index 33bd344f..3c97eb79 100644 --- a/lib/NGCP/Schema/Result/invoices.pm +++ b/lib/NGCP/Schema/Result/invoices.pm @@ -16,33 +16,25 @@ __PACKAGE__->add_columns( is_auto_increment => 1, is_nullable => 0, }, - "year", - { data_type => "smallint", extra => { unsigned => 1 }, is_nullable => 0 }, - "month", - { data_type => "tinyint", extra => { unsigned => 1 }, is_nullable => 0 }, "serial", + { data_type => "varchar", is_nullable => 0, size => 32 }, + "period_start", { data_type => "integer", extra => { unsigned => 1 }, is_nullable => 0 }, + "period_end", + { data_type => "integer", extra => { unsigned => 1 }, is_nullable => 0 }, + "amount_net", + { data_type => "double precision", default_value => 0, is_nullable => 0 }, + "amount_vat", + { data_type => "double precision", default_value => 0, is_nullable => 0 }, + "amount_total", + { data_type => "double precision", default_value => 0, is_nullable => 0 }, "data", { data_type => "blob", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); -__PACKAGE__->add_unique_constraint("yms_idx", ["year", "month", "serial"]); - -__PACKAGE__->has_many( - "contract_balances", - "NGCP::Schema::Result::contract_balances", - { "foreign.invoice_id" => "self.id" }, - { cascade_copy => 0, cascade_delete => 0 }, -); - -__PACKAGE__->has_many( - "orders", - "NGCP::Schema::Result::orders", - { "foreign.invoice_id" => "self.id" }, - { cascade_copy => 0, cascade_delete => 0 }, -); +__PACKAGE__->add_unique_constraint("serial_idx", ["serial"]); sub TO_JSON { my ($self) = @_; @@ -52,90 +44,3 @@ sub TO_JSON { } 1; -__END__ - -=encoding UTF-8 - -=head1 NAME - -NGCP::Schema::Result::invoices - -=head1 COMPONENTS LOADED - -=over 4 - -=item * L - -=item * L - -=back - -=head1 TABLE: C - -=head1 ACCESSORS - -=head2 id - - data_type: 'integer' - extra: {unsigned => 1} - is_auto_increment: 1 - is_nullable: 0 - -=head2 year - - data_type: 'smallint' - extra: {unsigned => 1} - is_nullable: 0 - -=head2 month - - data_type: 'tinyint' - extra: {unsigned => 1} - is_nullable: 0 - -=head2 serial - - data_type: 'integer' - extra: {unsigned => 1} - is_nullable: 0 - -=head2 data - - data_type: 'blob' - is_nullable: 1 - -=head1 PRIMARY KEY - -=over 4 - -=item * L - -=back - -=head1 UNIQUE CONSTRAINTS - -=head2 C - -=over 4 - -=item * L - -=item * L - -=item * L - -=back - -=head1 RELATIONS - -=head2 contract_balances - -Type: has_many - -Related object: L - -=head2 orders - -Type: has_many - -Related object: L