mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-26 07:53:58 +00:00
Vourcherify
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Bookings\DataTransferObjects;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyServiceConfigurationsObject;
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject;
|
||||
use App\Classes\Modules\Vouchers\DataTransferObjects\ValidatedVoucherObject;
|
||||
|
||||
class CalculationObject implements DataTransferObject
|
||||
{
|
||||
@@ -15,15 +16,20 @@ class CalculationObject implements DataTransferObject
|
||||
/** @var CompanyServiceConfigurationsObject */
|
||||
private $configurations;
|
||||
|
||||
/** @var ValidatedVoucherObject */
|
||||
private $voucherObject;
|
||||
|
||||
/**
|
||||
* CalculationObject constructor.
|
||||
* @param CurrencyConversionObject $conversionObject
|
||||
* @param CompanyServiceConfigurationsObject $configurations
|
||||
* @param ValidatedVoucherObject $voucherObject
|
||||
*/
|
||||
public function __construct(CurrencyConversionObject $conversionObject, CompanyServiceConfigurationsObject $configurations)
|
||||
public function __construct(CurrencyConversionObject $conversionObject, CompanyServiceConfigurationsObject $configurations, ?ValidatedVoucherObject $voucherObject = null)
|
||||
{
|
||||
$this->conversionObject = $conversionObject;
|
||||
$this->configurations = $configurations;
|
||||
$this->voucherObject = $voucherObject;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +49,15 @@ class CalculationObject implements DataTransferObject
|
||||
return $this->configurations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return ValidatedVoucherObject
|
||||
*/
|
||||
public function getValidatedVoucherObject(): ?ValidatedVoucherObject
|
||||
{
|
||||
return $this->voucherObject;
|
||||
}
|
||||
|
||||
public function getConvertibleTotal(){
|
||||
return $this->getConversionObject()->getType() === 1 ? $this->getConversionObject()->getAmount() : $this->getConversionTotal();
|
||||
}
|
||||
@@ -87,9 +102,31 @@ class CalculationObject implements DataTransferObject
|
||||
return ($this->getSubTotal()/100) * $this->getConfigurations()->getTax();
|
||||
}
|
||||
|
||||
public function getTotal(): float {
|
||||
return $this->getSubTotal() + $this->getTax();
|
||||
public function getVoucherDiscountAmount(): float {
|
||||
if($this->getValidatedVoucherObject()){
|
||||
return $this->getValidatedVoucherObject()->getTotalDiscountAmount();
|
||||
}
|
||||
else{
|
||||
return 0.00;
|
||||
}
|
||||
}
|
||||
|
||||
public function getVoucherCode(): string {
|
||||
if($this->getValidatedVoucherObject()){
|
||||
return $this->getValidatedVoucherObject()->getCode();
|
||||
}
|
||||
else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public function getTotal(): float {
|
||||
if($this->getValidatedVoucherObject()){
|
||||
return $this->getValidatedVoucherObject()->getTotalAmount() + $this->getTax();
|
||||
}
|
||||
else{
|
||||
return $this->getSubTotal() + $this->getTax();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user