mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Remove delivery not from try/catch block
This commit is contained in:
parent
0fe357cda6
commit
f22745d131
@ -845,13 +845,11 @@ class InvoiceController extends BaseController
|
||||
*/
|
||||
public function deliveryNote(ShowInvoiceRequest $request, Invoice $invoice)
|
||||
{
|
||||
|
||||
$file = $invoice->service()->getInvoiceDeliveryNote($invoice, $invoice->invitations->first()->contact);
|
||||
|
||||
try {
|
||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
} catch (\Exception $e) {
|
||||
return response(['message' => 'Oops, something went wrong. Make sure you have symlink to storage/ in public/ directory.'], 500);
|
||||
}
|
||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,7 +212,7 @@ class CompanyExport implements ShouldQueue
|
||||
|
||||
$this->export_data['credit_invitations'] = CreditInvitation::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($credit){
|
||||
|
||||
$credit = $this->transformArrayOfKeys($credit, ['company_id', 'user_id', 'client_contact_id', 'recurring_invoice_id']);
|
||||
$credit = $this->transformArrayOfKeys($credit, ['company_id', 'user_id', 'client_contact_id', 'credit_id']);
|
||||
|
||||
return $credit->makeVisible(['id']);
|
||||
|
||||
@ -271,7 +271,7 @@ class CompanyExport implements ShouldQueue
|
||||
|
||||
$this->export_data['invoice_invitations'] = InvoiceInvitation::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($invoice){
|
||||
|
||||
$invoice = $this->transformArrayOfKeys($invoice, ['company_id', 'user_id', 'client_contact_id', 'recurring_invoice_id']);
|
||||
$invoice = $this->transformArrayOfKeys($invoice, ['company_id', 'user_id', 'client_contact_id', 'invoice_id']);
|
||||
|
||||
return $invoice->makeVisible(['id']);
|
||||
|
||||
@ -332,7 +332,7 @@ class CompanyExport implements ShouldQueue
|
||||
|
||||
$this->export_data['quote_invitations'] = QuoteInvitation::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($quote){
|
||||
|
||||
$quote = $this->transformArrayOfKeys($quote, ['company_id', 'user_id', 'client_contact_id', 'recurring_invoice_id']);
|
||||
$quote = $this->transformArrayOfKeys($quote, ['company_id', 'user_id', 'client_contact_id', 'quote_id']);
|
||||
|
||||
return $quote->makeVisible(['id']);
|
||||
|
||||
|
@ -80,13 +80,13 @@ class CompanyImport implements ShouldQueue
|
||||
// 'recurring_invoices',
|
||||
// 'quotes',
|
||||
// 'payments',
|
||||
// 'paymentables',
|
||||
// 'subscriptions',
|
||||
// 'expenses',
|
||||
// 'tasks',
|
||||
// 'documents',
|
||||
// 'subscriptions',
|
||||
// 'webhooks',
|
||||
// 'system_logs',
|
||||
// 'paymentables',
|
||||
// 'company_ledger',
|
||||
// 'backups',
|
||||
];
|
||||
|
@ -71,10 +71,6 @@ class Quote extends BaseModel
|
||||
'custom_surcharge2',
|
||||
'custom_surcharge3',
|
||||
'custom_surcharge4',
|
||||
// 'custom_surcharge_tax1',
|
||||
// 'custom_surcharge_tax2',
|
||||
// 'custom_surcharge_tax3',
|
||||
// 'custom_surcharge_tax4',
|
||||
'design_id',
|
||||
'assigned_user_id',
|
||||
'exchange_rate',
|
||||
|
@ -19,17 +19,24 @@ use App\Models\Company;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\CompanyToken;
|
||||
use App\Models\CompanyUser;
|
||||
use App\Models\Credit;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\Expense;
|
||||
use App\Models\ExpenseCategory;
|
||||
use App\Models\GroupSetting;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentTerm;
|
||||
use App\Models\Paymentable;
|
||||
use App\Models\Product;
|
||||
use App\Models\Project;
|
||||
use App\Models\Quote;
|
||||
use App\Models\QuoteInvitation;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Models\RecurringInvoiceInvitation;
|
||||
use App\Models\Subscription;
|
||||
use App\Models\Task;
|
||||
use App\Models\TaskStatus;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\User;
|
||||
@ -545,7 +552,7 @@ class ImportCompanyTest extends TestCase
|
||||
|
||||
// Recurring Invoice Invitations
|
||||
|
||||
|
||||
// Invoices
|
||||
$this->assertEquals(2, count($this->backup_json_object->invoices));
|
||||
|
||||
$this->genericImport(Invoice::class,
|
||||
@ -564,13 +571,223 @@ class ImportCompanyTest extends TestCase
|
||||
|
||||
$this->assertEquals(2, Invoice::count());
|
||||
|
||||
// Invoices
|
||||
|
||||
|
||||
|
||||
// Invoices
|
||||
|
||||
// Invoice Invitations
|
||||
|
||||
$this->assertEquals(2, count($this->backup_json_object->invoice_invitations));
|
||||
|
||||
$this->genericImport(InvoiceInvitation::class,
|
||||
['user_id', 'client_contact_id', 'company_id', 'id', 'hashed_id', 'invoice_id'],
|
||||
[
|
||||
['users' => 'user_id'],
|
||||
['invoices' => 'invoice_id'],
|
||||
['client_contacts' => 'client_contact_id'],
|
||||
],
|
||||
'invoice_invitations',
|
||||
'key');
|
||||
|
||||
$this->assertEquals(2, InvoiceInvitation::count());
|
||||
|
||||
// Invoice Invitations
|
||||
|
||||
|
||||
// Quotes
|
||||
$this->assertEquals(2, count($this->backup_json_object->quotes));
|
||||
|
||||
$this->genericImport(Quote::class,
|
||||
['user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'recurring_id','status'],
|
||||
[
|
||||
['users' => 'user_id'],
|
||||
['users' => 'assigned_user_id'],
|
||||
['recurring_invoices' => 'recurring_id'],
|
||||
['clients' => 'client_id'],
|
||||
['subscriptions' => 'subscription_id'],
|
||||
['projects' => 'project_id'],
|
||||
['vendors' => 'vendor_id'],
|
||||
],
|
||||
'quotes',
|
||||
'number');
|
||||
|
||||
$this->assertEquals(2, Quote::count());
|
||||
|
||||
|
||||
// Quotes
|
||||
|
||||
// Quotes Invitations
|
||||
|
||||
$this->assertEquals(2, count($this->backup_json_object->quote_invitations));
|
||||
|
||||
$this->genericImport(QuoteInvitation::class,
|
||||
['user_id', 'client_contact_id', 'company_id', 'id', 'hashed_id', 'quote_id'],
|
||||
[
|
||||
['users' => 'user_id'],
|
||||
['quotes' => 'quote_id'],
|
||||
['client_contacts' => 'client_contact_id'],
|
||||
],
|
||||
'quote_invitations',
|
||||
'key');
|
||||
|
||||
$this->assertEquals(2, QuoteInvitation::count());
|
||||
|
||||
// Quotes Invitations
|
||||
|
||||
// Credits
|
||||
$this->assertEquals(2, count($this->backup_json_object->credits));
|
||||
|
||||
$this->genericImport(Credit::class,
|
||||
['user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'recurring_id','status'],
|
||||
[
|
||||
['users' => 'user_id'],
|
||||
['users' => 'assigned_user_id'],
|
||||
['recurring_invoices' => 'recurring_id'],
|
||||
['clients' => 'client_id'],
|
||||
['subscriptions' => 'subscription_id'],
|
||||
['projects' => 'project_id'],
|
||||
['vendors' => 'vendor_id'],
|
||||
],
|
||||
'quotes',
|
||||
'number');
|
||||
|
||||
$this->assertEquals(2, Credit::count());
|
||||
|
||||
|
||||
// Credits
|
||||
|
||||
// Credits Invitations
|
||||
|
||||
$this->assertEquals(2, count($this->backup_json_object->credit_invitations));
|
||||
|
||||
$this->genericImport(CreditInvitation::class,
|
||||
['user_id', 'client_contact_id', 'company_id', 'id', 'hashed_id', 'credit_id'],
|
||||
[
|
||||
['users' => 'user_id'],
|
||||
['quotes' => 'credit_id'],
|
||||
['client_contacts' => 'client_contact_id'],
|
||||
],
|
||||
'credit_invitations',
|
||||
'key');
|
||||
|
||||
$this->assertEquals(2, CreditInvitation::count());
|
||||
|
||||
// Credits Invitations
|
||||
|
||||
|
||||
// Expenses
|
||||
|
||||
$this->assertEquals(2, count($this->backup_json_object->expenses));
|
||||
|
||||
$this->genericImport(Expense::class,
|
||||
['assigned_user_id', 'user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'project_id','vendor_id'],
|
||||
[
|
||||
['users' => 'user_id'],
|
||||
['users' => 'assigned_user_id'],
|
||||
['clients' => 'client_id'],
|
||||
['projects' => 'project_id'],
|
||||
['vendors' => 'vendor_id'],
|
||||
],
|
||||
'expenses',
|
||||
'number');
|
||||
|
||||
$this->assertEquals(2, Expense::count());
|
||||
|
||||
// Expenses
|
||||
|
||||
|
||||
|
||||
// Tasks
|
||||
|
||||
$this->assertEquals(3, count($this->backup_json_object->tasks));
|
||||
|
||||
$this->genericImport(Task::class,
|
||||
['assigned_user_id', 'user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'invoice_id','project_id'],
|
||||
[
|
||||
['users' => 'user_id'],
|
||||
['users' => 'assigned_user_id'],
|
||||
['clients' => 'client_id'],
|
||||
['projects' => 'project_id'],
|
||||
['invoices' => 'invoice_id'],
|
||||
],
|
||||
'tasks',
|
||||
'number');
|
||||
|
||||
$this->assertEquals(3, Task::count());
|
||||
|
||||
// Tasks
|
||||
|
||||
|
||||
// Payments
|
||||
|
||||
$this->assertEquals(2, count($this->backup_json_object->payments));
|
||||
|
||||
$this->genericImport(Payment::class,
|
||||
['assigned_user_id', 'user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'client_contact_id','invitation_id','vendor_id','paymentables'],
|
||||
[
|
||||
['users' => 'user_id'],
|
||||
['users' => 'assigned_user_id'],
|
||||
['clients' => 'client_id'],
|
||||
['client_contacts' => 'client_contact_id'],
|
||||
['vendors' => 'vendor_id'],
|
||||
['invoice_invitations' => 'invitation_id'],
|
||||
['company_gateways' => 'company_gateway_id'],
|
||||
],
|
||||
'payments',
|
||||
'number');
|
||||
|
||||
$this->assertEquals(2, Payment::count());
|
||||
|
||||
// Payments
|
||||
|
||||
|
||||
// Paymentables
|
||||
|
||||
// $this->assertEquals(2, count($this->backup_json_object->paymentables));
|
||||
|
||||
// $this->paymentablesImport();
|
||||
|
||||
// $this->assertEquals(2, Paymentable::count());
|
||||
|
||||
|
||||
// Paymentables
|
||||
}
|
||||
|
||||
private function paymentablesImport()
|
||||
{
|
||||
|
||||
foreach($this->backup_json_object->paymentables as $paymentable)
|
||||
{
|
||||
$paymentable = new Paymentable();
|
||||
$paymentable->payment_id = $this->transformId('payments', $paymentable->payment_id);
|
||||
$paymentable->paymentable_type = $paymentable->paymentable_type;
|
||||
$paymentable->amount = $paymentable->amount;
|
||||
$paymentable->refunded = $paymentable->refunded;
|
||||
$paymentable->created_at = $paymentable->created_at;
|
||||
$paymentable->deleted_at = $paymentable->deleted_at;
|
||||
$paymentable->updated_at = $paymentable->updated_at;
|
||||
$paymentable->paymentable_id = $this->convertPaymentableId($paymentable->paymentable_type, $paymentable->paymentable_id);
|
||||
$paymentable->paymentable_type = $paymentable->paymentable_type;
|
||||
$paymentable->save(['timestamps' => false]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function convertPaymentableId($type, $id)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'invoices':
|
||||
return $this->transformId('invoices', $id);
|
||||
break;
|
||||
case Credit::class:
|
||||
return $this->transformId('credits', $id);
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function genericNewClassImport($class, $unset, $transforms, $object_property)
|
||||
{
|
||||
|
||||
|
Binary file not shown.
@ -55,9 +55,9 @@ class UserTest extends TestCase
|
||||
PasswordProtection::class
|
||||
);
|
||||
|
||||
if (config('ninja.testvars.travis') !== false) {
|
||||
$this->markTestSkipped('Skip test for Travis');
|
||||
}
|
||||
// if (config('ninja.testvars.travis') !== false) {
|
||||
// $this->markTestSkipped('Skip test for Travis');
|
||||
// }
|
||||
}
|
||||
|
||||
public function testUserList()
|
||||
@ -101,15 +101,14 @@ class UserTest extends TestCase
|
||||
|
||||
public function testUserAttachAndDetach()
|
||||
{
|
||||
|
||||
$this->withoutMiddleware(PasswordProtection::class);
|
||||
|
||||
$user = UserFactory::create($this->account->id);
|
||||
$user->first_name = 'Test';
|
||||
$user->last_name = 'Palloni';
|
||||
$user->email = $this->default_email;
|
||||
$user->save();
|
||||
|
||||
$data = $user->toArray();
|
||||
$data = [
|
||||
'first_name' => 'Test',
|
||||
'last_name' => 'Palloni',
|
||||
'email' => $this->default_email,
|
||||
];
|
||||
|
||||
$response = false;
|
||||
|
||||
@ -129,6 +128,8 @@ class UserTest extends TestCase
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
// $this->assertNotNull($user->company_user);
|
||||
// $this->assertEquals($user->company_user->company_id, $this->company->id);
|
||||
|
||||
@ -136,13 +137,16 @@ class UserTest extends TestCase
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->delete('/api/v1/users/'.$this->encodePrimaryKey($user->id).'/detach_from_company?include=company_user');
|
||||
])->delete('/api/v1/users/'.$arr['data']['id'].'/detach_from_company?include=company_user');
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$cu = CompanyUser::whereUserId($user->id)->whereCompanyId($this->company->id)->first();
|
||||
$ct = CompanyToken::whereUserId($user->id)->whereCompanyId($this->company->id)->first();
|
||||
$user_id = $this->decodePrimaryKey($arr['data']['id']);
|
||||
|
||||
$cu = CompanyUser::whereUserId($user_id)->whereCompanyId($this->company->id)->first();
|
||||
$ct = CompanyToken::whereUserId($user_id)->whereCompanyId($this->company->id)->first();
|
||||
$user = User::find($user_id);
|
||||
|
||||
$this->assertNull($cu);
|
||||
$this->assertNull($ct);
|
||||
$this->assertNotNull($user);
|
||||
@ -172,14 +176,12 @@ class UserTest extends TestCase
|
||||
$cu->save();
|
||||
|
||||
/*Create New Blank User and Attach to Company 2*/
|
||||
$new_user = UserFactory::create($this->account->id);
|
||||
$new_user->first_name = 'Test';
|
||||
$new_user->last_name = 'Palloni';
|
||||
$new_user->email = $this->default_email;
|
||||
$new_user->save();
|
||||
|
||||
$data = $new_user->toArray();
|
||||
|
||||
$data = [
|
||||
'first_name' => 'Test',
|
||||
'last_name' => 'Palloni',
|
||||
'email' => $this->default_email,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $company_token->token,
|
||||
|
Loading…
Reference in New Issue
Block a user