Fix for invite resend permission

This commit is contained in:
David Bomba 2021-03-16 07:35:19 +11:00
parent 6a2332526b
commit 1e72f20c3d
4 changed files with 43 additions and 14 deletions

View File

@ -68,9 +68,9 @@ class UpdatePaymentRequest extends Request
unset($input['amount']); unset($input['amount']);
} }
if (isset($input['number'])) { // if (isset($input['number'])) {
unset($input['number']); // unset($input['number']);
} // }
if (isset($input['invoices']) && is_array($input['invoices']) !== false) { if (isset($input['invoices']) && is_array($input['invoices']) !== false) {
foreach ($input['invoices'] as $key => $value) { foreach ($input['invoices'] as $key => $value) {

View File

@ -23,6 +23,6 @@ class ReconfirmUserRequest extends Request
*/ */
public function authorize() : bool public function authorize() : bool
{ {
return auth()->user()->id == $this->user->id; return auth()->user()->id == $this->user->id || auth()->user()->isAdmin();
} }
} }

View File

@ -11,6 +11,8 @@
namespace App\Services\BillingSubscription; namespace App\Services\BillingSubscription;
use App\Models\ClientSubscription;
class BillingSubscriptionService class BillingSubscriptionService
{ {
@ -24,11 +26,37 @@ class BillingSubscriptionService
public function createInvoice($payment_hash) public function createInvoice($payment_hash)
{ {
//create the invoice if necessary ie. only is a payment was actually processed //create the invoice if necessary ie. only is a payment was actually processed
/*
If trial_enabled -> return early
-- what we need to know that we don't already
-- Has a promo code been entered, and does it match
-- Is this a recurring subscription
--
1. Is this a recurring product?
2. What is the quantity? ie is this a multi seat product ( does this mean we need this value stored in the client sub?)
*/
} }
public function createClientSubscription($payment_hash) private function convertInvoiceToRecurring()
{
//The first invoice is a plain invoice - the second is fired on the recurring schedule.
}
public function createClientSubscription($payment_hash, $recurring_invoice_id = null)
{ {
//create the client sub record //create the client sub record
//?trial enabled?
$cs = new ClientSubscription();
$cs->subscription_id = $this->billing_subscription->id;
$cs->company_id = $this->billing_subscription->company_id;
// client_id
$cs->save();
} }
public function triggerWebhook($payment_hash) public function triggerWebhook($payment_hash)

View File

@ -16,6 +16,7 @@ use App\Models\Client;
use App\Models\Document; use App\Models\Document;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\InvoiceInvitation; use App\Models\InvoiceInvitation;
use App\Models\Payment;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
class InvoiceTransformer extends EntityTransformer class InvoiceTransformer extends EntityTransformer
@ -30,7 +31,7 @@ class InvoiceTransformer extends EntityTransformer
protected $availableIncludes = [ protected $availableIncludes = [
// 'invitations', // 'invitations',
'history', 'history',
// 'payments', 'payments',
'client', 'client',
// 'documents', // 'documents',
]; ];
@ -56,15 +57,15 @@ class InvoiceTransformer extends EntityTransformer
return $this->includeItem($invoice->client, $transformer, Client::class); return $this->includeItem($invoice->client, $transformer, Client::class);
} }
public function includePayments(Invoice $invoice)
{
$transformer = new PaymentTransformer( $this->serializer);
return $this->includeCollection($invoice->payments, $transformer, Payment::class);
}
/* /*
public function includePayments(Invoice $invoice)
{
$transformer = new PaymentTransformer($this->account, $this->serializer, $invoice);
return $this->includeCollection($invoice->payments, $transformer, ENTITY_PAYMENT);
}
public function includeExpenses(Invoice $invoice) public function includeExpenses(Invoice $invoice)
{ {
$transformer = new ExpenseTransformer($this->account, $this->serializer); $transformer = new ExpenseTransformer($this->account, $this->serializer);