diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 7b450eaacdf7..0980ed8507f3 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -493,7 +493,10 @@ class CompanySettings extends BaseSettings public $payment_email_all_contacts = false; + public $show_pdfhtml_on_mobile = true; + public static $casts = [ + 'show_pdfhtml_on_mobile' => 'bool', 'payment_email_all_contacts' => 'bool', 'statement_design_id' => 'string', 'delivery_note_design_id' => 'string', diff --git a/app/Livewire/PdfSlot.php b/app/Livewire/PdfSlot.php index b0a89d33877c..709b14940dca 100644 --- a/app/Livewire/PdfSlot.php +++ b/app/Livewire/PdfSlot.php @@ -57,6 +57,8 @@ class PdfSlot extends Component private $entity_calc; + public $html_entity_option = true; + public function mount() { MultiDB::setDb($this->db); @@ -128,7 +130,8 @@ class PdfSlot extends Component $this->entity_calc = $this->entity->calc(); $this->settings = $this->entity->client ? $this->entity->client->getMergedSettings() : $this->entity->company->settings; - + $this->html_entity_option = $this->entity->client ? $this->entity->client->getSetting('show_pdfhtml_on_mobile') : $this->entity->company->getSetting('show_pdfhtml_on_mobile'); + $this->show_cost = in_array('$product.unit_cost', $this->settings->pdf_variables->product_columns); $this->show_line_total = in_array('$product.line_total', $this->settings->pdf_variables->product_columns); $this->show_quantity = in_array('$product.quantity', $this->settings->pdf_variables->product_columns); diff --git a/app/Repositories/Migration/PaymentMigrationRepository.php b/app/Repositories/Migration/PaymentMigrationRepository.php index 72d98237fbb4..a15fa0cb4a63 100644 --- a/app/Repositories/Migration/PaymentMigrationRepository.php +++ b/app/Repositories/Migration/PaymentMigrationRepository.php @@ -100,8 +100,8 @@ class PaymentMigrationRepository extends BaseRepository $payment->deleted_at = $data['deleted_at'] ?: null; - if ($payment->currency_id == 0) { - $payment->currency_id = $payment->company->settings->currency_id; + if (!$payment->currency_id || $payment->currency_id == 0 || $payment->currency_id == '') { + $payment->currency_id = $payment->client->settings->currency_id ?? $payment->company->settings->currency_id; } /*Ensure payment number generated*/ diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 44eecbc6c016..fe0f2381259c 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -11,25 +11,29 @@ namespace App\Services\Client; +use App\Utils\Number; use App\Models\Client; use App\Models\Credit; use App\Models\Invoice; use App\Models\Payment; use App\Services\Email\Email; -use App\Services\Email\EmailObject; -use App\Utils\Number; use App\Utils\Traits\MakesDates; -use Illuminate\Mail\Mailables\Address; use Illuminate\Support\Facades\DB; +use App\Services\Email\EmailObject; +use App\Utils\Traits\GeneratesCounter; +use Illuminate\Mail\Mailables\Address; +use Illuminate\Database\QueryException; class ClientService { - use MakesDates; + use MakesDates, GeneratesCounter; private string $client_start_date; private string $client_end_date; + private bool $completed = true; + public function __construct(private Client $client) { } @@ -145,6 +149,31 @@ class ClientService return $this; } + public function applyNumber(): self + { + $x = 1; + + if(isset($this->client->number)) + return $this; + + do { + try { + $this->client->number = $this->getNextClientNumber($this->client); + $this->client->saveQuietly(); + + $this->completed = false; + } catch (QueryException $e) { + $x++; + + if ($x > 10) { + $this->completed = false; + } + } + } while ($this->completed); + + return $this; + } + public function updatePaymentBalance() { $amount = Payment::query()->where('client_id', $this->client->id) diff --git a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php index 22e7e792c85e..5159e3314c1e 100644 --- a/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/pdf-slot.blade.php @@ -21,7 +21,11 @@ @endif + @if($html_entity_option) + @endif +