mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Recurring Invoice history / activities
This commit is contained in:
parent
3b5a6d5392
commit
16c5665cc6
@ -30,6 +30,7 @@ function nlog($output, $context = []): void
|
||||
}
|
||||
|
||||
$trace = debug_backtrace();
|
||||
//nlog( debug_backtrace()[1]['function']);
|
||||
// \Illuminate\Support\Facades\Log::channel('invoiceninja')->info(print_r($trace[1]['class'],1), []);
|
||||
\Illuminate\Support\Facades\Log::channel('invoiceninja')->info($output, $context);
|
||||
|
||||
|
@ -27,6 +27,7 @@ use App\Models\Account;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Repositories\RecurringInvoiceRepository;
|
||||
use App\Transformers\RecurringInvoiceTransformer;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\SavesDocuments;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -37,10 +37,6 @@ class ContactKeyLogin
|
||||
if (Auth::guard('contact')->check()) {
|
||||
Auth::guard('contact')->logout();
|
||||
}
|
||||
nlog("merp");
|
||||
nlog($request->has('magic_link'));
|
||||
nlog($request->input('magic_link'));
|
||||
nlog($request->all());
|
||||
|
||||
if ($request->segment(3) && config('ninja.db.multi_db_enabled')) {
|
||||
if (MultiDB::findAndSetDbByContactKey($request->segment(3))) {
|
||||
@ -71,7 +67,6 @@ nlog($request->all());
|
||||
}
|
||||
} elseif ($request->segment(2) && $request->segment(2) == 'magic_link' && $request->segment(3)) {
|
||||
$contact_email = Cache::get($request->segment(3));
|
||||
nlog("double merp");
|
||||
if($client_contact = ClientContact::where('email', $contact_email)->first()){
|
||||
Auth::guard('contact')->login($client_contact, true);
|
||||
|
||||
@ -83,7 +78,6 @@ nlog("double merp");
|
||||
}
|
||||
}
|
||||
|
||||
nlog("exit");
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
@ -22,15 +22,6 @@ class Cors
|
||||
return Response::make('OK', 200, $headers);
|
||||
}
|
||||
|
||||
/* Work around for file downloads where the response cannot contain have headers set */
|
||||
// if($request instanceOf BinaryFileResponse)
|
||||
// return $next($request);
|
||||
// else
|
||||
// return $next($request)
|
||||
// ->header('Access-Control-Allow-Origin', '*')
|
||||
// ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
|
||||
// ->header('Access-Control-Allow-Headers', 'X-API-SECRET,X-API-TOKEN,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range');
|
||||
|
||||
$response = $next($request);
|
||||
|
||||
$response->headers->set('Access-Control-Allow-Origin', '*');
|
||||
|
@ -53,7 +53,6 @@ class QueryLogging
|
||||
$time = $timeEnd - $timeStart;
|
||||
|
||||
nlog($request->method().' - '.urldecode($request->url()).": $count queries - ".$time);
|
||||
// nlog($request->method().' - '.urldecode($request->fullUrl()).": $count queries - ".$time);
|
||||
|
||||
// if($count > 50)
|
||||
//nlog($queries);
|
||||
|
@ -64,16 +64,6 @@ class StoreRecurringInvoiceRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
// foreach($this->input('documents') as $document)
|
||||
// {
|
||||
// if($document instanceof UploadedFile){
|
||||
// nlog("i am an uploaded file");
|
||||
// nlog($document);
|
||||
// }
|
||||
// else
|
||||
// nlog($document);
|
||||
// }
|
||||
|
||||
if (array_key_exists('design_id', $input) && is_string($input['design_id'])) {
|
||||
$input['design_id'] = $this->decodePrimaryKey($input['design_id']);
|
||||
}
|
||||
|
@ -59,10 +59,6 @@ class StoreUserRequest extends Request
|
||||
|
||||
//unique user rule - check company_user table for user_id / company_id / account_id if none exist we can add the user. ELSE return false
|
||||
|
||||
//nlog($this->all());
|
||||
//nlog($this->input('company_user.account'));
|
||||
// nlog($this->input('company_user.account.id'));
|
||||
// nlog($this->input('company_user.account.id'));
|
||||
|
||||
if (isset($input['company_user'])) {
|
||||
if (! isset($input['company_user']['is_admin'])) {
|
||||
|
@ -43,12 +43,12 @@ class CreateRecurringInvoiceActivity implements ShouldQueue
|
||||
|
||||
$fields = new stdClass;
|
||||
|
||||
$fields->recurring_invoice_id = $event->recurring_invoice_id->id;
|
||||
$fields->client_id = $event->recurring_invoice_id->client_id;
|
||||
$fields->user_id = $event->recurring_invoice_id->user_id;
|
||||
$fields->company_id = $event->recurring_invoice_id->company_id;
|
||||
$fields->recurring_invoice_id = $event->recurring_invoice->id;
|
||||
$fields->client_id = $event->recurring_invoice->client_id;
|
||||
$fields->user_id = $event->recurring_invoice->user_id;
|
||||
$fields->company_id = $event->recurring_invoice->company_id;
|
||||
$fields->activity_type_id = Activity::CREATE_RECURRING_INVOICE;
|
||||
|
||||
$this->activity_repo->save($fields, $event->recurring_invoice_id, $event->event_vars);
|
||||
$this->activity_repo->save($fields, $event->recurring_invoice, $event->event_vars);
|
||||
}
|
||||
}
|
||||
|
@ -4240,6 +4240,11 @@ $LANG = array(
|
||||
'migration_already_completed' => 'Company already migrated',
|
||||
'migration_already_completed_desc' => 'Looks like you already migrated <b> :company_name </b>to the V5 version of the Invoice Ninja. In case you want to start over, you can force migrate to wipe existing data.',
|
||||
|
||||
'activity_100' => ':user created recurring invoice :recurring_invoice',
|
||||
'activity_101' => ':user updated recurring invoice :recurring_invoice',
|
||||
'activity_102' => ':user archived recurring invoice :recurring_invoice',
|
||||
'activity_103' => ':user deleted recurring invoice :recurring_invoice',
|
||||
'activity_104' => ':user restored recurring invoice :recurring_invoice',
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -41,6 +41,11 @@ use App\Events\Quote\QuoteWasCreated;
|
||||
use App\Events\Quote\QuoteWasDeleted;
|
||||
use App\Events\Quote\QuoteWasRestored;
|
||||
use App\Events\Quote\QuoteWasUpdated;
|
||||
use App\Events\RecurringInvoice\RecurringInvoiceWasArchived;
|
||||
use App\Events\RecurringInvoice\RecurringInvoiceWasCreated;
|
||||
use App\Events\RecurringInvoice\RecurringInvoiceWasDeleted;
|
||||
use App\Events\RecurringInvoice\RecurringInvoiceWasRestored;
|
||||
use App\Events\RecurringInvoice\RecurringInvoiceWasUpdated;
|
||||
use App\Events\Subscription\SubscriptionWasArchived;
|
||||
use App\Events\Subscription\SubscriptionWasCreated;
|
||||
use App\Events\Subscription\SubscriptionWasDeleted;
|
||||
@ -68,6 +73,7 @@ use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -538,6 +544,76 @@ class EventTest extends TestCase
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testRecurringInvoiceEvents()
|
||||
{
|
||||
/* Test fire new invoice */
|
||||
$data = [
|
||||
'client_id' => $this->client->hashed_id,
|
||||
'number' => 'dudex',
|
||||
'frequency_id' => 1,
|
||||
];
|
||||
|
||||
$this->expectsEvents([
|
||||
RecurringInvoiceWasCreated::class,
|
||||
RecurringInvoiceWasUpdated::class,
|
||||
RecurringInvoiceWasArchived::class,
|
||||
RecurringInvoiceWasRestored::class,
|
||||
RecurringInvoiceWasDeleted::class,
|
||||
]);
|
||||
|
||||
try {
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/recurring_invoices/', $data);
|
||||
} catch (ValidationException $e) {
|
||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||
}
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
$data = [
|
||||
'client_id' => $this->client->hashed_id,
|
||||
'number' => 'dude2',
|
||||
'frequency_id' => 1,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->put('/api/v1/recurring_invoices/' . $arr['data']['id'], $data)
|
||||
->assertStatus(200);
|
||||
|
||||
|
||||
$data = [
|
||||
'ids' => [$arr['data']['id']],
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/recurring_invoices/bulk?action=archive', $data)
|
||||
->assertStatus(200);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/recurring_invoices/bulk?action=restore', $data)
|
||||
->assertStatus(200);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/recurring_invoices/bulk?action=delete', $data)
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testClientEvents()
|
||||
{
|
||||
$this->expectsEvents([
|
||||
|
Loading…
x
Reference in New Issue
Block a user