type = $type; $this->document = $document; $this->documentTemplate = $this->getDocumentTemplate($type, $documentTemplate); $this->logo = $this->getLogo($logo); $this->backGroundColor = $backGroundColor; $this->signedUrl = $this->getSignedUrl($type, $signedUrl); $this->histories = ($histories) ? $histories : $document->histories; $this->transactions = ($transactions) ? $transactions : $document->transactions; $this->date_format = $this->getCompanyDateFormat(); $this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType); $this->textStatusMessage = $this->getTextStatusMessage($type, $textStatusMessage); $this->textHistories = $this->getTextHistories($type, $textHistories); $this->textHistoryStatus = $this->getTextHistoryStatus($type, $textHistoryStatus); $this->checkButtonReconciled = $checkButtonReconciled; $this->checkButtonCancelled = $checkButtonCancelled; $this->routeButtonAddNew = $this->getRouteButtonAddNew($type, $routeButtonAddNew); $this->routeButtonEdit = $this->getRouteButtonEdit($type, $routeButtonEdit); $this->routeButtonDuplicate = $this->getRouteButtonDuplicate($type, $routeButtonDuplicate); $this->routeButtonPrint = $this->getRouteButtonPrint($type, $routeButtonPrint); $this->routeButtonPdf = $this->getRouteButtonPdf($type, $routeButtonPdf); $this->routeButtonCancelled = $this->getRouteButtonCancelled($type, $routeButtonCancelled); $this->routeButtonCustomize = $this->getRouteButtonCustomize($type, $routeButtonCustomize); $this->routeButtonDelete = $this->getRouteButtonDelete($type, $routeButtonDelete); $this->routeButtonPaid = $this->getRouteButtonPaid($type, $routeButtonPaid); $this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate); $this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate); $this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete); $this->permissionButtonCustomize = $this->getPermissionButtonCustomize($type, $permissionButtonCustomize); $this->hideButtonGroupDivider1 = $hideButtonGroupDivider1; $this->hideButtonGroupDivider2 = $hideButtonGroupDivider2; $this->hideButtonGroupDivider3 = $hideButtonGroupDivider3; $this->hideButtonMoreActions = $hideButtonMoreActions; $this->hideButtonAddNew = $hideButtonAddNew; $this->hideButtonEdit = $hideButtonEdit; $this->hideButtonDuplicate = $hideButtonDuplicate; $this->hideButtonPrint = $hideButtonPrint; $this->hideButtonPdf = $hideButtonPdf; $this->hideButtonCancel = $hideButtonCancel; $this->hideButtonCustomize = $hideButtonCustomize; $this->hideButtonDelete = $hideButtonDelete; $this->hideHeader = $hideHeader; $this->hideRecurringMessage = $hideRecurringMessage; $this->hideStatusMessage = $hideStatusMessage; $this->hideTimeline = $hideTimeline; $this->hideFooter = $hideFooter; $this->hideFooterHistories = $hideFooterHistories; $this->hideFooterTransactions = $hideFooterTransactions; $this->classHeaderStatus = $this->getClassHeaderStatus($type, $classHeaderStatus); $this->classHeaderContact = $this->getClassHeaderContact($type, $classHeaderContact); $this->classHeaderAmount = $this->getClassHeaderAmount($type, $classHeaderAmount); $this->classHeaderDueAt = $this->getClassHeaderDueAt($type, $classHeaderDueAt); $this->hideHeaderStatus = $hideHeaderStatus; $this->hideHeaderContact = $hideHeaderContact; $this->hideHeaderAmount = $hideHeaderAmount; $this->hideHeaderDueAt = $hideHeaderDueAt; $this->textHeaderContact = $this->getTextHeaderContact($type, $textHeaderContact); $this->textHeaderAmount = $this->getTextHeaderAmount($type, $textHeaderAmount); $this->textHeaderDueAt = $this->getTextHeaderDueAt($type, $textHeaderDueAt); $this->hideTimelineStatuses = $this->getTimelineStatuses($type, $hideTimelineStatuses); $this->hideTimelineCreate = $hideTimelineCreate; $this->hideTimelineSent = $hideTimelineSent; $this->hideTimelinePaid = $hideTimelinePaid; $this->hideButtonSent = $hideButtonSent; $this->hideButtonReceived = $hideButtonReceived; $this->hideButtonEmail = $hideButtonEmail; $this->hideButtonShare = $hideButtonShare; $this->hideButtonPaid = $hideButtonPaid; $this->textTimelineCreateTitle = $this->getTextTimelineCreateTitle($type, $textTimelineCreateTitle); $this->textTimelineCreateMessage = $this->getTextTimelineCreateMessage($type, $textTimelineCreateMessage); $this->textTimelineSentTitle = $this->getTextTimelineSentTitle($type, $textTimelineSentTitle); $this->textTimelineSentStatusDraft = $this->getTextTimelineSentStatusDraft($type, $textTimelineSentStatusDraft); $this->textTimelineSentStatusMarkSent = $this->getTextTimelineSentStatusMarkSent($type, $textTimelineSentStatusMarkSent); $this->textTimelineSentStatusReceived = $this->getTextTimelineSentStatusReceived($type, $textTimelineSentStatusReceived); $this->textTimelineSendStatusMail = $this->getTextTimelineSendStatusMail($type, $textTimelineSendStatusMail); $this->textTimelineGetPaidTitle = $this->getTextTimelineGetPaidTitle($type, $textTimelineGetPaidTitle); $this->textTimelineGetPaidStatusAwait = $this->getTextTimelineGetPaidStatusAwait($type, $textTimelineGetPaidStatusAwait); $this->textTimelineGetPaidStatusPartiallyPaid = $this->getTextTimelineGetPaidStatusPartiallyPaid($type, $textTimelineGetPaidStatusPartiallyPaid); $this->textTimelineGetPaidMarkPaid = $this->getTextTimelineGetPaidMarkPaid($type, $textTimelineGetPaidMarkPaid); $this->textTimelineGetPaidAddPayment = $this->getTextTimelineGetPaidAddPayment($type, $textTimelineGetPaidAddPayment); $this->routeButtonSent = $this->getRouteButtonSent($type, $routeButtonSent); $this->routeButtonReceived = $this->getRouteButtonReceived($type, $routeButtonReceived); $this->routeButtonEmail = $this->getRouteButtonEmail($type, $routeButtonEmail); $this->hideCompanyDetails = $hideCompanyDetails; $this->hideCompanyLogo = $hideCompanyLogo; $this->hideCompanyName = $hideCompanyName; $this->hideContactAddress = $hideContactAddress; $this->hideContactTaxNumber = $hideContactTaxNumber; $this->hideContactPhone = $hideContactPhone; $this->hideContactEmail = $hideContactEmail; $this->hideOrderNumber = $hideOrderNumber; $this->hideDocumentNumber = $hideDocumentNumber; $this->hideOrderNumber = $hideOrderNumber; $this->hideIssuedAt = $hideIssuedAt; $this->hideDueAt = $hideDueAt; $this->textContactInfo = $textContactInfo; $this->textIssuedAt = $textIssuedAt; $this->textDocumentNumber = $textDocumentNumber; $this->textDueAt = $textDueAt; $this->textOrderNumber = $textOrderNumber; $this->hideItems = $this->getHideItems($type, $hideItems, $hideName, $hideDescription); $this->hideName = $this->getHideName($type, $hideName); $this->hideDescription = $this->getHideDescription($type, $hideDescription); $this->hideQuantity = $this->getHideQuantity($type, $hideQuantity); $this->hidePrice = $this->getHidePrice($type, $hidePrice); $this->hideDiscount = $this->getHideDiscount($type, $hideDiscount); $this->hideAmount = $this->getHideAmount($type, $hideAmount); $this->hideNote = $hideNote; $this->hideAttachment = $hideAttachment; $this->attachment = $attachment; $this->textItems = $textItems; $this->textQuantity = $textQuantity; $this->textPrice = $textPrice; $this->textAmount = $textAmount; $this->textDeleteModal = $textDeleteModal; } protected function getTextRecurringType($type, $textRecurringType) { if (!empty($textRecurringType)) { return $textRecurringType; } $default_key = config('type.' . $type . '.translation.prefix'); $translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key); if (!empty($translation)) { return $translation; } return 'general.invoices'; } protected function getTextStatusMessage($type, $textStatusMessage) { if (!empty($textStatusMessage)) { return $textStatusMessage; } $default_key = config('type.' . $type . '.translation.prefix') . '.messages.draft'; $translation = $this->getTextFromConfig($type, 'status_message', $default_key); if (!empty($translation)) { return $translation; } return 'invoices.messages.draft'; } protected function getDocumentTemplate($type, $documentTemplate) { if (!empty($documentTemplate)) { return $documentTemplate; } $documentTemplate = 'default'; switch ($type) { case 'sale': case 'income': case 'invoice': $documentTemplate = setting('invoice.template', 'default'); break; } return $documentTemplate; } protected function getLogo($logo) { if (!empty($logo)) { return $logo; } $media = Media::find(setting('company.logo')); if (!empty($media)) { $path = Storage::path($media->getDiskPath()); if (!is_file($path)) { return $logo; } } else { $path = base_path('public/img/company.png'); } $image = Image::cache(function($image) use ($path) { $width = $height = setting('invoice.logo_size', 128); $image->make($path)->resize($width, $height)->encode(); }); if (empty($image)) { return $logo; } $extension = File::extension($path); return 'data:image/' . $extension . ';base64,' . base64_encode($image); } protected function getSignedUrl($type, $signedUrl) { if (!empty($signedUrl)) { return $signedUrl; } $page = config("type.{$type}.route.prefix"); $route = 'signed.' . $page . '.show'; try { route($route, [$this->document->id, 'company_id' => session('company_id')]); $signedUrl = URL::signedRoute($route, [$this->document->id, 'company_id' => session('company_id')]); } catch (\Exception $e) { $route = ''; } return $signedUrl; } protected function getTextHistories($type, $textHistories) { if (!empty($textHistories)) { return $textHistories; } $default_key = config('type.' . $type . '.translation.prefix') . '.histories'; $translation = $this->getTextFromConfig($type, 'histories', $default_key); if (!empty($translation)) { return $translation; } return 'invoices.histories'; } protected function getTextHistoryStatus($type, $textHistoryStatus) { if (!empty($textHistoryStatus)) { return $textHistoryStatus; } $default_key = config('type.' . $type . '.translation.prefix') . '.statuses.'; $translation = $this->getTextFromConfig($type, 'history_status', $default_key); if (!empty($translation)) { return $translation; } return 'invoices.statuses.'; } protected function getRouteButtonAddNew($type, $routeButtonAddNew) { if (!empty($routeButtonAddNew)) { return $routeButtonAddNew; } $page = config("type.{$type}.route.prefix"); $route = $page . '.create'; try { route($route); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonEdit($type, $routeButtonEdit) { if (!empty($routeButtonEdit)) { return $routeButtonEdit; } $page = config("type.{$type}.route.prefix"); $route = $page . '.edit'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonDuplicate($type, $routeButtonDuplicate) { if (!empty($routeButtonDuplicate)) { return $routeButtonDuplicate; } $page = config("type.{$type}.route.prefix"); $route = $page . '.duplicate'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonPrint($type, $routeButtonPrint) { if (!empty($routeButtonPrint)) { return $routeButtonPrint; } $page = config("type.{$type}.route.prefix"); $route = $page . '.print'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonPdf($type, $routeButtonPdf) { if (!empty($routeButtonPdf)) { return $routeButtonPdf; } $page = config("type.{$type}.route.prefix"); $route = $page . '.pdf'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonCancelled($type, $routeButtonCancelled) { if (!empty($routeButtonCancelled)) { return $routeButtonCancelled; } $page = config("type.{$type}.route.prefix"); $route = $page . '.cancelled'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonCustomize($type, $routeButtonCustomize) { if (!empty($routeButtonCustomize)) { return $routeButtonCustomize; } $route = 'settings.' . $type . '.edit'; try { route($route); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonDelete($type, $routeButtonDelete) { if (!empty($routeButtonDelete)) { return $routeButtonDelete; } $page = config("type.{$type}.route.prefix"); $route = $page . '.destroy'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonPaid($type, $routeButtonPaid) { if (!empty($routeButtonPaid)) { return $routeButtonPaid; } $page = config("type.{$type}.route.prefix"); $route = $page . '.paid'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonSent($type, $routeButtonSent) { if (!empty($routeButtonSent)) { return $routeButtonSent; } $page = config("type.{$type}.route.prefix"); $route = $page . '.sent'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonReceived($type, $routeButtonReceived) { if (!empty($routeButtonReceived)) { return $routeButtonReceived; } $page = config("type.{$type}.route.prefix"); $route = $page . '.received'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getRouteButtonEmail($type, $routeButtonEmail) { if (!empty($routeButtonEmail)) { return $routeButtonEmail; } $page = config("type.{$type}.route.prefix"); $route = $page . '.email'; try { //example route parameter. $parameter = 1; route($route, $parameter); } catch (\Exception $e) { $route = ''; } return $route; } protected function getPermissionCreate($type, $permissionCreate) { if (!empty($permissionCreate)) { return $permissionCreate; } $permissionCreate = $this->getPermissionFromConfig($type, 'create'); return $permissionCreate; } protected function getPermissionUpdate($type, $permissionUpdate) { if (!empty($permissionUpdate)) { return $permissionUpdate; } $permissionUpdate = $this->getPermissionFromConfig($type, 'update'); return $permissionUpdate; } protected function getPermissionDelete($type, $permissionDelete) { if (!empty($permissionDelete)) { return $permissionDelete; } $permissionDelete = $this->getPermissionFromConfig($type, 'delete'); return $permissionDelete; } protected function getPermissionButtonCustomize($type, $permissionButtonCustomize) { if (!empty($permissionButtonCustomize)) { return $permissionButtonCustomize; } $permissionUpdate = $this->getPermissionFromConfig($type, 'update'); return $permissionUpdate; } protected function getTextHeaderContact($type, $textHeaderContact) { if (!empty($textHeaderContact)) { return $textHeaderContact; } $default_key = Str::plural(config('type.' . $type . '.contact_type'), 2); $translation = $this->getTextFromConfig($type, 'header_contact', $default_key, 'trans_choice'); if (!empty($translation)) { return $translation; } return 'general.customers'; } protected function getTextHeaderAmount($type, $textHeaderAmount) { if (!empty($textHeaderAmount)) { return $textHeaderAmount; } $translation = $this->getTextFromConfig($type, 'header_amount', 'amount_due'); if (!empty($translation)) { return $translation; } return 'general.amount_due'; } protected function getTextHeaderDueAt($type, $textHeaderDueAt) { if (!empty($textHeaderDueAt)) { return $textHeaderDueAt; } $translation = $this->getTextFromConfig($type, 'header_due_at', 'due_on'); if (!empty($translation)) { return $translation; } return 'general.due_on'; } protected function getClassHeaderStatus($type, $classHeaderStatus) { if (!empty($classHeaderStatus)) { return $classHeaderStatus; } return 'col-md-2'; } protected function getClassHeaderContact($type, $classHeaderContact) { if (!empty($classHeaderContact)) { return $classHeaderContact; } return 'col-md-6'; } protected function getClassHeaderAmount($type, $classHeaderAmount) { if (!empty($classHeaderAmount)) { return $classHeaderAmount; } return 'col-md-2'; } protected function getClassHeaderDueAt($type, $classHeaderDueAt) { if (!empty($classHeaderDueAt)) { return $classHeaderDueAt; } return 'col-md-2'; } protected function getTimelineStatuses($type, $hideTimelineStatuses) { if (!empty($hideTimelineStatuses)) { return $hideTimelineStatuses; } $hideTimelineStatuses = ['paid', 'cancelled']; return $hideTimelineStatuses; } protected function getTextTimelineCreateTitle($type, $textTimelineCreateTitle) { if (!empty($textTimelineCreateTitle)) { return $textTimelineCreateTitle; } $default_key = 'create_' . $type; $translation = $this->getTextFromConfig($type, 'timeline_create_title', $default_key); if (!empty($translation)) { return $translation; } return 'invoices.create_invoice'; } protected function getTextTimelineCreateMessage($type, $textTimelineCreateMessage) { if (!empty($textTimelineCreateMessage)) { return $textTimelineCreateMessage; } $translation = $this->getTextFromConfig($type, 'timeline_create_message', 'messages.status.created'); if (!empty($translation)) { return $translation; } return 'invoices.messages.status.created'; } protected function getTextTimelineSentTitle($type, $textTimelineSentTitle) { if (!empty($textTimelineSentTitle)) { return $textTimelineSentTitle; } switch ($type) { case 'bill': case 'expense': case 'purchase': $default_key = 'receive_bill'; break; default: $default_key = 'send_invoice'; break; } $translation = $this->getTextFromConfig($type, 'timeline_sent_title', $default_key); if (!empty($translation)) { return $translation; } return 'invoices.send_invoice'; } protected function getTextTimelineSentStatusDraft($type, $textTimelineSentStatusDraft) { if (!empty($textTimelineSentStatusDraft)) { return $textTimelineSentStatusDraft; } switch ($type) { case 'bill': case 'expense': case 'purchase': $default_key = 'messages.status.receive.draft'; break; default: $default_key = 'messages.status.send.draft'; break; } $translation = $this->getTextFromConfig($type, 'timeline_sent_status_draft', $default_key); if (!empty($translation)) { return $translation; } return 'invoices.messages.status.send.draft'; } protected function getTextTimelineSentStatusMarkSent($type, $textTimelineSentStatusMarkSent) { if (!empty($textTimelineSentStatusMarkSent)) { return $textTimelineSentStatusMarkSent; } switch ($type) { case 'bill': case 'expense': case 'purchase': $default_key = 'mark_received'; break; default: $default_key = 'mark_sent'; break; } $translation = $this->getTextFromConfig($type, 'timeline_sent_status_mark_sent', $default_key); if (!empty($translation)) { return $translation; } return 'invoices.mark_sent'; } protected function getTextTimelineSentStatusReceived($type, $textTimelineSentStatusReceived) { if (!empty($textTimelineSentStatusReceived)) { return $textTimelineSentStatusReceived; } switch ($type) { case 'bill': case 'expense': case 'purchase': $textTimelineSentStatusReceived = 'mark_received'; break; default: $textTimelineSentStatusReceived = 'mark_sent'; break; } $translation = $this->getTextFromConfig($type, 'timeline_sent_status_received', $default_key); if (!empty($translation)) { return $translation; } return 'invoices.mark_sent'; } protected function getTextTimelineSendStatusMail($type, $textTimelineSendStatusMail) { if (!empty($textTimelineSendStatusMail)) { return $textTimelineSendStatusMail; } $translation = $this->getTextFromConfig($type, 'timeline_sent_status_mail', 'send_mail'); if (!empty($translation)) { return $translation; } return 'invoices.send_mail'; } protected function getTextTimelineGetPaidTitle($type, $textTimelineGetPaidTitle) { if (!empty($textTimelineGetPaidTitle)) { return $textTimelineGetPaidTitle; } switch ($type) { case 'bill': case 'expense': case 'purchase': $default_key = 'make_payment'; break; default: $default_key = 'get_paid'; break; } $translation = $this->getTextFromConfig($type, 'timeline_get_paid_title', $default_key); if (!empty($translation)) { return $translation; } return 'invoices.get_paid'; } protected function getTextTimelineGetPaidStatusAwait($type, $textTimelineGetPaidStatusAwait) { if (!empty($textTimelineGetPaidStatusAwait)) { return $textTimelineGetPaidStatusAwait; } $translation = $this->getTextFromConfig($type, 'timeline_get_paid_status_await', 'messages.status.paid.await'); if (!empty($translation)) { return $translation; } return 'invoices.messages.status.paid.await'; } protected function getTextTimelineGetPaidStatusPartiallyPaid($type, $textTimelineGetPaidStatusPartiallyPaid) { if (!empty($textTimelineGetPaidStatusPartiallyPaid)) { return $textTimelineGetPaidStatusPartiallyPaid; } $translation = $this->getTextFromConfig($type, 'timeline_get_paid_status_partially_paid', 'partially_paid'); if (!empty($translation)) { return $translation; } return 'general.partially_paid'; } protected function getTextTimelineGetPaidMarkPaid($type, $textTimelineGetPaidMarkPaid) { if (!empty($textTimelineGetPaidMarkPaid)) { return $textTimelineGetPaidMarkPaid; } $translation = $this->getTextFromConfig($type, 'timeline_get_paid_mark_paid', 'mark_paid'); if (!empty($translation)) { return $translation; } return 'invoices.mark_paid'; } protected function getTextTimelineGetPaidAddPayment($type, $textTimelineGetPaidAddPayment) { if (!empty($textTimelineGetPaidAddPayment)) { return $textTimelineGetPaidAddPayment; } $translation = $this->getTextFromConfig($type, 'timeline_get_paid_add_payment', 'add_payment'); if (!empty($translation)) { return $translation; } return 'invoices.add_payment'; } protected function getHideItems($type, $hideItems, $hideName, $hideDescription) { if (!empty($hideItems)) { return $hideItems; } $hide = $this->getHideFromConfig($type, 'items'); if ($hide) { return $hide; } $hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false; return $hideItems; } protected function getHideName($type, $hideName) { if (!empty($hideName)) { return $hideName; } // if you use settting translation if ($hideName = setting($type . '.hide_item_name', false)) { return $hideName; } $hide = $this->getHideFromConfig($type, 'name'); if ($hide) { return $hide; } // @todo what return value invoice or always false?? return setting('invoice.hide_item_name', $hideName); } protected function getHideDescription($type, $hideDescription) { if (!empty($hideDescription)) { return $hideDescription; } // if you use settting translation if ($hideDescription = setting($type . '.hide_item_description', false)) { return $hideDescription; } $hide = $this->getHideFromConfig($type, 'description'); if ($hide) { return $hide; } // @todo what return value invoice or always false?? return setting('invoice.hide_item_description', $hideDescription); } protected function getHideQuantity($type, $hideQuantity) { if (!empty($hideQuantity)) { return $hideQuantity; } // if you use settting translation if ($hideQuantity = setting($type . '.hide_quantity', false)) { return $hideQuantity; } $hide = $this->getHideFromConfig($type, 'quantity'); if ($hide) { return $hide; } // @todo what return value invoice or always false?? return setting('invoice.hide_quantity', $hideQuantity); } protected function getHidePrice($type, $hidePrice) { if (!empty($hidePrice)) { return $hidePrice; } // if you use settting translation if ($hidePrice = setting($type . '.hide_price', false)) { return $hidePrice; } $hide = $this->getHideFromConfig($type, 'price'); if ($hide) { return $hide; } // @todo what return value invoice or always false?? return setting('invoice.hide_price', $hidePrice); } protected function getHideDiscount($type, $hideDiscount) { if (!empty($hideDiscount)) { return $hideDiscount; } // if you use settting translation if ($hideDiscount = setting($type . '.hide_discount', false)) { return $hideDiscount; } $hide = $this->getHideFromConfig($type, 'discount'); if ($hide) { return $hide; } // @todo what return value invoice or always false?? return setting('invoice.hide_discount', $hideDiscount); } protected function getHideAmount($type, $hideAmount) { if (!empty($hideAmount)) { return $hideAmount; } // if you use settting translation if ($hideAmount = setting($type . '.hide_amount', false)) { return $hideAmount; } $hide = $this->getHideFromConfig($type, 'amount'); if ($hide) { return $hide; } // @todo what return value invoice or always false?? return setting('invoice.hide_amount', $hideAmount); } }