Working on templates

This commit is contained in:
David Bomba 2020-10-09 12:59:59 +11:00
parent 7f31d076b6
commit cf7ee6338e
4 changed files with 34 additions and 5 deletions

View File

@ -22,6 +22,7 @@ use App\Utils\Traits\MakesDates;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
/** /**
* Class InvitationController. * Class InvitationController.
@ -33,9 +34,10 @@ class InvitationController extends Controller
public function router(string $entity, string $invitation_key) public function router(string $entity, string $invitation_key)
{ {
$key = $entity.'_id'; $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]) $invitation = $entity_obj::whereRaw('BINARY `key`= ?', [$invitation_key])
->with('contact.client') ->with('contact.client')

View File

@ -65,8 +65,27 @@ class StartupCheck
} }
} }
/*Build template cache*/
$name = 'templates';
if ($request->has('clear_cache') || ! Cache::has($name)) {
}
$response = $next($request); $response = $next($request);
return $response; return $response;
} }
private function buildTemplates()
{
$data = [];
$data['invoice'][
'subject' => EmailTemplateDefaults::emailInvoiceSubject(),
'body' => EmailTemplateDefaults::emailInvoiceTemplate),
]
}
} }

View File

@ -53,7 +53,8 @@ class AutoBillInvoice extends AbstractService
if ((int)$this->invoice->balance == 0) if ((int)$this->invoice->balance == 0)
return $this->invoice->service()->markPaid()->save(); 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 */ /* Determine $amount */
if ($this->invoice->partial > 0) if ($this->invoice->partial > 0)
@ -70,7 +71,7 @@ class AutoBillInvoice extends AbstractService
return $this->invoice; return $this->invoice;
/* $gateway fee */ /* $gateway fee */
$fee = $gateway_token->gateway->calcGatewayFee($this->invoice->partial); $fee = $gateway_token->gateway->calcGatewayFee($amount);
/* Build payment hash */ /* Build payment hash */
$payment_hash = PaymentHash::create([ $payment_hash = PaymentHash::create([
@ -98,7 +99,7 @@ class AutoBillInvoice extends AbstractService
info("finalizing"); info("finalizing");
info(print_r($this->used_credit,1)); info(print_r($this->used_credit,1));
$amount = array_sum(array_column($this->used_credit, 'amount')); $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 = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id);
$payment->amount = $amount; $payment->amount = $amount;

View File

@ -55,12 +55,19 @@ class RecurringService
if($this->recurring_entity->remaining_cycles == 0) if($this->recurring_entity->remaining_cycles == 0)
return $this; return $this;
$this->recurring_entity->status_id = RecurringInvoice::STATUS_ACTIVE; $this->createInvitations()->setStatus(RecurringInvoice::STATUS_ACTIVE);
return $this; return $this;
} }
public function setStatus($status)
{
$this->recurring_entity->status_id = $status;
return $this;
}
/** /**
* Applies the invoice number. * Applies the invoice number.
* @return $this InvoiceService object * @return $this InvoiceService object