From 350d2f3900bb2db1ca664af46961c49bbffa296f Mon Sep 17 00:00:00 2001 From: M Adyan Rohutomo Date: Wed, 14 Sep 2022 22:13:34 +0700 Subject: [PATCH 1/2] create migration for payment order --- ...alter_payment_orders_table_add_columns.php | 47 ++++++++++++++ ...28_create_payment_order_invoices_table.php | 41 ++++++++++++ ...eate_payment_order_down_payments_table.php | 41 ++++++++++++ ...207_create_payment_order_returns_table.php | 41 ++++++++++++ ...1334_create_payment_order_others_table.php | 46 ++++++++++++++ ...7_create_payment_order_histories_table.php | 41 ++++++++++++ ...755_create_purchase_invoice_done_table.php | 38 ++++++++++++ ...322_create_payment_order_archive_table.php | 62 +++++++++++++++++++ 8 files changed, 357 insertions(+) create mode 100644 database/migrations/tenant/2022_09_06_205955_alter_payment_orders_table_add_columns.php create mode 100644 database/migrations/tenant/2022_09_06_210428_create_payment_order_invoices_table.php create mode 100644 database/migrations/tenant/2022_09_06_211031_create_payment_order_down_payments_table.php create mode 100644 database/migrations/tenant/2022_09_06_211207_create_payment_order_returns_table.php create mode 100644 database/migrations/tenant/2022_09_06_211334_create_payment_order_others_table.php create mode 100644 database/migrations/tenant/2022_09_06_211447_create_payment_order_histories_table.php create mode 100644 database/migrations/tenant/2022_09_06_211755_create_purchase_invoice_done_table.php create mode 100644 database/migrations/tenant/2022_09_07_184322_create_payment_order_archive_table.php diff --git a/database/migrations/tenant/2022_09_06_205955_alter_payment_orders_table_add_columns.php b/database/migrations/tenant/2022_09_06_205955_alter_payment_orders_table_add_columns.php new file mode 100644 index 000000000..983b2b32e --- /dev/null +++ b/database/migrations/tenant/2022_09_06_205955_alter_payment_orders_table_add_columns.php @@ -0,0 +1,47 @@ +unsignedInteger('form_id')->nullable()->index(); + $table->unsignedInteger('supplier_id')->index(); + $table->decimal('total_invoice', 65, 30); + $table->decimal('total_down_payment', 65, 30); + $table->decimal('total_return', 65, 30); + $table->decimal('total_other', 65, 30); + $table->timestamps(); + + $table->foreign('form_id') + ->references('id') + ->on('forms'); + $table->foreign('supplier_id') + ->references('id') + ->on('suppliers'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('payment_orders', function (Blueprint $table) { + $table->dropForeign(['supplier_id']); + $table->dropForeign(['form_id']); + $table->dropColumn(['updated_at', 'created_at', 'total_other', 'total_return', 'total_down_payment', 'total_invoice', 'supplier_id', 'form_id']); + }); + } +} diff --git a/database/migrations/tenant/2022_09_06_210428_create_payment_order_invoices_table.php b/database/migrations/tenant/2022_09_06_210428_create_payment_order_invoices_table.php new file mode 100644 index 000000000..61e3c0e4e --- /dev/null +++ b/database/migrations/tenant/2022_09_06_210428_create_payment_order_invoices_table.php @@ -0,0 +1,41 @@ +id(); + $table->unsignedInteger('payment_order_id')->index(); + $table->unsignedInteger('purchase_invoice_id')->index(); + $table->decimal('amount', 65, 30); + $table->timestamps(); + + $table->foreign('payment_order_id') + ->references('id') + ->on('payment_orders'); + $table->foreign('purchase_invoice_id') + ->references('id') + ->on('purchase_invoices'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('payment_order_invoices'); + } +} diff --git a/database/migrations/tenant/2022_09_06_211031_create_payment_order_down_payments_table.php b/database/migrations/tenant/2022_09_06_211031_create_payment_order_down_payments_table.php new file mode 100644 index 000000000..330becc52 --- /dev/null +++ b/database/migrations/tenant/2022_09_06_211031_create_payment_order_down_payments_table.php @@ -0,0 +1,41 @@ +id(); + $table->unsignedInteger('payment_order_id')->index(); + $table->unsignedInteger('purchase_down_payment_id')->index(); + $table->decimal('amount', 65, 30); + $table->timestamps(); + + $table->foreign('payment_order_id') + ->references('id') + ->on('payment_orders'); + $table->foreign('purchase_down_payment_id') + ->references('id') + ->on('purchase_down_payments'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('payment_order_down_payments'); + } +} diff --git a/database/migrations/tenant/2022_09_06_211207_create_payment_order_returns_table.php b/database/migrations/tenant/2022_09_06_211207_create_payment_order_returns_table.php new file mode 100644 index 000000000..a26d140c0 --- /dev/null +++ b/database/migrations/tenant/2022_09_06_211207_create_payment_order_returns_table.php @@ -0,0 +1,41 @@ +id(); + $table->unsignedInteger('payment_order_id')->index(); + $table->unsignedInteger('purchase_return_id')->index(); + $table->decimal('amount', 65, 30); + $table->timestamps(); + + $table->foreign('payment_order_id') + ->references('id') + ->on('payment_orders'); + $table->foreign('purchase_return_id') + ->references('id') + ->on('purchase_returns'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('payment_order_returns'); + } +} diff --git a/database/migrations/tenant/2022_09_06_211334_create_payment_order_others_table.php b/database/migrations/tenant/2022_09_06_211334_create_payment_order_others_table.php new file mode 100644 index 000000000..d48a1ed36 --- /dev/null +++ b/database/migrations/tenant/2022_09_06_211334_create_payment_order_others_table.php @@ -0,0 +1,46 @@ +id(); + $table->unsignedInteger('payment_order_id')->index(); + $table->unsignedInteger('chart_of_account_id')->index(); + $table->unsignedInteger('allocation_id')->nullable()->index(); + $table->decimal('amount', 65, 30); + $table->text('notes')->nullable(); + $table->timestamps(); + + $table->foreign('payment_order_id') + ->references('id') + ->on('payment_orders'); + $table->foreign('chart_of_account_id') + ->references('id') + ->on('chart_of_accounts'); + $table->foreign('allocation_id') + ->references('id') + ->on('allocations'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('payment_order_others'); + } +} diff --git a/database/migrations/tenant/2022_09_06_211447_create_payment_order_histories_table.php b/database/migrations/tenant/2022_09_06_211447_create_payment_order_histories_table.php new file mode 100644 index 000000000..2d6920661 --- /dev/null +++ b/database/migrations/tenant/2022_09_06_211447_create_payment_order_histories_table.php @@ -0,0 +1,41 @@ +id(); + $table->unsignedInteger('payment_order_id')->index(); + $table->unsignedInteger('user_id')->index(); + $table->string('activity')->nullable(); + $table->timestamps(); + + $table->foreign('payment_order_id') + ->references('id') + ->on('payment_orders'); + $table->foreign('user_id') + ->references('id') + ->on('users'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('payment_order_histories'); + } +} diff --git a/database/migrations/tenant/2022_09_06_211755_create_purchase_invoice_done_table.php b/database/migrations/tenant/2022_09_06_211755_create_purchase_invoice_done_table.php new file mode 100644 index 000000000..b6ce10bd2 --- /dev/null +++ b/database/migrations/tenant/2022_09_06_211755_create_purchase_invoice_done_table.php @@ -0,0 +1,38 @@ +id(); + $table->unsignedInteger('purchase_invoice_id')->index(); + $table->string('ref_no')->nullable(); + $table->decimal('value', 65, 30); + $table->timestamps(); + + $table->foreign('purchase_invoice_id') + ->references('id') + ->on('purchase_invoices'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('purchase_invoice_done'); + } +} diff --git a/database/migrations/tenant/2022_09_07_184322_create_payment_order_archive_table.php b/database/migrations/tenant/2022_09_07_184322_create_payment_order_archive_table.php new file mode 100644 index 000000000..89aaaf3c1 --- /dev/null +++ b/database/migrations/tenant/2022_09_07_184322_create_payment_order_archive_table.php @@ -0,0 +1,62 @@ +id(); + $table->unsignedInteger('payment_order_id')->index(); + $table->string('payment_type'); + $table->datetime('due_date')->nullable(); + $table->unsignedInteger('payment_account_id')->nullable(); + $table->decimal('amount', 65, 30); + $table->unsignedInteger('paymentable_id')->nullable(); + $table->string('paymentable_type')->nullable(); + $table->string('paymentable_name')->nullable(); + $table->unsignedInteger('payment_id')->nullable(); + $table->unsignedInteger('form_id')->nullable()->index(); + $table->unsignedInteger('supplier_id')->index(); + $table->decimal('total_invoice', 65, 30); + $table->decimal('total_down_payment', 65, 30); + $table->decimal('total_return', 65, 30); + $table->decimal('total_other', 65, 30); + $table->timestamps(); + + $table->foreign('payment_order_id') + ->references('id') + ->on('payment_orders'); + $table->foreign('payment_account_id') + ->references('id') + ->on('chart_of_accounts'); + $table->foreign('payment_id') + ->references('id') + ->on('payments'); + $table->foreign('form_id') + ->references('id') + ->on('forms'); + $table->foreign('supplier_id') + ->references('id') + ->on('suppliers'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('payment_order_archive'); + } +} From 4649d5a395d82fc487b8f72f1fc382134a52b40a Mon Sep 17 00:00:00 2001 From: M Adyan Rohutomo Date: Wed, 26 Oct 2022 22:53:42 +0700 Subject: [PATCH 2/2] add migration and seeder --- .../2022_09_06_211447_create_payment_order_histories_table.php | 1 + database/seeds/first/PermissionSeeder.php | 1 + 2 files changed, 2 insertions(+) diff --git a/database/migrations/tenant/2022_09_06_211447_create_payment_order_histories_table.php b/database/migrations/tenant/2022_09_06_211447_create_payment_order_histories_table.php index 2d6920661..37df5723c 100644 --- a/database/migrations/tenant/2022_09_06_211447_create_payment_order_histories_table.php +++ b/database/migrations/tenant/2022_09_06_211447_create_payment_order_histories_table.php @@ -18,6 +18,7 @@ public function up() $table->unsignedInteger('payment_order_id')->index(); $table->unsignedInteger('user_id')->index(); $table->string('activity')->nullable(); + $table->json('archive')->nullable(); $table->timestamps(); $table->foreign('payment_order_id') diff --git a/database/seeds/first/PermissionSeeder.php b/database/seeds/first/PermissionSeeder.php index fbc1b8215..0c9b22ecd 100644 --- a/database/seeds/first/PermissionSeeder.php +++ b/database/seeds/first/PermissionSeeder.php @@ -71,6 +71,7 @@ private function setPurchasePermission() 'purchase invoice', 'purchase down payment', 'purchase return', + 'purchase payment order', ]; foreach ($allPermission as $permission) {