feat:통합정산 정산상세 승인취소 기능 추가
This commit is contained in:
@@ -232,6 +232,27 @@ public function bulkMarkPaid(Request $request): JsonResponse
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인취소 처리
|
||||
*/
|
||||
public function unapprove(int $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$commission = $this->service->unapprove($id);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '승인이 취소되었습니다.',
|
||||
'data' => $commission,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => $e->getMessage(),
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 취소 처리
|
||||
*/
|
||||
|
||||
@@ -255,6 +255,22 @@ public function markAsPaid(?string $bankReference = null): bool
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인취소 처리 (approved → pending)
|
||||
*/
|
||||
public function unapprove(): bool
|
||||
{
|
||||
if ($this->status !== self::STATUS_APPROVED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->update([
|
||||
'status' => self::STATUS_PENDING,
|
||||
'approved_by' => null,
|
||||
'approved_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 취소 처리
|
||||
*/
|
||||
|
||||
@@ -350,6 +350,20 @@ public function bulkMarkAsPaid(array $ids, ?string $bankReference = null): int
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인취소 처리
|
||||
*/
|
||||
public function unapprove(int $commissionId): SalesCommission
|
||||
{
|
||||
$commission = SalesCommission::findOrFail($commissionId);
|
||||
|
||||
if (!$commission->unapprove()) {
|
||||
throw new \Exception('승인취소할 수 없는 상태입니다.');
|
||||
}
|
||||
|
||||
return $commission->fresh(['tenant', 'partner.user', 'manager']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 취소 처리
|
||||
*/
|
||||
|
||||
@@ -337,6 +337,23 @@ function bulkMarkPaid() {
|
||||
});
|
||||
}
|
||||
|
||||
function unapproveCommission(id) {
|
||||
if (!confirm('승인을 취소하시겠습니까?')) return;
|
||||
|
||||
fetch('{{ url("finance/sales-commissions") }}/' + id + '/unapprove', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) { alert(data.message); location.reload(); }
|
||||
else { alert(data.message || '오류가 발생했습니다.'); }
|
||||
});
|
||||
}
|
||||
|
||||
function cancelCommission(id) {
|
||||
if (!confirm('취소하시겠습니까?')) return;
|
||||
|
||||
|
||||
@@ -171,6 +171,7 @@
|
||||
<button type="button" onclick="approveCommission({{ $commission->id }})" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors">승인</button>
|
||||
<button type="button" onclick="cancelCommission({{ $commission->id }})" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors">취소</button>
|
||||
@elseif ($commission->status === 'approved')
|
||||
<button type="button" onclick="unapproveCommission({{ $commission->id }})" class="px-4 py-2 bg-yellow-500 hover:bg-yellow-600 text-white rounded-lg transition-colors">승인취소</button>
|
||||
<button type="button" onclick="markPaidCommission({{ $commission->id }})" class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors">지급완료</button>
|
||||
@endif
|
||||
<button type="button" onclick="closeDetailModal()" class="px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition-colors">닫기</button>
|
||||
|
||||
@@ -1030,6 +1030,7 @@
|
||||
Route::get('/{id}/detail', [\App\Http\Controllers\Finance\SalesCommissionController::class, 'detail'])->name('detail');
|
||||
Route::post('/{id}/approve', [\App\Http\Controllers\Finance\SalesCommissionController::class, 'approve'])->name('approve');
|
||||
Route::post('/{id}/mark-paid', [\App\Http\Controllers\Finance\SalesCommissionController::class, 'markPaid'])->name('mark-paid');
|
||||
Route::post('/{id}/unapprove', [\App\Http\Controllers\Finance\SalesCommissionController::class, 'unapprove'])->name('unapprove');
|
||||
Route::post('/{id}/cancel', [\App\Http\Controllers\Finance\SalesCommissionController::class, 'cancel'])->name('cancel');
|
||||
Route::put('/{id}/update-date', [\App\Http\Controllers\Finance\SalesCommissionController::class, 'updateCommissionDate'])->name('update-date');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user