dev
Aji Kamaludin 1 year ago
parent 37384d24b7
commit 4a16f6ed38
No known key found for this signature in database
GPG Key ID: 19058F67F0083AD3

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Customer; use App\Models\Customer;
use App\Models\PaylaterHistory; use App\Models\PaylaterHistory;
use App\Services\GeneralService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -47,7 +48,8 @@ class PaylaterController extends Controller
$customer->paylaterHistories()->create([ $customer->paylaterHistories()->create([
'credit' => $request->limit, 'credit' => $request->limit,
'description' => $request->description, 'description' => GeneralService::generatePaylaterTopupCode(),
'note' => $request->description,
'type' => PaylaterHistory::TYPE_UPGRADE, 'type' => PaylaterHistory::TYPE_UPGRADE,
]); ]);

@ -33,6 +33,7 @@ class PaylaterHistory extends Model
'debit', 'debit',
'credit', 'credit',
'description', 'description',
'note',
'customer_id', 'customer_id',
'type', 'type',
'is_valid', 'is_valid',

@ -5,6 +5,7 @@ namespace App\Services;
use App\Models\Customer; use App\Models\Customer;
use App\Models\DepositHistory; use App\Models\DepositHistory;
use App\Models\DepositLocation; use App\Models\DepositLocation;
use App\Models\PaylaterHistory;
use App\Models\PoinHistory; use App\Models\PoinHistory;
use App\Models\Sale; use App\Models\Sale;
use App\Models\Setting; use App\Models\Setting;
@ -147,6 +148,15 @@ class GeneralService
return substr($r, 0, -1); 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() public static function generateDepositCode()
{ {
$code = DepositHistory::where('type', DepositHistory::TYPE_DEPOSIT) $code = DepositHistory::where('type', DepositHistory::TYPE_DEPOSIT)

@ -16,7 +16,8 @@ return new class extends Migration
$table->decimal('debit', 20, 2)->default(0); $table->decimal('debit', 20, 2)->default(0);
$table->decimal('credit', 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->ulid('customer_id')->nullable();
$table->smallInteger('type')->default(0); $table->smallInteger('type')->default(0);
$table->smallInteger('is_valid')->default(0); $table->smallInteger('is_valid')->default(0);

@ -32,6 +32,13 @@ export default function Detail({ paylater }) {
</div> </div>
</div> </div>
</div> </div>
<div className="w-full px-5">
<div className="my-5">
<div className="bg-blue-50 text-blue-700 p-3 border rounded-md">
{paylater.note}
</div>
</div>
</div>
</div> </div>
</CustomerLayout> </CustomerLayout>
) )

@ -50,6 +50,12 @@ export default function PaylaterLimitHistory(props) {
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400 mb-4"> <table className="w-full text-sm text-left text-gray-500 dark:text-gray-400 mb-4">
<thead className="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400"> <thead className="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr> <tr>
<th
scope="col"
className="py-3 px-6"
>
#
</th>
<th <th
scope="col" scope="col"
className="py-3 px-6" className="py-3 px-6"
@ -92,6 +98,9 @@ export default function PaylaterLimitHistory(props) {
scope="row" scope="row"
className="py-4 px-6 font-medium text-gray-900 whitespace-nowrap dark:text-white" className="py-4 px-6 font-medium text-gray-900 whitespace-nowrap dark:text-white"
> >
{history.description}
</td>
<td>
<Link <Link
className="hover:underline" className="hover:underline"
href={route( href={route(
@ -110,7 +119,7 @@ export default function PaylaterLimitHistory(props) {
{formatIDR(history.credit)} {formatIDR(history.credit)}
</td> </td>
<td className="py-4 px-6"> <td className="py-4 px-6">
{history.description} {history.note}
</td> </td>
<td className="py-4 px-6"> <td className="py-4 px-6">
{history.creator.name} {history.creator.name}

Loading…
Cancel
Save