1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Merge pull request #9749 from turbo124/v5-develop

Indexes for database.
This commit is contained in:
David Bomba 2024-07-10 14:39:06 +10:00 committed by GitHub
commit dd16f85a73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 75 additions and 5 deletions

View File

@ -63,7 +63,7 @@ class SendEmailRequest extends Request
$user = auth()->user();
return [
'template' => 'bail|required|in:'.implode(',', $this->templates),
'template' => 'bail|required|string|in:'.implode(',', $this->templates),
'entity' => 'bail|required|in:App\Models\Invoice,App\Models\Quote,App\Models\Credit,App\Models\RecurringInvoice,App\Models\PurchaseOrder,App\Models\Payment',
'entity_id' => ['bail', 'required', Rule::exists($this->entity_plural, 'id')->where('company_id', $user->company()->id)],
'cc_email.*' => 'bail|sometimes|email',

View File

@ -56,7 +56,7 @@ class UpdateExpenseRequest extends Request
$rules['invoice_id'] = 'bail|sometimes|nullable|exists:invoices,id,company_id,'.$user->company()->id;
$rules['documents'] = 'bail|sometimes|array';
$rules['amount'] = ['sometimes', 'bail', 'nullable', 'numeric', 'max:99999999999999'];
return $this->globalRules($rules);
}

View File

@ -46,7 +46,7 @@ class ExpenseRepository extends BaseRepository
/** @var \App\Models\User $user */
$user = auth()->user();
$payment_date = &$data['payment_date'];
$payment_date = isset($data['payment_date']) ? $data['payment_date'] : false;
if($payment_date && $payment_date == $expense->payment_date) {
//do nothing

View File

@ -211,7 +211,7 @@ class CompanyTransformer extends EntityTransformer
'smtp_password' => $company->smtp_password ? '********' : '',
'smtp_local_domain' => (string)$company->smtp_local_domain ?? '',
'smtp_verify_peer' => (bool)$company->smtp_verify_peer,
// 'e_invoice' => $company->e_invoice ?: new \stdClass(),
'e_invoice' => $company->e_invoice ?: new \stdClass(),
];
}

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('invoices', function (Blueprint $table){
$table->index(['project_id','deleted_at']);
});
Schema::table('quotes', function (Blueprint $table) {
$table->index(['project_id','deleted_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};

View File

@ -47,6 +47,46 @@ class ExpenseApiTest extends TestCase
Model::reguard();
}
public function testVendorPayment()
{
$data = [
'amount' => 100,
'payment_date' => now()->format('Y-m-d'),
'vendor_id' => $this->vendor->hashed_id,
'date' => '2021-10-01',
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/expenses', $data);
$arr = $response->json();
$response->assertStatus(200);
$this->assertEquals($this->vendor->hashed_id, $arr['data']['vendor_id']);
$this->assertEquals(now()->format('Y-m-d'), $arr['data']['payment_date']);
$data = [
'amount' => 100,
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/expenses/'.$arr['data']['id'], $data);
$arr = $response->json();
$response->assertStatus(200);
$this->assertEquals(now()->format('Y-m-d'), $arr['data']['payment_date']);
}
public function testExpensePutWithVendorStatus()
{

View File

@ -47,7 +47,6 @@ class VendorApiTest extends TestCase
Model::reguard();
}
public function testVendorContactCreation()
{
$data = [