1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00

Merge pull request #5197 from turbo124/v5-stable

v5.1.29
This commit is contained in:
David Bomba 2021-03-21 09:34:15 +11:00 committed by GitHub
commit 4b2c8318c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 136 additions and 28 deletions

View File

@ -1 +1 @@
5.1.28 5.1.29

View File

@ -51,7 +51,7 @@ class InvoiceItem
public $custom_value4 = ''; 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 = [ public static $casts = [
'type_id' => 'string', 'type_id' => 'string',

View File

@ -21,9 +21,9 @@ use Illuminate\Http\Request;
class ConnectedAccountController extends BaseController 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() public function __construct()
{ {

View File

@ -241,7 +241,7 @@ class BaseDriver extends AbstractPaymentDriver
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); 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(); return $payment->service()->applyNumber()->save();
} }

View File

@ -56,7 +56,7 @@ class BillingSubscriptionService
{ {
$invoice_repo = new InvoiceRepository(); $invoice_repo = new InvoiceRepository();
$data['line_items'] = $this->createLineItems($data['quantity']); $data['line_items'] = $this->createLineItems($data);
/* /*
If trial_enabled -> return early If trial_enabled -> return early
@ -74,27 +74,74 @@ class BillingSubscriptionService
} }
private function createLineItems($quantity): array private function createLineItems($data): array
{ {
$line_items = []; $line_items = [];
$product = $this->billing_subscription->product; $product = $this->billing_subscription->product;
$item = new InvoiceItem; $item = new InvoiceItem;
$item->quantity = $quantity; $item->quantity = $data['quantity'];
$item->product_key = $product->product_key; $item->product_key = $product->product_key;
$item->notes = $product->notes; $item->notes = $product->notes;
$item->cost = $product->price; $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 //$item->type_id need to switch whether the subscription is a service or product
$line_items[] = $item; $line_items[] = $item;
//do we have a promocode? enter this as a line item. //do we have a promocode? enter this as a line item.
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; return $line_items;
} }
private function createPromoLine($data)
{
$product = $this->billing_subscription->product;
$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 = $discounted_amount;
$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() private function convertInvoiceToRecurring()
{ {
//The first invoice is a plain invoice - the second is fired on the recurring schedule. //The first invoice is a plain invoice - the second is fired on the recurring schedule.

View File

@ -34,7 +34,7 @@ trait UserNotifies
array_push($required_permissions, 'all_user_notifications'); 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'); array_push($notifiable_methods, 'mail');
} }

View File

@ -13,7 +13,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true), 'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', ''), 'app_domain' => env('APP_DOMAIN', ''),
'app_version' => '5.1.28', 'app_version' => '5.1.29',
'minimum_client_version' => '5.0.16', 'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1', 'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false), 'api_secret' => env('API_SECRET', false),

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddInvoiceIdToClientSubscriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
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');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}

View File

@ -1976,7 +1976,7 @@ $LANG = array(
'require_invoice_signature_help' => 'Require client to provide their signature.', 'require_invoice_signature_help' => 'Require client to provide their signature.',
'require_quote_signature' => 'Quote Signature', 'require_quote_signature' => 'Quote Signature',
'require_quote_signature_help' => 'Require client to provide their 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:', 'sign_here' => 'Please sign here:',
'authorization' => 'Authorization', 'authorization' => 'Authorization',
'signed' => 'Signed', 'signed' => 'Signed',
@ -3449,10 +3449,10 @@ $LANG = array(
'client_country' => 'Client Country', 'client_country' => 'Client Country',
'client_is_active' => 'Client is Active', 'client_is_active' => 'Client is Active',
'client_balance' => 'Client Balance', 'client_balance' => 'Client Balance',
'client_address1' => 'Client Address 1', 'client_address1' => 'Client Street',
'client_address2' => 'Client Address 2', 'client_address2' => 'Client Apt/Suite',
'client_shipping_address1' => 'Client Shipping Address 1', 'client_shipping_address1' => 'Client Shipping Street',
'client_shipping_address2' => 'Client Shipping Address 2', 'client_shipping_address2' => 'Client Shipping Apt/Suite',
'tax_rate1' => 'Tax Rate 1', 'tax_rate1' => 'Tax Rate 1',
'tax_rate2' => 'Tax Rate 2', 'tax_rate2' => 'Tax Rate 2',
'tax_rate3' => 'Tax Rate 3', 'tax_rate3' => 'Tax Rate 3',
@ -3532,8 +3532,8 @@ $LANG = array(
'marked_credit_as_sent' => 'Successfully marked credit as sent', 'marked_credit_as_sent' => 'Successfully marked credit as sent',
'email_subject_payment_partial' => 'Email Partial Payment Subject', 'email_subject_payment_partial' => 'Email Partial Payment Subject',
'is_approved' => 'Is Approved', '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.', '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: <a href="https://invoiceninja.github.io/cross-site-migration.html">https://invoiceninja.github.io/cross-site-migration.html</a>', 'cross_migration_message' => 'Cross account migration is not allowed. Please read more about it here: <a href="https://invoiceninja.github.io/docs/migration/#troubleshooting">https://invoiceninja.github.io/docs/migration/#troubleshooting</a>',
'email_credit' => 'Email Credit', 'email_credit' => 'Email Credit',
'client_email_not_set' => 'Client does not have an email address set', 'client_email_not_set' => 'Client does not have an email address set',
'ledger' => 'Ledger', 'ledger' => 'Ledger',
@ -3912,7 +3912,7 @@ $LANG = array(
'show' => 'Show', 'show' => 'Show',
'empty_columns' => 'Empty Columns', 'empty_columns' => 'Empty Columns',
'project_name' => 'Project Name', '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', 'this_quarter' => 'This Quarter',
'to_update_run' => 'To update run', 'to_update_run' => 'To update run',
'registration_url' => 'Registration URL', 'registration_url' => 'Registration URL',
@ -3968,8 +3968,8 @@ $LANG = array(
'list_of_recurring_invoices' => 'List of recurring invoices', 'list_of_recurring_invoices' => 'List of recurring invoices',
'details_of_recurring_invoice' => 'Here are some details about recurring invoice', 'details_of_recurring_invoice' => 'Here are some details about recurring invoice',
'cancellation' => 'Cancellation', 'cancellation' => 'Cancellation',
'about_cancellation' => 'In case you want to stop the recurring invoice, please click the request the cancellation.', '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. Your service may be cancelled with no further notification to you.', '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!', 'cancellation_pending' => 'Cancellation pending, we\'ll be in touch!',
'list_of_payments' => 'List of payments', 'list_of_payments' => 'List of payments',
'payment_details' => 'Details of the payment', 'payment_details' => 'Details of the payment',
@ -4135,19 +4135,26 @@ $LANG = array(
'payment_message_extended' => 'Thank you for your payment of :amount for :invoice', '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.', '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', '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', 'start_migration' => 'Start Migration',
'recurring_cancellation_request' => 'Request for recurring invoice cancellation from :contact', 'recurring_cancellation_request' => 'Request for recurring invoice cancellation from :contact',
'recurring_cancellation_request_body' => ':contact from Client :client requested to cancel Recurring Invoice :invoice', 'recurring_cancellation_request_body' => ':contact from Client :client requested to cancel Recurring Invoice :invoice',
'hello' => 'Hello', 'hello' => 'Hello',
'group_documents' => 'Group documents', 'group_documents' => 'Group documents',
'quote_approval_confirmation_label' => 'Are you sure you want to approve this quote?', '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', 'migration_select_company_label' => 'Select companies to migrate',
'force_migration' => 'Force migration', 'force_migration' => 'Force migration',
'require_password_with_social_login' => 'Require Password with Social Login', 'require_password_with_social_login' => 'Require Password with Social Login',
@ -4170,6 +4177,29 @@ $LANG = array(
'migration_auth_label' => 'Let\'s continue by authenticating.', 'migration_auth_label' => 'Let\'s continue by authenticating.',
'api_secret' => 'API secret', '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.', '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; return $LANG;