wip
This commit is contained in:
@@ -212,11 +212,8 @@ function convertToOriginalFormat($apiPrice)
|
||||
|
||||
function lastDayOfMonth($month, $year)
|
||||
{
|
||||
// Create a DateTime object for the first day of the given month
|
||||
$date = new DateTime("$year-$month-01");
|
||||
// Modify the date to the last day of the same month
|
||||
$date->modify('last day of this month');
|
||||
|
||||
// Return the formatted date
|
||||
return $date->format('d');
|
||||
return $date;
|
||||
}
|
||||
|
||||
@@ -70,17 +70,12 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
]);
|
||||
}
|
||||
|
||||
// if (lastDayOfMonth($today->format('m'), $today->format('Y'))) {
|
||||
// return Action::modal('modal-response', [
|
||||
// 'title' => 'Bu gun aýyn sonky guni!',
|
||||
// 'body' => 'Ayyn sonky guni toleg alynmayar.',
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// in sonky gun otduh gune dushse 6 gunem toleg gecmeli dal, 5 gecirmeli dal;
|
||||
// in sonky gun 6 dushse gunem 5 gunem dushindim;
|
||||
|
||||
|
||||
if ($this->canAcceptPayment($today)) {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'Bu gun aýyn sonky guni!',
|
||||
'body' => 'Ayyn sonky guni toleg alynmayar.',
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $resource->branch || ! $resource->branch->billing_visa_master_username) {
|
||||
return Action::modal('modal-response', [
|
||||
@@ -260,4 +255,35 @@ class MakePaymentNovaVisaMaster extends Action
|
||||
'usd_payment_amount' => $usd_payment,
|
||||
]);
|
||||
}
|
||||
|
||||
public function canAcceptPayment($today)
|
||||
{
|
||||
$year = $today->format('Y');
|
||||
$month = $today->format('m');
|
||||
$lastDay = lastDayOfMonth($year, $month);
|
||||
|
||||
// Condition 1: Check if today is the last day of the month
|
||||
if ($today->format('Y-m-d') === $lastDay->format('Y-m-d')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine the day of the week for the last day of the month
|
||||
$lastDayOfWeek = $lastDay->format('l'); // e.g., 'Sunday', 'Saturday'
|
||||
|
||||
// Condition 2: If the last day is Sunday, disallow Friday, Saturday, Sunday
|
||||
if ($lastDayOfWeek === 'Sunday') {
|
||||
$forbiddenDays = ['Friday', 'Saturday', 'Sunday'];
|
||||
if (in_array($today->format('l'), $forbiddenDays)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Condition 3: If the last day is Saturday, disallow Friday
|
||||
if ($lastDayOfWeek === 'Saturday' && $today->format('l') === 'Friday') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If none of the conditions match, allow payment
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user