mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for bank rule tests
This commit is contained in:
parent
41dcb7cf4a
commit
d6f327c4ef
@ -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;
|
||||
|
@ -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']);
|
||||
|
@ -34,8 +34,15 @@
|
||||
<p class="text-gray-500 w-full"></p>
|
||||
<div class="flex place-content-end">
|
||||
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
|
||||
<input wire:model.debounce.300ms="data.{{ $index }}.recurring_qty" type="text" class="w-1/4 rounded-md border-gray-300 shadow-sm sm:text-sm text-center" placeholder="0"/>
|
||||
|
||||
<select wire:model.debounce.300ms="data.{{ $index }}.recurring_qty" class="rounded-md border-gray-300 shadow-sm sm:text-sm">
|
||||
<option value="1" selected="selected">1</option>
|
||||
@for ($i = 2; $i <= $subscription->max_seats_limit; $i++)
|
||||
<option value="{{$i}}">{{$i}}</option>
|
||||
@endfor
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
</div>
|
||||
@error("data.{$index}.recurring_qty")
|
||||
@ -102,16 +109,24 @@
|
||||
<h3>{!! nl2br($product->notes) !!}</h3>
|
||||
<p class="ml-0">{{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }} </p>
|
||||
</div>
|
||||
<p class="mt-1 text-sm text-gray-500"></p>
|
||||
|
||||
</div>
|
||||
<div class="flex content-end text-sm mt-1">
|
||||
<div class="flex justify-between text-sm mt-1">
|
||||
@if(is_numeric($product->custom_value2))
|
||||
<p class="text-gray-500 w-full"></p>
|
||||
<p class="text-gray-500 w-3/4"></p>
|
||||
<div class="flex place-content-end">
|
||||
@if($subscription->use_inventory_management && $product->in_stock_quantity == 0)
|
||||
<p class="w-full text-sm font-light text-red-500 text-right mr-2 mt-2">Out of stock</p>
|
||||
@else
|
||||
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
|
||||
<select wire:model.debounce.300ms="data.{{ $index }}.optional_recurring_qty" class="rounded-md border-gray-300 shadow-sm sm:text-sm">
|
||||
@endif
|
||||
<select wire:model.debounce.300ms="data.{{ $index }}.optional_recurring_qty" class="rounded-md border-gray-300 shadow-sm sm:text-sm"
|
||||
@if($subscription->use_inventory_management && $product->in_stock_quantity == 0)
|
||||
disabled
|
||||
@endif
|
||||
>
|
||||
<option value="0" selected="selected">0</option>
|
||||
@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++)
|
||||
<option value="{{$i}}">{{$i}}</option>
|
||||
@endfor
|
||||
</select>
|
||||
@ -138,18 +153,23 @@
|
||||
</div>
|
||||
<p class="mt-1 text-sm text-gray-500"></p>
|
||||
</div>
|
||||
<div class="flex content-end text-sm mt-1">
|
||||
<div class="flex justify-between text-sm mt-1">
|
||||
@if(is_numeric($product->custom_value2))
|
||||
<p class="text-gray-500 w-full"></p>
|
||||
<p class="text-gray-500 w-3/4"></p>
|
||||
<div class="flex place-content-end">
|
||||
@if($subscription->use_inventory_management && $product->in_stock_quantity == 0)
|
||||
<p class="w-full text-sm font-light text-red-500 text-right mr-2 mt-2">Out of stock</p>
|
||||
@else
|
||||
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
|
||||
@endif
|
||||
<select wire:model.debounce.300ms="data.{{ $index }}.optional_qty" class="rounded-md border-gray-300 shadow-sm sm:text-sm">
|
||||
<option value="0" selected="selected">0</option>
|
||||
@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++)
|
||||
<option value="{{$i}}">{{$i}}</option>
|
||||
@endfor
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@ -178,14 +198,14 @@
|
||||
<form wire:submit.prevent="handleCoupon" class="">
|
||||
@csrf
|
||||
<div class="mt-2">
|
||||
<label for="email" class="block text-sm font-medium text-white">{{ ctrans('texts.promo_code') }}</label>
|
||||
<label for="coupon" class="block text-sm font-medium text-white">{{ ctrans('texts.promo_code') }}</label>
|
||||
<div class="mt-1 flex rounded-md shadow-sm">
|
||||
<div class="relative flex flex-grow items-stretch focus-within:z-10">
|
||||
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
|
||||
</div>
|
||||
<input type="text" wire:model.debounce.300ms="coupon" class="block w-full rounded-none rounded-l-md border-gray-300 pl-10 focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="">
|
||||
<input type="text" wire:model.debounce.300ms="coupon" class="block w-full rounded-none rounded-l-md border-gray-300 pl-2 focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-700" placeholder="">
|
||||
</div>
|
||||
<button type="button" class="relative -ml-px inline-flex items-center space-x-2 rounded-r-md border border-gray-300 bg-gray-50 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500">
|
||||
<button class="relative -ml-px inline-flex items-center space-x-2 rounded-r-md border border-gray-300 bg-gray-50 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500">
|
||||
|
||||
<span>{{ ctrans('texts.apply') }}</span>
|
||||
</button>
|
||||
@ -195,6 +215,13 @@
|
||||
@endif
|
||||
|
||||
<div class="border-t-2 border-gray-200 border-opacity-50 mt-8">
|
||||
|
||||
@if($discount)
|
||||
<div class="flex font-semibold justify-between py-6 text-sm uppercase">
|
||||
<span>{{ ctrans('texts.discount') }}</span>
|
||||
<span>{{ $discount }}</span>
|
||||
</div>
|
||||
@endif
|
||||
<div class="flex font-semibold justify-between py-6 text-sm uppercase">
|
||||
<span>{{ ctrans('texts.total') }}</span>
|
||||
<span>{{ $total }}</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user