diff --git a/app/Http/Controllers/ClientPortal/InvitationController.php b/app/Http/Controllers/ClientPortal/InvitationController.php index e891f57691..7cb3c536d8 100644 --- a/app/Http/Controllers/ClientPortal/InvitationController.php +++ b/app/Http/Controllers/ClientPortal/InvitationController.php @@ -22,6 +22,7 @@ use App\Utils\Traits\MakesDates; use App\Utils\Traits\MakesHash; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Str; /** * Class InvitationController. @@ -33,9 +34,10 @@ class InvitationController extends Controller public function router(string $entity, string $invitation_key) { + $key = $entity.'_id'; - $entity_obj = 'App\Models\\'.ucfirst($entity).'Invitation'; + $entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation'; //todo sensitive to the route parameters here $invitation = $entity_obj::whereRaw('BINARY `key`= ?', [$invitation_key]) ->with('contact.client') diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index acb9e53e04..cc3e892475 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -65,8 +65,27 @@ class StartupCheck } } + + /*Build template cache*/ + $name = 'templates'; + + if ($request->has('clear_cache') || ! Cache::has($name)) { + + } + $response = $next($request); return $response; } + + + private function buildTemplates() + { + $data = []; + + $data['invoice'][ + 'subject' => EmailTemplateDefaults::emailInvoiceSubject(), + 'body' => EmailTemplateDefaults::emailInvoiceTemplate), + ] + } } diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 4d3b0781ae..f94a4d98ef 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -53,7 +53,8 @@ class AutoBillInvoice extends AbstractService if ((int)$this->invoice->balance == 0) return $this->invoice->service()->markPaid()->save(); - $this->applyCreditPayment(); //if the credits cover the payments, we stop here, build the payment with credits and exit early + //if the credits cover the payments, we stop here, build the payment with credits and exit early + $this->applyCreditPayment(); /* Determine $amount */ if ($this->invoice->partial > 0) @@ -70,7 +71,7 @@ class AutoBillInvoice extends AbstractService return $this->invoice; /* $gateway fee */ - $fee = $gateway_token->gateway->calcGatewayFee($this->invoice->partial); + $fee = $gateway_token->gateway->calcGatewayFee($amount); /* Build payment hash */ $payment_hash = PaymentHash::create([ @@ -98,7 +99,7 @@ class AutoBillInvoice extends AbstractService info("finalizing"); info(print_r($this->used_credit,1)); $amount = array_sum(array_column($this->used_credit, 'amount')); - info("amount {$amount}"); + info("amount {$amount}"); $payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id); $payment->amount = $amount; diff --git a/app/Services/Recurring/RecurringService.php b/app/Services/Recurring/RecurringService.php index 7cbfa0e8b1..56b75f5e67 100644 --- a/app/Services/Recurring/RecurringService.php +++ b/app/Services/Recurring/RecurringService.php @@ -55,12 +55,19 @@ class RecurringService if($this->recurring_entity->remaining_cycles == 0) return $this; - $this->recurring_entity->status_id = RecurringInvoice::STATUS_ACTIVE; + $this->createInvitations()->setStatus(RecurringInvoice::STATUS_ACTIVE); return $this; } + public function setStatus($status) + { + $this->recurring_entity->status_id = $status; + + return $this; + } + /** * Applies the invoice number. * @return $this InvoiceService object