diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index d2c5c82aef..410da19872 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -16,6 +16,8 @@ use App\Models\User; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Carbon; +use InvalidArgumentException; +use RuntimeException; /** * InvoiceFilters. @@ -136,6 +138,10 @@ class InvoiceFilters extends QueryFilters }); } + /** + * @return Builder + * @throws RuntimeException + */ public function without_deleted_clients() { @@ -144,6 +150,10 @@ class InvoiceFilters extends QueryFilters }); } + /** + * @return Builder + * @throws InvalidArgumentException + */ public function upcoming() { return $this->builder @@ -154,6 +164,10 @@ class InvoiceFilters extends QueryFilters ->orderBy('due_date', 'ASC'); } + /** + * @return void + * @throws InvalidArgumentException + */ public function overdue() { $this->builder->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) @@ -165,6 +179,11 @@ class InvoiceFilters extends QueryFilters ->orderBy('due_date', 'ASC'); } + /** + * @param string $client_id + * @return Builder + * @throws InvalidArgumentException + */ public function payable(string $client_id = '') { if (strlen($client_id) == 0) { @@ -222,8 +241,20 @@ class InvoiceFilters extends QueryFilters } else { return $this->builder->company()->with(['invitations.company'], ['documents.company']); } + } -// return $this->builder->whereCompanyId(auth()->user()->company()->id); + /** + * @param string $filter + * @return Builder + * @throws InvalidArgumentException + */ + public function private_notes($filter = '') :Builder + { + if (strlen($filter) == 0) { + return $this->builder; + } + + return $this->builder->where('private_notes', 'LIKE', '%'.$filter.'%'); } /** diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 39e807126e..88b6bb04cd 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -781,7 +781,8 @@ class InvoiceController extends BaseController case 'email': //check query parameter for email_type and set the template else use calculateTemplate - if (request()->has('email_type') && in_array(request()->input('email_type'), ['reminder1', 'reminder2', 'reminder3', 'reminder_endless', 'custom1', 'custom2', 'custom3'])) { + // if (request()->has('email_type') && in_array(request()->input('email_type'), ['reminder1', 'reminder2', 'reminder3', 'reminder_endless', 'custom1', 'custom2', 'custom3'])) { + if (request()->has('email_type') && property_exists($invoice->company->settings, request()->input('email_type'))) { $this->reminder_template = $invoice->client->getSetting(request()->input('email_type')); } else { $this->reminder_template = $invoice->calculateTemplate('invoice'); diff --git a/app/Http/Livewire/PaymentsTable.php b/app/Http/Livewire/PaymentsTable.php index 716efb7872..208f3cc549 100644 --- a/app/Http/Livewire/PaymentsTable.php +++ b/app/Http/Livewire/PaymentsTable.php @@ -43,7 +43,7 @@ class PaymentsTable extends Component ->where('company_id', $this->company->id) ->where('client_id', auth()->guard('contact')->user()->client_id) ->whereIn('status_id', [Payment::STATUS_FAILED, Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_REFUNDED, Payment::STATUS_PARTIALLY_REFUNDED]) - ->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc') + ->orderBy($this->sort_field, $this->sort_asc ? 'desc' : 'asc') ->withTrashed() ->paginate($this->per_page); diff --git a/app/Utils/Traits/MakesReminders.php b/app/Utils/Traits/MakesReminders.php index eabecca327..7ffa392048 100644 --- a/app/Utils/Traits/MakesReminders.php +++ b/app/Utils/Traits/MakesReminders.php @@ -77,10 +77,6 @@ trait MakesReminders private function checkEndlessReminder($last_sent_date, $endless_reminder_frequency_id) :bool { - // nlog("endless date match = ".$this->addTimeInterval($last_sent_date, $endless_reminder_frequency_id)); - // nlog("Endless reminder bool = "); - // nlog(Carbon::now()->startOfDay()->eq($this->addTimeInterval($last_sent_date, $endless_reminder_frequency_id))); - if (Carbon::now()->startOfDay()->eq($this->addTimeInterval($last_sent_date, $endless_reminder_frequency_id))) { return true; } diff --git a/database/seeders/CurrenciesSeeder.php b/database/seeders/CurrenciesSeeder.php index 16bb51897b..71a482d726 100644 --- a/database/seeders/CurrenciesSeeder.php +++ b/database/seeders/CurrenciesSeeder.php @@ -130,7 +130,7 @@ class CurrenciesSeeder extends Seeder ['id' => 105, 'name' => 'Gambia Dalasi', 'code' => 'GMD', 'symbol' => 'D', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 106, 'name' => 'Paraguayan Guarani', 'code' => 'PYG', 'symbol' => '₲', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 107, 'name' => 'Malawi Kwacha', 'code' => 'MWK', 'symbol' => 'MK', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['id' => 108, 'name' => 'Zimbabwean Dollar', 'code' => 'ZWL', 'symbol' => 'Z$', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['id' => 108, 'name' => 'Zimbabwean Dollar', 'code' => 'ZWL', 'symbol' => 'Z$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 109, 'name' => 'Cambodian Riel', 'code' => 'KHR', 'symbol' => '៛', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 110, 'name' => 'Vanuatu Vatu', 'code' => 'VUV', 'symbol' => 'VT', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 111, 'name' => 'Cuban Peso', 'code' => 'CUP', 'symbol' => '₱', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],