visa master fix bug
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Modules\VisaMasterSettings\Models\VisaMasterSettings;
|
|||||||
use App\Repos\Payment\OnlinePaymentRepo;
|
use App\Repos\Payment\OnlinePaymentRepo;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Blade;
|
use Illuminate\Support\Facades\Blade;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
@@ -279,40 +280,36 @@ class MakePaymentNovaVisaMaster extends Action
|
|||||||
*
|
*
|
||||||
* @param \Illuminate\Support\Carbon $today
|
* @param \Illuminate\Support\Carbon $today
|
||||||
*/
|
*/
|
||||||
public function canAcceptPayment(\Illuminate\Support\Carbon $today): bool
|
public function canAcceptPayment(Carbon $today): bool
|
||||||
{
|
{
|
||||||
$year = $today->format('Y');
|
$lastDay = $today->copy()->endOfMonth();
|
||||||
$month = $today->format('m');
|
$lastDayOfWeek = $lastDay->format('l');
|
||||||
$lastDay = lastDayOfMonth(year: $year, month: $month);
|
|
||||||
|
|
||||||
// Condition 1: Check if today is the last day of the month
|
$oneDayBefore = $lastDay->copy()->subDay(); // Saturday
|
||||||
if ($today->format('Y-m-d') === $lastDay->format('Y-m-d')) {
|
$twoDaysBefore = $lastDay->copy()->subDays(2); // Friday
|
||||||
|
|
||||||
|
// Condition 1: Today is the last day
|
||||||
|
if ($today->isSameDay($lastDay)) {
|
||||||
info('check 1');
|
info('check 1');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the day of the week for the last day of the month
|
// Condition 2: Last day is Sunday → forbid Friday & Saturday
|
||||||
$lastDayOfWeek = $lastDay->format('l'); // e.g., 'Sunday', 'Saturday'
|
if ($lastDayOfWeek === 'Sunday' && ($today->isSameDay($oneDayBefore) || $today->isSameDay($twoDaysBefore))) {
|
||||||
|
info('check 2');
|
||||||
|
|
||||||
// Condition 2: If the last day is Sunday, disallow Friday, Saturday, Sunday
|
return false;
|
||||||
if ($lastDayOfWeek === 'Sunday') {
|
|
||||||
$forbiddenDays = ['Friday', 'Saturday', 'Sunday'];
|
|
||||||
if (in_array($today->format('l'), $forbiddenDays)) {
|
|
||||||
info('check 2');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Condition 3: If the last day is Saturday, disallow Friday
|
// Condition 3: Last day is Saturday → forbid Friday
|
||||||
if ($lastDayOfWeek === 'Saturday' && $today->format('l') === 'Friday') {
|
if ($lastDayOfWeek === 'Saturday' && $today->isSameDay($oneDayBefore)) {
|
||||||
info('check 3');
|
info('check 3');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If none of the conditions match, allow payment
|
// Default: allow payment
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ use App\Nova\Resources\Order\Card\Requisite\Concerns\CardRequisiteFieldsForIndex
|
|||||||
use App\Repos\Order\Card\CardOrderRepo;
|
use App\Repos\Order\Card\CardOrderRepo;
|
||||||
use App\Repos\Order\Card\CardTypeRepo;
|
use App\Repos\Order\Card\CardTypeRepo;
|
||||||
use App\Repos\Order\OrderRepo;
|
use App\Repos\Order\OrderRepo;
|
||||||
use App\Repos\Payment\OnlinePaymentRepo;
|
|
||||||
use App\Repos\System\Nova\NovaRepo;
|
use App\Repos\System\Nova\NovaRepo;
|
||||||
use App\Repos\System\Settings\Legal\PassportRepo;
|
use App\Repos\System\Settings\Legal\PassportRepo;
|
||||||
use App\Repos\System\Settings\Location\RegionRepo;
|
use App\Repos\System\Settings\Location\RegionRepo;
|
||||||
@@ -31,7 +30,6 @@ use Laravel\Nova\Fields\Select;
|
|||||||
use Laravel\Nova\Fields\Text;
|
use Laravel\Nova\Fields\Text;
|
||||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
use Laravel\Nova\Panel;
|
use Laravel\Nova\Panel;
|
||||||
use Laravel\Nova\URL;
|
|
||||||
use Nurmuhammet\NovaInputmask\NovaInputmask;
|
use Nurmuhammet\NovaInputmask\NovaInputmask;
|
||||||
|
|
||||||
class CardRequisite extends Resource
|
class CardRequisite extends Resource
|
||||||
@@ -159,20 +157,6 @@ class CardRequisite extends Resource
|
|||||||
$model->update(['unique_id' => CardOrderRepo::fillUniqueId($model)]);
|
$model->update(['unique_id' => CardOrderRepo::fillUniqueId($model)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the location to redirect the user after creation.
|
|
||||||
*
|
|
||||||
* @param \Laravel\Nova\Resource<CardRequisiteModel> $resource
|
|
||||||
*/
|
|
||||||
public static function redirectAfterCreate(NovaRequest $request, $resource): URL|string
|
|
||||||
{
|
|
||||||
$payment = (new OnlinePaymentRepo)->payCardOrder($resource);
|
|
||||||
|
|
||||||
return $payment['status'] === 'success'
|
|
||||||
? URL::remote($payment['url'])
|
|
||||||
: sprintf('resources/%s/%s', static::uriKey(), $resource->getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the fields for index.
|
* Get the fields for index.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user