From e2314359b971d5d8ce5959daeb39fa375f701cd6 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 20 Mar 2021 11:54:47 +1100 Subject: [PATCH 1/7] Pass back the correct entity! --- app/Http/Controllers/ConnectedAccountController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ConnectedAccountController.php b/app/Http/Controllers/ConnectedAccountController.php index 9a6c07155d..03347318d6 100644 --- a/app/Http/Controllers/ConnectedAccountController.php +++ b/app/Http/Controllers/ConnectedAccountController.php @@ -21,9 +21,9 @@ use Illuminate\Http\Request; class ConnectedAccountController extends BaseController { - protected $entity_type = CompanyUser::class; + protected $entity_type = User::class; - protected $entity_transformer = CompanyUserTransformer::class; + protected $entity_transformer = UserTransformer::class; public function __construct() { From ba91c96c40dfbd85a355e6e85f0064e419e68c25 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 20 Mar 2021 13:49:45 +1100 Subject: [PATCH 2/7] update texts --- app/DataMapper/InvoiceItem.php | 2 +- .../BillingSubscriptionService.php | 24 ++++++- resources/lang/en/texts.php | 66 ++++++++++++++----- 3 files changed, 70 insertions(+), 22 deletions(-) diff --git a/app/DataMapper/InvoiceItem.php b/app/DataMapper/InvoiceItem.php index 974121958f..35328227bd 100644 --- a/app/DataMapper/InvoiceItem.php +++ b/app/DataMapper/InvoiceItem.php @@ -51,7 +51,7 @@ class InvoiceItem public $custom_value4 = ''; - public $type_id = '1'; //1 = product, 2 = service, 3 unpaid gateway fee, 4 paid gateway fee, 5 late fee + public $type_id = '1'; //1 = product, 2 = service, 3 unpaid gateway fee, 4 paid gateway fee, 5 late fee, 6 promo code public static $casts = [ 'type_id' => 'string', diff --git a/app/Services/BillingSubscription/BillingSubscriptionService.php b/app/Services/BillingSubscription/BillingSubscriptionService.php index 62eba98640..9d406b4b2d 100644 --- a/app/Services/BillingSubscription/BillingSubscriptionService.php +++ b/app/Services/BillingSubscription/BillingSubscriptionService.php @@ -56,7 +56,7 @@ class BillingSubscriptionService { $invoice_repo = new InvoiceRepository(); - $data['line_items'] = $this->createLineItems($data['quantity']); + $data['line_items'] = $this->createLineItems($data); /* If trial_enabled -> return early @@ -74,27 +74,45 @@ class BillingSubscriptionService } - private function createLineItems($quantity): array + private function createLineItems($data): array { $line_items = []; $product = $this->billing_subscription->product; $item = new InvoiceItem; - $item->quantity = $quantity; + $item->quantity = $data['quantity']; $item->product_key = $product->product_key; $item->notes = $product->notes; $item->cost = $product->price; + $item->tax_rate1 = $product->tax_rate1 ?: 0; + $item->tax_name1 = $product->tax_name1 ?: ''; + $item->tax_rate2 = $product->tax_rate2 ?: 0; + $item->tax_name2 = $product->tax_name2 ?: ''; + $item->tax_rate3 = $product->tax_rate3 ?: 0; + $item->tax_name3 = $product->tax_name3 ?: ''; + $item->custom_value1 = $product->custom_value1 ?: ''; + $item->custom_value2 = $product->custom_value2 ?: ''; + $item->custom_value3 = $product->custom_value3 ?: ''; + $item->custom_value4 = $product->custom_value4 ?: ''; + //$item->type_id need to switch whether the subscription is a service or product $line_items[] = $item; //do we have a promocode? enter this as a line item. + if(strlen($data['coupon']) >=1) + $line_items = $this->createPromoLine($data); return $line_items; } + private function createPromoLine($data) + { + $item = new InvoiceItem; + } + private function convertInvoiceToRecurring() { //The first invoice is a plain invoice - the second is fired on the recurring schedule. diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 427445d983..06a296e094 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1976,7 +1976,7 @@ $LANG = array( 'require_invoice_signature_help' => 'Require client to provide their signature.', 'require_quote_signature' => 'Quote Signature', 'require_quote_signature_help' => 'Require client to provide their signature.', - 'i_agree' => 'I Agree To', + 'i_agree' => 'I Agree To The Terms', 'sign_here' => 'Please sign here:', 'authorization' => 'Authorization', 'signed' => 'Signed', @@ -3449,10 +3449,10 @@ $LANG = array( 'client_country' => 'Client Country', 'client_is_active' => 'Client is Active', 'client_balance' => 'Client Balance', - 'client_address1' => 'Client Address 1', - 'client_address2' => 'Client Address 2', - 'client_shipping_address1' => 'Client Shipping Address 1', - 'client_shipping_address2' => 'Client Shipping Address 2', + 'client_address1' => 'Client Street', + 'client_address2' => 'Client Apt/Suite', + 'client_shipping_address1' => 'Client Shipping Street', + 'client_shipping_address2' => 'Client Shipping Apt/Suite', 'tax_rate1' => 'Tax Rate 1', 'tax_rate2' => 'Tax Rate 2', 'tax_rate3' => 'Tax Rate 3', @@ -3532,8 +3532,8 @@ $LANG = array( 'marked_credit_as_sent' => 'Successfully marked credit as sent', 'email_subject_payment_partial' => 'Email Partial Payment Subject', 'is_approved' => 'Is Approved', - 'migration_went_wrong' => 'Oops, something went wrong! Make sure you did proper setup with V2 of Invoice Ninja, before starting migration.', - 'cross_migration_message' => 'Cross account migration is not allowed. Please read more about it here: https://invoiceninja.github.io/cross-site-migration.html', + 'migration_went_wrong' => 'Oops, something went wrong! Please make sure you have setup an Invoice Ninja v5 instance before starting the migration.', + 'cross_migration_message' => 'Cross account migration is not allowed. Please read more about it here: https://invoiceninja.github.io/docs/migration/#troubleshooting', 'email_credit' => 'Email Credit', 'client_email_not_set' => 'Client does not have an email address set', 'ledger' => 'Ledger', @@ -3912,7 +3912,7 @@ $LANG = array( 'show' => 'Show', 'empty_columns' => 'Empty Columns', 'project_name' => 'Project Name', - 'counter_pattern_error' => 'To use :client_counter please add either :number or :id_number to prevent conflicts', + 'counter_pattern_error' => 'To use :client_counter please add either :client_number or :client_id_number to prevent conflicts', 'this_quarter' => 'This Quarter', 'to_update_run' => 'To update run', 'registration_url' => 'Registration URL', @@ -3968,8 +3968,8 @@ $LANG = array( 'list_of_recurring_invoices' => 'List of recurring invoices', 'details_of_recurring_invoice' => 'Here are some details about recurring invoice', 'cancellation' => 'Cancellation', - 'about_cancellation' => 'In case you want to stop the recurring invoice, please click the request the cancellation.', - 'cancellation_warning' => 'Warning! You are requesting a cancellation of this service. Your service may be cancelled with no further notification to you.', + 'about_cancellation' => 'In case you want to stop the recurring invoice,\n please click the request the cancellation.', + 'cancellation_warning' => 'Warning! You are requesting a cancellation of this service.\n Your service may be cancelled with no further notification to you.', 'cancellation_pending' => 'Cancellation pending, we\'ll be in touch!', 'list_of_payments' => 'List of payments', 'payment_details' => 'Details of the payment', @@ -4135,19 +4135,26 @@ $LANG = array( 'payment_message_extended' => 'Thank you for your payment of :amount for :invoice', 'online_payments_minimum_note' => 'Note: Online payments are supported only if amount is bigger than $1 or currency equivalent.', 'payment_token_not_found' => 'Payment token not found, please try again. If an issue still persist, try with another payment method', - - ///////////////////////////////////////////////// + 'vendor_address1' => 'Vendor Street', + 'vendor_address2' => 'Vendor Apt/Suite', + 'partially_unapplied' => 'Partially Unapplied', + 'select_a_gmail_user' => 'Please select a user authenticated with Gmail', + 'list_long_press' => 'List Long Press', + 'show_actions' => 'Show Actions', + 'start_multiselect' => 'Start Multiselect', + 'email_sent_to_confirm_email' => 'An email has been sent to confirm the email address', + 'converted_paid_to_date' => 'Converted Paid to Date', + 'converted_credit_balance' => 'Converted Credit Balance', + 'converted_total' => 'Converted Total', + 'reply_to_name' => 'Reply-To Name', + 'payment_status_-2' => 'Partially Unapplied', + 'color_theme' => 'Color Theme', 'start_migration' => 'Start Migration', 'recurring_cancellation_request' => 'Request for recurring invoice cancellation from :contact', 'recurring_cancellation_request_body' => ':contact from Client :client requested to cancel Recurring Invoice :invoice', 'hello' => 'Hello', 'group_documents' => 'Group documents', 'quote_approval_confirmation_label' => 'Are you sure you want to approve this quote?', - - 'click_agree_to_accept_terms' => 'Click "Agree" to Accept Terms.', - 'agree' => 'Agree', - - 'pending_approval' => 'Pending Approval', 'migration_select_company_label' => 'Select companies to migrate', 'force_migration' => 'Force migration', 'require_password_with_social_login' => 'Require Password with Social Login', @@ -4160,7 +4167,7 @@ $LANG = array( 'security_settings' => 'Security Settings', 'resend_email' => 'Resend Email', 'confirm_your_email_address' => 'Please confirm your email address', - 'freshbooks' => 'FreshBooks', + 'freshbooks' => 'FreshBooks', 'invoice2go' => 'Invoice2go', 'invoicely' => 'Invoicely', 'waveaccounting' => 'Wave Accounting', @@ -4170,6 +4177,29 @@ $LANG = array( 'migration_auth_label' => 'Let\'s continue by authenticating.', 'api_secret' => 'API secret', 'migration_api_secret_notice' => 'You can find API_SECRET in the .env file or Invoice Ninja v5. If property is missing, leave field blank.', + 'use_last_email' => 'Use last email', + 'activate_company' => 'Activate Company', + 'activate_company_help' => 'Enable emails, recurring invoices and notifications', + 'an_error_occurred_try_again' => 'An error occurred, please try again', + 'please_first_set_a_password' => 'Please first set a password', + 'changing_phone_disables_two_factor' => 'Warning: Changing your phone number will disable 2FA', + 'help_translate' => 'Help Translate', + 'please_select_a_country' => 'Please select a country', + 'disabled_two_factor' => 'Successfully disabled 2FA', + 'connected_google' => 'Successfully connected account', + 'disconnected_google' => 'Successfully disconnected account', + 'delivered' => 'Delivered', + 'spam' => 'Spam', + 'view_docs' => 'View Docs', + 'enter_phone_to_enable_two_factor' => 'Please provide a mobile phone number to enable two factor authentication', + 'send_sms' => 'Send SMS', + 'sms_code' => 'SMS Code', + 'connect_google' => 'Connect Google', + 'disconnect_google' => 'Disconnect Google', + 'disable_two_factor' => 'Disable Two Factor', + 'invoice_task_datelog' => 'Invoice Task Datelog', + 'invoice_task_datelog_help' => 'Add date details to the invoice line items', + 'promo_code' => 'Promo code', ); return $LANG; From 6be79ad0225336f57db1b65ee5ca9b9afd155f4d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 20 Mar 2021 13:57:03 +1100 Subject: [PATCH 3/7] Billing Subs --- .../BillingSubscriptionService.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Services/BillingSubscription/BillingSubscriptionService.php b/app/Services/BillingSubscription/BillingSubscriptionService.php index 9d406b4b2d..1ce2b296b6 100644 --- a/app/Services/BillingSubscription/BillingSubscriptionService.php +++ b/app/Services/BillingSubscription/BillingSubscriptionService.php @@ -103,14 +103,32 @@ class BillingSubscriptionService //do we have a promocode? enter this as a line item. if(strlen($data['coupon']) >=1) - $line_items = $this->createPromoLine($data); + $line_items[] = $this->createPromoLine($data); return $line_items; } private function createPromoLine($data) { + + $product = $this->billing_subscription->product; + + $price = 0; + $item = new InvoiceItem; + $item->quantity = 1; + $item->product_key = ctrans('texts.promo_code'); + $item->notes = ctrans('texts.promo_code'); + $item->cost = $price; + $item->tax_rate1 = $product->tax_rate1 ?: 0; + $item->tax_name1 = $product->tax_name1 ?: ''; + $item->tax_rate2 = $product->tax_rate2 ?: 0; + $item->tax_name2 = $product->tax_name2 ?: ''; + $item->tax_rate3 = $product->tax_rate3 ?: 0; + $item->tax_name3 = $product->tax_name3 ?: ''; + + return $item; + } private function convertInvoiceToRecurring() From 2eb7de95adaa1e4a77326c2047bf7aa6ca33d1f4 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 20 Mar 2021 14:39:30 +1100 Subject: [PATCH 4/7] Add invoie_id to client subs --- .../BillingSubscriptionService.php | 17 ++++++++-- ...voice_id_to_client_subscriptions_table.php | 31 +++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2021_03_20_033751_add_invoice_id_to_client_subscriptions_table.php diff --git a/app/Services/BillingSubscription/BillingSubscriptionService.php b/app/Services/BillingSubscription/BillingSubscriptionService.php index 1ce2b296b6..0043e028e5 100644 --- a/app/Services/BillingSubscription/BillingSubscriptionService.php +++ b/app/Services/BillingSubscription/BillingSubscriptionService.php @@ -102,7 +102,7 @@ class BillingSubscriptionService //do we have a promocode? enter this as a line item. - if(strlen($data['coupon']) >=1) + if(strlen($data['coupon']) >=1 && ($data['coupon'] == $this->billing_subscription->promo_code) && $this->billing_subscription->promo_discount > 0) $line_items[] = $this->createPromoLine($data); return $line_items; @@ -113,13 +113,24 @@ class BillingSubscriptionService $product = $this->billing_subscription->product; - $price = 0; + $discounted_amount = 0; + $discount = 0; + $amount = $data['quantity'] * $product->cost; + if ($this->billing_subscription->is_amount_discount == true) { + $discount = $this->billing_subscription->promo_discount; + } + else { + $discount = round($amount * ($this->billing_subscription->promo_discount / 100), 2); + } + + $discounted_amount = $amount - $discount; + $item = new InvoiceItem; $item->quantity = 1; $item->product_key = ctrans('texts.promo_code'); $item->notes = ctrans('texts.promo_code'); - $item->cost = $price; + $item->cost = $discounted_amount; $item->tax_rate1 = $product->tax_rate1 ?: 0; $item->tax_name1 = $product->tax_name1 ?: ''; $item->tax_rate2 = $product->tax_rate2 ?: 0; diff --git a/database/migrations/2021_03_20_033751_add_invoice_id_to_client_subscriptions_table.php b/database/migrations/2021_03_20_033751_add_invoice_id_to_client_subscriptions_table.php new file mode 100644 index 0000000000..18e1e7241a --- /dev/null +++ b/database/migrations/2021_03_20_033751_add_invoice_id_to_client_subscriptions_table.php @@ -0,0 +1,31 @@ +unsignedInteger('invoice_id')->nullable(); + + $table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade')->onUpdate('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + } +} From 36ffeb93448cb78010f1223663409d7fb67d8b32 Mon Sep 17 00:00:00 2001 From: = Date: Sun, 21 Mar 2021 08:53:33 +1100 Subject: [PATCH 5/7] bug fixes --- app/PaymentDrivers/BaseDriver.php | 2 +- ...3_20_033751_add_invoice_id_to_client_subscriptions_table.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 03ef21bb33..afba9ba52f 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -241,7 +241,7 @@ class BaseDriver extends AbstractPaymentDriver event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); - (new BillingSubscriptionService)->completePurchase($this->payment_hash); + //(new BillingSubscriptionService)->completePurchase($this->payment_hash); return $payment->service()->applyNumber()->save(); } diff --git a/database/migrations/2021_03_20_033751_add_invoice_id_to_client_subscriptions_table.php b/database/migrations/2021_03_20_033751_add_invoice_id_to_client_subscriptions_table.php index 18e1e7241a..1bf3e9c397 100644 --- a/database/migrations/2021_03_20_033751_add_invoice_id_to_client_subscriptions_table.php +++ b/database/migrations/2021_03_20_033751_add_invoice_id_to_client_subscriptions_table.php @@ -15,7 +15,7 @@ class AddInvoiceIdToClientSubscriptionsTable extends Migration { Schema::table('client_subscriptions', function (Blueprint $table) { $table->unsignedInteger('invoice_id')->nullable(); - + $table->unsignedInteger('quantity')->default(1); $table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade')->onUpdate('cascade'); }); } From 5b290b177049284e6d1f59b4792c16b8d6ecc095 Mon Sep 17 00:00:00 2001 From: = Date: Sun, 21 Mar 2021 08:57:11 +1100 Subject: [PATCH 6/7] Small fix for usernotifies --- app/Utils/Traits/Notifications/UserNotifies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Utils/Traits/Notifications/UserNotifies.php b/app/Utils/Traits/Notifications/UserNotifies.php index 4620c29cda..91455c16ea 100644 --- a/app/Utils/Traits/Notifications/UserNotifies.php +++ b/app/Utils/Traits/Notifications/UserNotifies.php @@ -34,7 +34,7 @@ trait UserNotifies array_push($required_permissions, 'all_user_notifications'); } - if (count(array_intersect($required_permissions, $notifications->email)) >= 1 || count(array_intersect($required_permissions, ['all_user_notifications'])) >= 1 || count(array_intersect($required_permissions, 'all_notifications')) >= 1) { + if (count(array_intersect($required_permissions, $notifications->email)) >= 1 || count(array_intersect($required_permissions, ['all_user_notifications'])) >= 1 || count(array_intersect($required_permissions, ['all_notifications'])) >= 1) { array_push($notifiable_methods, 'mail'); } From 53c606e744728ca5f1403e64eb13df3fba69f179 Mon Sep 17 00:00:00 2001 From: = Date: Sun, 21 Mar 2021 09:33:09 +1100 Subject: [PATCH 7/7] v5.1.29 --- VERSION.txt | 2 +- config/ninja.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 34a36e75f9..6935e0e042 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.1.28 \ No newline at end of file +5.1.29 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index b8955bfe31..a5109ce774 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -13,7 +13,7 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', ''), - 'app_version' => '5.1.28', + 'app_version' => '5.1.29', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', false),