Update for designer

This commit is contained in:
David Bomba 2023-03-13 07:57:10 +11:00
parent 206b2dd235
commit 69718f475d
2 changed files with 50 additions and 20 deletions

View File

@ -11,19 +11,26 @@
namespace App\Services\Pdf; namespace App\Services\Pdf;
use App\DataMapper\ClientSettings; use App\Models\Quote;
use App\Models\Client; use App\Models\Client;
use App\Models\Credit;
use App\Models\Design;
use App\Models\Vendor;
use App\Models\Company; use App\Models\Company;
use App\Models\Country; use App\Models\Country;
use App\Models\Credit;
use App\Models\Currency;
use App\Models\Design;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\InvoiceInvitation; use App\Models\Currency;
use App\Models\PurchaseOrder; use App\Models\PurchaseOrder;
use App\Models\Quote; use App\Models\QuoteInvitation;
use App\Models\Vendor;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use App\Models\CreditInvitation;
use App\Services\Pdf\PdfBuilder;
use App\Services\Pdf\PdfService;
use App\Models\InvoiceInvitation;
use App\Services\Pdf\PdfDesigner;
use App\DataMapper\ClientSettings;
use App\Services\Pdf\PdfConfiguration;
use App\Models\PurchaseOrderInvitation;
class PdfMock class PdfMock
{ {
@ -81,23 +88,46 @@ class PdfMock
public function initEntity(): mixed public function initEntity(): mixed
{ {
match ($this->request['entity_type']) { $settings = new \stdClass;
'invoice' => $entity = Invoice::factory()->make(), $settings->entity = Client::class;
'quote' => $entity = Quote::factory()->make(), $settings->currency_id = '1';
'credit' => $entity = Credit::factory()->make(), $settings->industry_id = '';
'purchase_order' => $entity = PurchaseOrder::factory()->make(), $settings->size_id = '';
default => $entity = Invoice::factory()->make()
};
if ($this->request['entity_type'] == PurchaseOrder::class) { switch ($this->request['entity_type']) {
$entity->vendor = Vendor::factory()->make(); case 'invoice':
} else { $entity = Invoice::factory()->make();
$entity->client = Client::factory()->make(); $entity->client = Client::factory()->make(['settings' => $settings]);
$entity->invitation = InvoiceInvitation::factory()->make();
break;
case 'quote':
$entity = Quote::factory()->make();
$entity->client = Client::factory()->make(['settings' => $settings]);
$entity->invitation = QuoteInvitation::factory()->make();
break;
case 'credit':
$entity = Credit::factory()->make();
$entity->client = Client::factory()->make(['settings' => $settings]);
$entity->invitation = CreditInvitation::factory()->make();
break;
case 'purchase_order':
$entity = PurchaseOrder::factory()->make();
$entity->client = Client::factory()->make(['settings' => $settings]);
$entity->invitation = PurchaseOrderInvitation::factory()->make();
break;
case PurchaseOrder::class:
$entity = PurchaseOrder::factory()->make();
$entity->invitation = PurchaseOrderInvitation::factory()->make();
$entity->vendor = Vendor::factory()->make();
break;
default:
# code...
break;
} }
$entity->tax_map = $this->getTaxMap(); $entity->tax_map = $this->getTaxMap();
$entity->total_tax_map = $this->getTotalTaxMap(); $entity->total_tax_map = $this->getTotalTaxMap();
$entity->invitation = InvoiceInvitation::factory()->make();
$entity->invitation->company = $this->company; $entity->invitation->company = $this->company;
return $entity; return $entity;

View File

@ -40,7 +40,7 @@ class VendorFactory extends Factory
'postal_code' => $this->faker->postcode(), 'postal_code' => $this->faker->postcode(),
'country_id' => 4, 'country_id' => 4,
'vendor_hash' => Str::random(40), 'vendor_hash' => Str::random(40),
'currency_id' => 1,
]; ];
} }
} }