mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Updates for logic
This commit is contained in:
parent
c010c99547
commit
f3f91f75b8
@ -37,8 +37,10 @@ class Methods extends Component
|
||||
|
||||
public function handleSelect(string $company_gateway_id, string $gateway_type_id)
|
||||
{
|
||||
|
||||
$this->dispatch('purchase.context', property: 'client_id', value: auth()->guard('contact')->user()->client->hashed_id);
|
||||
/** @var \App\Models\ClientContact $contact */
|
||||
$contact = auth()->guard('contact')->user();
|
||||
|
||||
$this->dispatch('purchase.context', property: 'client_id', value: $contact->client->hashed_id);
|
||||
|
||||
nlog($this->context);
|
||||
|
||||
@ -50,12 +52,10 @@ class Methods extends Component
|
||||
->adjustInventory()
|
||||
->save();
|
||||
|
||||
|
||||
|
||||
Cache::put($this->hash, [
|
||||
Cache::put($this->context['hash'], [
|
||||
'subscription_id' => $this->subscription->hashed_id,
|
||||
'email' => auth()->guard('contact')->user()->email,
|
||||
'client_id' => auth()->guard('contact')->user()->client->hashed_id,
|
||||
'email' => $contact->email,
|
||||
'client_id' => $contact->client->hashed_id,
|
||||
'invoice_id' => $invoice->hashed_id,
|
||||
'context' => 'purchase',
|
||||
'campaign' => $this->context['campaign'],
|
||||
|
@ -47,6 +47,97 @@ class Purchase extends Component
|
||||
|
||||
public string $id;
|
||||
|
||||
/** $context = [
|
||||
* 'hash' => string,
|
||||
* 'quantity' => int,
|
||||
* 'request_data' => [
|
||||
* 'q' => string,
|
||||
* ],
|
||||
* 'campaign => ?string,
|
||||
* 'bundle' => $bundle,
|
||||
* 'contact' => [
|
||||
* 'first_name' => ?string,
|
||||
* 'last_name' => ?string,
|
||||
* 'phone' => ?string,
|
||||
* 'custom_value1' => ?string,
|
||||
* 'custom_value2' => ?string,
|
||||
* 'custom_value3' => ?string,
|
||||
* 'custom_value4' => ?string,
|
||||
* 'email' => ?string,
|
||||
* 'email_verified_at' => ?int,
|
||||
* 'confirmation_code' => ?string,
|
||||
* 'is_primary' => bool,
|
||||
* 'confirmed' => bool,
|
||||
* 'last_login' => ?datetime,
|
||||
* 'failed_logins' => ?int,
|
||||
* 'accepted_terms_version' => ?string,
|
||||
* 'avatar' => ?string,
|
||||
* 'avatar_type' => ?string,
|
||||
* 'avatar_size' => ?string,
|
||||
* 'is_locked' => bool,
|
||||
* 'send_email' => bool,
|
||||
* 'contact_key' => string,
|
||||
* 'created_at' => int,
|
||||
* 'updated_at' => int,
|
||||
* 'deleted_at' => int,
|
||||
* 'hashed_id' => string,
|
||||
* ],
|
||||
* 'client_id' => string,
|
||||
* 'quantity' => int,
|
||||
* 'products' => [
|
||||
* [
|
||||
* 'product_key' => string,
|
||||
* 'quantity' => int,
|
||||
* 'total_raw' => float,
|
||||
* 'total' => string,
|
||||
* ],
|
||||
* ]
|
||||
* ];
|
||||
*
|
||||
* $bundle =[
|
||||
* 'optional_one_time_products' => array,
|
||||
* 'one_time_products' => array,
|
||||
* 'optional_recurring_products' => array,
|
||||
* 'recurring_products' => [
|
||||
* 'hashed_id' => [
|
||||
* 'product' => [
|
||||
* 'id' => int,
|
||||
* 'company_id' => int,
|
||||
* 'user_id' => int,
|
||||
* 'assigned_user_id' => ?int,
|
||||
* 'project_id' => ?int,
|
||||
* 'vendor_id' => ?int,
|
||||
* 'custom_value1' => ?string,
|
||||
* 'custom_value2' => ?string,
|
||||
* 'custom_value3' => ?string,
|
||||
* 'custom_value4' => ?string,
|
||||
* 'product_key' => ?string,
|
||||
* 'notes' => ?string,
|
||||
* 'cost' => float,
|
||||
* 'price' => float,
|
||||
* 'quantity' => float,
|
||||
* 'tax_name1' => ?string,
|
||||
* 'tax_rate1' => float,
|
||||
* 'tax_name2' => ?string,
|
||||
* 'tax_rate2' => float,
|
||||
* 'tax_name3' => ?string,
|
||||
* 'tax_rate3' => float,
|
||||
* 'deleted_at' => ?int,
|
||||
* 'created_at' => ?int,
|
||||
* 'updated_at' => ?int,
|
||||
* 'is_deleted' => bool,
|
||||
* 'in_stock_quantity' => ?int,
|
||||
* 'stock_notification' => bool,
|
||||
* 'stock_notification_threshold' => ?int,
|
||||
* 'max_quantity' => ?int,
|
||||
* 'product_image' => ?string,
|
||||
* 'tax_id' => ?int,
|
||||
* 'hashed_id' => ?string,
|
||||
* ],
|
||||
* ],
|
||||
* ],
|
||||
* ] $bundle
|
||||
*/
|
||||
public array $context = [];
|
||||
|
||||
#[On('purchase.context')]
|
||||
|
@ -133,7 +133,8 @@ class Summary extends Component
|
||||
if (isset($this->context['bundle']) === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$products = [];
|
||||
|
||||
foreach ($this->context['bundle']['recurring_products'] as $key => $item) {
|
||||
$products[] = [
|
||||
'product_key' => $item['product']['product_key'],
|
||||
|
@ -35,7 +35,6 @@ class SubscriptionCalculator
|
||||
{
|
||||
|
||||
$invoice_repo = new InvoiceRepository();
|
||||
$subscription_repo = new SubscriptionRepository();
|
||||
|
||||
$invoice = InvoiceFactory::create($this->subscription->company_id, $this->subscription->user_id);
|
||||
$invoice->subscription_id = $this->subscription->id;
|
||||
@ -55,8 +54,7 @@ class SubscriptionCalculator
|
||||
|
||||
/**
|
||||
* Build Line Items
|
||||
*
|
||||
* @param array $context
|
||||
* @param array $context
|
||||
* @return array
|
||||
*/
|
||||
private function buildItems(array $context): array
|
||||
|
Loading…
Reference in New Issue
Block a user