mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Copied transaction, receipt & currecny module from Exchange
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
|
||||
class TransactionDetail extends AbstractModel
|
||||
{
|
||||
protected $table = 'transaction_detail';
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function transaction(): BelongsTo
|
||||
{
|
||||
return $this->BelongsTo( Transaction::class, 'transaction_id', 'id');
|
||||
}
|
||||
|
||||
public function convert_original_price()
|
||||
{
|
||||
if($this->transaction()->first()->booking()->first()->fix_currency_id !== 1) {
|
||||
$currency_rate = $this->transaction()->first()->currency()->first()->rates()->where('payment_method_type', $this->transaction()->first()->payment_method)->first();
|
||||
return number_format($this->price / $currency_rate->selling, 2);
|
||||
}
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function convert_original_amount()
|
||||
{
|
||||
if($this->transaction()->first()->booking()->first()->fix_currency_id !== 1) {
|
||||
$currency_rate = $this->transaction()->first()->currency()->first()->rates()->where('payment_method_type', $this->transaction()->first()->payment_method)->first();
|
||||
return number_format($this->amount / $currency_rate->selling, 2);
|
||||
}
|
||||
return $this->amount;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user