mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 15:34:37 -04:00
Fixes for expense repository
This commit is contained in:
parent
398e72a968
commit
116d0f4b15
@ -56,7 +56,7 @@ class UpdateExpenseRequest extends Request
|
|||||||
$rules['invoice_id'] = 'bail|sometimes|nullable|exists:invoices,id,company_id,'.$user->company()->id;
|
$rules['invoice_id'] = 'bail|sometimes|nullable|exists:invoices,id,company_id,'.$user->company()->id;
|
||||||
$rules['documents'] = 'bail|sometimes|array';
|
$rules['documents'] = 'bail|sometimes|array';
|
||||||
$rules['amount'] = ['sometimes', 'bail', 'nullable', 'numeric', 'max:99999999999999'];
|
$rules['amount'] = ['sometimes', 'bail', 'nullable', 'numeric', 'max:99999999999999'];
|
||||||
|
|
||||||
return $this->globalRules($rules);
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class ExpenseRepository extends BaseRepository
|
|||||||
/** @var \App\Models\User $user */
|
/** @var \App\Models\User $user */
|
||||||
$user = auth()->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) {
|
if($payment_date && $payment_date == $expense->payment_date) {
|
||||||
//do nothing
|
//do nothing
|
||||||
|
@ -47,6 +47,46 @@ class ExpenseApiTest extends TestCase
|
|||||||
Model::reguard();
|
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()
|
public function testExpensePutWithVendorStatus()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ class VendorApiTest extends TestCase
|
|||||||
Model::reguard();
|
Model::reguard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testVendorContactCreation()
|
public function testVendorContactCreation()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user