add transfer date notice

This commit is contained in:
edmondlang
2022-03-11 10:34:27 +08:00
parent ca6c81c27b
commit eb466ef227
4 changed files with 14 additions and 3 deletions
@@ -72,7 +72,8 @@ class FetchBookingPaymentQuotationLogic extends AbstractControllerLogic
return $this->response(['data' => $this->generatesBookingQuotation->execute(
$this->fetchBookingQuotation->execute($booking->company, $conversionObject),
$this->fetchesCompanyPaymentAttemptLimit->execute($booking->company)
$this->fetchesCompanyPaymentAttemptLimit->execute($booking->company),
$conversionObject
)]);
}
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Bookings\Services;
use App\Classes\Modules\Bookings\DataTransferObjects\CalculationObject;
use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject;
use App\Http\Resources\BankResource;
use App\Models\Bank;
use Carbon\Carbon;
@@ -12,12 +13,14 @@ use Carbon\CarbonInterval;
class GeneratesBookingQuotation
{
public function execute(CalculationObject $calculationObject, ?int $paymentAttemptLimit = 0){
public function execute(CalculationObject $calculationObject, ?int $paymentAttemptLimit = 0, ?CurrencyConversionObject $currencyConversionObject = null){
$date = Carbon::now();
$days = $date->diffInDays($date->copy()->addMinutes($paymentAttemptLimit));
$hours = $date->diffInHours($date->copy()->addMinutes($paymentAttemptLimit)->subDays($days)) ;
$minutes = $date->diffInMinutes($date->copy()->addMinutes($paymentAttemptLimit)->subDays($days)->subHours($hours));
$receive_date = $currencyConversionObject ? Carbon::now()->endOfDay()->addWeekdays($currencyConversionObject->getServiceId() === 1 ? 1 : 3)->timezone('Asia/Singapore')->format('4:00 \P\M, jS M, Y \G\M\T T') : null;
return [
'bank' => new BankResource(Bank::find($calculationObject->getConfigurations()->getBankId())),
'rate' => $calculationObject->getConfigurations()->getRate(),
@@ -30,6 +33,7 @@ class GeneratesBookingQuotation
'sub_total' => $calculationObject->getSubTotal(),
'total' => $calculationObject->getTotal(),
'date' => Carbon::now()->timezone('Asia/Singapore')->format('h:i a, jS M, Y \G\M\T T'),
'receive_date' => $receive_date,
'payment_attempt_limit' => CarbonInterval::days($days)->hours($hours)->minutes($minutes)->forHumans()
];
}
@@ -14,6 +14,7 @@ use App\Models\Company;
use App\Models\Currency;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Carbon\Carbon;
class FetchCompanyBookingQuotationLogic extends AbstractControllerLogic
{
@@ -71,7 +72,7 @@ class FetchCompanyBookingQuotationLogic extends AbstractControllerLogic
if($calculationObject->getConvertibleTotal() < $calculationObject->getConfigurations()->getMinLimit()) throw new RequestValidationException('Your transfer is below the minimum amount allowed of '.$calculationObject->getConfigurations()->getMinLimit().' '.$currency->short_code);
//TODO add po limit validation
return $this->response(['data' => $this->generatesBookingQuotation->execute($calculationObject)]);
return $this->response(['data' => $this->generatesBookingQuotation->execute($calculationObject, 0, $conversionObject)]);
}
@@ -6,6 +6,11 @@
<small class="bold fs-10 text-danger">{{error}}</small>
</div>
</div>
<div class="row m-b-15" v-if="calculation.date">
<div class="col text-center">
<div class="fs-14 muted" >The recipient will receive the transfer amount by <br><span class="bold text-success">{{ this.calculation.receive_date }}</span></div>
</div>
</div>
<div class="row">
<div class="col">
<div class="row m-l-0 m-r-0">