Fixed transaction missing type issue and fixed recurring vue exception..
This commit is contained in:
@ -63,9 +63,9 @@ class RecurringTransactions extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$type = request()->get('type', 'income-recurring');
|
||||
$real_type = request()->get('real_type', $this->getRealTypeOfRecurringTransaction($type));
|
||||
$contact_type = config('type.transaction.' . $real_type . '.contact_type');
|
||||
$type = $this->getTypeRecurringTransaction(request()->get('type', 'income-recurring'));
|
||||
$real_type = $this->getTypeTransaction(request()->get('real_type', $this->getRealTypeOfRecurringTransaction($type)));
|
||||
$contact_type = config('type.transaction.' . $real_type . '.contact_type', 'customer');
|
||||
|
||||
$number = $this->getNextTransactionNumber('-recurring');
|
||||
|
||||
@ -139,8 +139,8 @@ class RecurringTransactions extends Controller
|
||||
public function edit(Transaction $recurring_transaction)
|
||||
{
|
||||
$type = $recurring_transaction->type;
|
||||
$real_type = request()->get('real_type', $this->getRealTypeOfRecurringTransaction($type));
|
||||
$contact_type = config('type.transaction.' . $real_type . '.contact_type');
|
||||
$real_type = $this->getTypeTransaction(request()->get('real_type', $this->getRealTypeOfRecurringTransaction($type)));
|
||||
$contact_type = config('type.transaction.' . $real_type . '.contact_type', 'customer');
|
||||
|
||||
$number = $this->getNextTransactionNumber('-recurring');
|
||||
|
||||
|
@ -98,7 +98,7 @@ class Transactions extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$type = request()->get('type', 'income');
|
||||
$type = $this->getTypeTransaction(request()->get('type', 'income'));
|
||||
$real_type = $this->getRealTypeTransaction($type);
|
||||
|
||||
$number = $this->getNextTransactionNumber($type);
|
||||
|
@ -16,6 +16,12 @@ class CreateTransaction extends Job implements HasOwner, HasSource, ShouldCreate
|
||||
{
|
||||
event(new TransactionCreating($this->request));
|
||||
|
||||
if (! array_key_exists($this->request->get('type'), config('type.transaction'))) {
|
||||
$type = (empty($this->request->get('recurring_frequency')) || ($this->request->get('recurring_frequency') == 'no')) ? Transaction::INCOME_TYPE : Transaction::INCOME_RECURRING_TYPE;
|
||||
|
||||
$this->request->merge(['type' => $type]);
|
||||
}
|
||||
|
||||
\DB::transaction(function () {
|
||||
$this->model = Transaction::create($this->request->all());
|
||||
|
||||
|
@ -16,6 +16,12 @@ class UpdateTransaction extends Job implements ShouldUpdate
|
||||
|
||||
event(new TransactionUpdating($this->model, $this->request));
|
||||
|
||||
if (! array_key_exists($this->request->get('type'), config('type.transaction'))) {
|
||||
$type = (empty($this->request->get('recurring_frequency')) || ($this->request->get('recurring_frequency') == 'no')) ? Transaction::INCOME_TYPE : Transaction::INCOME_RECURRING_TYPE;
|
||||
|
||||
$this->request->merge(['type' => $type]);
|
||||
}
|
||||
|
||||
\DB::transaction(function () {
|
||||
$this->model->update($this->request->all());
|
||||
|
||||
|
@ -205,6 +205,11 @@ trait Transactions
|
||||
];
|
||||
}
|
||||
|
||||
public function getTypeTransaction(string $type = Transaction::INCOME_TYPE): string
|
||||
{
|
||||
return array_key_exists($type, config('type.transaction')) ? $type : Transaction::INCOME_TYPE;
|
||||
}
|
||||
|
||||
public function getRealTypeTransaction(string $type): string
|
||||
{
|
||||
$type = $this->getRealTypeOfRecurringTransaction($type);
|
||||
@ -214,6 +219,15 @@ trait Transactions
|
||||
return $type;
|
||||
}
|
||||
|
||||
public function getTypeRecurringTransaction(string $type = Transaction::INCOME_RECURRING_TYPE): string
|
||||
{
|
||||
if (! Str::contains($type, '-recurring')) {
|
||||
return Transaction::INCOME_RECURRING_TYPE;
|
||||
}
|
||||
|
||||
return array_key_exists($type, config('type.transaction')) ? $type : Transaction::INCOME_RECURRING_TYPE;
|
||||
}
|
||||
|
||||
public function getRealTypeOfRecurringTransaction(string $recurring_type): string
|
||||
{
|
||||
return Str::replace('-recurring', '', $recurring_type);
|
||||
|
Reference in New Issue
Block a user