A free open source IT asset/license management system
Implement quantity
Marcus Moore556af49acd2b
diff --git a/app/Http/Controllers/Reports/CustomComponentReportController.php b/app/Http/Controllers/Reports/CustomComponentReportController.phpindex 82b3e2a6b9..005fac7961 100644--- a/app/Http/Controllers/Reports/CustomComponentReportController.php+++ b/app/Http/Controllers/Reports/CustomComponentReportController.php@@ -68,7 +68,17 @@ class CustomComponentReportController extends Controller]);if ($request->filled(['purchase_start', 'purchase_end'])) {- $components->whereBetween('components.purchase_date', [$request->input('purchase_start'), $request->input('purchase_end')]);+ $components->whereBetween('components.purchase_date', [+ $request->input('purchase_start'),+ $request->input('purchase_end'),+ ]);+ }++ if ($request->filled(['quantity_start', 'quantity_end'])) {+ $components->whereBetween('components.qty', [+ $request->input('quantity_start'),+ $request->input('quantity_end'),+ ]);}$localConstraints = [diff --git a/resources/views/reports/custom/component.blade.php b/resources/views/reports/custom/component.blade.phpindex 492003fe80..c6b5f28cb0 100644--- a/resources/views/reports/custom/component.blade.php+++ b/resources/views/reports/custom/component.blade.php@@ -313,18 +313,18 @@</div><!-- Quantity -->- <div class="form-group quantity-range{{ ($errors->has('quantity_cost_start') || $errors->has('quantity_cost_end')) ? ' has-error' : '' }}">- <label for="quantity_cost_start" class="col-md-3 control-label">{{ trans('general.quantity') }}</label>+ <div class="form-group quantity-range{{ ($errors->has('quantity_start') || $errors->has('quantity_end')) ? ' has-error' : '' }}">+ <label for="quantity_start" class="col-md-3 control-label">{{ trans('general.quantity') }}</label><div class="input-group col-md-7">- <input type="number" min="0" class="form-control" name="quantity_cost_start" aria-label="quantity_cost_start" value="{{ $template->textValue('quantity_cost_start', old('quantity_cost_start')) }}">+ <input type="number" min="0" class="form-control" name="quantity_start" aria-label="quantity_start" value="{{ $template->textValue('quantity_start', old('quantity_start')) }}"><span class="input-group-addon"> - </span>- <input type="number" min="0" class="form-control" name="quantity_cost_end" aria-label="quantity_cost_end" value="{{ $template->textValue('quantity_cost_end', old('quantity_cost_end')) }}">+ <input type="number" min="0" class="form-control" name="quantity_end" aria-label="quantity_end" value="{{ $template->textValue('quantity_end', old('quantity_end')) }}"></div>- @if ($errors->has('quantity_cost_start') || $errors->has('quantity_cost_end'))+ @if ($errors->has('quantity_start') || $errors->has('quantity_end'))<div class="col-md-9 col-lg-offset-3">- {!! $errors->first('quantity_cost_start', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}- {!! $errors->first('quantity_cost_end', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}+ {!! $errors->first('quantity_start', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}+ {!! $errors->first('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.phpindex fe91ee2186..e725edf015 100644--- a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php+++ b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php@@ -357,15 +357,13 @@ class CustomComponentReportTest extends TestCasepublic function test_limiting_by_quantity(){- $this->markTestIncomplete();-Component::factory()->create(['name' => 'Component A', 'qty' => 5]);Component::factory()->create(['name' => 'Component B', 'qty' => 50]);$this->sendRequest(['component_name' => '1',- 'quantity_cost_start' => 1,- 'quantity_cost_end' => 10,+ 'quantity_start' => 1,+ 'quantity_end' => 10,])->assertOk()->assertCsvHeader()