pint format

dev
Aji Kamaludin 1 year ago
parent 394e4bb40b
commit 53af55bf98
No known key found for this signature in database
GPG Key ID: 19058F67F0083AD3

@ -41,4 +41,4 @@
- [x] ubah filter di mitra list dan customer list menjadi seperti di sale index - [x] ubah filter di mitra list dan customer list menjadi seperti di sale index
- [x] untuk detail mitra nanti akan ada button untuk (transaksi mitra dengan cakupan: pembelian voucher, pembayaran hutang, - [x] untuk detail mitra nanti akan ada button untuk (transaksi mitra dengan cakupan: pembelian voucher, pembayaran hutang,
topuplimit, penambahan batas bayar, history deposit) topuplimit, penambahan batas bayar, history deposit)
- [ ] tambah floating button untuk notifikasi deposit (angka saja), di dashboard tambahkan list deposit terbaru - [ ] di dashboard tambahkan list deposit terbaru

@ -115,8 +115,8 @@ class CustomerController extends Controller
public function update(Request $request, Customer $customer) public function update(Request $request, Customer $customer)
{ {
$request->validate([ $request->validate([
'email' => 'nullable|email|unique:customers,email,' . $customer->id, 'email' => 'nullable|email|unique:customers,email,'.$customer->id,
'username' => 'required|string|min:5|alpha_dash|unique:customers,username,' . $customer->id, 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,'.$customer->id,
'password' => 'nullable|string|min:8', 'password' => 'nullable|string|min:8',
'name' => 'required|string', 'name' => 'required|string',
'fullname' => 'required|string', 'fullname' => 'required|string',

@ -220,8 +220,8 @@ class CustomerMitraController extends Controller
public function update(Request $request, Customer $customer) public function update(Request $request, Customer $customer)
{ {
$request->validate([ $request->validate([
'email' => 'nullable|email|unique:customers,email,' . $customer->id, 'email' => 'nullable|email|unique:customers,email,'.$customer->id,
'username' => 'required|string|min:5|alpha_dash|unique:customers,username,' . $customer->id, 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,'.$customer->id,
'password' => 'nullable|string|min:8', 'password' => 'nullable|string|min:8',
'name' => 'required|string', 'name' => 'required|string',
'fullname' => 'required|string', 'fullname' => 'required|string',

@ -55,7 +55,7 @@ class PaylaterController extends Controller
public function show(PaylaterHistory $paylater) public function show(PaylaterHistory $paylater)
{ {
return inertia('Paylater/Detail', [ return inertia('Paylater/Detail', [
'paylater' => $paylater->load(['customer']) 'paylater' => $paylater->load(['customer']),
]); ]);
} }

@ -42,7 +42,7 @@ class DepositController extends Controller
public function create(Request $request) public function create(Request $request)
{ {
$customer = $request->user('customer'); $customer = $request->user('customer');
if (!$customer->allow_transaction) { if (! $customer->allow_transaction) {
return redirect()->back() return redirect()->back()
->with('message', ['type' => 'error', 'message' => 'akun anda dibekukan tidak dapat melakukan transaksi']); ->with('message', ['type' => 'error', 'message' => 'akun anda dibekukan tidak dapat melakukan transaksi']);
} }
@ -102,7 +102,7 @@ class DepositController extends Controller
'direct' => $request->direct, 'direct' => $request->direct,
'bank_admin_fee' => Setting::getByKey('ADMINFEE_MANUAL_TRANSFER'), 'bank_admin_fee' => Setting::getByKey('ADMINFEE_MANUAL_TRANSFER'),
'cash_admin_fee' => Setting::getByKey('ADMINFEE_CASH_DEPOSIT'), 'cash_admin_fee' => Setting::getByKey('ADMINFEE_CASH_DEPOSIT'),
'back' => $request->back ?? 'transactions.deposit.index' 'back' => $request->back ?? 'transactions.deposit.index',
]); ]);
} }
@ -157,7 +157,7 @@ class DepositController extends Controller
if ($is_valid == DepositHistory::STATUS_VALID) { if ($is_valid == DepositHistory::STATUS_VALID) {
$deposit->update_customer_balance(); $deposit->update_customer_balance();
} }
// TODO: update for paylater // TODO: update for paylater
DB::commit(); DB::commit();
@ -190,7 +190,7 @@ class DepositController extends Controller
$deposit->save(); $deposit->save();
} }
// TODO: update for paylater // TODO: update for paylater
DB::commit(); DB::commit();

@ -3,10 +3,7 @@
namespace App\Http\Controllers\Customer; namespace App\Http\Controllers\Customer;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Account;
use App\Models\Customer;
use App\Models\DepositHistory; use App\Models\DepositHistory;
use App\Models\DepositLocation;
use App\Models\PaylaterHistory; use App\Models\PaylaterHistory;
use App\Models\Setting; use App\Models\Setting;
use App\Services\GeneralService; use App\Services\GeneralService;
@ -32,10 +29,10 @@ class PaylaterController extends Controller
if ($paylater->type == PaylaterHistory::TYPE_REPAYMENT) { if ($paylater->type == PaylaterHistory::TYPE_REPAYMENT) {
$deposit = DepositHistory::where('related_id', $paylater->id)->first(); $deposit = DepositHistory::where('related_id', $paylater->id)->first();
if (!in_array($deposit->is_valid, [DepositHistory::STATUS_VALID])) { if (! in_array($deposit->is_valid, [DepositHistory::STATUS_VALID])) {
return redirect()->route('transactions.deposit.show', [ return redirect()->route('transactions.deposit.show', [
'deposit' => $deposit, 'deposit' => $deposit,
'back' => 'customer.paylater.index' 'back' => 'customer.paylater.index',
]); ]);
} }
} }
@ -65,7 +62,7 @@ class PaylaterController extends Controller
$customer = $request->user('customer'); $customer = $request->user('customer');
// validate amount // validate amount
if ($customer->paylater->usage < $request->amount) { if ($customer->paylater->usage < $request->amount) {
return redirect()->back() return redirect()->back()
->with('message', ['type' => 'error', 'message' => 'Nominal Tagihan tidak boleh lebih dari tagihan']); ->with('message', ['type' => 'error', 'message' => 'Nominal Tagihan tidak boleh lebih dari tagihan']);
@ -75,7 +72,7 @@ class PaylaterController extends Controller
$repayment = DepositHistory::query() $repayment = DepositHistory::query()
->where([ ->where([
['customer_id', '=', $customer->id], ['customer_id', '=', $customer->id],
['type', '=', DepositHistory::TYPE_REPAYMENT] ['type', '=', DepositHistory::TYPE_REPAYMENT],
])->where(function ($query) { ])->where(function ($query) {
$query->where('is_valid', '!=', DepositHistory::STATUS_VALID) $query->where('is_valid', '!=', DepositHistory::STATUS_VALID)
->where('is_valid', '!=', DepositHistory::STATUS_REJECT) ->where('is_valid', '!=', DepositHistory::STATUS_REJECT)
@ -130,7 +127,7 @@ class PaylaterController extends Controller
return redirect()->route('transactions.deposit.show', [ return redirect()->route('transactions.deposit.show', [
'deposit' => $deposit->id, 'deposit' => $deposit->id,
'direct' => 'true', 'direct' => 'true',
'back' => 'customer.paylater.index' 'back' => 'customer.paylater.index',
]); ]);
} }
} }

@ -52,7 +52,7 @@ class DepositHistory extends Model
'format_created_at', 'format_created_at',
'amount', 'amount',
'image_prove_url', 'image_prove_url',
'admin_fee' 'admin_fee',
]; ];
protected static function booted(): void protected static function booted(): void
@ -99,10 +99,10 @@ class DepositHistory extends Model
{ {
return Attribute::make(get: function () { return Attribute::make(get: function () {
if ($this->credit == 0) { if ($this->credit == 0) {
return 'Rp ' . number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); return 'Rp '.number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.');
} }
return '-Rp ' . number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); return '-Rp '.number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.');
}); });
} }
@ -165,7 +165,7 @@ class DepositHistory extends Model
} }
Notification::create([ Notification::create([
'entity_type' => User::class, 'entity_type' => User::class,
'description' => $this->customer->fullname . ' melakukan deposit transfer manual sebesar : ' . $this->amount . $status, 'description' => $this->customer->fullname.' melakukan deposit transfer manual sebesar : '.$this->amount.$status,
]); ]);
} }
@ -176,14 +176,14 @@ class DepositHistory extends Model
} }
Notification::create([ Notification::create([
'entity_type' => User::class, 'entity_type' => User::class,
'description' => $this->customer->fullname . ' melakukan deposit manual sebesar : ' . $this->amount . $status, 'description' => $this->customer->fullname.' melakukan deposit manual sebesar : '.$this->amount.$status,
]); ]);
} }
if ($this->payment_channel == Setting::PAYMENT_MIDTRANS) { if ($this->payment_channel == Setting::PAYMENT_MIDTRANS) {
Notification::create([ Notification::create([
'entity_type' => User::class, 'entity_type' => User::class,
'description' => $this->customer->fullname . ' melakukan deposit via midtrans sebesar : ' . $this->amount, 'description' => $this->customer->fullname.' melakukan deposit via midtrans sebesar : '.$this->amount,
]); ]);
} }
} }
@ -192,7 +192,7 @@ class DepositHistory extends Model
{ {
Notification::create([ Notification::create([
'entity_id' => $this->customer_id, 'entity_id' => $this->customer_id,
'description' => 'Deposit ' . $this->description . ' sebesar ' . $this->amount . ' sudah sukses diterima', 'description' => 'Deposit '.$this->description.' sebesar '.$this->amount.' sudah sukses diterima',
]); ]);
} }
} }

@ -17,7 +17,7 @@ class PaylaterCustomer extends Model
]; ];
protected $appends = [ protected $appends = [
'paylater_description' 'paylater_description',
]; ];
public function customer() public function customer()
@ -30,10 +30,11 @@ class PaylaterCustomer extends Model
return Attribute::make(get: function () { return Attribute::make(get: function () {
if ($this->day_deadline_at != null) { if ($this->day_deadline_at != null) {
$deadlineAt = Carbon::parse($this->day_deadline_at)->translatedFormat('d F Y'); $deadlineAt = Carbon::parse($this->day_deadline_at)->translatedFormat('d F Y');
return "lunasi pinjaman kamu sebelum jatuh tempo pada {$deadlineAt}"; return "lunasi pinjaman kamu sebelum jatuh tempo pada {$deadlineAt}";
} }
return "yuk gunakan terus saldo yang tersedia"; return 'yuk gunakan terus saldo yang tersedia';
}); });
} }
} }

@ -71,10 +71,10 @@ class PaylaterHistory extends Model
{ {
return Attribute::make(get: function () { return Attribute::make(get: function () {
if ($this->credit == 0) { if ($this->credit == 0) {
return 'Rp ' . number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); return 'Rp '.number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.');
} }
return '-Rp ' . number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); return '-Rp '.number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.');
}); });
} }
@ -116,7 +116,7 @@ class PaylaterHistory extends Model
{ {
Notification::create([ Notification::create([
'entity_id' => $this->customer_id, 'entity_id' => $this->customer_id,
'description' => 'Pembayaran ' . $this->description . ' sebesar ' . $this->amount . ' sudah sukses diterima', 'description' => 'Pembayaran '.$this->description.' sebesar '.$this->amount.' sudah sukses diterima',
]); ]);
} }

@ -139,9 +139,9 @@ class GeneralService
$time = explode(':', $time); $time = explode(':', $time);
foreach ($time as $t) { //00 : 00 foreach ($time as $t) { //00 : 00
if ($t < 10) { if ($t < 10) {
$r .= '0' . (int) $t . ':'; $r .= '0'.(int) $t.':';
} else { } else {
$r .= $t . ':'; $r .= $t.':';
} }
} }
@ -154,7 +154,7 @@ class GeneralService
->whereDate('created_at', now()) ->whereDate('created_at', now())
->count() + 1; ->count() + 1;
return 'Invoice #TLH' . now()->format('dmy') . GeneralService::formatNumberCode($code); return 'Invoice #TLH'.now()->format('dmy').GeneralService::formatNumberCode($code);
} }
public static function generateDepositCode() public static function generateDepositCode()
@ -163,7 +163,7 @@ class GeneralService
->whereDate('created_at', now()) ->whereDate('created_at', now())
->count() + 1; ->count() + 1;
return 'Invoice #DSR' . now()->format('dmy') . GeneralService::formatNumberCode($code); return 'Invoice #DSR'.now()->format('dmy').GeneralService::formatNumberCode($code);
} }
public static function generateDepositRepayCode() public static function generateDepositRepayCode()
@ -172,7 +172,7 @@ class GeneralService
->whereDate('created_at', now()) ->whereDate('created_at', now())
->count() + 1; ->count() + 1;
return 'Invoice #PLH' . now()->format('dmy') . GeneralService::formatNumberCode($code); return 'Invoice #PLH'.now()->format('dmy').GeneralService::formatNumberCode($code);
} }
public static function generateSaleVoucherCode() public static function generateSaleVoucherCode()
@ -181,14 +181,14 @@ class GeneralService
->where('payed_with', '!=', Sale::PAYED_WITH_POIN) ->where('payed_with', '!=', Sale::PAYED_WITH_POIN)
->count() + 1; ->count() + 1;
return 'Invoice #VCR' . now()->format('dmy') . GeneralService::formatNumberCode($code); return 'Invoice #VCR'.now()->format('dmy').GeneralService::formatNumberCode($code);
} }
public static function generateBonusPoinCode() public static function generateBonusPoinCode()
{ {
$code = PoinHistory::whereDate('created_at', now())->count() + 1; $code = PoinHistory::whereDate('created_at', now())->count() + 1;
return 'Invoice #BPN' . now()->format('dmy') . GeneralService::formatNumberCode($code); return 'Invoice #BPN'.now()->format('dmy').GeneralService::formatNumberCode($code);
} }
public static function generateExchangePoinCode() public static function generateExchangePoinCode()
@ -197,19 +197,19 @@ class GeneralService
->where('payed_with', '=', Sale::PAYED_WITH_POIN) ->where('payed_with', '=', Sale::PAYED_WITH_POIN)
->count() + 1; ->count() + 1;
return 'Invoice #PVC' . now()->format('dmy') . GeneralService::formatNumberCode($code); return 'Invoice #PVC'.now()->format('dmy').GeneralService::formatNumberCode($code);
} }
public static function formatNumberCode($number) public static function formatNumberCode($number)
{ {
if ($number < 10) { if ($number < 10) {
return '000' . $number; return '000'.$number;
} }
if ($number < 100) { if ($number < 100) {
return '00' . $number; return '00'.$number;
} }
if ($number < 1000) { if ($number < 1000) {
return '0' . $number; return '0'.$number;
} }
return $number; return $number;

Loading…
Cancel
Save