diff --git a/app/Designs/Bold.php b/app/Designs/Bold.php index 0f1f3013f32d..8a6a14d795ac 100644 --- a/app/Designs/Bold.php +++ b/app/Designs/Bold.php @@ -66,7 +66,7 @@ class Bold extends AbstractDesign return '
-

$your_invoice_label

$client_details +

$entity_label

$client_details
diff --git a/app/Designs/Business.php b/app/Designs/Business.php index 507845992d25..c3682b9036f3 100644 --- a/app/Designs/Business.php +++ b/app/Designs/Business.php @@ -71,7 +71,7 @@ class Business extends AbstractDesign return '
- $invoice_issued_to_label + $entity_label
$client_details
diff --git a/app/Designs/Creative.php b/app/Designs/Creative.php index 2ee2bf4c8608..791526942f12 100644 --- a/app/Designs/Creative.php +++ b/app/Designs/Creative.php @@ -69,8 +69,8 @@ class Creative extends AbstractDesign return '
-

Invoice

- #entity_number +

$entity_label

+ $entity_number
diff --git a/app/Designs/Hipster.php b/app/Designs/Hipster.php index cd8c591ebe03..099c00790d1f 100644 --- a/app/Designs/Hipster.php +++ b/app/Designs/Hipster.php @@ -79,7 +79,7 @@ class Hipster extends AbstractDesign $date
- $balance_due_label + $due_date_label $due_date
diff --git a/app/Designs/Playful.php b/app/Designs/Playful.php index 8eeafbb87819..5134e2c21a30 100644 --- a/app/Designs/Playful.php +++ b/app/Designs/Playful.php @@ -67,7 +67,7 @@ class Playful extends AbstractDesign
-

$invoice_to_label:

+

$entity_label

$client_details diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 042e904207bf..cdda440da7d5 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -24,6 +24,7 @@ use App\Http\Requests\User\ShowUserRequest; use App\Http\Requests\User\StoreUserRequest; use App\Http\Requests\User\UpdateUserRequest; use App\Jobs\Company\CreateCompanyToken; +use App\Models\CompanyToken; use App\Models\CompanyUser; use App\Models\User; use App\Repositories\UserRepository; @@ -627,7 +628,10 @@ class UserController extends BaseController $company_user = CompanyUser::whereUserId($user->id) ->whereCompanyId(auth()->user()->companyId())->first(); - $company_user->token->delete(); + $token = $company_user->token->where('company_id', $company_user->company_id)->where('user_id', $company_user->user_id)->first(); + + $token->delete(); + $company_user->delete(); return response()->json(['message' => 'User detached from company'], 200); diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index afc6dd973a3d..93fd1833cd57 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -12,6 +12,9 @@ namespace App\Utils\Traits; use App\Models\Country; +use App\Models\Credit; +use App\Models\Invoice; +use App\Models\Quote; use App\Utils\Number; /** @@ -274,12 +277,25 @@ trait MakesInvoiceValues $data['$number'] = $this->number ?: ' '; $data['$invoice.number'] = &$data['$number']; $data['$invoice_number'] = &$data['$number']; + $data['$entity_number'] = &$data['$number']; $data['$po_number'] = $this->po_number ?: ' '; $data['$invoice.po_number'] = &$data['$po_number']; $data['$line_taxes'] = $this->makeLineTaxes() ?: ' '; $data['$invoice.line_taxes'] = &$data['$line_taxes']; $data['$total_taxes'] = $this->makeTotalTaxes() ?: ' '; $data['$invoice.total_taxes'] = &$data['$total_taxes']; + + if($this instanceof Invoice) + $data['$entity_label'] = ctrans('texts.invoice'); + + if($this instanceof Quote) + $data['$entity_label'] = ctrans('texts.quote'); + + if($this instanceof Credit) + $data['$entity_label'] = ctrans('texts.credit'); + + + // $data['$tax'] = ; // $data['$item'] = ; // $data['$description'] = ; diff --git a/tests/Integration/DesignTest.php b/tests/Integration/DesignTest.php index eb7d85d3991b..4519ab79843c 100644 --- a/tests/Integration/DesignTest.php +++ b/tests/Integration/DesignTest.php @@ -6,6 +6,7 @@ use App\Designs\Designer; use App\Designs\Modern; use App\Jobs\Invoice\CreateInvoicePdf; use App\Jobs\Quote\CreateQuotePdf; +use App\Utils\Traits\GeneratesCounter; use Tests\MockAccountData; use Tests\TestCase; @@ -16,6 +17,7 @@ use Tests\TestCase; class DesignTest extends TestCase { use MockAccountData; + use GeneratesCounter; public function setUp() :void { @@ -45,7 +47,7 @@ class DesignTest extends TestCase $this->invoice->uses_inclusive_taxes = false; $settings = $this->invoice->client->settings; - $settings->invoice_design_id = "6"; + $settings->invoice_design_id = "5"; $this->client->settings = $settings; $this->client->save(); @@ -74,6 +76,29 @@ class DesignTest extends TestCase CreateQuotePdf::dispatchNow($this->quote, $this->quote->company, $this->quote->client->primary_contact()->first()); } + + public function testAllDesigns() + { + + for($x=1; $x<=10; $x++) + { + + $settings = $this->invoice->client->settings; + $settings->quote_design_id = (string)$x; + + $this->client->settings = $settings; + $this->client->save(); + + CreateQuotePdf::dispatchNow($this->quote, $this->quote->company, $this->quote->client->primary_contact()->first()); + + $this->quote->number = $this->getNextQuoteNumber($this->quote->client); + $this->quote->save(); + + } + + $this->assertTrue(true); + + } }