Added transaction split helpers..
This commit is contained in:
parent
bd45ee1ea1
commit
6bb35cf3a3
@ -364,6 +364,7 @@ class Transaction extends Model
|
|||||||
{
|
{
|
||||||
$type = $this->getRealTypeOfRecurringTransaction($this->type);
|
$type = $this->getRealTypeOfRecurringTransaction($this->type);
|
||||||
$type = $this->getRealTypeOfTransferTransaction($type);
|
$type = $this->getRealTypeOfTransferTransaction($type);
|
||||||
|
$type = $this->getRealTypeOfSplitTransaction($type);
|
||||||
|
|
||||||
$type = str_replace('-', '_', $type);
|
$type = str_replace('-', '_', $type);
|
||||||
|
|
||||||
|
@ -51,6 +51,23 @@ trait Transactions
|
|||||||
return Str::endsWith($type, '-transfer');
|
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
|
public function isDocumentTransaction(): bool
|
||||||
{
|
{
|
||||||
$document_id = $this->document_id ?? $this->transaction->document_id ?? $this->model->document_id ?? null;
|
$document_id = $this->document_id ?? $this->transaction->document_id ?? $this->model->document_id ?? null;
|
||||||
@ -63,11 +80,6 @@ trait Transactions
|
|||||||
return ! $this->isDocumentTransaction();
|
return ! $this->isDocumentTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isNotTransferTransaction(): bool
|
|
||||||
{
|
|
||||||
return ! $this->isTransferTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIncomeTypes(string $return = 'array'): string|array
|
public function getIncomeTypes(string $return = 'array'): string|array
|
||||||
{
|
{
|
||||||
return $this->getTransactionTypes(Transaction::INCOME_TYPE, $return);
|
return $this->getTransactionTypes(Transaction::INCOME_TYPE, $return);
|
||||||
@ -202,6 +214,11 @@ trait Transactions
|
|||||||
return Str::replace('-transfer', '', $transfer_type);
|
return Str::replace('-transfer', '', $transfer_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRealTypeOfSplitTransaction(string $transfer_type): string
|
||||||
|
{
|
||||||
|
return Str::replace('-split', '', $transfer_type);
|
||||||
|
}
|
||||||
|
|
||||||
public function getNextTransactionNumber($suffix = ''): string
|
public function getNextTransactionNumber($suffix = ''): string
|
||||||
{
|
{
|
||||||
$prefix = setting('transaction' . $suffix . '.number_prefix');
|
$prefix = setting('transaction' . $suffix . '.number_prefix');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user