From 4a16f6ed38f78619acca628bda710f2b6a7007ea Mon Sep 17 00:00:00 2001 From: Aji Kamaludin Date: Fri, 30 Jun 2023 02:17:10 +0700 Subject: [PATCH] bit fix --- app/Http/Controllers/Admin/PaylaterController.php | 4 +++- app/Models/PaylaterHistory.php | 1 + app/Services/GeneralService.php | 10 ++++++++++ ...3_06_03_033734_create_paylater_histories_table.php | 3 ++- resources/js/Customer/Paylater/Detail.jsx | 7 +++++++ .../js/Pages/CustomerHistory/PaylaterLimitHistory.jsx | 11 ++++++++++- 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Admin/PaylaterController.php b/app/Http/Controllers/Admin/PaylaterController.php index ebb719b..ab10828 100644 --- a/app/Http/Controllers/Admin/PaylaterController.php +++ b/app/Http/Controllers/Admin/PaylaterController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\Customer; use App\Models\PaylaterHistory; +use App\Services\GeneralService; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -47,7 +48,8 @@ class PaylaterController extends Controller $customer->paylaterHistories()->create([ 'credit' => $request->limit, - 'description' => $request->description, + 'description' => GeneralService::generatePaylaterTopupCode(), + 'note' => $request->description, 'type' => PaylaterHistory::TYPE_UPGRADE, ]); diff --git a/app/Models/PaylaterHistory.php b/app/Models/PaylaterHistory.php index 3fe1993..16335a1 100644 --- a/app/Models/PaylaterHistory.php +++ b/app/Models/PaylaterHistory.php @@ -33,6 +33,7 @@ class PaylaterHistory extends Model 'debit', 'credit', 'description', + 'note', 'customer_id', 'type', 'is_valid', diff --git a/app/Services/GeneralService.php b/app/Services/GeneralService.php index 4dab4a7..cb7ac62 100644 --- a/app/Services/GeneralService.php +++ b/app/Services/GeneralService.php @@ -5,6 +5,7 @@ namespace App\Services; use App\Models\Customer; use App\Models\DepositHistory; use App\Models\DepositLocation; +use App\Models\PaylaterHistory; use App\Models\PoinHistory; use App\Models\Sale; use App\Models\Setting; @@ -147,6 +148,15 @@ class GeneralService return substr($r, 0, -1); } + public static function generatePaylaterTopupCode() + { + $code = PaylaterHistory::where('type', PaylaterHistory::TYPE_UPGRADE) + ->whereDate('created_at', now()) + ->count() + 1; + + return 'Invoice #TLH'.now()->format('dmy').GeneralService::formatNumberCode($code); + } + public static function generateDepositCode() { $code = DepositHistory::where('type', DepositHistory::TYPE_DEPOSIT) diff --git a/database/migrations/2023_06_03_033734_create_paylater_histories_table.php b/database/migrations/2023_06_03_033734_create_paylater_histories_table.php index 025933d..72a5677 100644 --- a/database/migrations/2023_06_03_033734_create_paylater_histories_table.php +++ b/database/migrations/2023_06_03_033734_create_paylater_histories_table.php @@ -16,7 +16,8 @@ return new class extends Migration $table->decimal('debit', 20, 2)->default(0); $table->decimal('credit', 20, 2)->default(0); - $table->text('description')->nullable(); + $table->string('description')->nullable(); + $table->text('note')->nullable(); $table->ulid('customer_id')->nullable(); $table->smallInteger('type')->default(0); $table->smallInteger('is_valid')->default(0); diff --git a/resources/js/Customer/Paylater/Detail.jsx b/resources/js/Customer/Paylater/Detail.jsx index 9afd740..63b0920 100644 --- a/resources/js/Customer/Paylater/Detail.jsx +++ b/resources/js/Customer/Paylater/Detail.jsx @@ -32,6 +32,13 @@ export default function Detail({ paylater }) { +
+
+
+ {paylater.note} +
+
+
) diff --git a/resources/js/Pages/CustomerHistory/PaylaterLimitHistory.jsx b/resources/js/Pages/CustomerHistory/PaylaterLimitHistory.jsx index 608a949..0a37094 100644 --- a/resources/js/Pages/CustomerHistory/PaylaterLimitHistory.jsx +++ b/resources/js/Pages/CustomerHistory/PaylaterLimitHistory.jsx @@ -50,6 +50,12 @@ export default function PaylaterLimitHistory(props) { +
+ # + + {history.description} + + - {history.description} + {history.note} {history.creator.name}