mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor purchase context and dispatch purchase next
This commit is contained in:
parent
f119c26905
commit
9acdb89ab8
@ -46,21 +46,21 @@ class Methods extends Component
|
|||||||
{
|
{
|
||||||
/** @var \App\Models\ClientContact $contact */
|
/** @var \App\Models\ClientContact $contact */
|
||||||
$contact = auth()->guard('contact')->user();
|
$contact = auth()->guard('contact')->user();
|
||||||
|
|
||||||
$this->dispatch('purchase.context', property: 'client_id', value: $contact->client->hashed_id);
|
$this->dispatch('purchase.context', property: 'client_id', value: $contact->client->hashed_id);
|
||||||
|
|
||||||
$this->context['client_id'] = $contact->client->hashed_id;
|
$this->context['client_id'] = $contact->client->hashed_id;
|
||||||
|
|
||||||
nlog($this->context);
|
nlog($this->context);
|
||||||
|
|
||||||
$invoice = $this->subscription
|
$invoice = $this->subscription
|
||||||
->calc()
|
->calc()
|
||||||
->buildPurchaseInvoice($this->context)
|
->buildPurchaseInvoice($this->context)
|
||||||
->service()
|
->service()
|
||||||
->fillDefaults()
|
->fillDefaults()
|
||||||
->adjustInventory()
|
->adjustInventory()
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
Cache::put($this->context['hash'], [
|
Cache::put($this->context['hash'], [
|
||||||
'subscription_id' => $this->subscription->hashed_id,
|
'subscription_id' => $this->subscription->hashed_id,
|
||||||
'email' => $contact->email,
|
'email' => $contact->email,
|
||||||
@ -71,7 +71,16 @@ class Methods extends Component
|
|||||||
'bundle' => $this->context['bundle'],
|
'bundle' => $this->context['bundle'],
|
||||||
], now()->addMinutes(60));
|
], now()->addMinutes(60));
|
||||||
|
|
||||||
|
$payable_amount = $invoice->partial > 0
|
||||||
|
? \App\Utils\Number::formatValue($invoice->partial, $invoice->client->currency())
|
||||||
|
: \App\Utils\Number::formatValue($invoice->balance, $invoice->client->currency());
|
||||||
|
|
||||||
|
$this->dispatch('purchase.context', property: 'form.company_gateway_id', value: $company_gateway_id);
|
||||||
|
$this->dispatch('purchase.context', property: 'form.payment_method_id', value: $gateway_type_id);
|
||||||
|
$this->dispatch('purchase.context', property: 'form.invoice_hashed_id', value: $invoice->hashed_id);
|
||||||
|
$this->dispatch('purchase.context', property: 'form.payable_amount', value: $payable_amount);
|
||||||
|
|
||||||
|
$this->dispatch('purchase.next');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user