|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Support\Facades\Schema; |
|
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
5
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
6
|
|
|
|
|
7
|
|
|
class CreateInvoicesTables extends Migration |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Run the migrations. |
|
11
|
|
|
* |
|
12
|
|
|
* @return void |
|
13
|
|
|
*/ |
|
14
|
|
|
public function up() |
|
15
|
|
|
{ |
|
16
|
|
|
$tableNames = config('soap.invoices.table_names'); |
|
17
|
|
|
|
|
18
|
|
|
Schema::create($tableNames['invoices'], function (Blueprint $table) { |
|
19
|
|
|
$table->uuid('id')->primary(); |
|
20
|
|
|
$table->uuid('related_id'); |
|
21
|
|
|
$table->string('related_type'); |
|
22
|
|
|
$table->bigInteger('tax')->default(0)->description('in cents'); |
|
23
|
|
|
$table->bigInteger('total')->default(0)->description('in cents, including tax'); |
|
24
|
|
|
$table->bigInteger('discount')->default(0)->description('in cents'); |
|
25
|
|
|
$table->char('currency', 3); |
|
26
|
|
|
$table->char('reference', 17); |
|
27
|
|
|
$table->char('status', 16)->nullable(); |
|
28
|
|
|
$table->text('receiver_info')->nullable(); |
|
29
|
|
|
$table->text('sender_info')->nullable(); |
|
30
|
|
|
$table->text('payment_info')->nullable(); |
|
31
|
|
|
$table->text('note')->nullable(); |
|
32
|
|
|
$table->boolean('is_bill')->default(false); |
|
33
|
|
|
|
|
34
|
|
|
$table->timestamps(); |
|
35
|
|
|
$table->softDeletes(); |
|
36
|
|
|
|
|
37
|
|
|
$table->index(['invoicable_id', 'invoicable_type']); |
|
38
|
|
|
}); |
|
39
|
|
|
|
|
40
|
|
|
Schema::create($tableNames['invoice_lines'], function (Blueprint $table) { |
|
41
|
|
|
$table->uuid('id')->primary(); |
|
42
|
|
|
$table->bigInteger('amount')->default(0)->description('in cents, including tax'); |
|
43
|
|
|
$table->bigInteger('tax')->default(0)->description('in cents'); |
|
44
|
|
|
$table->json('tax_details')->nullable()->default(null); |
|
45
|
|
|
$table->uuid('invoice_id')->index(); |
|
46
|
|
|
$table->char('description', 255); |
|
47
|
|
|
$table->uuid('invoiceable_id'); |
|
48
|
|
|
$table->string('invoiceable_type'); |
|
49
|
|
|
$table->char('name', 255)->nullable(); |
|
50
|
|
|
$table->bigInteger('discount')->default(0)->description('in cents'); |
|
51
|
|
|
$table->bigInteger('quantity')->default(1); |
|
52
|
|
|
$table->boolean('is_free')->default(false); |
|
53
|
|
|
$table->boolean('is_complimentary')->default(false); |
|
54
|
|
|
$table->timestamps(); |
|
55
|
|
|
$table->softDeletes(); |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
$table->index(['invoiceable_id', 'invoiceable_type']); |
|
59
|
|
|
$table->foreign('invoice_id')->references('id')->on('invoices'); |
|
60
|
|
|
}); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Reverse the migrations. |
|
65
|
|
|
* |
|
66
|
|
|
* @return void |
|
67
|
|
|
*/ |
|
68
|
|
|
public function down() |
|
69
|
|
|
{ |
|
70
|
|
|
$tableNames = config('invoice.table_names'); |
|
71
|
|
|
|
|
72
|
|
|
Schema::dropIfExists($tableNames['invoice_lines']); |
|
73
|
|
|
Schema::dropIfExists($tableNames['invoices']); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|