1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-17 16:42:48 +01:00

Merge branch 'v5-develop' into v5-stable

This commit is contained in:
David Bomba 2021-04-14 14:53:04 +10:00
commit 13c7c8d53a
149 changed files with 380859 additions and 373356 deletions

View File

@ -20,3 +20,4 @@ NINJA_ENVIRONMENT=hosted
COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
TRAVIS=true
API_SECRET=superdoopersecrethere
PHANTOMJS_PDF_GENERATION=false

View File

@ -3,7 +3,24 @@
## [Unreleased (daily channel)](https://github.com/invoiceninja/invoiceninja/tree/v5-develop)
### Added:
- Subscriptions are now going to show the frequency in the table (#5412)
- Subscriptions: During upgrade webhook request message will be shown for easier debugging (#5411)
- PDF: Custom fields now will be shared across invoices, quotes & credits (#5410)
- Client portal: Invoices are now sorted in the descending order (#5408)
- Payments: ACH notification after the initial bank account connecting process (#5405)
### Fixed:
- Fixes for counters where patterns without {$counter} could causes endless recursion.
- Fixes for surcharge tax displayed amount on PDF.
- Fixes for custom designs not rendering the custom template
- Fixes for missing bulk actions on Subscriptions
- Fixes CSS padding on the show page for recurring invoices (#5412)
- Fixes for rendering invalid HTML & parsing invalid XML (#5395)
### Removed:
- Removed one-time payments table (#5412)
## v5.1.43
### Fixed:
- Whitelabel regression.

View File

@ -1 +1 @@
5.1.43
5.1.45

View File

@ -14,8 +14,10 @@ namespace App\Console\Commands;
use App\DataMapper\CompanySettings;
use App\DataMapper\FeesAndLimits;
use App\Events\Invoice\InvoiceWasCreated;
use App\Factory\GroupSettingFactory;
use App\Factory\InvoiceFactory;
use App\Factory\InvoiceItemFactory;
use App\Factory\SubscriptionFactory;
use App\Helpers\Invoice\InvoiceSum;
use App\Jobs\Company\CreateCompanyTaskStatuses;
use App\Models\Account;
@ -30,6 +32,7 @@ use App\Models\Expense;
use App\Models\Product;
use App\Models\Project;
use App\Models\Quote;
use App\Models\RecurringInvoice;
use App\Models\Task;
use App\Models\User;
use App\Models\Vendor;
@ -201,6 +204,78 @@ class CreateSingleAccount extends Command
}
$this->createGateways($company, $user);
$this->createSubsData($company, $user);
}
private function createSubsData($company, $user)
{
$gs = GroupSettingFactory::create($company->id, $user->id);
$gs->name = "plans";
$gs->save();
$p1 = Product::factory()->create([
'user_id' => $user->id,
'company_id' => $company->id,
'product_key' => 'pro_plan',
'notes' => 'The Pro Plan',
'cost' => 10,
'price' => 10,
'quantity' => 1,
]);
$p2 = Product::factory()->create([
'user_id' => $user->id,
'company_id' => $company->id,
'product_key' => 'enterprise_plan',
'notes' => 'The Enterprise Plan',
'cost' => 10,
'price' => 10,
'quantity' => 1,
]);
$p3 = Product::factory()->create([
'user_id' => $user->id,
'company_id' => $company->id,
'product_key' => 'free_plan',
'notes' => 'The Free Plan',
'cost' => 0,
'price' => 0,
'quantity' => 1,
]);
$webhook_config = [
'post_purchase_url' => 'http://ninja.test:8000/api/admin/plan',
'post_purchase_rest_method' => 'POST',
'post_purchase_headers' => [],
];
$sub = SubscriptionFactory::create($company->id, $user->id);
$sub->name = "Pro Plan";
$sub->group_id = $gs->id;
$sub->recurring_product_ids = "{$p1->hashed_id}";
$sub->webhook_configuration = $webhook_config;
$sub->allow_plan_changes = true;
$sub->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
$sub->save();
$sub = SubscriptionFactory::create($company->id, $user->id);
$sub->name = "Enterprise Plan";
$sub->group_id = $gs->id;
$sub->recurring_product_ids = "{$p2->hashed_id}";
$sub->webhook_configuration = $webhook_config;
$sub->allow_plan_changes = true;
$sub->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
$sub->save();
$sub = SubscriptionFactory::create($company->id, $user->id);
$sub->name = "Free Plan";
$sub->group_id = $gs->id;
$sub->recurring_product_ids = "{$p3->hashed_id}";
$sub->webhook_configuration = $webhook_config;
$sub->allow_plan_changes = true;
$sub->frequency_id = RecurringInvoice::FREQUENCY_MONTHLY;
$sub->save();
}
private function createClient($company, $user)

View File

@ -0,0 +1,47 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Events\Subscription;
use App\Models\Company;
use App\Models\Subscription;
use Illuminate\Queue\SerializesModels;
/**
* Class SubscriptionWasArchived.
*/
class SubscriptionWasArchived
{
use SerializesModels;
/**
* @var Subscription
*/
public $subscription;
public $company;
public $event_vars;
/**
* Create a new event instance.
*
* @param Subscription $subscription
* @param Company $company
* @param array $event_vars
*/
public function __construct(Subscription $subscription, Company $company, array $event_vars)
{
$this->subscription = $subscription;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Events\Subscription;
use App\Models\Company;
use App\Models\Subscription;
use Illuminate\Queue\SerializesModels;
/**
* Class SubscriptionWasDeleted.
*/
class SubscriptionWasDeleted
{
use SerializesModels;
/**
* @var Subscription
*/
public $subscription;
public $company;
public $event_vars;
/**
* Create a new event instance.
*
* @param Subscription $subscription
* @param Company $company
* @param array $event_vars
*/
public function __construct(Subscription $subscription, Company $company, array $event_vars)
{
$this->subscription = $subscription;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Events\Subscription;
use App\Models\Company;
use App\Models\Subscription;
use Illuminate\Queue\SerializesModels;
/**
* Class SubscriptionWasRestored.
*/
class SubscriptionWasRestored
{
use SerializesModels;
/**
* @var Subscription
*/
public $subscription;
public $company;
public $event_vars;
public $fromDeleted;
/**
* Create a new event instance.
*
* @param Subscription $subscription
* @param Company $company
* @param array $event_vars
*/
public function __construct(Subscription $subscription, $fromDeleted, Company $company, array $event_vars)
{
$this->subscription = $subscription;
$this->fromDeleted = $fromDeleted;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Events\Subscription;
use App\Models\Company;
use App\Models\Subscription;
use Illuminate\Queue\SerializesModels;
/**
* Class SubscriptionWasUpdated.
*/
class SubscriptionWasUpdated
{
use SerializesModels;
/**
* @var Subscription
*/
public $subscription;
public $company;
public $event_vars;
/**
* Create a new event instance.
*
* @param Subscription $subscription
* @param Company $company
* @param array $event_vars
*/
public function __construct(Subscription $subscription, Company $company, array $event_vars)
{
$this->subscription = $subscription;
$this->company = $company;
$this->event_vars = $event_vars;
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Exceptions;
use Exception;
class FilePermissionsFailure extends Exception
{
// ..
}

View File

@ -11,6 +11,9 @@
namespace App\Exceptions;
use App\Exceptions\FilePermissionsFailure;
use App\Exceptions\InternalPDFFailure;
use App\Exceptions\PhantomPDFFailure;
use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException;
@ -94,7 +97,7 @@ class Handler extends ExceptionHandler
}
}
if(config('ninja.expanded_logging'))
// if(config('ninja.expanded_logging'))
parent::report($exception);
}
@ -134,6 +137,12 @@ class Handler extends ExceptionHandler
{
if ($exception instanceof ModelNotFoundException && $request->expectsJson()) {
return response()->json(['message'=>$exception->getMessage()], 400);
}elseif($exception instanceof InternalPDFFailure && $request->expectsJson()){
return response()->json(['message' => $exception->getMessage()], 500);
}elseif($exception instanceof PhantomPDFFailure && $request->expectsJson()){
return response()->json(['message' => $exception->getMessage()], 500);
}elseif($exception instanceof FilePermissionsFailure) {
return response()->json(['message' => $exception->getMessage()], 500);
} elseif ($exception instanceof ThrottleRequestsException && $request->expectsJson()) {
return response()->json(['message'=>'Too many requests'], 429);
} elseif ($exception instanceof FatalThrowableError && $request->expectsJson()) {
@ -152,8 +161,7 @@ class Handler extends ExceptionHandler
} elseif ($exception instanceof MethodNotAllowedHttpException && $request->expectsJson()) {
return response()->json(['message'=>'Method not support for this route'], 404);
} elseif ($exception instanceof ValidationException && $request->expectsJson()) {
info(print_r($exception->validator->getMessageBag(), 1));
nlog($exception->validator->getMessageBag());
return response()->json(['message' => 'The given data was invalid.', 'errors' => $exception->validator->getMessageBag()], 422);
} elseif ($exception instanceof RelationNotFoundException && $request->expectsJson()) {
return response()->json(['message' => $exception->getMessage()], 400);
@ -161,8 +169,6 @@ class Handler extends ExceptionHandler
return response()->json(['message' => $exception->getMessage()], 400);
} elseif ($exception instanceof GenericPaymentDriverFailure) {
$data['message'] = $exception->getMessage();
//dd($data);
// return view('errors.layout', $data);
}
return parent::render($request, $exception);

View File

@ -0,0 +1,10 @@
<?php
namespace App\Exceptions;
use Exception;
class InternalPDFFailure extends Exception
{
// ..
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Exceptions;
use Exception;
class PhantomPDFFailure extends Exception
{
// ..
}

View File

@ -11,17 +11,21 @@
namespace App\Factory;
use App\Models\Client;
use App\Models\GroupSetting;
class GroupSettingFactory
{
public static function create(int $company_id, int $user_id) :GroupSetting
{
$settings = new \stdClass;
$settings->entity = Client::class;
$gs = new GroupSetting;
$gs->name = '';
$gs->company_id = $company_id;
$gs->user_id = $user_id;
$gs->settings = '{}';
$gs->settings = $settings;
return $gs;
}

View File

@ -12,6 +12,7 @@
namespace App\Helpers\Invoice;
use App\Models\Invoice;
use App\Models\TaxRate;
use App\Utils\Traits\NumberFormatter;
use Illuminate\Support\Collection;
@ -90,16 +91,16 @@ class InvoiceSum
private function calculateCustomValues()
{
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge1, $this->invoice->custom_surcharge_tax1);
// $this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge1, $this->invoice->custom_surcharge_tax1);
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge1);
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge2, $this->invoice->custom_surcharge_tax2);
// $this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge2, $this->invoice->custom_surcharge_tax2);
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge2);
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge3, $this->invoice->custom_surcharge_tax3);
// $this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge3, $this->invoice->custom_surcharge_tax3);
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge3);
$this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge4, $this->invoice->custom_surcharge_tax4);
// $this->total_taxes += $this->valuerTax($this->invoice->custom_surcharge4, $this->invoice->custom_surcharge_tax4);
$this->total_custom_values += $this->valuer($this->invoice->custom_surcharge4);
$this->total += $this->total_custom_values;
@ -112,18 +113,24 @@ class InvoiceSum
if (strlen($this->invoice->tax_name1) > 1) {
$tax = $this->taxer($this->total, $this->invoice->tax_rate1);
$tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name1, $this->invoice->tax_rate1);
$this->total_taxes += $tax;
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.floatval($this->invoice->tax_rate1).'%', 'total' => $tax];
}
if (strlen($this->invoice->tax_name2) > 1) {
$tax = $this->taxer($this->total, $this->invoice->tax_rate2);
$tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name2, $this->invoice->tax_rate2);
$this->total_taxes += $tax;
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.floatval($this->invoice->tax_rate2).'%', 'total' => $tax];
}
if (strlen($this->invoice->tax_name3) > 1) {
$tax = $this->taxer($this->total, $this->invoice->tax_rate3);
$tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name3, $this->invoice->tax_rate3);
$this->total_taxes += $tax;
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.floatval($this->invoice->tax_rate3).'%', 'total' => $tax];
}
@ -300,6 +307,37 @@ class InvoiceSum
return $this;
}
private function getSurchargeTaxTotalForKey($key, $rate)
{
$tax_component = 0;
if($this->invoice->custom_surcharge_tax1)
{
$tax_component += round($this->invoice->custom_surcharge1 * ($rate / 100), 2);
}
if($this->invoice->custom_surcharge_tax2)
{
$tax_component += round($this->invoice->custom_surcharge2 * ($rate / 100), 2);
}
if($this->invoice->custom_surcharge_tax3)
{
$tax_component += round($this->invoice->custom_surcharge3 * ($rate / 100), 2);
}
if($this->invoice->custom_surcharge_tax4)
{
$tax_component += round($this->invoice->custom_surcharge4 * ($rate / 100), 2);
}
return $tax_component;
}
public function getTaxMap()
{
return $this->tax_map;

View File

@ -282,7 +282,7 @@ class ClientController extends BaseController
$this->uploadLogo($request->file('company_logo'), $client->company, $client);
event(new ClientWasUpdated($client, $client->company, Ninja::eventVars()));
event(new ClientWasUpdated($client, $client->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($client->fresh());
}
@ -380,7 +380,7 @@ class ClientController extends BaseController
$this->uploadLogo($request->file('company_logo'), $client->company, $client);
event(new ClientWasCreated($client, $client->company, Ninja::eventVars()));
event(new ClientWasCreated($client, $client->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($client);
}

View File

@ -89,29 +89,6 @@ class PaymentMethodController extends Controller
]);
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return void
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return void
*/
public function update(Request $request, $id)
{
//
}
public function verify(ClientGatewayToken $payment_method)
{
$gateway = $this->getClientGateway();
@ -148,7 +125,7 @@ class PaymentMethodController extends Controller
->detach($payment_method);
try {
event(new MethodDeleted($payment_method, auth('contact')->user()->company, Ninja::eventVars()));
event(new MethodDeleted($payment_method, auth('contact')->user()->company, Ninja::eventVars(auth('contact')->user()->id)));
$payment_method->delete();
} catch (Exception $e) {

View File

@ -14,8 +14,10 @@ namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\Subscriptions\ShowPlanSwitchRequest;
use App\Models\RecurringInvoice;
use App\Models\Subscription;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class SubscriptionPlanSwitchController extends Controller
{
@ -23,15 +25,32 @@ class SubscriptionPlanSwitchController extends Controller
* Show the page for switching between plans.
*
* @param ShowPlanSwitchRequest $request
* @param Subscription $subscription
* @param RecurringInvoice $recurring_invoice
* @param string $target
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(ShowPlanSwitchRequest $request, Subscription $subscription, Subscription $target)
public function index(ShowPlanSwitchRequest $request, RecurringInvoice $recurring_invoice, Subscription $target)
{
$amount = $recurring_invoice->subscription
->service()
->calculateUpgradePrice($recurring_invoice, $target);
/**
*
* Null value here is a proxy for
* denying the user a change plan option
*
*/
if(is_null($amount))
render('subscriptions.denied');
return render('subscriptions.switch', [
'subscription' => $subscription,
'subscription' => $recurring_invoice->subscription,
'recurring_invoice' => $recurring_invoice,
'target' => $target,
'amount' => $amount,
]);
}
}

View File

@ -173,7 +173,7 @@ class ClientSubscriptionController extends BaseController
{
$client_subscription = $this->client_subscription_repo->save($request->all(), ClientSubscriptionFactory::create(auth()->user()->company()->id, auth()->user()->id));
event(new ClientsubscriptionWasCreated($client_subscription, $client_subscription->company, Ninja::eventVars()));
event(new ClientsubscriptionWasCreated($client_subscription, $client_subscription->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($client_subscription);
}

View File

@ -201,7 +201,7 @@ class CreditController extends BaseController
->fillDefaults()
->save();
event(new CreditWasCreated($credit, $credit->company, Ninja::eventVars()));
event(new CreditWasCreated($credit, $credit->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($credit);
}
@ -378,7 +378,7 @@ class CreditController extends BaseController
$credit->service()->deletePdf();
event(new CreditWasUpdated($credit, $credit->company, Ninja::eventVars()));
event(new CreditWasUpdated($credit, $credit->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($credit);
}

View File

@ -157,7 +157,7 @@ class EmailController extends BaseController
$this->entity_transformer = QuoteTransformer::class;
if ($entity_obj->invitations->count() >= 1)
event(new QuoteWasEmailed($entity_obj->invitations->first(), $entity_obj->company, Ninja::eventVars(), 'quote'));
event(new QuoteWasEmailed($entity_obj->invitations->first(), $entity_obj->company, Ninja::eventVars(auth()->user()->id), 'quote'));
}
@ -166,7 +166,7 @@ class EmailController extends BaseController
$this->entity_transformer = CreditTransformer::class;
if ($entity_obj->invitations->count() >= 1)
event(new CreditWasEmailed($entity_obj->invitations->first(), $entity_obj->company, Ninja::eventVars(), 'credit'));
event(new CreditWasEmailed($entity_obj->invitations->first(), $entity_obj->company, Ninja::eventVars(auth()->user()->id), 'credit'));
}

View File

@ -279,7 +279,7 @@ class ExpenseController extends BaseController
$this->uploadLogo($request->file('company_logo'), $expense->company, $expense);
event(new ExpenseWasUpdated($expense, $expense->company, Ninja::eventVars()));
event(new ExpenseWasUpdated($expense, $expense->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($expense->fresh());
}
@ -373,7 +373,7 @@ class ExpenseController extends BaseController
{
$expense = $this->expense_repo->save($request->all(), ExpenseFactory::create(auth()->user()->company()->id, auth()->user()->id));
event(new ExpenseWasCreated($expense, $expense->company, Ninja::eventVars()));
event(new ExpenseWasCreated($expense, $expense->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($expense);
}

View File

@ -218,7 +218,7 @@ class InvoiceController extends BaseController
->triggeredActions($request)
->save();
event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars()));
event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($invoice);
}
@ -399,7 +399,7 @@ class InvoiceController extends BaseController
$invoice->service()->deletePdf();
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars()));
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($invoice);
}

View File

@ -382,7 +382,7 @@ class PaymentController extends BaseController
$payment = $this->payment_repo->save($request->all(), $payment);
event(new PaymentWasUpdated($payment, $payment->company, Ninja::eventVars()));
event(new PaymentWasUpdated($payment, $payment->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($payment);
}

View File

@ -211,7 +211,7 @@ class QuoteController extends BaseController
$quote = $quote->service()->fillDefaults()->save();
event(new QuoteWasCreated($quote, $quote->company, Ninja::eventVars()));
event(new QuoteWasCreated($quote, $quote->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($quote);
}
@ -389,7 +389,7 @@ class QuoteController extends BaseController
$quote->service()->deletePdf();
event(new QuoteWasUpdated($quote, $quote->company, Ninja::eventVars()));
event(new QuoteWasUpdated($quote, $quote->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($quote);
}

View File

@ -11,6 +11,7 @@
namespace App\Http\Controllers;
use App\Exceptions\FilePermissionsFailure;
use App\Utils\Ninja;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Artisan;
@ -61,6 +62,9 @@ class SelfUpdateController extends BaseController
return response()->json(['message' => ctrans('texts.self_update_not_available')], 403);
}
if(!$this->testWritable())
throw new FilePermissionsFailure('Cannot update system because files are not writable!');
// Check if new version is available
if($updater->source()->isNewVersionAvailable()) {
@ -90,6 +94,19 @@ class SelfUpdateController extends BaseController
}
private function testWritable()
{
$directoryIterator = new \RecursiveDirectoryIterator(base_path());
foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) {
if ($file->isFile() && ! $file->isWritable()) {
return false;
}
}
return true;
}
public function checkVersion()
{
return trim(file_get_contents(config('ninja.version_url')));

View File

@ -85,7 +85,7 @@ class ClientController extends BaseController
$this->uploadLogo($request->file('company_logo'), $company, $client);
event(new ClientWasCreated($client, $company, Ninja::eventVars()));
event(new ClientWasCreated($client, $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
return $this->itemResponse($client);
}

View File

@ -85,7 +85,7 @@ class InvoiceController extends BaseController
$invoice = $invoice->service()->triggeredActions($request)->save();
event(new InvoiceWasCreated($invoice, $company, Ninja::eventVars()));
event(new InvoiceWasCreated($invoice, $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
return $this->itemResponse($invoice);
}

View File

@ -13,6 +13,7 @@
namespace App\Http\Controllers;
use App\Events\Subscription\SubscriptionWasCreated;
use App\Events\Subscription\SubscriptionWasUpdated;
use App\Factory\SubscriptionFactory;
use App\Http\Requests\Subscription\CreateSubscriptionRequest;
use App\Http\Requests\Subscription\DestroySubscriptionRequest;
@ -24,9 +25,12 @@ use App\Models\Subscription;
use App\Repositories\SubscriptionRepository;
use App\Transformers\SubscriptionTransformer;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
class SubscriptionController extends BaseController
{
use MakesHash;
protected $entity_type = Subscription::class;
protected $entity_transformer = SubscriptionTransformer::class;
@ -173,7 +177,7 @@ class SubscriptionController extends BaseController
{
$subscription = $this->subscription_repo->save($request->all(), SubscriptionFactory::create(auth()->user()->company()->id, auth()->user()->id));
event(new SubscriptionWasCreated($subscription, $subscription->company, Ninja::eventVars()));
event(new SubscriptionWasCreated($subscription, $subscription->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($subscription);
}
@ -348,6 +352,8 @@ class SubscriptionController extends BaseController
$subscription = $this->subscription_repo->save($request->all(), $subscription);
event(new SubscriptionWasUpdated($subscription, $subscription->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($subscription);
}
@ -407,4 +413,72 @@ class SubscriptionController extends BaseController
return $this->itemResponse($subscription->fresh());
}
/**
* Perform bulk actions on the list view.
*
* @return Response
*
*
* @OA\Post(
* path="/api/v1/subscriptions/bulk",
* operationId="bulkSubscriptions",
* tags={"subscriptions"},
* summary="Performs bulk actions on an array of subscriptions",
* description="",
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
* @OA\Parameter(ref="#/components/parameters/index"),
* @OA\RequestBody(
* description="User credentials",
* required=true,
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* type="array",
* @OA\Items(
* type="integer",
* description="Array of hashed IDs to be bulk 'actioned",
* example="[0,1,2,3]",
* ),
* )
* )
* ),
* @OA\Response(
* response=200,
* description="The Subscription response",
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
* @OA\JsonContent(ref="#/components/schemas/Subscription"),
* ),
* @OA\Response(
* response=422,
* description="Validation error",
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
* ),
* @OA\Response(
* response="default",
* description="Unexpected Error",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* ),
* )
*/
public function bulk()
{
$action = request()->input('action');
$ids = request()->input('ids');
$subscriptions = Subscription::withTrashed()->find($this->transformKeys($ids));
$subscriptions->each(function ($subscription, $key) use ($action) {
if (auth()->user()->can('edit', $subscription)) {
$this->subscription_repo->{$action}($subscription);
}
});
return $this->listResponse(Subscription::withTrashed()->whereIn('id', $this->transformKeys($ids)));
}
}

View File

@ -279,10 +279,10 @@ class TaskController extends BaseController
$task = $this->task_repo->save($request->all(), $task);
if($task->status_order != $old_task->status_order)
$this->task_repo->sortStatuses($old_task, $task);
// if($task->status_order != $old_task->status_order)
// $this->task_repo->sortStatuses($old_task, $task);
event(new TaskWasUpdated($task, $task->company, Ninja::eventVars()));
event(new TaskWasUpdated($task, $task->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($task->fresh());
}
@ -376,7 +376,7 @@ class TaskController extends BaseController
{
$task = $this->task_repo->save($request->all(), TaskFactory::create(auth()->user()->company()->id, auth()->user()->id));
event(new TaskWasCreated($task, $task->company, Ninja::eventVars()));
event(new TaskWasCreated($task, $task->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($task);
}

View File

@ -211,7 +211,7 @@ class UserController extends BaseController
nlog("in the store method of the usercontroller class");
event(new UserWasCreated($user, auth()->user(), $company, Ninja::eventVars()));
event(new UserWasCreated($user, auth()->user(), $company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($user->fresh());
}
@ -401,7 +401,7 @@ class UserController extends BaseController
$user->company_user()->update(["permissions_updated_at" => now()]);
}
event(new UserWasUpdated($user, auth()->user(), auth()->user()->company, Ninja::eventVars()));
event(new UserWasUpdated($user, auth()->user(), auth()->user()->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($user);
}
@ -474,7 +474,7 @@ class UserController extends BaseController
/* If the user passes the company user we archive the company user */
$user = $this->user_repo->delete($request->all(), $user);
event(new UserWasDeleted($user, auth()->user(), auth()->user()->company, Ninja::eventVars()));
event(new UserWasDeleted($user, auth()->user(), auth()->user()->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($user->fresh());
}

View File

@ -278,7 +278,7 @@ class VendorController extends BaseController
$this->uploadLogo($request->file('company_logo'), $vendor->company, $vendor);
event(new VendorWasUpdated($vendor, $vendor->company, Ninja::eventVars()));
event(new VendorWasUpdated($vendor, $vendor->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($vendor->fresh());
}
@ -376,7 +376,7 @@ class VendorController extends BaseController
$this->uploadLogo($request->file('company_logo'), $vendor->company, $vendor);
event(new VendorWasCreated($vendor, $vendor->company, Ninja::eventVars()));
event(new VendorWasCreated($vendor, $vendor->company, Ninja::eventVars(auth()->user()->id)));
return $this->itemResponse($vendor);
}

View File

@ -111,6 +111,8 @@ class BillingPortalPurchase extends Component
'discount_applied' => false,
'show_loading_bar' => false,
'not_eligible' => null,
'not_eligible_message' => null,
'payment_required' => true,
];
/**
@ -269,6 +271,9 @@ class BillingPortalPurchase extends Component
return $this;
}
if((int)$this->subscription->price == 0)
$this->steps['payment_required'] = false;
else
$this->steps['fetched_payment_methods'] = true;
$this->methods = $contact->client->service()->getPaymentMethods($this->price);
@ -327,6 +332,7 @@ class BillingPortalPurchase extends Component
if (is_array($is_eligible)) {
$this->steps['not_eligible'] = true;
$this->steps['not_eligible_message'] = $is_eligible['exception'];
$this->steps['show_loading_bar'] = false;
return;
@ -337,6 +343,7 @@ class BillingPortalPurchase extends Component
'email' => $this->email ?? $this->contact->email,
'client_id' => $this->contact->client->id,
'invoice_id' => $this->invoice->id,
'context' => 'purchase',
now()->addMinutes(60)]
);
@ -354,6 +361,30 @@ class BillingPortalPurchase extends Component
'email' => $this->email ?? $this->contact->email,
'quantity' => $this->quantity,
'contact_id' => $this->contact->id,
'client_id' => $this->contact->client->id,
]);
}
public function handlePaymentNotRequired()
{
$is_eligible = $this->subscription->service()->isEligible($this->contact);
if ($is_eligible['status_code'] != 200) {
$this->steps['not_eligible'] = true;
$this->steps['not_eligible_message'] = $is_eligible['exception']['message'];
$this->steps['show_loading_bar'] = false;
return;
}
return $this->subscription->service()->handleNoPaymentRequired([
'email' => $this->email ?? $this->contact->email,
'quantity' => $this->quantity,
'contact_id' => $this->contact->id,
'client_id' => $this->contact->client->id,
'coupon' => '',
]);
}

View File

@ -26,6 +26,11 @@ class InvoicesTable extends Component
public $status = [];
public function mount()
{
$this->sort_asc = false;
}
public function render()
{
$local_status = [];
@ -62,6 +67,7 @@ class InvoicesTable extends Component
$query = $query
->where('client_id', auth('contact')->user()->client->id)
->where('status_id', '<>', Invoice::STATUS_DRAFT)
->withTrashed()
->paginate($this->per_page);
return render('components.livewire.invoices-table', [

View File

@ -1,40 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Livewire;
use App\Models\Invoice;
use App\Utils\Traits\WithSorting;
use Livewire\Component;
use Livewire\WithPagination;
class SubscriptionInvoicesTable extends Component
{
use WithPagination;
use WithSorting;
public $per_page = 10;
public function render()
{
$query = Invoice::query()
->where('client_id', auth('contact')->user()->client->id)
->whereNotNull('subscription_id')
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
->where('balance', '=', 0)
->paginate($this->per_page);
return render('components.livewire.subscriptions-invoices-table', [
'invoices' => $query,
]);
}
}

View File

@ -14,16 +14,27 @@ namespace App\Http\Livewire;
use App\Models\ClientContact;
use App\Models\Subscription;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Livewire\Component;
class SubscriptionPlanSwitch extends Component
{
/**
* @var RecurringInvoice
*/
public $recurring_invoice;
/**
* @var Subscription
*/
public $subscription;
/**
* @var ?float
*/
public $amount;
/**
* @var Subscription
*/
@ -62,9 +73,9 @@ class SubscriptionPlanSwitch extends Component
public function mount()
{
$this->total = $this->subscription->service()->getPriceBetweenSubscriptions($this->subscription, $this->target);
$this->total = $this->amount;
$this->methods = $this->contact->client->service()->getPaymentMethods(100);
$this->methods = $this->contact->client->service()->getPaymentMethods($this->amount);
$this->hash = Str::uuid()->toString();
}
@ -73,11 +84,23 @@ class SubscriptionPlanSwitch extends Component
{
$this->state['show_loading_bar'] = true;
$this->state['invoice'] = $this->subscription->service()->createChangePlanInvoice([
$this->state['invoice'] = $this->target->service()->createChangePlanInvoice([
'recurring_invoice' => $this->recurring_invoice,
'subscription' => $this->subscription,
'target' => $this->target,
'hash' => $this->hash,
]);
Cache::put($this->hash, [
'subscription_id' => $this->target->id,
'target_id' => $this->target->id,
'recurring_invoice' => $this->recurring_invoice->id,
'client_id' => $this->recurring_invoice->client->id,
'invoice_id' => $this->state['invoice']->id,
'context' => 'change_plan',
now()->addMinutes(60)]
);
$this->state['payment_initialised'] = true;
$this->emit('beforePaymentEventsCompleted');

View File

@ -17,7 +17,7 @@ class ShowPlanSwitchRequest extends FormRequest
*/
public function authorize()
{
return (bool)$this->subscription->allow_plan_changes;
return (bool)$this->recurring_invoice->subscription->allow_plan_changes;
}
/**

View File

@ -35,10 +35,11 @@ class StoreSubscriptionRequest extends Request
public function rules()
{
$rules = [
'product_id' => ['sometimes'],
'product_ids' => ['sometimes'],
'recurring_product_ids' => ['sometimes'],
'assigned_user_id' => ['sometimes'],
'is_recurring' => ['sometimes'],
'frequency_id' => ['sometimes'],
'frequency_id' => ['required_with:recurring_product_ids'],
'auto_bill' => ['sometimes'],
'promo_code' => ['sometimes'],
'promo_discount' => ['sometimes'],

View File

@ -13,6 +13,7 @@ namespace App\Http\Requests\Subscription;
use App\Http\Requests\Request;
use App\Utils\Traits\ChecksEntityStatus;
use Illuminate\Validation\Rule;
class UpdateSubscriptionRequest extends Request
{
@ -36,11 +37,31 @@ class UpdateSubscriptionRequest extends Request
public function rules()
{
$rules = [
//
'product_ids' => ['sometimes'],
'recurring_product_ids' => ['sometimes'],
'assigned_user_id' => ['sometimes'],
'is_recurring' => ['sometimes'],
'frequency_id' => ['required_with:recurring_product_ids'],
'auto_bill' => ['sometimes'],
'promo_code' => ['sometimes'],
'promo_discount' => ['sometimes'],
'is_amount_discount' => ['sometimes'],
'allow_cancellation' => ['sometimes'],
'per_set_enabled' => ['sometimes'],
'min_seats_limit' => ['sometimes'],
'max_seats_limit' => ['sometimes'],
'trial_enabled' => ['sometimes'],
'trial_duration' => ['sometimes'],
'allow_query_overrides' => ['sometimes'],
'allow_plan_changes' => ['sometimes'],
'refund_period' => ['sometimes'],
'webhook_configuration' => ['array'],
'name' => ['required', Rule::unique('subscriptions')->where('company_id', auth()->user()->company()->id)->ignore($this->subscription->id)]
];
return $this->globalRules($rules);
}
protected function prepareForValidation()

View File

@ -84,7 +84,7 @@ class ValidInvoicesRules implements Rule
}
else if($invoice['amount'] > $inv->balance) {
$this->error_msg = ctrans('texts.amount_greater_than_balance');
$this->error_msg = ctrans('texts.amount_greater_than_balance_v5');
return false;
}

View File

@ -12,6 +12,7 @@
namespace App\Jobs\Entity;
use App\Exceptions\FilePermissionsFailure;
use App\Models\Account;
use App\Models\Credit;
use App\Models\CreditInvitation;
@ -168,6 +169,7 @@ class CreateEntityPdf implements ShouldQueue
else {
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
}
} catch (\Exception $e) {
nlog(print_r($e->getMessage(), 1));
}
@ -176,8 +178,20 @@ class CreateEntityPdf implements ShouldQueue
info($maker->getCompiledHTML());
}
if ($pdf) {
try{
Storage::disk($this->disk)->put($file_path, $pdf);
}
catch(\Exception $e)
{
throw new FilePermissionsFailure('Could not write the PDF, permission issues!');
}
}
return $file_path;

View File

@ -142,7 +142,7 @@ class EmailEntity implements ShouldQueue
{
switch ($this->entity_string) {
case 'invoice':
event(new InvoiceWasEmailedAndFailed($this->invitation, $this->company, $message, $this->reminder_template, Ninja::eventVars()));
event(new InvoiceWasEmailedAndFailed($this->invitation, $this->company, $message, $this->reminder_template, Ninja::eventVars(auth()->user()->id)));
break;
default:

View File

@ -105,10 +105,10 @@ class NinjaMailerJob implements ShouldQueue
switch ($class) {
case Invoice::class:
event(new InvoiceWasEmailedAndFailed($this->nmo->invitation, $this->nmo->company, $message, $this->nmo->reminder_template, Ninja::eventVars()));
event(new InvoiceWasEmailedAndFailed($this->nmo->invitation, $this->nmo->company, $message, $this->nmo->reminder_template, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
break;
case Payment::class:
event(new PaymentWasEmailedAndFailed($this->nmo->entity, $this->nmo->company, $message, Ninja::eventVars()));
event(new PaymentWasEmailedAndFailed($this->nmo->entity, $this->nmo->company, $message, Ninja::eventVars(auth()->user ? auth()->user()->id : null)));
break;
default:
# code...

View File

@ -91,7 +91,7 @@ class EmailPayment implements ShouldQueue
NinjaMailerJob::dispatch($nmo);
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars()));
event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
}
}
}

View File

@ -84,7 +84,7 @@ class CreateUser
if(!Ninja::isSelfHost()){
nlog("in the create user class");
event(new UserWasCreated($user, $user, $this->company, Ninja::eventVars()));
event(new UserWasCreated($user, $user, $this->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
}
return $user;

View File

@ -192,6 +192,7 @@ class MultiDB
return true;
}
self::setDefaultDatabase();
return false;
}
@ -205,6 +206,7 @@ class MultiDB
return true;
}
}
self::setDefaultDatabase();
return false;
}
@ -218,6 +220,7 @@ class MultiDB
return true;
}
}
self::setDefaultDatabase();
return false;
}
@ -230,6 +233,7 @@ class MultiDB
return true;
}
}
self::setDefaultDatabase();
return false;
}
@ -242,16 +246,20 @@ class MultiDB
return true;
}
}
self::setDefaultDatabase();
return false;
}
public static function findAndSetDbByDomain($subdomain) :bool
{
if (! config('ninja.db.multi_db_enabled'))
return (Company::whereSubdomain($subdomain)->exists() === true);
foreach (self::$dbs as $db) {
if ($company = Company::on($db)->whereSubdomain($subdomain)->first()) {
self::setDb($company->db);
return true;
}
}

View File

@ -43,8 +43,10 @@ class ArchivedClientActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->client->user_id;
$fields->client_id = $event->client->id;
$fields->user_id = $event->client->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->client->company_id;
$fields->activity_type_id = Activity::ARCHIVE_CLIENT;

View File

@ -45,8 +45,10 @@ class ClientUpdatedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->client->user_id;
$fields->client_id = $client->id;
$fields->user_id = $client->user_id;
$fields->user_id = $user_id;
$fields->company_id = $client->company_id;
$fields->activity_type_id = Activity::UPDATE_CLIENT;

View File

@ -43,8 +43,10 @@ class CreatedClientActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->client->user_id;
$fields->client_id = $event->client->id;
$fields->user_id = $event->client->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->client->company_id;
$fields->activity_type_id = Activity::CREATE_CLIENT;

View File

@ -43,8 +43,10 @@ class CreatedCreditActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->credit->user_id;
$fields->credit_id = $event->credit->id;
$fields->user_id = $event->credit->user_id;
$fields->user_id = $user_id;
$fields->client_id = $event->credit->client_id;
$fields->company_id = $event->credit->company_id;

View File

@ -43,8 +43,11 @@ class CreatedExpenseActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->expense->user_id;
$fields->expense_id = $event->expense->id;
$fields->user_id = $event->expense->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->expense->company_id;
$fields->activity_type_id = Activity::CREATE_EXPENSE;

View File

@ -43,9 +43,11 @@ class CreatedQuoteActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->quote->user_id;
$fields->quote_id = $event->quote->id;
$fields->client_id = $event->quote->client_id;
$fields->user_id = $event->quote->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->quote->company_id;
$fields->activity_type_id = Activity::CREATE_QUOTE;

View File

@ -0,0 +1,55 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Listeners\Activity;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class CreatedSubscriptionActivity implements ShouldQueue
{
protected $activity_repo;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->subscription->user_id;
$fields->subscription_id = $event->subscription->id;
$fields->user_id = $user_id;
$fields->company_id = $event->subscription->company_id;
$fields->activity_type_id = Activity::CREATE_SUBSCRIPTION;
$this->activity_repo->save($fields, $event->subscription, $event->event_vars);
}
}

View File

@ -43,8 +43,10 @@ class CreatedTaskActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->task->user_id;
$fields->task_id = $event->task->id;
$fields->user_id = $event->task->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->task->company_id;
$fields->activity_type_id = Activity::CREATE_TASK;

View File

@ -43,8 +43,10 @@ class CreatedVendorActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->vendor->user_id;
$fields->vendor_id = $event->vendor->id;
$fields->user_id = $event->vendor->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->vendor->company_id;
$fields->activity_type_id = Activity::CREATE_VENDOR;

View File

@ -43,9 +43,11 @@ class CreditArchivedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->credit->user_id;
$fields->payment_id = $event->credit->id;
$fields->client_id = $event->credit->client_id;
$fields->user_id = $event->credit->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->credit->company_id;
$fields->activity_type_id = Activity::ARCHIVE_CREDIT;

View File

@ -43,8 +43,10 @@ class DeleteClientActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->client->user_id;
$fields->client_id = $event->client->id;
$fields->user_id = $event->client->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->client->company_id;
$fields->activity_type_id = Activity::DELETE_CLIENT;

View File

@ -43,9 +43,11 @@ class DeleteCreditActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->credit->user_id;
$fields->client_id = $event->credit->client_id;
$fields->credit_id = $event->credit->id;
$fields->user_id = $event->credit->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->credit->company_id;
$fields->activity_type_id = Activity::DELETE_CREDIT;

View File

@ -45,8 +45,10 @@ class ExpenseArchivedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->expense->user_id;
$fields->expense_id = $expense->id;
$fields->user_id = $expense->user_id;
$fields->user_id = $user_id;
$fields->company_id = $expense->company_id;
$fields->activity_type_id = Activity::ARCHIVE_EXPENSE;

View File

@ -43,8 +43,10 @@ class ExpenseDeletedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->expense->user_id;
$fields->expense_id = $event->expense->id;
$fields->user_id = $event->expense->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->expense->company_id;
$fields->activity_type_id = Activity::DELETE_VENDOR;

View File

@ -43,8 +43,10 @@ class ExpenseRestoredActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->expense->user_id;
$fields->expense_id = $event->expense->id;
$fields->user_id = $event->expense->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->expense->company_id;
$fields->activity_type_id = Activity::RESTORE_EXPENSE;

View File

@ -43,10 +43,12 @@ class ExpenseUpdatedActivity implements ShouldQueue
$expense = $event->expense;
$user_id = $event->event_vars['user_id'] ?: $event->expense->user_id;
$fields = new stdClass;
$fields->expense_id = $expense->id;
$fields->user_id = $expense->user_id;
$fields->user_id = $user_id;
$fields->company_id = $expense->company_id;
$fields->activity_type_id = Activity::UPDATE_EXPENSE;

View File

@ -48,9 +48,11 @@ class PaymentArchivedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->payment->user_id;
$fields->payment_id = $payment->id;
$fields->client_id = $payment->client_id;
$fields->user_id = $payment->user_id;
$fields->user_id = $user_id;
$fields->company_id = $payment->company_id;
$fields->activity_type_id = Activity::ARCHIVE_PAYMENT;

View File

@ -43,13 +43,15 @@ class PaymentCreatedActivity implements ShouldQueue
$payment = $event->payment;
$user_id = $event->event_vars['user_id'] ?: $event->payment->user_id;
$invoices = $payment->invoices;
$fields = new stdClass;
$fields->payment_id = $payment->id;
$fields->client_id = $payment->client_id;
$fields->user_id = $payment->user_id;
$fields->user_id = $user_id;
$fields->company_id = $payment->company_id;
$fields->activity_type_id = Activity::CREATE_PAYMENT;

View File

@ -43,13 +43,15 @@ class PaymentDeletedActivity implements ShouldQueue
$payment = $event->payment;
$user_id = $event->event_vars['user_id'] ?: $event->payment->user_id;
$invoices = $payment->invoices;
$fields = new stdClass;
$fields->payment_id = $payment->id;
$fields->client_id = $payment->client_id;
$fields->user_id = $payment->user_id;
$fields->user_id = $user_id;
$fields->company_id = $payment->company_id;
$fields->activity_type_id = Activity::DELETE_PAYMENT;

View File

@ -43,9 +43,11 @@ class PaymentRefundedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->payment->user_id;
$fields->client_id = $event->payment->id;
$fields->client_id = $event->payment->client_id;
$fields->user_id = $event->payment->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->payment->company_id;
$fields->activity_type_id = Activity::REFUNDED_PAYMENT;
$fields->payment_id = $event->payment->id;

View File

@ -48,9 +48,11 @@ class PaymentUpdatedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->payment->user_id;
$fields->payment_id = $payment->id;
$fields->client_id = $payment->client_id;
$fields->user_id = $payment->user_id;
$fields->user_id = $user_id;
$fields->company_id = $payment->company_id;
$fields->activity_type_id = Activity::UPDATE_PAYMENT;

View File

@ -43,8 +43,10 @@ class PaymentVoidedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->payment->user_id;
$fields->client_id = $event->payment->id;
$fields->user_id = $event->payment->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->payment->company_id;
$fields->activity_type_id = Activity::VOIDED_PAYMENT;
$fields->payment_id = $event->payment->id;

View File

@ -45,9 +45,11 @@ class QuoteUpdatedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->quote->user_id;
$fields->quote_id = $quote->id;
$fields->client_id = $quote->client_id;
$fields->user_id = $quote->user_id;
$fields->user_id = $user_id;
$fields->company_id = $quote->company_id;
$fields->activity_type_id = Activity::UPDATE_QUOTE;

View File

@ -43,8 +43,10 @@ class RestoreClientActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->client->user_id;
$fields->client_id = $event->client->id;
$fields->user_id = $event->client->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->client->company_id;
$fields->activity_type_id = Activity::RESTORE_CLIENT;

View File

@ -0,0 +1,57 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Listeners\Activity;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class SubscriptionArchivedActivity implements ShouldQueue
{
protected $activity_repo;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$subscription = $event->subscription;
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->subscription->user_id;
$fields->subscription_id = $subscription->id;
$fields->user_id = $user_id;
$fields->company_id = $subscription->company_id;
$fields->activity_type_id = Activity::ARCHIVE_SUBSCRIPTIOn;
$this->activity_repo->save($fields, $subscription, $event->event_vars);
}
}

View File

@ -0,0 +1,55 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Listeners\Activity;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class SubscriptionDeletedActivity implements ShouldQueue
{
protected $activity_repo;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->subscription->user_id;
$fields->subscription_id = $event->subscription->id;
$fields->user_id = $user_id;
$fields->company_id = $event->subscription->company_id;
$fields->activity_type_id = Activity::DELETE_SUBSCRIPTION;
$this->activity_repo->save($fields, $event->subscription, $event->event_vars);
}
}

View File

@ -0,0 +1,55 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Listeners\Activity;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class SubscriptionRestoredActivity implements ShouldQueue
{
protected $activity_repo;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->subscription->user_id;
$fields->subscription_id = $event->subscription->id;
$fields->user_id = $user_id;
$fields->company_id = $event->subscription->company_id;
$fields->activity_type_id = Activity::RESTORE_SUBSCRIPTION;
$this->activity_repo->save($fields, $event->subscription, $event->event_vars);
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Listeners\Activity;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use stdClass;
class SubscriptionUpdatedActivity implements ShouldQueue
{
protected $activity_repo;
/**
* Create the event listener.
*
* @param ActivityRepository $activity_repo
*/
public function __construct(ActivityRepository $activity_repo)
{
$this->activity_repo = $activity_repo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
MultiDB::setDb($event->company->db);
$subscription = $event->subscription;
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->subscription->user_id;
$fields->subscription_id = $subscription->id;
$fields->user_id = $user_id;
$fields->company_id = $subscription->company_id;
$fields->activity_type_id = Activity::UPDATE_SUBSCRIPTION;
$this->activity_repo->save($fields, $subscription, $event->event_vars);
}
}

View File

@ -45,8 +45,10 @@ class TaskArchivedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->task->user_id;
$fields->task_id = $task->id;
$fields->user_id = $task->user_id;
$fields->user_id = $user_id;
$fields->company_id = $task->company_id;
$fields->activity_type_id = Activity::ARCHIVE_TASK;

View File

@ -43,8 +43,10 @@ class TaskDeletedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->task->user_id;
$fields->task_id = $event->task->id;
$fields->user_id = $event->task->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->task->company_id;
$fields->activity_type_id = Activity::DELETE_TASK;

View File

@ -43,8 +43,10 @@ class TaskRestoredActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->task->user_id;
$fields->task_id = $event->task->id;
$fields->user_id = $event->task->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->task->company_id;
$fields->activity_type_id = Activity::RESTORE_TASK;

View File

@ -45,8 +45,10 @@ class TaskUpdatedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->task->user_id;
$fields->task_id = $task->id;
$fields->user_id = $task->user_id;
$fields->user_id = $user_id;
$fields->company_id = $task->company_id;
$fields->activity_type_id = Activity::UPDATE_TASK;

View File

@ -43,9 +43,11 @@ class UpdatedCreditActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->credit->user_id;
$fields->credit_id = $event->credit->id;
$fields->client_id = $event->credit->client_id;
$fields->user_id = $event->credit->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->credit->company_id;
$fields->activity_type_id = Activity::UPDATE_CREDIT;

View File

@ -45,8 +45,10 @@ class VendorArchivedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->vendor->user_id;
$fields->vendor_id = $vendor->id;
$fields->user_id = $vendor->user_id;
$fields->user_id = $user_id;
$fields->company_id = $vendor->company_id;
$fields->activity_type_id = Activity::ARCHIVE_VENDOR;

View File

@ -43,8 +43,10 @@ class VendorDeletedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->vendor->user_id;
$fields->vendor_id = $event->vendor->id;
$fields->user_id = $event->vendor->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->vendor->company_id;
$fields->activity_type_id = Activity::DELETE_VENDOR;

View File

@ -43,8 +43,10 @@ class VendorRestoredActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->vendor->user_id;
$fields->vendor_id = $event->vendor->id;
$fields->user_id = $event->vendor->user_id;
$fields->user_id = $user_id;
$fields->company_id = $event->vendor->company_id;
$fields->activity_type_id = Activity::RESTORE_VENDOR;

View File

@ -45,8 +45,10 @@ class VendorUpdatedActivity implements ShouldQueue
$fields = new stdClass;
$user_id = $event->event_vars['user_id'] ?: $event->vendor->user_id;
$fields->vendor_id = $vendor->id;
$fields->user_id = $vendor->user_id;
$fields->user_id = $user_id;
$fields->company_id = $vendor->company_id;
$fields->activity_type_id = Activity::UPDATE_VENDOR;

View File

@ -0,0 +1,43 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Mail\Gateways;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class ACHVerificationNotification extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('email.gateways.ach-verification-notification');
}
}

View File

@ -49,6 +49,10 @@ class TemplateEmail extends Mailable
{
$template_name = 'email.template.'.$this->build_email->getTemplate();
if($this->build_email->getTemplate() == 'custom') {
$this->build_email->setBody(str_replace('$body', $this->build_email->getBody(), $this->client->getSetting('email_style_custom')));
}
$settings = $this->client->getMergedSettings();
$company = $this->client->company;

View File

@ -84,6 +84,12 @@ class Activity extends StaticModel
const INVOICE_REMINDER3_SENT = 65;
const INVOICE_REMINDER_ENDLESS_SENT = 66;
const CREATE_SUBSCRIPTION = 80;
const UPDATE_SUBSCRIPTION = 81;
const ARCHIVE_SUBSCRIPTION = 82;
const DELETE_SUBSCRIPTION = 83;
const RESTORE_SUBSCRIPTION = 84;
protected $casts = [
'is_system' => 'boolean',
'updated_at' => 'timestamp',

View File

@ -255,10 +255,10 @@ class Credit extends BaseModel
}
if (! $invitation) {
event(new CreditWasUpdated($this, $this->company, Ninja::eventVars()));
event(new CreditWasUpdated($this, $this->company, Ninja::eventVars(auth()->user()->id)));
CreateEntityPdf::dispatchNow($this->invitations->first());
} else {
event(new CreditWasUpdated($this, $this->company, Ninja::eventVars()));
event(new CreditWasUpdated($this, $this->company, Ninja::eventVars(auth()->user()->id)));
CreateEntityPdf::dispatchNow($invitation);
}

View File

@ -129,7 +129,7 @@ class CreditInvitation extends BaseModel
$storage_path = Storage::url($this->credit->client->quote_filepath().$this->credit->numberFormatter().'.pdf');
if (! Storage::exists($this->credit->client->credit_filepath().$this->credit->numberFormatter().'.pdf')) {
event(new CreditWasUpdated($this, $this->company, Ninja::eventVars()));
event(new CreditWasUpdated($this, $this->company, Ninja::eventVars(auth()->user()->id)));
CreateEntityPdf::dispatchNow($this);
}

View File

@ -397,7 +397,7 @@ class Invoice extends BaseModel
$storage_path = Storage::$type($this->client->invoice_filepath().$this->numberFormatter().'.pdf');
if (! Storage::exists($this->client->invoice_filepath().$this->numberFormatter().'.pdf')) {
event(new InvoiceWasUpdated($this, $this->company, Ninja::eventVars()));
event(new InvoiceWasUpdated($this, $this->company, Ninja::eventVars(auth()->user()->id)));
CreateEntityPdf::dispatchNow($invitation);
}

View File

@ -143,7 +143,7 @@ class InvoiceInvitation extends BaseModel
$storage_path = Storage::url($this->invoice->client->invoice_filepath().$this->invoice->numberFormatter().'.pdf');
if (! Storage::exists($this->invoice->client->invoice_filepath().$this->invoice->numberFormatter().'.pdf')) {
event(new InvoiceWasUpdated($this->invoice, $this->company, Ninja::eventVars()));
event(new InvoiceWasUpdated($this->invoice, $this->company, Ninja::eventVars(auth()->user()->id)));
CreateEntityPdf::dispatchNow($this);
}

View File

@ -243,7 +243,7 @@ class Payment extends BaseModel
$this->status_id = $this->refunded == $this->amount ? self::STATUS_REFUNDED : self::STATUS_PARTIALLY_REFUNDED;
$this->save();
event(new PaymentWasRefunded($this, $refund_change, $this->company, Ninja::eventVars()));
event(new PaymentWasRefunded($this, $refund_change, $this->company, Ninja::eventVars(auth()->user()->id)));
}
return true;
@ -280,7 +280,7 @@ class Payment extends BaseModel
$this->status_id = self::STATUS_CANCELLED;
$this->save();
event(new PaymentWasVoided($this, $this->company, Ninja::eventVars()));
event(new PaymentWasVoided($this, $this->company, Ninja::eventVars(auth()->user()->id)));
}
public function getLink()

View File

@ -213,7 +213,7 @@ class Quote extends BaseModel
nlog($storage_path);
if (! Storage::exists($this->client->quote_filepath().$this->numberFormatter().'.pdf')) {
event(new QuoteWasUpdated($this, $this->company, Ninja::eventVars()));
event(new QuoteWasUpdated($this, $this->company, Ninja::eventVars(auth()->user()->id)));
CreateEntityPdf::dispatchNow($invitation);
}

View File

@ -133,7 +133,7 @@ class QuoteInvitation extends BaseModel
$storage_path = Storage::url($this->quote->client->quote_filepath().$this->quote->numberFormatter().'.pdf');
if (! Storage::exists($this->quote->client->quote_filepath().$this->quote->numberFormatter().'.pdf')) {
event(new QuoteWasUpdated($this->quote, $this->company, Ninja::eventVars()));
event(new QuoteWasUpdated($this->quote, $this->company, Ninja::eventVars(auth()->user()->id)));
CreateEntityPdf::dispatchNow($this);
}

View File

@ -184,7 +184,7 @@ class RecurringInvoice extends BaseModel
public function invoices()
{
return $this->hasMany(Invoice::class, 'id', 'recurring_id')->withTrashed();
return $this->hasMany(Invoice::class, 'recurring_id', 'id')->withTrashed();
}
public function invitations()

View File

@ -141,7 +141,7 @@ class CreditCard
$this->checkout->payment_hash->data = array_merge((array)$this->checkout->payment_hash->data, ['checkout_payment_ref' => $payment]);
$this->checkout->payment_hash->save();
if ($this->checkout->client->currency()->code === 'EUR') {
if ($this->checkout->client->currency()->code == 'EUR') {
$payment->{'3ds'} = ['enabled' => true];
$payment->{'success_url'} = route('payment_webhook', [

View File

@ -209,7 +209,8 @@ class CheckoutComPaymentDriver extends BaseDriver
$payment = new \Checkout\Models\Payments\Payment($method, $this->client->getCurrencyCode());
$payment->amount = $this->convertToCheckoutAmount($amount, $this->client->getCurrencyCode());
$payment->reference = $cgt->meta->last4 . '-' . now();
//$payment->reference = $cgt->meta->last4 . '-' . now();
$payment->reference = $invoice->number . '-' . now();
$request = new PaymentResponseRequest();
$request->setMethod('POST');

View File

@ -11,6 +11,12 @@
namespace App\PaymentDrivers;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Payment;
use App\Models\PaymentHash;
use App\Models\SystemLog;
use App\PaymentDrivers\Stripe\CreditCard;
use App\Utils\Traits\MakesHash;
class DriverTemplate extends BaseDriver

View File

@ -14,8 +14,11 @@ namespace App\PaymentDrivers\Stripe;
use App\Exceptions\PaymentFailed;
use App\Http\Requests\Request;
use App\Jobs\Mail\NinjaMailerJob;
use App\Jobs\Mail\NinjaMailerObject;
use App\Jobs\Mail\PaymentFailureMailer;
use App\Jobs\Util\SystemLogger;
use App\Mail\Gateways\ACHVerificationNotification;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Payment;
@ -47,7 +50,7 @@ class ACH
return render('gateways.stripe.ach.authorize', array_merge($data));
}
public function authorizeResponse($request)
public function authorizeResponse(Request $request)
{
$this->stripe->init();
@ -63,6 +66,14 @@ class ACH
$client_gateway_token = $this->storePaymentMethod($source, $request->input('method'), $customer);
$mailer = new NinjaMailerObject();
$mailer->mailable = new ACHVerificationNotification();
$mailer->company = auth('contact')->user()->client->company;
$mailer->settings = auth('contact')->user()->client->company->settings;
$mailer->to_user = auth('contact')->user();
NinjaMailerJob::dispatchNow($mailer);
return redirect()->route('client.payment_methods.verification', ['payment_method' => $client_gateway_token->hashed_id, 'method' => GatewayType::BANK_TRANSFER]);
}

View File

@ -67,6 +67,11 @@ use App\Events\Quote\QuoteWasEmailed;
use App\Events\Quote\QuoteWasRestored;
use App\Events\Quote\QuoteWasUpdated;
use App\Events\Quote\QuoteWasViewed;
use App\Events\Subscription\SubscriptionWasArchived;
use App\Events\Subscription\SubscriptionWasCreated;
use App\Events\Subscription\SubscriptionWasDeleted;
use App\Events\Subscription\SubscriptionWasRestored;
use App\Events\Subscription\SubscriptionWasUpdated;
use App\Events\Task\TaskWasArchived;
use App\Events\Task\TaskWasCreated;
use App\Events\Task\TaskWasDeleted;
@ -89,6 +94,7 @@ use App\Listeners\Activity\CreatedClientActivity;
use App\Listeners\Activity\CreatedCreditActivity;
use App\Listeners\Activity\CreatedExpenseActivity;
use App\Listeners\Activity\CreatedQuoteActivity;
use App\Listeners\Activity\CreatedSubscriptionActivity;
use App\Listeners\Activity\CreatedTaskActivity;
use App\Listeners\Activity\CreatedVendorActivity;
use App\Listeners\Activity\CreditArchivedActivity;
@ -106,6 +112,10 @@ use App\Listeners\Activity\PaymentUpdatedActivity;
use App\Listeners\Activity\PaymentVoidedActivity;
use App\Listeners\Activity\QuoteUpdatedActivity;
use App\Listeners\Activity\RestoreClientActivity;
use App\Listeners\Activity\SubscriptionArchivedActivity;
use App\Listeners\Activity\SubscriptionDeletedActivity;
use App\Listeners\Activity\SubscriptionRestoredActivity;
use App\Listeners\Activity\SubscriptionUpdatedActivity;
use App\Listeners\Activity\TaskArchivedActivity;
use App\Listeners\Activity\TaskDeletedActivity;
use App\Listeners\Activity\TaskRestoredActivity;
@ -396,6 +406,21 @@ class EventServiceProvider extends ServiceProvider
TaskWasRestored::class => [
TaskRestoredActivity::class,
],
SubscriptionWasCreated::class => [
CreatedSubscriptionActivity::class,
],
SubscriptionWasUpdated::class => [
SubscriptionUpdatedActivity::class,
],
SubscriptionWasArchived::class => [
SubscriptionArchivedActivity::class,
],
SubscriptionWasDeleted::class => [
SubscriptionDeletedActivity::class,
],
SubscriptionWasRestored::class => [
SubscriptionRestoredActivity::class,
],
VendorWasCreated::class => [
CreatedVendorActivity::class,
],

View File

@ -55,7 +55,7 @@ class BaseRepository
$className = $this->getEventClass($entity, 'Archived');
if (class_exists($className)) {
event(new $className($entity, $entity->company, Ninja::eventVars()));
event(new $className($entity, $entity->company, Ninja::eventVars(auth()->user()->id)));
}
}
@ -81,7 +81,7 @@ class BaseRepository
$className = $this->getEventClass($entity, 'Restored');
if (class_exists($className)) {
event(new $className($entity, $fromDeleted, $entity->company, Ninja::eventVars()));
event(new $className($entity, $fromDeleted, $entity->company, Ninja::eventVars(auth()->user()->id)));
}
}
@ -102,7 +102,7 @@ class BaseRepository
$className = $this->getEventClass($entity, 'Deleted');
if (class_exists($className) && ! ($entity instanceof Company)) {
event(new $className($entity, $entity->company, Ninja::eventVars()));
event(new $className($entity, $entity->company, Ninja::eventVars(auth()->user()->id)));
}
}

View File

@ -155,7 +155,7 @@ class PaymentRepository extends BaseRepository {
}
if ( ! $is_existing_payment && ! $this->import_mode ) {
event( new PaymentWasCreated( $payment, $payment->company, Ninja::eventVars() ) );
event( new PaymentWasCreated( $payment, $payment->company, Ninja::eventVars(auth()->user()->id) ) );
}
nlog("payment amount = {$payment->amount}");
@ -205,7 +205,7 @@ class PaymentRepository extends BaseRepository {
$payment = $payment->service()->deletePayment();
event(new PaymentWasDeleted($payment, $payment->company, Ninja::eventVars()));
event(new PaymentWasDeleted($payment, $payment->company, Ninja::eventVars(auth()->user()->id)));
return $payment;
//return parent::delete($payment);

Some files were not shown because too many files have changed in this diff Show More