Skip to content

A free open source IT asset/license management system

Implement quantity

Marcus Moore7c9a5fb5af53
diff --git a/app/Http/Controllers/Reports/CustomComponentReportController.php b/app/Http/Controllers/Reports/CustomComponentReportController.php
index 005fac7961..56bdeeebf4 100644
--- a/app/Http/Controllers/Reports/CustomComponentReportController.php
+++ b/app/Http/Controllers/Reports/CustomComponentReportController.php
@@ -81,6 +81,13 @@ class CustomComponentReportController extends Controller
]);
}
+ if ($request->filled(['min_quantity_start', 'min_quantity_end'])) {
+ $components->whereBetween('components.min_amt', [
+ $request->input('min_quantity_start'),
+ $request->input('min_quantity_end'),
+ ]);
+ }
+
$localConstraints = [
'by_model_number' => 'components.model_number',
'by_name' => 'components.name',
diff --git a/resources/views/reports/custom/component.blade.php b/resources/views/reports/custom/component.blade.php
index c6b5f28cb0..817034fe85 100644
--- a/resources/views/reports/custom/component.blade.php
+++ b/resources/views/reports/custom/component.blade.php
@@ -330,18 +330,18 @@
</div>
<!-- Min. Quantity -->
- <div class="form-group min_quantity-range{{ ($errors->has('min_quantity_cost_start') || $errors->has('min_quantity_cost_end')) ? ' has-error' : '' }}">
- <label for="min_quantity_cost_start" class="col-md-3 control-label">{{ trans('mail.min_QTY') }}</label>
+ <div class="form-group min_quantity-range{{ ($errors->has('min_quantity_start') || $errors->has('min_quantity_end')) ? ' has-error' : '' }}">
+ <label for="min_quantity_start" class="col-md-3 control-label">{{ trans('mail.min_QTY') }}</label>
<div class="input-group col-md-7">
- <input type="number" min="0" class="form-control" name="min_quantity_cost_start" aria-label="min_quantity_cost_start" value="{{ $template->textValue('min_quantity_cost_start', old('min_quantity_cost_start')) }}">
+ <input type="number" min="0" class="form-control" name="min_quantity_start" aria-label="min_quantity_start" value="{{ $template->textValue('min_quantity_start', old('min_quantity_start')) }}">
<span class="input-group-addon"> - </span>
- <input type="number" min="0" class="form-control" name="min_quantity_cost_end" aria-label="min_quantity_cost_end" value="{{ $template->textValue('min_quantity_cost_end', old('min_quantity_cost_end')) }}">
+ <input type="number" min="0" class="form-control" name="min_quantity_end" aria-label="min_quantity_end" value="{{ $template->textValue('min_quantity_end', old('min_quantity_end')) }}">
</div>
- @if ($errors->has('min_quantity_cost_start') || $errors->has('min_quantity_cost_end'))
+ @if ($errors->has('min_quantity_start') || $errors->has('min_quantity_end'))
<div class="col-md-9 col-lg-offset-3">
- {!! $errors->first('min_quantity_cost_start', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
- {!! $errors->first('min_quantity_cost_end', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
+ {!! $errors->first('min_quantity_start', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
+ {!! $errors->first('min_quantity_end', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
@endif
</div>
diff --git a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php
index e725edf015..5ed8987b64 100644
--- a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php
+++ b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php
@@ -373,15 +373,13 @@ class CustomComponentReportTest extends TestCase
public function test_limiting_by_minimum_quantity()
{
- $this->markTestIncomplete();
-
Component::factory()->create(['name' => 'Component A', 'min_amt' => 2]);
Component::factory()->create(['name' => 'Component B', 'min_amt' => 20]);
$this->sendRequest([
'component_name' => '1',
- 'min_quantity_cost_start' => 1,
- 'min_quantity_cost_end' => 5,
+ 'min_quantity_start' => 1,
+ 'min_quantity_end' => 5,
])
->assertOk()
->assertCsvHeader()