From c254544b198f8f7fe24220194003ab4c2551d476 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 29 May 2016 12:56:10 +0300 Subject: [PATCH] Added setting to hide second tax rate --- .../2014_05_17_175626_add_quotes.php | 6 ++-- ..._05_18_085739_add_invoice_type_support.php | 32 +++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/database/migrations/2014_05_17_175626_add_quotes.php b/database/migrations/2014_05_17_175626_add_quotes.php index 96ae916cafae..c332013d240d 100644 --- a/database/migrations/2014_05_17_175626_add_quotes.php +++ b/database/migrations/2014_05_17_175626_add_quotes.php @@ -14,9 +14,9 @@ class AddQuotes extends Migration { { Schema::table('invoices', function($table) { - $table->boolean('is_quote')->default(0); + $table->boolean('invoice_type_id')->default(0); $table->unsignedInteger('quote_id')->nullable(); - $table->unsignedInteger('quote_invoice_id')->nullable(); + $table->unsignedInteger('quote_invoice_id')->nullable(); }); } @@ -30,7 +30,7 @@ class AddQuotes extends Migration { Schema::table('invoices', function($table) { $table->dropColumn('is_quote'); - $table->dropColumn('quote_id'); + $table->dropColumn('invoice_type_id'); $table->dropColumn('quote_invoice_id'); }); } diff --git a/database/migrations/2016_05_18_085739_add_invoice_type_support.php b/database/migrations/2016_05_18_085739_add_invoice_type_support.php index 7b0b928d811b..faeb6ae0845d 100644 --- a/database/migrations/2016_05_18_085739_add_invoice_type_support.php +++ b/database/migrations/2016_05_18_085739_add_invoice_type_support.php @@ -12,9 +12,20 @@ class AddInvoiceTypeSupport extends Migration */ public function up() { - Schema::table('invoices', function ($table) { - $table->renameColumn('is_quote', 'invoice_type_id'); - }); + if (Schema::hasColumn('invoices', 'is_quote')) { + DB::update('update invoices set is_quote = is_quote + 1'); + + Schema::table('invoices', function ($table) { + $table->renameColumn('is_quote', 'invoice_type_id'); + }); + } + + Schema::table('accounts', function($table) + { + $table->boolean('enable_second_tax_rate')->default(false); + }); + + } /** @@ -24,8 +35,17 @@ class AddInvoiceTypeSupport extends Migration */ public function down() { - Schema::table('invoices', function ($table) { - $table->renameColumn('invoice_type_id', 'is_quote'); - }); + if (Schema::hasColumn('invoices', 'invoice_type_id')) { + DB::update('update invoices set invoice_type_id = invoice_type_id - 1'); + + Schema::table('invoices', function ($table) { + $table->renameColumn('invoice_type_id', 'is_quote'); + }); + } + + Schema::table('accounts', function($table) + { + $table->dropColumn('enable_second_tax_rate'); + }); } }