Skip to content

Commit b31d29e

Browse files
committed
Updated tax rates
1 parent 8220b93 commit b31d29e

File tree

6 files changed

+73
-21
lines changed

6 files changed

+73
-21
lines changed

resources/lang/en/lang.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,5 +438,6 @@
438438
'rate' => 'rate',
439439
'add_tax_rate' => 'add tax rate',
440440
'back_to_tax_rates' => 'back to tax rates',
441-
'edit_tax_rate' => 'edit tax rate'
441+
'edit_tax_rate' => 'edit tax rate',
442+
'tax_rate_percent' => 'tax rate %'
442443
];
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<div>
2+
<div class="row">
3+
<div class="col-sm-6">
4+
@include('laravel-crm::partials.form.select',[
5+
'name' => 'tax_rate_id',
6+
'label' => ucfirst(__('laravel-crm::lang.tax_rate')),
7+
'options' => ['' => ''] + \VentureDrake\LaravelCrm\Models\TaxRate::pluck('name', 'id')->toArray(),
8+
'attributes' => [
9+
'wire:model' => 'tax_rate_id'
10+
]
11+
])
12+
</div>
13+
<div class="col-sm-6">
14+
@include('laravel-crm::partials.form.text',[
15+
'name' => 'tax_rate',
16+
'label' => ucfirst(__('laravel-crm::lang.tax_rate_percent')),
17+
'append' => '<span class="fa fa-percent" aria-hidden="true"></span>',
18+
'attributes' => [
19+
'wire:model' => 'tax_rate',
20+
'readonly' => 'readonly'
21+
]
22+
])
23+
</div>
24+
</div>
25+
</div>

resources/views/products/partials/card-show.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
<dd class="col-sm-9">{{ $product->sales_account }}</dd>
4545
<dt class="col-sm-3 text-right">{{ ucfirst(__('laravel-crm::lang.unit')) }}</dt>
4646
<dd class="col-sm-9">{{ $product->unit }}</dd>
47-
<dt class="col-sm-3 text-right">{{ ucfirst(__('laravel-crm::lang.tax')) }}</dt>
48-
<dd class="col-sm-9">{{ $product->taxRate->name }}</dd>
4947
<dt class="col-sm-3 text-right">{{ ucfirst(__('laravel-crm::lang.tax_rate')) }}</dt>
48+
<dd class="col-sm-9">{{ $product->taxRate->name ?? null }}</dd>
49+
<dt class="col-sm-3 text-right">{{ ucfirst(__('laravel-crm::lang.tax_rate_percent')) }}</dt>
5050
<dd class="col-sm-9">{{ $product->tax_rate ?? $product->taxRate->rate ?? 0 }}%</dd>
5151
<dt class="col-sm-3 text-right">{{ ucfirst(__('laravel-crm::lang.category')) }}</dt>
5252
<dd class="col-sm-9">{{ $product->productCategory->name ?? null }}</dd>

resources/views/products/partials/fields.blade.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,9 @@
6666
])
6767
</div>
6868
</div>
69-
<div class="row">
70-
<div class="col-sm-6">
71-
@include('laravel-crm::partials.form.select',[
72-
'name' => 'tax_rate_id',
73-
'label' => ucfirst(__('laravel-crm::lang.tax')),
74-
'options' => ['' => ''] + \VentureDrake\LaravelCrm\Models\TaxRate::pluck('name', 'id')->toArray(),
75-
'value' => old('tax_rate_id', (isset($product) ? $product->taxRate->id ?? null : null))
76-
])
77-
</div>
78-
<div class="col-sm-6">
79-
@include('laravel-crm::partials.form.text',[
80-
'name' => 'tax_rate',
81-
'label' => ucfirst(__('laravel-crm::lang.tax_rate')),
82-
'append' => '<span class="fa fa-percent" aria-hidden="true"></span>',
83-
'value' => old('tax_rate', $product->tax_rate ?? null)
84-
])
85-
</div>
86-
</div>
69+
@livewire('product-form',[
70+
'product' => $product ?? null
71+
])
8772
<div class="row">
8873
<div class="col-sm-6">
8974
@include('laravel-crm::partials.form.select',[
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace VentureDrake\LaravelCrm\Http\Livewire;
4+
5+
use Livewire\Component;
6+
use VentureDrake\LaravelCrm\Models\TaxRate;
7+
use VentureDrake\LaravelCrm\Services\SettingService;
8+
9+
class LiveProductForm extends Component
10+
{
11+
private $settingService;
12+
public $tax_rate_id;
13+
public $tax_rate;
14+
15+
public function boot(SettingService $settingService)
16+
{
17+
$this->settingService = $settingService;
18+
}
19+
20+
public function mount($product)
21+
{
22+
$this->tax_rate_id = old('tax_rate_id') ?? $product->taxRate->id ?? null;
23+
$this->tax_rate = old('tax_rate') ?? $product->tax_rate ?? $product->taxRate->rate ?? null;
24+
}
25+
26+
public function updatedTaxRateId($value)
27+
{
28+
if($value) {
29+
$this->tax_rate = TaxRate::find($value)->rate;
30+
} else {
31+
$this->tax_rate = number_format($this->settingService->get('tax_rate')->value ?? 0, 2);
32+
}
33+
}
34+
35+
public function render()
36+
{
37+
return view('laravel-crm::livewire.product-form');
38+
}
39+
}

src/LaravelCrmServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use VentureDrake\LaravelCrm\Http\Livewire\LiveOrderForm;
4747
use VentureDrake\LaravelCrm\Http\Livewire\LiveOrderItems;
4848
use VentureDrake\LaravelCrm\Http\Livewire\LivePhoneEdit;
49+
use VentureDrake\LaravelCrm\Http\Livewire\LiveProductForm;
4950
use VentureDrake\LaravelCrm\Http\Livewire\LiveQuoteForm;
5051
use VentureDrake\LaravelCrm\Http\Livewire\LiveQuoteItems;
5152
use VentureDrake\LaravelCrm\Http\Livewire\LiveRelatedContactOrganisation;
@@ -480,6 +481,7 @@ function ($perPage = 30, $page = null, $options = []) {
480481
Livewire::component('invoice-lines', LiveInvoiceLines::class);
481482
Livewire::component('send-invoice', SendInvoice::class);
482483
Livewire::component('pay-invoice', PayInvoice::class);
484+
Livewire::component('product-form', LiveProductForm::class);
483485

484486
if ($this->app->runningInConsole()) {
485487
$this->app->booted(function () {

0 commit comments

Comments
 (0)