booking = $booking; $this->transaction = $transaction; $this->amount = $amount; $this->currency_rate = $currency_rate; } /** * @return Booking */ public function getBooking(): Booking { return $this->booking; } /** * @return Transaction */ public function getTransaction(): Transaction { return $this->transaction; } public function getAmount(): float { return $this->amount; } public function getCurrencyRate(): float { return $this->currency_rate; } /** * @return float */ public function setUnrequestedAmount() { $this->unrequested_amount = $this->transaction->original_amount == $this->amount ? $this->transaction->original_amount : $this->transaction->original_amount - $this->amount; return $this; } public function getUnrequestedAmount() { return $this->unrequested_amount; } public function setConversionObject() { $this->conversionObject = new CurrencyConversionObject(floatval(str_replace(',', '', $this->getUnrequestedAmount())), $this->booking->convertible_currency_id, $this->booking->service_id, $this->booking->fix_currency_id === 1 ? 0 : 1); return $this; } public function getConversionObject() { return $this->conversionObject; } public function setConfigurations() { $this->configurations = app('App\Classes\Modules\Bookings\Services\FetchesBookingQuotation')->execute($this->booking->company, $this->getConversionObject()); return $this; } public function getConfigurations() { return $this->configurations; } public function setRefundAmount() { $this->refund_amount = $this->transaction->amount == $this->getConfigurations()->getLocalTotal() ? $this->transaction->amount : $this->transaction->amount - $this->getConfigurations()->getLocalTotal(); return $this; } public function getRefundAmount() { return $this->refund_amount; } public function setRefundServiceCharge() { $this->refund_service_charge = $this->transaction->service_charge == $this->getConfigurations()->getServiceCharge() ? $this->transaction->service_charge : $this->transaction->service_charge - $this->getConfigurations()->getServiceCharge(); return $this; } public function getRefundServiceCharge() { return $this->refund_service_charge; } public function setRefundTax() { $this->refund_tax = $this->transaction->tax == $this->getConfigurations()->getTax() ? $this->transaction->tax : $this->transaction->tax - $this->getConfigurations()->getTax(); return $this; } public function getRefundTax() { return $this->refund_tax; } public function setRefundTotalAmount() { $this->refund_total_amount = $this->getRefundAmount() + $this->getRefundServiceCharge() + $this->getRefundTax(); return $this; } public function getRefundTotalAmount() { return $this->refund_total_amount; } public function setRefundConversionAmount() { $this->refund_conversion_amount = $this->getCurrencyRate() ? $this->transaction->original_amount * (1 / $this->getCurrencyRate()) : $this->transaction->original_amount; return $this; } public function getRefundConversionAmount() { return $this->refund_conversion_amount; } public function init(){ $this->setUnrequestedAmount(); $this->setConversionObject(); $this->setConfigurations(); $this->setRefundAmount(); $this->setRefundServiceCharge(); $this->setRefundTax(); $this->setRefundTotalAmount(); $this->setRefundConversionAmount(); } }