diff --git a/app/Http/Livewire/BillingPortalPurchasev2.php b/app/Http/Livewire/BillingPortalPurchasev2.php index 1cfc3df365be..f2d3ad226a56 100644 --- a/app/Http/Livewire/BillingPortalPurchasev2.php +++ b/app/Http/Livewire/BillingPortalPurchasev2.php @@ -188,12 +188,13 @@ class BillingPortalPurchasev2 extends Component public $optional_recurring_products; public $optional_products; public $total; + public $discount; public function mount() { MultiDB::setDb($this->company->db); - $this->quantity = 1; + $this->discount = 0; $this->data = []; @@ -310,23 +311,19 @@ class BillingPortalPurchasev2 extends Component public function updatedData() { + } public function updating($prop) { - // $this->resetValidation($prop); - // $this->resetErrorBag($prop); + } public function updated($propertyName) { - $x = $this->validateOnly($propertyName, $this->rules(), [], $this->attributes()); - // // $validatedData = $this->validate(); $this->buildBundle(); - // $order_validator = Validator::make($this->all(), $this->rules(), [], $this->attributes()); - } public function rules() @@ -526,7 +523,7 @@ class BillingPortalPurchasev2 extends Component ]], 'user_input_promo_code' => $this->coupon, 'coupon' => empty($this->subscription->promo_code) ? '' : $this->coupon, - 'quantity' => $this->quantity, + // 'quantity' => $this->quantity, ]; $is_eligible = $this->subscription->service()->isEligible($this->contact); @@ -569,7 +566,7 @@ class BillingPortalPurchasev2 extends Component { return $this->subscription->service()->startTrial([ 'email' => $this->email ?? $this->contact->email, - 'quantity' => $this->quantity, + // 'quantity' => $this->quantity, 'contact_id' => $this->contact->id, 'client_id' => $this->contact->client->id, ]); @@ -598,41 +595,11 @@ class BillingPortalPurchasev2 extends Component ]); } - /** - * Update quantity property. - * - * @param string $option - * @return int - */ - public function updateQuantity(string $option): int - { - $this->handleCoupon(); - - if ($this->quantity == 1 && $option == 'decrement') { - $this->price = $this->price * 1; - return $this->quantity; - } - - if ($this->quantity > $this->subscription->max_seats_limit && $option == 'increment') { - $this->price = $this->price * $this->subscription->max_seats_limit; - return $this->quantity; - } - - if ($option == 'increment') { - $this->quantity++; - $this->price = $this->price * $this->quantity; - return $this->quantity; - } - - $this->quantity--; - $this->price = $this->price * $this->quantity; - - return $this->quantity; - } - public function handleCoupon() { + nlog("coupy coup"); + if($this->steps['discount_applied']){ $this->price = $this->subscription->promo_price; return; diff --git a/app/Services/Bank/ProcessBankRules.php b/app/Services/Bank/ProcessBankRules.php index 2a2c2bae63bb..99ef98064a02 100644 --- a/app/Services/Bank/ProcessBankRules.php +++ b/app/Services/Bank/ProcessBankRules.php @@ -44,12 +44,6 @@ class ProcessBankRules extends AbstractService private function matchCredit() { - $this->credit_rules = $this->bank_transaction->company->credit_rules(); - - if(!is_array($this->credit_rules)) - return; - - $this->invoices = Invoice::where('company_id', $this->bank_transaction->company_id) ->whereIn('status_id', [1,2,3]) ->where('is_deleted', 0) @@ -69,6 +63,8 @@ class ProcessBankRules extends AbstractService return; } + $this->credit_rules = $this->bank_transaction->company->credit_rules(); + //stub for credit rules foreach($this->credit_rules as $rule) { @@ -85,14 +81,16 @@ class ProcessBankRules extends AbstractService $this->categories = collect(Cache::get('bank_categories')); - if(!is_array($this->debit_rules)) - return; + foreach($this->debit_rules as $bank_transaction_rule) { $matches = 0; + if(!is_array($bank_transaction_rule['rules'])) + continue; + foreach($bank_transaction_rule['rules'] as $rule) { $rule_count = count($bank_transaction_rule['rules']); diff --git a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php index 1eb309caae87..98d41f7e2929 100644 --- a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchasev2.blade.php @@ -34,8 +34,15 @@

{{ ctrans('texts.qty') }}

- + +
+ @endif @error("data.{$index}.recurring_qty") @@ -102,16 +109,24 @@

{!! nl2br($product->notes) !!}

{{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }}

-

+ -
+
@if(is_numeric($product->custom_value2)) -

+

+ @if($subscription->use_inventory_management && $product->in_stock_quantity == 0) +

Out of stock

+ @else

{{ ctrans('texts.qty') }}

- use_inventory_management && $product->in_stock_quantity == 0) + disabled + @endif + > - @for ($i = 1; $i < $product->custom_value2; $i++) + @for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product->in_stock_quantity,$product->custom_value2) : $product->custom_value2); $i++) @endfor @@ -138,18 +153,23 @@

-
+
@if(is_numeric($product->custom_value2)) -

+

+ @if($subscription->use_inventory_management && $product->in_stock_quantity == 0) +

Out of stock

+ @else

{{ ctrans('texts.qty') }}

+ @endif
+ @endif
@@ -175,30 +195,37 @@ @endforeach @if(!empty($subscription->promo_code) && !$subscription->trial_enabled) -
- @csrf -
- -
-
-
+ + @csrf +
+ +
+
+
+
+ +
+
-
- -
-
- + @endif
-
- {{ ctrans('texts.total') }} - {{ $total }} -
+ + @if($discount) +
+ {{ ctrans('texts.discount') }} + {{ $discount }} +
+ @endif +
+ {{ ctrans('texts.total') }} + {{ $total }} +