1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Refactor for bank transactions

This commit is contained in:
David Bomba 2022-09-21 15:30:57 +10:00
parent d7931fa6ba
commit f4a12660ad
4 changed files with 29 additions and 8 deletions

View File

@ -143,6 +143,7 @@ class IncomeTransformer implements BankRevenueInterface
'date' => $transaction->date, 'date' => $transaction->date,
'bank_account_id' => $transaction->accountId, 'bank_account_id' => $transaction->accountId,
'description' => $transaction->description->original, 'description' => $transaction->description->original,
'base_type' => $transaction->baseType,
]; ];
} }

View File

@ -31,7 +31,20 @@ class UpdateBankTransactionRequest extends Request
public function rules() public function rules()
{ {
/* Ensure we have a client name, and that all emails are unique*/ /* Ensure we have a client name, and that all emails are unique*/
$rules = []; $rules = [
'date' => 'bail|required|date',
'description', 'bail|required|string'
];
if (isset($this->currency_code))
$rules['currency_code'] = 'sometimes|exists:currencies,code';
if(isset($this->vendor_id))
$rules['vendor_id'] = 'bail|required|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
if(isset($this->expense_id))
$rules['expense_id'] = 'bail|required|exists:expenses,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
return $rules; return $rules;
} }
@ -45,6 +58,15 @@ class UpdateBankTransactionRequest extends Request
{ {
$input = $this->all(); $input = $this->all();
if(array_key_exists('vendor_id', $input))
$input['vendor_id'] = $this->decodePrimaryKey($input['vendor_id']);
if(array_key_exists('expense_id', $input))
$input['expense_id'] = $this->decodePrimaryKey($input['expense_id']);
if(array_key_exists('ninja_category_id', $input))
$input['ninja_category_id'] = $this->decodePrimaryKey($input['ninja_category_id']);
$this->replace($input); $this->replace($input);
} }

View File

@ -24,10 +24,11 @@ class BankTransactionRepository extends BaseRepository
public function save($data, BankTransaction $bank_transaction) public function save($data, BankTransaction $bank_transaction)
{ {
//stub to store $bank_transaction->fill($data);
return $bank_transaction->save(); $bank_transaction->save();
return $bank_transaction;
} }
} }

View File

@ -19,11 +19,7 @@ return new class extends Migration
$table->unsignedInteger('account_id'); $table->unsignedInteger('account_id');
$table->unsignedInteger('company_id'); $table->unsignedInteger('company_id');
$table->unsignedInteger('user_id'); $table->unsignedInteger('user_id');
$table->unsignedInteger('invoice_id');
$table->unsignedInteger('expense_id');
$table->boolean('is_matched')->default(0);
$table->text('provider_name'); //providerName ie Chase $table->text('provider_name'); //providerName ie Chase
$table->bigInteger('provider_id'); //id of the bank $table->bigInteger('provider_id'); //id of the bank
$table->bigInteger('bank_account_id'); //id $table->bigInteger('bank_account_id'); //id
@ -62,6 +58,7 @@ return new class extends Migration
$table->unsignedInteger('category_id')->nullable(); $table->unsignedInteger('category_id')->nullable();
$table->unsignedInteger('ninja_category_id')->nullable(); $table->unsignedInteger('ninja_category_id')->nullable();
$table->string('category_type')->index(); $table->string('category_type')->index();
$table->string('base_type')->index();
$table->date('date')->nullable(); $table->date('date')->nullable();
$table->unsignedBigInteger('bank_account_id'); $table->unsignedBigInteger('bank_account_id');
$table->text('description')->nullable(); $table->text('description')->nullable();