Files

245 lines
5.2 KiB
PHP

<?php
namespace App\Classes\Modules\Transactions\DataTransferObjects;
use App\Classes\General\Interfaces\DataTransferObject;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use Carbon\Carbon;
class TransactionObject implements DataTransferObject
{
/** @var string */
private $billNo;
/** @var string */
private $transactionType;
/** @var int */
private $issuer;
/** @var int */
private $receiver;
/** @var int */
private $recipientBankAccountId;
/** @var int */
private $paymentMethod;
/** @var float */
private $amount;
/** @var float */
private $originalAmount;
/** @var int */
private $currencyId;
/** @var int */
private $originalCurrencyId;
/** @var float */
private $currencyRate;
/** @var float */
private $tax;
/** @var float */
private $serviceCharge;
/** @var Carbon|null */
private $expiresOn;
/** @var int|null */
private $status;
/** @var array|null */
private $details;
/** @var string */
private $paymentReference;
/**
* TransactionObject constructor.
* @param string $billNo
* @param string $transactionType
* @param int $issuer
* @param int $receiver
* @param int $recipientBankAccountId
* @param int $paymentMethod
* @param float $amount
* @param float $originalAmount
* @param int $currencyId
* @param int $originalCurrencyId
* @param float $currencyRate
* @param float $tax
* @param float $serviceCharge
* @param Carbon|null $expiresOn
* @param int|null $status
* @param array|null $details
* @param string $paymentReference
*/
public function __construct(string $billNo, string $transactionType, int $issuer, int $receiver, int $recipientBankAccountId, int $paymentMethod, float $amount, float $originalAmount, int $currencyId, int $originalCurrencyId, float $currencyRate, float $tax, float $serviceCharge, ?Carbon $expiresOn, ?int $status = ApprovalStatus::PENDING_SUBMISSION, ?array $details = [], ?string $paymentReference = null)
{
$this->billNo = $billNo;
$this->transactionType = $transactionType;
$this->issuer = $issuer;
$this->receiver = $receiver;
$this->recipientBankAccountId = $recipientBankAccountId;
$this->paymentMethod = $paymentMethod;
$this->amount = $amount;
$this->originalAmount = $originalAmount;
$this->currencyId = $currencyId;
$this->originalCurrencyId = $originalCurrencyId;
$this->currencyRate = $currencyRate;
$this->tax = $tax;
$this->serviceCharge = $serviceCharge;
$this->expiresOn = $expiresOn;
$this->status = $status;
$this->details = $details;
$this->paymentReference = $paymentReference;
}
/**
* @return string
*/
public function getBillNo(): string
{
return $this->billNo;
}
/**
* @return string
*/
public function getTransactionType(): string
{
return $this->transactionType;
}
/**
* @return int
*/
public function getIssuer(): int
{
return $this->issuer;
}
/**
* @return int
*/
public function getReceiver(): int
{
return $this->receiver;
}
/**
* @return int
*/
public function getRecipientBankAccountId(): int
{
return $this->recipientBankAccountId;
}
/**
* @return int
*/
public function getPaymentMethod(): int
{
return $this->paymentMethod;
}
/**
* @return float
*/
public function getAmount(): float
{
return $this->amount;
}
/**
* @return float
*/
public function getOriginalAmount(): float
{
return $this->originalAmount;
}
/**
* @return int
*/
public function getCurrencyId(): int
{
return $this->currencyId;
}
/**
* @return int
*/
public function getOriginalCurrencyId(): int
{
return $this->originalCurrencyId;
}
/**
* @return float
*/
public function getCurrencyRate(): float
{
return $this->currencyRate;
}
/**
* @return float
*/
public function getTax(): float
{
return $this->tax;
}
/**
* @return float
*/
public function getServiceCharge(): float
{
return $this->serviceCharge;
}
/**
* @return Carbon|null
*/
public function getExpiresOn(): ?Carbon
{
return $this->expiresOn;
}
/**
* @return int
*/
public function getStatus(): int
{
return $this->status;
}
/**
* @return array
*/
public function getDetails(): array
{
return array_map(function($product){
return new TransactionDetailObject($product['stockCode'] ?? '', $product['description'] ?? '', $product['quantity'] ?? '', floatval(str_replace(',', '', $product['unit_price'])));
}, $this->details);
}
/**
* @return string|null
*/
public function getPaymentReference(): ?string
{
return $this->paymentReference;
}
}