mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Client subscriptions + bug fixes (#5238)
* Fixes for converting quote to invoice * Fixes for naming PDFs * Refresh entity prior to sending * Fixes for subscriptions * Add in required use * Fixes for notifications * Fixes for notifications
This commit is contained in:
parent
442a93caab
commit
cb7f27462b
@ -574,7 +574,8 @@ class CompanySettings extends BaseSettings
|
||||
public static function notificationDefaults() :stdClass
|
||||
{
|
||||
$notification = new stdClass;
|
||||
$notification->email = ['all_notifications'];
|
||||
$notification->email = [];
|
||||
// $notification->email = ['all_notifications'];
|
||||
|
||||
return $notification;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ class EmailController extends BaseController
|
||||
|
||||
$entity_obj->service()->markSent()->save();
|
||||
|
||||
EmailEntity::dispatch($invitation, $invitation->company, $template, $data)
|
||||
EmailEntity::dispatch($invitation->fresh(), $invitation->company, $template, $data)
|
||||
->delay(now()->addSeconds(5));
|
||||
|
||||
}
|
||||
|
@ -795,6 +795,8 @@ class InvoiceController extends BaseController
|
||||
|
||||
$file_path = $invoice->service()->getInvoicePdf($contact);
|
||||
|
||||
nlog($file_path);
|
||||
|
||||
return response()->download($file_path, basename($file_path));
|
||||
}
|
||||
|
||||
|
@ -532,7 +532,7 @@ class QuoteController extends BaseController
|
||||
return response()->json(['message' => ctrans('texts.sent_message')], 200);
|
||||
}
|
||||
|
||||
if ($action == 'convert') {
|
||||
if ($action == 'convert' || $action == 'convert_to_invoice') {
|
||||
$this->entity_type = Quote::class;
|
||||
$this->entity_transformer = QuoteTransformer::class;
|
||||
|
||||
|
@ -54,7 +54,7 @@ class CreditEmailedNotification implements ShouldQueue
|
||||
|
||||
// $notification = new EntitySentNotification($event->invitation, 'credit');
|
||||
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'credit', ['all_notifications', 'credit_sent']);
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'credit', ['all_notifications', 'credit_sent', 'credit_sent_all']);
|
||||
|
||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
||||
unset($methods[$key]);
|
||||
|
@ -60,7 +60,7 @@ class InvoiceEmailedNotification implements ShouldQueue
|
||||
// $notification = new EntitySentNotification($event->invitation, 'invoice');
|
||||
|
||||
/* Returns an array of notification methods */
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent']);
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
|
||||
|
||||
/* If one of the methods is email then we fire the EntitySentMailer */
|
||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
||||
|
@ -56,7 +56,7 @@ class InvoiceFailedEmailNotification
|
||||
|
||||
// $notification = new EntitySentNotification($event->invitation, 'invoice');
|
||||
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent']);
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'invoice', ['all_notifications', 'invoice_sent', 'invoice_sent_all']);
|
||||
|
||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
||||
unset($methods[$key]);
|
||||
|
@ -55,7 +55,7 @@ class QuoteEmailedNotification implements ShouldQueue
|
||||
|
||||
// $notification = new EntitySentNotification($event->invitation, 'quote');
|
||||
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'quote', ['all_notifications', 'quote_sent']);
|
||||
$methods = $this->findUserNotificationTypes($event->invitation, $company_user, 'quote', ['all_notifications', 'quote_sent', 'quote_sent_all']);
|
||||
|
||||
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
|
||||
unset($methods[$key]);
|
||||
|
@ -191,7 +191,9 @@ class BaseModel extends Model
|
||||
|
||||
public function numberFormatter()
|
||||
{
|
||||
$formatted_number = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $this->number);
|
||||
$number = strlen($this->number) > 1 ? $this->number : class_basename($this);
|
||||
|
||||
$formatted_number = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $number);
|
||||
// Remove any runs of periods (thanks falstro!)
|
||||
$formatted_number = mb_ereg_replace("([\.]{2,})", '', $formatted_number);
|
||||
|
||||
|
@ -46,7 +46,7 @@ class BillingSubscriptionService
|
||||
public function completePurchase(PaymentHash $payment_hash)
|
||||
{
|
||||
|
||||
if (!property_exists($payment_hash, 'billing_context')) {
|
||||
if (!property_exists($payment_hash->data, 'billing_context')) {
|
||||
throw new \Exception("Illegal entrypoint into method, payload must contain billing context");
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ class BillingSubscriptionService
|
||||
$cs->subscription_id = $this->billing_subscription->id;
|
||||
$cs->company_id = $this->billing_subscription->company_id;
|
||||
$cs->trial_started = time();
|
||||
$cs->trial_duration = time() + $this->billing_subscription->trial_duration;
|
||||
$cs->trial_ends = time() + $this->billing_subscription->trial_duration;
|
||||
$cs->quantity = $data['quantity'];
|
||||
$cs->client_id = $contact->client->id;
|
||||
$cs->save();
|
||||
@ -192,6 +192,7 @@ class BillingSubscriptionService
|
||||
throw new \Exception("Could not match an invoice for payment of billing subscription");
|
||||
|
||||
//todo - need to remove the promo code - if it exists
|
||||
|
||||
return InvoiceToRecurringInvoiceFactory::create($invoice);
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ class BillingSubscriptionTransformer extends EntityTransformer
|
||||
|
||||
public function transform(BillingSubscription $billing_subscription): array
|
||||
{
|
||||
$std = new \stdClass;
|
||||
|
||||
return [
|
||||
'id' => $this->encodePrimaryKey($billing_subscription->id),
|
||||
'user_id' => $this->encodePrimaryKey($billing_subscription->user_id),
|
||||
@ -56,7 +58,7 @@ class BillingSubscriptionTransformer extends EntityTransformer
|
||||
'allow_plan_changes' => (bool)$billing_subscription->allow_plan_changes,
|
||||
'plan_map' => (string)$billing_subscription->plan_map,
|
||||
'refund_period' => (int)$billing_subscription->refund_period,
|
||||
'webhook_configuration' => (string)$billing_subscription->webhook_configuration,
|
||||
'webhook_configuration' => $billing_subscription->webhook_configuration ?: $std,
|
||||
'purchase_page' => (string)route('client.subscription.purchase', $billing_subscription->hashed_id),
|
||||
'is_deleted' => (bool)$billing_subscription->is_deleted,
|
||||
'created_at' => (int)$billing_subscription->created_at,
|
||||
|
@ -34,10 +34,12 @@ 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(['all_user_notifications'], $notifications->email)) >= 1 || count(array_intersect(['all_notifications'],$notifications->email)) >= 1) {
|
||||
array_push($notifiable_methods, 'mail');
|
||||
}
|
||||
|
||||
nlog($notifiable_methods);
|
||||
|
||||
// if(count(array_intersect($required_permissions, $notifications->slack)) >=1)
|
||||
// array_push($notifiable_methods, 'slack');
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddNullableConstraintToRecurringInvoiceId extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('client_subscriptions', function (Blueprint $table) {
|
||||
$table->unsignedInteger('recurring_invoice_id')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user