Add File based templates

This commit is contained in:
gohil jayvirsinh
2021-06-19 12:11:21 +00:00
committed by Mohit Panjwani
parent 00961bcae1
commit d1dd704cdf
58 changed files with 277 additions and 382 deletions

View File

@ -51,7 +51,7 @@ test('create estimate', function () {
->assertStatus(200);
$this->assertDatabaseHas('estimates', [
'estimate_template_id' => $estimate['estimate_template_id'],
'template_name' => $estimate['template_name'],
'estimate_number' => $estimate['estimate_number'],
'discount_type' => $estimate['discount_type'],
'discount_val' => $estimate['discount_val'],
@ -97,7 +97,7 @@ test('update estimate', function () {
$newEstimate = $response->decodeResponseJson()['estimate'];
$this->assertDatabaseHas('estimates', [
'estimate_template_id' => $estimate2['estimate_template_id'],
'template_name' => $estimate2['template_name'],
'estimate_number' => $estimate2['estimate_number'],
'discount_type' => $estimate2['discount_type'],
'discount_val' => $estimate2['discount_val'],

View File

@ -46,7 +46,7 @@ test('create invoice', function () {
$response->assertOk();
$this->assertDatabaseHas('invoices', [
'invoice_template_id' => $invoice['invoice_template_id'],
'template_name' => $invoice['template_name'],
'invoice_number' => $invoice['invoice_number'],
'sub_total' => $invoice['sub_total'],
'discount' => $invoice['discount'],
@ -78,7 +78,7 @@ test('create invoice as sent', function () {
'tax' => $invoice['tax'],
'discount' => $invoice['discount'],
'user_id' => $invoice['user_id'],
'invoice_template_id' => $invoice['invoice_template_id'],
'template_name' => $invoice['template_name'],
]);
$this->assertDatabaseHas('invoice_items', $invoice['items'][0]);
@ -115,7 +115,7 @@ test('update invoice', function () {
'tax' => $invoice2['tax'],
'discount' => $invoice2['discount'],
'user_id' => $invoice2['user_id'],
'invoice_template_id' => $invoice2['invoice_template_id'],
'template_name' => $invoice2['template_name'],
]);
$this->assertDatabaseHas('invoice_items', $invoice2['items'][0]);

View File

@ -1,28 +0,0 @@
<?php
use Crater\Models\EstimateTemplate;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
$user = User::where('role', 'super admin')->first();
$this->withHeaders([
'company' => $user->company_id,
]);
Sanctum::actingAs(
$user,
['*']
);
});
test('estimate template has many estimates', function () {
$estimateTemplate = EstimateTemplate::factory()->hasEstimates(5)->create();
$this->assertCount(5, $estimateTemplate->estimates);
$this->assertTrue($estimateTemplate->estimates()->exists());
});

View File

@ -46,13 +46,6 @@ test('estimate has many taxes', function () {
$this->assertTrue($estimate->taxes()->exists());
});
test('estimate belongs to estimate template', function () {
$estimate = Estimate::factory()->forEstimateTemplate()->create();
$this->assertTrue($estimate->estimateTemplate()->exists());
});
test('get next estimate number', function () {
$estimate = Estimate::factory()->create();
@ -114,7 +107,7 @@ test('create estimate', function () {
$this->assertDatabaseHas('estimates', [
'estimate_number' => $estimate['estimate_number'],
'user_id' => $estimate['user_id'],
'estimate_template_id' => $estimate['estimate_template_id'],
'template_name' => $estimate['template_name'],
'sub_total' => $estimate['sub_total'],
'total' => $estimate['total'],
'discount' => $estimate['discount'],
@ -162,7 +155,7 @@ test('update estimate', function () {
$this->assertDatabaseHas('estimates', [
'estimate_number' => $newEstimate['estimate_number'],
'user_id' => $newEstimate['user_id'],
'estimate_template_id' => $newEstimate['estimate_template_id'],
'template_name' => $newEstimate['template_name'],
'sub_total' => $newEstimate['sub_total'],
'total' => $newEstimate['total'],
'discount' => $newEstimate['discount'],

View File

@ -1,28 +0,0 @@
<?php
use Crater\Models\InvoiceTemplate;
use Crater\Models\User;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
$user = User::where('role', 'super admin')->first();
$this->withHeaders([
'company' => $user->company_id,
]);
Sanctum::actingAs(
$user,
['*']
);
});
test('invoice template has many invoices', function () {
$invoiceTemplate = InvoiceTemplate::factory()->hasInvoices(5)->create();
$this->assertCount(5, $invoiceTemplate->invoices);
$this->assertTrue($invoiceTemplate->invoices()->exists());
});

View File

@ -54,12 +54,6 @@ test('invoice belongs to user', function () {
$this->assertTrue($invoice->user()->exists());
});
test('invoice belongs to invoice template', function () {
$invoice = Invoice::factory()->forInvoiceTemplate()->create();
$this->assertTrue($invoice->invoiceTemplate()->exists());
});
test('get next invoice number', function () {
$invoice = Invoice::factory()->create();
@ -140,7 +134,7 @@ test('create invoice', function () {
'discount' => $invoice['discount'],
'notes' => $invoice['notes'],
'user_id' => $invoice['user_id'],
'invoice_template_id' => $invoice['invoice_template_id'],
'template_name' => $invoice['template_name'],
]);
});
@ -191,7 +185,7 @@ test('update invoice', function () {
'discount' => $newInvoice['discount'],
'notes' => $newInvoice['notes'],
'user_id' => $newInvoice['user_id'],
'invoice_template_id' => $newInvoice['invoice_template_id'],
'template_name' => $newInvoice['template_name'],
]);
});

View File

@ -33,8 +33,8 @@ test('estimate request validation rules', function () {
'tax' => [
'required',
],
'estimate_template_id' => [
'required',
'template_name' => [
'required'
],
'items' => [
'required',

View File

@ -33,8 +33,8 @@ test('invoice request validation rules', function () {
'tax' => [
'required',
],
'invoice_template_id' => [
'required',
'template_name' => [
'required'
],
'items' => [
'required',