mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Tests for adding vendors to quotes, credits, invoice and recurring invoices
This commit is contained in:
parent
dd2fba48cd
commit
4e86fcf2ba
@ -76,6 +76,10 @@ class StoreRecurringInvoiceRequest extends Request
|
||||
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
|
||||
}
|
||||
|
||||
if (array_key_exists('vendor_id', $input) && is_string($input['vendor_id'])) {
|
||||
$input['vendor_id'] = $this->decodePrimaryKey($input['vendor_id']);
|
||||
}
|
||||
|
||||
if (isset($input['client_contacts'])) {
|
||||
foreach ($input['client_contacts'] as $key => $contact) {
|
||||
if (! array_key_exists('send_email', $contact) || ! array_key_exists('id', $contact)) {
|
||||
|
@ -107,6 +107,7 @@ class RecurringInvoice extends BaseModel
|
||||
'design_id',
|
||||
'assigned_user_id',
|
||||
'exchange_rate',
|
||||
'vendor_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@ -157,6 +158,11 @@ class RecurringInvoice extends BaseModel
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function vendor()
|
||||
{
|
||||
return $this->belongsTo(Vendor::class);
|
||||
}
|
||||
|
||||
public function activities()
|
||||
{
|
||||
return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(50);
|
||||
|
@ -75,6 +75,42 @@ class VendorApiTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testAddVendorToRecurringInvoice()
|
||||
{
|
||||
$data = [
|
||||
'name' => $this->faker->firstName,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/vendors', $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
$vendor_id = $arr['data']['id'];
|
||||
|
||||
$data = [
|
||||
'vendor_id' => $vendor_id,
|
||||
'client_id' => $this->client->hashed_id,
|
||||
'frequency_id' => 1,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/recurring_invoices', $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
$this->assertEquals($arr['data']['vendor_id'], $vendor_id);
|
||||
|
||||
}
|
||||
|
||||
public function testAddVendorToQuote()
|
||||
{
|
||||
$data = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user