Added transaction split helpers..

This commit is contained in:
Cüneyt Şentürk 2022-10-31 00:34:13 +03:00
parent bd45ee1ea1
commit 6bb35cf3a3
2 changed files with 23 additions and 5 deletions

View File

@ -364,6 +364,7 @@ class Transaction extends Model
{
$type = $this->getRealTypeOfRecurringTransaction($this->type);
$type = $this->getRealTypeOfTransferTransaction($type);
$type = $this->getRealTypeOfSplitTransaction($type);
$type = str_replace('-', '_', $type);

View File

@ -51,6 +51,23 @@ trait Transactions
return Str::endsWith($type, '-transfer');
}
public function isNotTransferTransaction(): bool
{
return ! $this->isTransferTransaction();
}
public function isSplitTransaction(): bool
{
$type = $this->type ?? $this->transaction->type ?? $this->model->type ?? Transaction::INCOME_TYPE;
return Str::endsWith($type, '-split');
}
public function isNotSplitTransaction(): bool
{
return ! $this->isSplitTransaction();
}
public function isDocumentTransaction(): bool
{
$document_id = $this->document_id ?? $this->transaction->document_id ?? $this->model->document_id ?? null;
@ -63,11 +80,6 @@ trait Transactions
return ! $this->isDocumentTransaction();
}
public function isNotTransferTransaction(): bool
{
return ! $this->isTransferTransaction();
}
public function getIncomeTypes(string $return = 'array'): string|array
{
return $this->getTransactionTypes(Transaction::INCOME_TYPE, $return);
@ -202,6 +214,11 @@ trait Transactions
return Str::replace('-transfer', '', $transfer_type);
}
public function getRealTypeOfSplitTransaction(string $transfer_type): string
{
return Str::replace('-split', '', $transfer_type);
}
public function getNextTransactionNumber($suffix = ''): string
{
$prefix = setting('transaction' . $suffix . '.number_prefix');