Fixes for purchase order previews

This commit is contained in:
David Bomba 2024-01-12 12:14:09 +11:00
parent 4cc65fcb40
commit afd563b6c3
5 changed files with 15 additions and 4 deletions

View File

@ -71,7 +71,6 @@ class PreviewController extends BaseController
$ps = new PdfService($invitation, 'product', [
'client' => $client ?? false,
// 'vendor' => $vendor ?? false,
"{$entity_prop}s" => [$entity_obj],
]);

View File

@ -191,7 +191,7 @@ class PreviewPurchaseOrderController extends BaseController
$invitation->setRelation($request->entity, $entity_obj);
}
$ps = new PdfService($invitation, 'purchase_order', [
'client' => $entity_obj->client ?? false,
'vendor' => $vendor ?? false,

View File

@ -58,7 +58,11 @@ class PreviewPurchaseOrderRequest extends Request
$input['amount'] = 0;
$input['balance'] = 0;
$input['number'] = isset($input['number']) ? $input['number'] : ctrans('texts.live_preview').' #'.rand(0, 1000); //30-06-2023
if($input['entity_id'] ?? false) {
$input['entity_id'] = $this->decodePrimaryKey($input['entity_id'], true);
}
$this->replace($input);
}

View File

@ -117,6 +117,14 @@ class PurchaseOrder extends BaseModel
use SoftDeletes;
use MakesDates;
protected $hidden = [
'id',
'private_notes',
'user_id',
'vendor_id',
'company_id',
];
protected $fillable = [
'number',
'discount',

View File

@ -221,7 +221,6 @@ class PdfConfiguration
$this->vendor = $this->entity->vendor;
$this->vendor_contact = $this->service->invitation->contact;
$this->path = $this->vendor->purchase_order_filepath($this->service->invitation);
$this->entity_design_id = 'invoice_design_id';
$this->entity_design_id = 'purchase_order_design_id';
$this->settings = $this->vendor->company->settings;
$this->settings_object = $this->vendor;
@ -274,6 +273,7 @@ class PdfConfiguration
*/
private function setDesign(): self
{
$design_id = $this->entity->design_id ?: $this->decodePrimaryKey($this->settings_object->getSetting($this->entity_design_id));
$this->design = Design::withTrashed()->find($design_id) ?? Design::withTrashed()->find(2);