fix:영업 대시보드 개인/단체 수수료율 동적 적용
- SalesPartner::isGroup()이 partner_type 기반으로 판별하도록 수정 - 대시보드 수수료율 표시: 개인 20%, 단체 30% 동적 반영 - 인수 수수료 계산: 개인 10%, 단체 15% 동적 반영 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -126,11 +126,13 @@ private function getDashboardData(Request $request): array
|
||||
+ $myCommissionsAsManager->where('status', SalesCommission::STATUS_APPROVED)->count(),
|
||||
];
|
||||
|
||||
// 역할별 수당 상세 (실제 데이터)
|
||||
// 역할별 수당 상세 (실제 데이터 - 파트너 유형에 따라 요율 다름)
|
||||
$isGroupPartner = $partner && $partner->isGroup();
|
||||
$partnerRateDisplay = $isGroupPartner ? 30 : 20;
|
||||
$commissionByRole = [
|
||||
[
|
||||
'name' => '판매자',
|
||||
'rate' => 20,
|
||||
'name' => $isGroupPartner ? '판매자 (단체)' : '판매자',
|
||||
'rate' => $partnerRateDisplay,
|
||||
'amount' => $partnerCommissionTotal,
|
||||
'paid' => $partnerCommissionPaid,
|
||||
'pending' => $partnerCommissionPending,
|
||||
@@ -174,8 +176,9 @@ private function getDashboardData(Request $request): array
|
||||
$handoverTotalRegFee = SalesContractProduct::whereIn('management_id', $handoverManagementIds)
|
||||
->sum('registration_fee');
|
||||
|
||||
// 수당 계산: 개발비 × 50% × 20% = 개발비 × 10%
|
||||
$handoverPartnerCommission = (int)($handoverTotalRegFee * 0.10);
|
||||
// 수당 계산: 개발비 × 50% × 요율% (개인 20% → 10%, 단체 30% → 15%)
|
||||
$handoverPartnerRate = $isGroupPartner ? 0.15 : 0.10;
|
||||
$handoverPartnerCommission = (int)($handoverTotalRegFee * $handoverPartnerRate);
|
||||
|
||||
// 내가 매니저로 지정된 인계 완료 건의 수당 계산
|
||||
$managedHandoverManagements = SalesTenantManagement::where('manager_user_id', $currentUserId)
|
||||
@@ -270,7 +273,7 @@ private function getDashboardData(Request $request): array
|
||||
->toArray();
|
||||
$devInProgressRegFee = SalesContractProduct::whereIn('management_id', $devInProgressManagementIds)
|
||||
->sum('registration_fee');
|
||||
$expectedFromDevInProgress = (int)($devInProgressRegFee * 0.10); // 개발비 × 10%
|
||||
$expectedFromDevInProgress = (int)($devInProgressRegFee * $handoverPartnerRate); // 개발비 × 요율 (개인 10%, 단체 15%)
|
||||
|
||||
// 2) 인계 완료 중 지급 미완료 건
|
||||
$handoverUnpaidRegFee = SalesContractProduct::whereIn('management_id', $handoverManagementIds)
|
||||
@@ -280,7 +283,7 @@ private function getDashboardData(Request $request): array
|
||||
->whereIn('management_id', $handoverManagementIds)
|
||||
->where('status', SalesCommission::STATUS_PAID)
|
||||
->sum('partner_commission');
|
||||
$expectedFromHandover = (int)($handoverUnpaidRegFee * 0.10) - $paidCommissionFromHandover;
|
||||
$expectedFromHandover = (int)($handoverUnpaidRegFee * $handoverPartnerRate) - $paidCommissionFromHandover;
|
||||
$expectedFromHandover = max(0, $expectedFromHandover);
|
||||
|
||||
// 총 예상 수당 (지급 완료 제외)
|
||||
@@ -308,7 +311,7 @@ private function getDashboardData(Request $request): array
|
||||
);
|
||||
|
||||
// 역할별 수당을 예상 수당 기준으로 재설정 (1차+2차 수당과 일치하도록)
|
||||
// 판매자 예상 수당 = 개발비 × 10% (개발 진행 중 + 인계 완료 미지급)
|
||||
// 판매자 예상 수당 = 개발비 × 요율 (개인 10%, 단체 15%)
|
||||
$commissionByRole[0]['amount'] = $totalExpectedCommission;
|
||||
|
||||
// 전환된 테넌트만 조회 (최신순, 페이지네이션)
|
||||
|
||||
Reference in New Issue
Block a user