Copied transaction, receipt & currecny module from Exchange

This commit is contained in:
Fairuz
2021-07-04 11:52:31 +08:00
parent 9bcb45e5cc
commit bc8ec2854a
113 changed files with 5403 additions and 5 deletions
+37
View File
@@ -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;
}
}