refactor invoice & estimate migrations

This commit is contained in:
raishvaria
2019-12-04 16:38:25 +05:30
parent 122c4f478f
commit 9b9761aa5a
7 changed files with 34 additions and 9 deletions

View File

@ -82,7 +82,7 @@ class Invoice extends Model
// So the substr returns this 000001
// Add the string in front and higher up the number.
// the %05d part makes sure that there are always 6 numbers in the string.
// the %06d part makes sure that there are always 6 numbers in the string.
// so it adds the missing zero's when needed.
return sprintf('%06d', intval($number) + 1);

View File

@ -4,6 +4,7 @@ namespace Crater\Listeners\Updates\v2;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Database\Schema\Blueprint;
use Crater\Events\UpdateFinished;
use Crater\Listeners\Updates\Listener;
use Crater\Setting;
@ -37,6 +38,9 @@ class Version201 extends Listener
// Remove the language files
$this->removeLanguageFiles();
// Change estimate & invoice migrations
$this->changeMigrations();
// Update Crater app version
Setting::setSetting('version', static::VERSION);
}
@ -58,4 +62,25 @@ class Version201 extends Listener
unlink($fr);
}
}
private function changeMigrations()
{
\Schema::table('invoices', function (Blueprint $table) {
$table->decimal('quantity', 15, 2)->change();
$table->decimal('discount', 15, 2)->nullable()->change();
});
\Schema::table('estimates', function (Blueprint $table) {
$table->decimal('quantity', 15, 2)->change();
$table->decimal('discount', 15, 2)->nullable()->change();
});
\Schema::table('invoice_items', function (Blueprint $table) {
$table->decimal('quantity', 15, 2)->change();
$table->decimal('discount', 15, 2)->nullable()->change();
});
\Schema::table('estimate_items', function (Blueprint $table) {
$table->decimal('quantity', 15, 2)->change();
$table->decimal('discount', 15, 2)->nullable()->change();
$table->unsignedBigInteger('discount_val')->nullable()->change();
});
}
}