From 4761f8a1c92704b985efa4b2805047cd9ed1d392 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 17 Dec 2022 09:26:31 +1100 Subject: [PATCH 1/4] Flip sort order for payments in client portal --- app/Http/Livewire/PaymentsTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From 426d1c45fd037aa2c6b7b3f89b054d6b4c60658a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 17 Dec 2022 10:04:00 +1100 Subject: [PATCH 2/4] Filter by private notes --- app/Filters/InvoiceFilters.php | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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.'%'); } /** From 36c2d9447942c1b5b67ce177825f1d55e89ea7f2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 17 Dec 2022 12:07:32 +1100 Subject: [PATCH 3/4] Update precision of zimbab dally --- database/seeders/CurrenciesSeeder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' => '.'], From e6903984f4b1ccff699ed29d27099eb115e44208 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 18 Dec 2022 14:34:58 +1100 Subject: [PATCH 4/4] Code cleanup --- app/Http/Controllers/InvoiceController.php | 3 ++- app/Utils/Traits/MakesReminders.php | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) 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/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; }