1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Refactor the tables

This commit is contained in:
David Bomba 2022-08-11 14:47:08 +10:00
parent 6f9baa1c37
commit 0c5efe3ec2
2 changed files with 43 additions and 7 deletions

View File

@ -423,8 +423,6 @@ class BankIntegrationController extends BaseController
*
* @return Response
*
*
*
* @OA\Post(
* path="/api/v1/bank_integrations/refresh_accounts",
* operationId="getRefreshAccounts",
@ -499,6 +497,43 @@ class BankIntegrationController extends BaseController
return response()->json(BankIntegration::query()->company(), 200);
}
/**
* Return the remote list of accounts stored on the third part provider.
*
* @return Response
*
* @OA\Post(
* path="/api/v1/bank_integrations/remove_account/account_id",
* operationId="getRemoveAccount",
* tags={"bank_integrations"},
* summary="Removes an account from the integration",
* description="Removes an account from the integration",
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
* @OA\Parameter(ref="#/components/parameters/include"),
* @OA\Response(
* response=200,
* description="Returns the bank_integration object",
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
* @OA\JsonContent(ref="#/components/schemas/BankIntegration"),
* ),
* @OA\Response(
* response=422,
* description="Validation error",
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
*
* ),
* @OA\Response(
* response="default",
* description="Unexpected Error",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* ),
* )
*/
public function removeAccount(AdminBankIntegrationRequest $request, $acc_id)
{
@ -507,9 +542,7 @@ class BankIntegrationController extends BaseController
if(!$bank_account_id)
return response()->json(['message' => 'Not yet authenticated with Bank Integration service'], 400);
$company_id = auth()->user()->company()->id;
$bi = BankIntegration::withTrashed()->where('bank_account_id', $acc_id)->where('company_id', $company_id)->firstOrFail();
$bi = BankIntegration::withTrashed()->where('bank_account_id', $acc_id)->where('company_id', auth()->user()->company()->id)->firstOrFail();
$yodlee = new Yodlee($bank_account_id);
$yodlee->setTestMode();
@ -524,7 +557,6 @@ class BankIntegrationController extends BaseController
public function getTransactions(AdminBankIntegrationRequest $request)
{
//handle API failures we have only accounts for success
$bank_account_id = auth()->user()->account->bank_integration_account_id;

View File

@ -20,6 +20,10 @@ return new class extends Migration
$table->unsignedInteger('company_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->bigInteger('provider_id'); //id of the bank
$table->bigInteger('bank_account_id'); //id
@ -57,7 +61,7 @@ return new class extends Migration
$table->unsignedInteger('category_id');
$table->string('category_type');
$table->date('date');
$table->unsignedBigInteger('account_id');
$table->unsignedBigInteger('bank_account_id');
$table->text('description');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');