From 16dd3ab1dfa304f687cb7db046023bf61674516e Mon Sep 17 00:00:00 2001 From: Muhammad Fajar Date: Tue, 8 Nov 2022 10:52:00 +0700 Subject: [PATCH] create migration invoices --- ...022_11_08_103959_create_invoices_table.php | 50 ++++++++++++++++ ...1_08_104903_create_invoice_items_table.php | 60 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 database/migrations/2022_11_08_103959_create_invoices_table.php create mode 100644 database/migrations/2022_11_08_104903_create_invoice_items_table.php diff --git a/database/migrations/2022_11_08_103959_create_invoices_table.php b/database/migrations/2022_11_08_103959_create_invoices_table.php new file mode 100644 index 00000000..e02a57ff --- /dev/null +++ b/database/migrations/2022_11_08_103959_create_invoices_table.php @@ -0,0 +1,50 @@ +id(); + $table->string('invoice_number')->nullable(); + $table->string('status')->nullable(); + $table->string('cancellation_reason')->nullable(); + $table->string('subject')->nullable(); + $table->string('recipient')->nullable(); + $table->date('invoiced_date')->nullable(); + $table->string('total_net')->nullable(); + $table->string('total_gross')->nullable(); + $table->string('details')->nullable(); + $table->string('note')->nullable(); + $table->timestamp('waiting_for_payment_at')->nullable(); + $table->timestamp('paid_at')->nullable(); + $table->timestamp('expired_at')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + + $table->foreignId('created_by')->nullable()->index(); + $table->foreignId('updated_by')->nullable()->index(); + $table->foreignId('deleted_by')->nullable()->index(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('invoices'); + } +}; diff --git a/database/migrations/2022_11_08_104903_create_invoice_items_table.php b/database/migrations/2022_11_08_104903_create_invoice_items_table.php new file mode 100644 index 00000000..718020b9 --- /dev/null +++ b/database/migrations/2022_11_08_104903_create_invoice_items_table.php @@ -0,0 +1,60 @@ +id(); + $table->nullableMorphs('itemable'); + $table->foreignId('parent_id')->nullable(); + $table->unsignedBigInteger('invoice_id')->nullable(); + $table->unsignedBigInteger('price_group_id')->nullable(); + $table->unsignedBigInteger('organization_id')->nullable(); + $table->string('type')->nullable(); + $table->string('price_gross')->nullable(); + $table->string('discount_type')->nullable()->default('percentage'); + $table->string('discount_percentage')->nullable(); + $table->string('discount_value')->nullable(); + $table->string('tax_type')->nullable()->default('percentage'); + $table->string('tax_percentage')->nullable(); + $table->string('tax_value')->nullable(); + $table->string('price_net')->nullable()->comment("price_net = price_gross - discount_value + tax_value"); + $table->string('total_net')->nullable()->comment("total_net = price_net * quantity"); + $table->string('notes')->nullable(); + $table->timestamps(); + $table->softDeletes(); + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + + + $table->index(['itemable_id', 'itemable_type']); + $table->index('organization_id'); + $table->index('invoice_id'); + $table->index('price_group_id'); + $table->index('created_by'); + $table->index('updated_by'); + $table->index('deleted_by'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('invoice_items'); + } +};