fix:법인카드 매월결제일 현재일자 기준 동적 계산 (결제일 지나면 익월로 자동 변경)
This commit is contained in:
@@ -216,13 +216,21 @@ public function summary(): JsonResponse
|
||||
$creditCard = $activeCards->firstWhere('card_type', 'credit');
|
||||
$paymentDay = $creditCard ? $creditCard->payment_day : 15;
|
||||
|
||||
// 휴일 조정 결제일 계산
|
||||
// 휴일 조정 결제일 계산 (현재 월)
|
||||
$originalDate = $this->createPaymentDate($now->year, $now->month, $paymentDay);
|
||||
$adjustedDate = $this->getAdjustedPaymentDate($tenantId, $now->year, $now->month, $paymentDay);
|
||||
|
||||
// 현재일이 결제일을 지났으면 다음 월로 이동
|
||||
if ($now->greaterThan($adjustedDate)) {
|
||||
$nextMonth = $now->copy()->addMonth();
|
||||
$originalDate = $this->createPaymentDate($nextMonth->year, $nextMonth->month, $paymentDay);
|
||||
$adjustedDate = $this->getAdjustedPaymentDate($tenantId, $nextMonth->year, $nextMonth->month, $paymentDay);
|
||||
}
|
||||
|
||||
$isAdjusted = !$originalDate->isSameDay($adjustedDate);
|
||||
|
||||
// 청구기간: 전월 1일 ~ 당월 결제일(조정후)
|
||||
$billingStart = $now->copy()->subMonth()->startOfMonth();
|
||||
// 청구기간: 결제일 기준 전월 1일 ~ 결제일
|
||||
$billingStart = $adjustedDate->copy()->subMonth()->startOfMonth();
|
||||
$billingEnd = $adjustedDate->copy();
|
||||
|
||||
// 카드번호 목록
|
||||
@@ -236,8 +244,8 @@ public function summary(): JsonResponse
|
||||
$cardNumbers
|
||||
);
|
||||
|
||||
// 선불결제 금액
|
||||
$yearMonth = $now->format('Y-m');
|
||||
// 선불결제 금액 (결제일 기준 월)
|
||||
$yearMonth = $adjustedDate->format('Y-m');
|
||||
$prepayment = CorporateCardPrepayment::getOrCreate($tenantId, $yearMonth);
|
||||
|
||||
return response()->json([
|
||||
|
||||
Reference in New Issue
Block a user