code for statement import invoice mapping

This commit is contained in:
Steve Ng
2023-10-06 10:59:36 +08:00
parent ddc1df0d6e
commit bc5d1eff88
10 changed files with 392 additions and 31 deletions
+19
View File
@@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Relations\HasOneThrough;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Staudenmeir\EloquentHasManyDeep\HasTableAlias;
use App\Models\StatementTransactionOwner;
class Transaction extends AbstractModel implements Documentable, Transactionable, Voucherifiable
@@ -53,6 +54,14 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
return $this->MorphOne(Transaction::class, 'owner')->where('type', TransactionType::CREDIT_NOTE);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\MorphOne
*/
public function transaction_owner()
{
return $this->MorphOne(StatementTransactionOwner::class, 'owner','owner_type','owner_id');
}
/**
* @return BelongsTo
*/
@@ -69,6 +78,16 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
return $this->BelongsTo( Company::class, 'issuer', 'id');
}
/**
* Get the user that owns the Transaction
*
* @return BelongsTo
*/
public function receiverCompany(): BelongsTo
{
return $this->belongsTo(Company::class, 'receiver', 'id');
}
/**
* @return BelongsTo
*/