Skip to content

Commit bba8afa

Browse files
committed
Add handle to Tax Rate
Add clear function to TaxEvent to fetch tax rate in event Tax interface tidy Adjust package version
1 parent d8f2ad4 commit bba8afa

File tree

5 files changed

+55
-10
lines changed

5 files changed

+55
-10
lines changed

controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Controller extends Package implements ProviderAggregateInterface
2727
{
2828
protected $pkgHandle = 'community_store';
2929
protected $appVersionRequired = '8.5';
30-
protected $pkgVersion = '2.7.5';
30+
protected $pkgVersion = '2.7.6-alpha1';
3131

3232
protected $npmPackages = [
3333
'sysend' => '1.3.4',

controllers/single_page/dashboard/store/settings/tax.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public function add_rate()
6565
{
6666
$data = $this->request->request->all();
6767
$errors = $this->validate($data);
68-
$this->error = null; //clear errors
6968
$this->error = $errors;
7069
if (!$errors->has()) {
7170
TaxRate::add($data);
@@ -83,7 +82,6 @@ public function add_rate()
8382
if ($this->request->request->get('taxRateID')) {
8483
$this->edit($this->request->request->get('taxRateID'));
8584
} else {
86-
//first we send the data to the shipping method type.
8785
$this->add();
8886
}
8987
}
@@ -95,14 +93,24 @@ public function validate($data)
9593
$e = $this->app->make('helper/validation/error');
9694

9795
if ("" == $data['taxLabel']) {
98-
$e->add(t("You need a label for this Tax Rate"));
96+
$e->add(t("Tax Rate Label required"));
97+
}
98+
99+
if ("" == $data['taxHandle']) {
100+
$e->add(t("Tax Rate Handle required"));
101+
} else {
102+
$vs = $this->app->make('helper/validation/strings');
103+
if (!$vs->handle($data['taxHandle'])) {
104+
$e->add(t('A valid handle must contain no punctuation or spaces.'));
105+
}
99106
}
107+
100108
if ("" != $data['taxRate']) {
101109
if (!is_numeric($data['taxRate'])) {
102110
$e->add(t("Tax Rate must be a number"));
103111
}
104112
} else {
105-
$e->add(t("You need to enter a tax rate"));
113+
$e->add(t("Tax Rate required"));;
106114
}
107115

108116
return $e;

single_pages/dashboard/store/settings/tax.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<div class="row">
2424
<div class="col-md-12 col-sm-4">
2525
<div class="form-group">
26-
<?= $form->label('taxEnabled', t('Enable Tax Rate')); ?>
26+
<?= $form->label('taxEnabled', t('Enable')); ?>
2727
<?= $form->select('taxEnabled', [false => t('No'), true => t('Yes')], $taxRate->isEnabled()); ?>
2828
</div>
2929
</div>
@@ -33,6 +33,12 @@
3333
<?= $form->text('taxLabel', $taxRate->getTaxLabel()); ?>
3434
</div>
3535
</div>
36+
<div class="col-md-12 col-sm-4">
37+
<div class="form-group">
38+
<?= $form->label('taxHandle', t('Handle')); ?>
39+
<?= $form->text('taxHandle', $taxRate->getTaxHandle()); ?>
40+
</div>
41+
</div>
3642
<div class="col-md-12 col-sm-4">
3743
<div class="form-group">
3844
<?= $form->label('taxRate', t('Tax Rate %')); ?>
@@ -151,7 +157,7 @@
151157

152158
<div class="dashboard-tax-rates">
153159

154-
<table class="table table-striped">
160+
<table class="table table-striped mb-5">
155161
<thead>
156162
<tr>
157163
<th><?= t("Tax Class"); ?></th>
@@ -171,7 +177,7 @@
171177
$taxClassRates = $tc->getTaxClassRates();
172178
if ($taxClassRates) {
173179
foreach ($taxClassRates as $taxRate) {
174-
echo '<span class="label label-primary">' . $taxRate->getTaxLabel() . '</span> ';
180+
echo '<span class="badge bg-primary text-white label label-primary">' . e($taxRate->getTaxLabel()) . '</span> ';
175181
}
176182
} else {
177183
?>
@@ -199,6 +205,7 @@
199205
<thead>
200206
<tr>
201207
<th><?= t("Tax Rate"); ?></th>
208+
<th><?= t("Handle"); ?></th>
202209
<th><?= t("Rate"); ?></th>
203210
<th><?= t("Enabled"); ?></th>
204211
<th><?= t('Applies To'); ?></th>
@@ -211,7 +218,8 @@
211218
<?php foreach ($taxRates as $tr) {
212219
?>
213220
<tr>
214-
<td><?= $tr->getTaxLabel(); ?></td>
221+
<td><?= e($tr->getTaxLabel()); ?></td>
222+
<td><span class="badge bg-light text-dark"><?= e($tr->getTaxHandle()); ?></span></td>
215223
<td><?= $tr->getTaxRate(); ?>%</td>
216224
<td><?= ($tr->isEnabled() ? t('Yes') : t('No')); ?></td>
217225
<?php

src/CommunityStore/Tax/TaxEvent.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,14 @@ public function getUpdatedLabel()
2929
return($this->updatedLabel);
3030
}
3131

32-
}
32+
public function getTaxRate()
33+
{
34+
return $this->subject;
35+
}
36+
37+
public function setTaxRate($rate)
38+
{
39+
$this->subject = $rate;
40+
}
41+
42+
}

src/CommunityStore/Tax/TaxRate.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class TaxRate
3535
*/
3636
protected $taxLabel;
3737

38+
/**
39+
* @ORM\Column(type="string", nullable=true)
40+
*/
41+
protected $taxHandle;
42+
3843
/**
3944
* @ORM\Column(type="float")
4045
*/
@@ -80,6 +85,12 @@ public function setTaxLabel($label)
8085
$this->taxLabel = $label;
8186
}
8287

88+
public function setTaxHandle($handle)
89+
{
90+
$this->taxHandle = $handle;
91+
}
92+
93+
8394
public function setTaxRate($rate)
8495
{
8596
$this->taxRate = $rate;
@@ -141,6 +152,10 @@ public function getTaxLabel()
141152
return $this->taxLabel;
142153
}
143154

155+
public function getTaxHandle() {
156+
return $this->taxHandle;
157+
}
158+
144159
public function getTaxRate()
145160
{
146161
return $this->taxRate;
@@ -365,6 +380,10 @@ public static function add($data)
365380
$tr->setTaxBasedOn($data['taxBased']);
366381
$tr->setTaxAddress($data['taxAddress']);
367382

383+
if (isset($data['taxHandle'])) {
384+
$tr->setTaxHandle($data['taxHandle']);
385+
}
386+
368387
if (!isset($data['taxCountry'])) {
369388
$data['taxCountry'] = [];
370389
}

0 commit comments

Comments
 (0)