partial update create mutations workflow
This commit is contained in:
@@ -40,21 +40,31 @@ class MutationDetail extends Model
|
||||
|
||||
public function isFullyApproved()
|
||||
{
|
||||
return $this->quantity_approved == $this->quantity_requested;
|
||||
return $this->quantity_approved !== null && $this->quantity_approved == $this->quantity_requested;
|
||||
}
|
||||
|
||||
public function isPartiallyApproved()
|
||||
{
|
||||
return $this->quantity_approved > 0 && $this->quantity_approved < $this->quantity_requested;
|
||||
return $this->quantity_approved !== null && $this->quantity_approved > 0 && $this->quantity_approved < $this->quantity_requested;
|
||||
}
|
||||
|
||||
public function isRejected()
|
||||
{
|
||||
return $this->quantity_approved == 0;
|
||||
// Hanya dianggap ditolak jika mutasi sudah di-approve/reject dan quantity_approved = 0
|
||||
$mutationStatus = $this->mutation->status->value ?? null;
|
||||
return in_array($mutationStatus, ['approved', 'completed', 'rejected']) && $this->quantity_approved == 0;
|
||||
}
|
||||
|
||||
public function getApprovalStatusAttribute()
|
||||
{
|
||||
$mutationStatus = $this->mutation->status->value ?? null;
|
||||
|
||||
// Jika mutasi belum di-approve, semua detail statusnya "Menunggu"
|
||||
if (!in_array($mutationStatus, ['approved', 'completed', 'rejected'])) {
|
||||
return 'Menunggu';
|
||||
}
|
||||
|
||||
// Jika mutasi sudah di-approve/complete, baru cek quantity_approved
|
||||
if ($this->isFullyApproved()) {
|
||||
return 'Disetujui Penuh';
|
||||
} elseif ($this->isPartiallyApproved()) {
|
||||
@@ -68,6 +78,14 @@ class MutationDetail extends Model
|
||||
|
||||
public function getApprovalStatusColorAttribute()
|
||||
{
|
||||
$mutationStatus = $this->mutation->status->value ?? null;
|
||||
|
||||
// Jika mutasi belum di-approve, semua detail statusnya "info" (menunggu)
|
||||
if (!in_array($mutationStatus, ['approved', 'completed', 'rejected'])) {
|
||||
return 'info';
|
||||
}
|
||||
|
||||
// Jika mutasi sudah di-approve/complete, baru cek quantity_approved
|
||||
if ($this->isFullyApproved()) {
|
||||
return 'success';
|
||||
} elseif ($this->isPartiallyApproved()) {
|
||||
|
||||
Reference in New Issue
Block a user