|
|
@@ -48,7 +48,7 @@ class PagarmeAnticipationService
|
|
|
path: "/recipients/{$recipientId}/bulk_anticipations",
|
|
|
|
|
|
payload: new BulkAnticipationRequestData(
|
|
|
- paymentDate: now()->toISOString(),
|
|
|
+ paymentDate: $this->getAnticipationPaymentDate(),
|
|
|
timeframe: 'start',
|
|
|
requestedAmount: $requestedAmount,
|
|
|
automaticTransfer: false,
|
|
|
@@ -73,4 +73,21 @@ class PagarmeAnticipationService
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private function getAnticipationPaymentDate(): string
|
|
|
+ {
|
|
|
+ $now = now()->timezone('America/Sao_Paulo');
|
|
|
+
|
|
|
+ if ($now->hour < 11) {
|
|
|
+ return $now->toISOString();
|
|
|
+ }
|
|
|
+
|
|
|
+ $nextBusinessDay = $now->copy()->addDay();
|
|
|
+
|
|
|
+ while ($nextBusinessDay->isWeekend()) {
|
|
|
+ $nextBusinessDay->addDay();
|
|
|
+ }
|
|
|
+
|
|
|
+ return $nextBusinessDay->startOfDay()->toISOString();
|
|
|
+ }
|
|
|
}
|