From 7365de781fd7d1ad67a0810bfd42f5ec98a67d45 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 13 Oct 2023 21:35:22 +1100 Subject: [PATCH 1/6] fixes for static analysis --- app/Factory/ProductFactory.php | 2 +- app/Factory/ProjectFactory.php | 3 +-- app/Models/Design.php | 7 ++++--- app/Models/Expense.php | 20 ++++++++++---------- app/Models/Invoice.php | 2 +- app/Models/InvoiceInvitation.php | 4 ++-- app/Models/Product.php | 18 +++++++++--------- app/Models/Project.php | 6 +++--- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/Factory/ProductFactory.php b/app/Factory/ProductFactory.php index 08e5c5a2b9f6..2b6622df2125 100644 --- a/app/Factory/ProductFactory.php +++ b/app/Factory/ProductFactory.php @@ -34,7 +34,7 @@ class ProductFactory $product->custom_value2 = ''; $product->custom_value3 = ''; $product->custom_value4 = ''; - $product->is_deleted = 0; + $product->is_deleted = false; $product->tax_id = 1; return $product; diff --git a/app/Factory/ProjectFactory.php b/app/Factory/ProjectFactory.php index 0549b1104094..8e964457ef6d 100644 --- a/app/Factory/ProjectFactory.php +++ b/app/Factory/ProjectFactory.php @@ -20,7 +20,6 @@ class ProjectFactory $project = new Project; $project->company_id = $company_id; $project->user_id = $user_id; - $project->public_notes = ''; $project->private_notes = ''; $project->budgeted_hours = 0; @@ -30,7 +29,7 @@ class ProjectFactory $project->custom_value2 = ''; $project->custom_value3 = ''; $project->custom_value4 = ''; - $project->is_deleted = 0; + $project->is_deleted = false; return $project; } diff --git a/app/Models/Design.php b/app/Models/Design.php index fbb6915135c4..c93453ed9e48 100644 --- a/app/Models/Design.php +++ b/app/Models/Design.php @@ -20,10 +20,11 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $user_id * @property int|null $company_id * @property string $name - * @property int $is_custom - * @property int $is_active + * @property bool $is_custom + * @property bool $is_active * @property object|null $design - * @property int $is_deleted + * @property bool $is_deleted + * @property bool $is_template * @property int|null $created_at * @property int|null $updated_at * @property int|null $deleted_at diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 875fa14172bb..314e3961eb66 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -33,22 +33,22 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property int|null $payment_type_id * @property int|null $recurring_expense_id * @property bool $is_deleted - * @property string $amount - * @property string $foreign_amount + * @property float $amount + * @property float $foreign_amount * @property string $exchange_rate * @property string|null $tax_name1 - * @property string $tax_rate1 + * @property float $tax_rate1 * @property string|null $tax_name2 - * @property string $tax_rate2 + * @property float $tax_rate2 * @property string|null $tax_name3 - * @property string $tax_rate3 + * @property float $tax_rate3 * @property string|null $date * @property string|null $payment_date * @property string|null $private_notes * @property string|null $public_notes * @property string|null $transaction_reference - * @property int $should_be_invoiced - * @property int $invoice_documents + * @property bool $should_be_invoiced + * @property bool $invoice_documents * @property int|null $transaction_id * @property string|null $custom_value1 * @property string|null $custom_value2 @@ -56,9 +56,9 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property string|null $custom_value4 * @property string|null $number * @property int|null $project_id - * @property string $tax_amount1 - * @property string $tax_amount2 - * @property string $tax_amount3 + * @property float $tax_amount1 + * @property float $tax_amount2 + * @property float $tax_amount3 * @property int $uses_inclusive_taxes * @property int $calculate_tax_by_amount * @property-read \App\Models\User|null $assigned_user diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 6ad30e5c7c30..22e9093f2d18 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -54,7 +54,7 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough; * @property string|null $last_sent_date * @property string|null $due_date * @property bool $is_deleted - * @property object|array $line_items + * @property object|array|string $line_items * @property object|null $backup * @property string|null $footer * @property string|null $public_notes diff --git a/app/Models/InvoiceInvitation.php b/app/Models/InvoiceInvitation.php index 08513619b003..f8fb383db5dd 100644 --- a/app/Models/InvoiceInvitation.php +++ b/app/Models/InvoiceInvitation.php @@ -27,8 +27,8 @@ use Illuminate\Support\Facades\Storage; * @property int $id * @property int $company_id * @property int $user_id - * @property int $client_contact_id - * @property int $invoice_id + * @property int|null $client_contact_id + * @property int|null $invoice_id * @property string $key * @property string|null $transaction_reference * @property string|null $message_id diff --git a/app/Models/Product.php b/app/Models/Product.php index d07445e7f1b5..e4736a0f7ca7 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -30,21 +30,21 @@ use League\CommonMark\CommonMarkConverter; * @property string|null $custom_value4 * @property string|null $product_key * @property string|null $notes - * @property string $cost - * @property string $price - * @property string $quantity + * @property float $cost + * @property float $price + * @property float $quantity * @property string|null $tax_name1 - * @property string $tax_rate1 + * @property float $tax_rate1 * @property string|null $tax_name2 - * @property string $tax_rate2 + * @property float $tax_rate2 * @property string|null $tax_name3 - * @property string $tax_rate3 + * @property float $tax_rate3 * @property int|null $deleted_at * @property int|null $created_at * @property int|null $updated_at - * @property int $is_deleted - * @property int $in_stock_quantity - * @property int $stock_notification + * @property bool $is_deleted + * @property float $in_stock_quantity + * @property bool $stock_notification * @property int $stock_notification_threshold * @property int|null $max_quantity * @property string|null $product_image diff --git a/app/Models/Project.php b/app/Models/Project.php index c2d09f250a11..a256b3e74fac 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -15,10 +15,10 @@ use Laracasts\Presenter\PresentableTrait; * @property int $company_id * @property int|null $client_id * @property string $name - * @property string $task_rate + * @property float $task_rate * @property string|null $due_date * @property string|null $private_notes - * @property string $budgeted_hours + * @property float $budgeted_hours * @property string|null $custom_value1 * @property string|null $custom_value2 * @property string|null $custom_value3 @@ -27,7 +27,7 @@ use Laracasts\Presenter\PresentableTrait; * @property int|null $updated_at * @property int|null $deleted_at * @property string|null $public_notes - * @property int $is_deleted + * @property bool $is_deleted * @property string|null $number * @property string $color * @property-read \App\Models\Client|null $client From 9d20c9b2fb05079facc24759efaaec5a46542140 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 14 Oct 2023 08:31:17 +1100 Subject: [PATCH 2/6] Minor static analysis --- app/Models/PurchaseOrder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/PurchaseOrder.php b/app/Models/PurchaseOrder.php index cf4841147e6e..61f334b62c12 100644 --- a/app/Models/PurchaseOrder.php +++ b/app/Models/PurchaseOrder.php @@ -42,8 +42,8 @@ use Illuminate\Support\Facades\Storage; * @property string|null $date * @property string|null $last_sent_date * @property string|null $due_date - * @property int $is_deleted - * @property object|null $line_items + * @property bool $is_deleted + * @property object|array|string $line_items * @property object|null $backup * @property string|null $footer * @property string|null $public_notes From e682017cf4e32151659a45092ef9a3b8874a871e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 14 Oct 2023 08:33:27 +1100 Subject: [PATCH 3/6] Fixes for trials in subscriptions --- app/Services/Subscription/SubscriptionService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 64b13fa38db3..901b970f0bfb 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -230,9 +230,9 @@ class SubscriptionService - we then return the user to either a predefined user endpoint, OR we return the user to the recurring invoice page. */ public function startTrial(array $data) - { + {nlog($data); // Redirects from here work just fine. Livewire will respect it. - $client_contact = ClientContact::find($this->decodePrimaryKey($data['contact_id'])); + $client_contact = ClientContact::find($data['contact_id']); if (!$this->subscription->trial_enabled) { return new \Exception("Trials are disabled for this product"); From 9db0159b06b551f803ef684e8de40f65a03a59d5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 14 Oct 2023 08:34:34 +1100 Subject: [PATCH 4/6] Fixes for trials in subscriptions --- app/Http/Livewire/BillingPortalPurchase.php | 4 ++-- app/Services/Subscription/SubscriptionService.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index 74e693faa459..f8e625e03cf8 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -425,8 +425,8 @@ class BillingPortalPurchase extends Component return $this->subscription->service()->startTrial([ 'email' => $this->email ?? $this->contact->email, 'quantity' => $this->quantity, - 'contact_id' => $this->contact->id, - 'client_id' => $this->contact->client->id, + 'contact_id' => $this->contact->hashed_id, + 'client_id' => $this->contact->client->hashed_id, ]); } diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 901b970f0bfb..64b13fa38db3 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -230,9 +230,9 @@ class SubscriptionService - we then return the user to either a predefined user endpoint, OR we return the user to the recurring invoice page. */ public function startTrial(array $data) - {nlog($data); + { // Redirects from here work just fine. Livewire will respect it. - $client_contact = ClientContact::find($data['contact_id']); + $client_contact = ClientContact::find($this->decodePrimaryKey($data['contact_id'])); if (!$this->subscription->trial_enabled) { return new \Exception("Trials are disabled for this product"); From 373690789e79a06e3a859a4c8ff86dd2c9e7cc5c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 14 Oct 2023 08:42:09 +1100 Subject: [PATCH 5/6] Fixes for trials in subscriptions --- app/Services/Subscription/SubscriptionService.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 64b13fa38db3..3794273d82d4 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -234,6 +234,9 @@ class SubscriptionService // Redirects from here work just fine. Livewire will respect it. $client_contact = ClientContact::find($this->decodePrimaryKey($data['contact_id'])); + if(is_string($data['client_id'])) + $data['client_id'] = $this->decodePrimaryKey($data['client_id']); + if (!$this->subscription->trial_enabled) { return new \Exception("Trials are disabled for this product"); } @@ -256,7 +259,7 @@ class SubscriptionService if (array_key_exists('coupon', $data) && ($data['coupon'] == $this->subscription->promo_code) && $this->subscription->promo_discount > 0) { $recurring_invoice->discount = $this->subscription->promo_discount; $recurring_invoice->is_amount_discount = $this->subscription->is_amount_discount; - } elseif (strlen($this->subscription->promo_code) == 0 && $this->subscription->promo_discount > 0) { + } elseif (strlen($this->subscription->promo_code ?? '') == 0 && $this->subscription->promo_discount > 0) { $recurring_invoice->discount = $this->subscription->promo_discount; $recurring_invoice->is_amount_discount = $this->subscription->is_amount_discount; } From f919df6b1090fcead7772b34a854c2e31f67de4e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 14 Oct 2023 08:42:27 +1100 Subject: [PATCH 6/6] v5.7.30 --- VERSION.txt | 2 +- config/ninja.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index fcd2fd579853..25285daaef52 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.7.29 \ No newline at end of file +5.7.30 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index 5c38ee2e3562..7ef548ab7efa 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -15,8 +15,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => env('APP_VERSION','5.7.29'), - 'app_tag' => env('APP_TAG','5.7.29'), + 'app_version' => env('APP_VERSION','5.7.30'), + 'app_tag' => env('APP_TAG','5.7.30'), 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),