feat:납입일 입력 시 수당지급일 자동 계산 (익월 10일)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -292,16 +292,37 @@ public function updateCommissionDate(int $id, Request $request)
|
||||
$field = $request->input('field');
|
||||
$date = $request->input('date') ?: now()->format('Y-m-d');
|
||||
|
||||
$commission->update([
|
||||
$field => $date,
|
||||
]);
|
||||
$updateData = [$field => $date];
|
||||
|
||||
return response()->json([
|
||||
// 납입일 입력 시 수당지급일 자동 계산 (익월 10일)
|
||||
$autoFields = [
|
||||
'first_payment_at' => 'first_partner_paid_at',
|
||||
'second_payment_at' => 'second_partner_paid_at',
|
||||
];
|
||||
|
||||
$autoField = null;
|
||||
$autoDate = null;
|
||||
if (isset($autoFields[$field])) {
|
||||
$autoField = $autoFields[$field];
|
||||
$autoDate = \Carbon\Carbon::parse($date)->addMonth()->day(10)->format('Y-m-d');
|
||||
$updateData[$autoField] = $autoDate;
|
||||
}
|
||||
|
||||
$commission->update($updateData);
|
||||
|
||||
$response = [
|
||||
'success' => true,
|
||||
'field' => $field,
|
||||
'date' => $commission->$field?->format('Y-m-d'),
|
||||
'date_display' => $commission->$field?->format('m/d'),
|
||||
]);
|
||||
];
|
||||
|
||||
if ($autoField) {
|
||||
$response['auto_field'] = $autoField;
|
||||
$response['auto_date'] = $autoDate;
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -352,11 +373,26 @@ public function clearCommissionDate(int $id, Request $request)
|
||||
}
|
||||
|
||||
$field = $request->input('field');
|
||||
$commission->update([$field => null]);
|
||||
$updateData = [$field => null];
|
||||
|
||||
// 납입일 삭제 시 수당지급일도 함께 초기화
|
||||
$autoFields = [
|
||||
'first_payment_at' => 'first_partner_paid_at',
|
||||
'second_payment_at' => 'second_partner_paid_at',
|
||||
];
|
||||
|
||||
$autoField = null;
|
||||
if (isset($autoFields[$field])) {
|
||||
$autoField = $autoFields[$field];
|
||||
$updateData[$autoField] = null;
|
||||
}
|
||||
|
||||
$commission->update($updateData);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'field' => $field,
|
||||
'auto_field' => $autoField,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user