Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed threshold explanation and min qty math #14601

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions app/Helpers/Helper.php
Expand Up @@ -740,7 +740,7 @@ public static function checkLowInventory()
$items_array[$all_count]['type'] = 'consumables';
$items_array[$all_count]['percent'] = $percent;
$items_array[$all_count]['remaining'] = $avail;
$items_array[$all_count]['min_amt'] = $consumable->min_amt;
$items_array[$all_count]['min_amt'] = ($consumable->min_amt) + $alert_threshold;
$all_count++;
}
}
Expand All @@ -759,7 +759,7 @@ public static function checkLowInventory()
$items_array[$all_count]['type'] = 'accessories';
$items_array[$all_count]['percent'] = $percent;
$items_array[$all_count]['remaining'] = $avail;
$items_array[$all_count]['min_amt'] = $accessory->min_amt;
$items_array[$all_count]['min_amt'] = ($accessory->min_amt) + $alert_threshold;
$all_count++;
}
}
Expand All @@ -778,7 +778,7 @@ public static function checkLowInventory()
$items_array[$all_count]['type'] = 'components';
$items_array[$all_count]['percent'] = $percent;
$items_array[$all_count]['remaining'] = $avail;
$items_array[$all_count]['min_amt'] = $component->min_amt;
$items_array[$all_count]['min_amt'] = ($component->min_amt) + $alert_threshold;
$all_count++;
}
}
Expand All @@ -800,7 +800,7 @@ public static function checkLowInventory()
$items_array[$all_count]['type'] = 'models';
$items_array[$all_count]['percent'] = $percent;
$items_array[$all_count]['remaining'] = $avail;
$items_array[$all_count]['min_amt'] = $asset_model->min_amt;
$items_array[$all_count]['min_amt'] = ($asset_model->min_amt) + $alert_threshold;
$all_count++;
}
}
Expand All @@ -819,7 +819,7 @@ public static function checkLowInventory()
$items_array[$all_count]['type'] = 'licenses';
$items_array[$all_count]['percent'] = $percent;
$items_array[$all_count]['remaining'] = $avail;
$items_array[$all_count]['min_amt'] = $license->min_amt;
$items_array[$all_count]['min_amt'] = ($license->min_amt) + $alert_threshold;
$all_count++;
}

Expand Down Expand Up @@ -1458,5 +1458,9 @@ public static function mapBackToLegacyLocale($new_locale = null)
}
return $new_locale; // better that you have some weird locale that doesn't fit into our mappings anywhere than 'void'
}
public static function sumThreshold($min_qty = null){

return $min_qty + Setting::getSettings()->alert_threshold;
}
Comment on lines +1461 to +1464
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a hunch this method name can be improved but I don't have a good suggestion...


}
7 changes: 5 additions & 2 deletions app/Http/Controllers/Accessories/AccessoriesController.php
Expand Up @@ -7,6 +7,7 @@
use App\Http\Requests\ImageUploadRequest;
use App\Models\Accessory;
use App\Models\Company;
use App\Models\Setting;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
Expand Down Expand Up @@ -49,7 +50,8 @@ public function create()
$category_type = 'accessory';

return view('accessories/edit')->with('category_type', $category_type)
->with('item', new Accessory);
->with('item', new Accessory)
->with('setting', Setting::getSettings());
}

/**
Expand Down Expand Up @@ -108,7 +110,8 @@ public function edit($accessoryId = null)
if ($item = Accessory::find($accessoryId)) {
$this->authorize($item);

return view('accessories/edit', compact('item'))->with('category_type', 'accessory');
return view('accessories/edit', compact('item'))->with('category_type', 'accessory')
->with('setting', Setting::getSettings());
}

return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/AssetModelsController.php
Expand Up @@ -8,6 +8,7 @@
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\CustomField;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -58,7 +59,8 @@ public function create()

return view('models/edit')->with('category_type', 'asset')
->with('depreciation_list', Helper::depreciationList())
->with('item', new AssetModel);
->with('item', new AssetModel)
->with('setting', Setting::getSettings());
}

/**
Expand Down Expand Up @@ -123,7 +125,8 @@ public function edit($modelId = null)
if ($item = AssetModel::find($modelId)) {
$category_type = 'asset';
$view = View::make('models/edit', compact('item', 'category_type'));
$view->with('depreciation_list', Helper::depreciationList());
$view->with('depreciation_list', Helper::depreciationList())
->with('setting', Setting::getSettings());

return $view;
}
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/Components/ComponentsController.php
Expand Up @@ -7,6 +7,7 @@
use App\Models\Company;
use App\Models\Component;
use App\Helpers\Helper;
use App\Models\Setting;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Storage;
Expand Down Expand Up @@ -52,7 +53,8 @@ public function create()
$this->authorize('create', Component::class);

return view('components/edit')->with('category_type', 'component')
->with('item', new Component);
->with('item', new Component)
->with('setting', Setting::getSettings());
}

/**
Expand Down Expand Up @@ -107,7 +109,8 @@ public function edit($componentId = null)
if ($item = Component::find($componentId)) {
$this->authorize('update', $item);

return view('components/edit', compact('item'))->with('category_type', 'component');
return view('components/edit', compact('item'))->with('category_type', 'component')
->with('setting', Setting::getSettings());
}

return redirect()->route('components.index')->with('error', trans('admin/components/message.does_not_exist'));
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/Consumables/ConsumablesController.php
Expand Up @@ -7,6 +7,7 @@
use App\Http\Requests\ImageUploadRequest;
use App\Models\Company;
use App\Models\Consumable;
use App\Models\Setting;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Validator;
Expand Down Expand Up @@ -49,7 +50,8 @@ public function create()
$this->authorize('create', Consumable::class);

return view('consumables/edit')->with('category_type', 'consumable')
->with('item', new Consumable);
->with('item', new Consumable)
->with('setting', Setting::getSettings());
}

/**
Expand Down Expand Up @@ -107,7 +109,8 @@ public function edit($consumableId = null)
if ($item = Consumable::find($consumableId)) {
$this->authorize($item);

return view('consumables/edit', compact('item'))->with('category_type', 'consumable');
return view('consumables/edit', compact('item'))->with('category_type', 'consumable')
->with('setting', Setting::getSettings());
}

return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.does_not_exist'));
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/Licenses/LicensesController.php
Expand Up @@ -7,6 +7,7 @@
use App\Models\Company;
use App\Models\License;
use App\Models\LicenseSeat;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
Expand Down Expand Up @@ -58,7 +59,8 @@ public function create()
return view('licenses/edit')
->with('depreciation_list', Helper::depreciationList())
->with('maintained_list', $maintained_list)
->with('item', new License);
->with('item', new License)
->with('setting', Setting::getSettings());
}

/**
Expand Down Expand Up @@ -134,7 +136,8 @@ public function edit($licenseId = null)

return view('licenses/edit', compact('item'))
->with('depreciation_list', Helper::depreciationList())
->with('maintained_list', $maintained_list);
->with('maintained_list', $maintained_list)
->with('setting', Setting::getSettings());
}


Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/AccessoriesTransformer.php
Expand Up @@ -37,7 +37,7 @@ public function transformAccessory(Accessory $accessory)
'purchase_date' => ($accessory->purchase_date) ? Helper::getFormattedDateObject($accessory->purchase_date, 'date') : null,
'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost),
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null,
'min_qty' => Helper::sumThreshold($accessory->min_amt),
'remaining_qty' => (int) $accessory->numRemaining(),
'users_count' => $accessory->users_count,

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/AssetModelsTransformer.php
Expand Up @@ -47,7 +47,7 @@ public function transformAssetModel(AssetModel $assetmodel)
] : null,
'image' => ($assetmodel->image != '') ? Storage::disk('public')->url('models/'.e($assetmodel->image)) : null,
'model_number' => e($assetmodel->model_number),
'min_amt' => ($assetmodel->min_amt) ? (int) $assetmodel->min_amt : null,
'min_amt' => Helper::sumThreshold($assetmodel->min_amt),
'depreciation' => ($assetmodel->depreciation) ? [
'id' => (int) $assetmodel->depreciation->id,
'name'=> e($assetmodel->depreciation->name),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/ComponentsTransformer.php
Expand Up @@ -32,7 +32,7 @@ public function transformComponent(Component $component)
'name' => e($component->location->name),
] : null,
'qty' => ($component->qty != '') ? (int) $component->qty : null,
'min_amt' => ($component->min_amt != '') ? (int) $component->min_amt : null,
'min_amt' => Helper::sumThreshold($component->min_amt),
'category' => ($component->category) ? [
'id' => (int) $component->category->id,
'name' => e($component->category->name),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/ConsumablesTransformer.php
Expand Up @@ -32,7 +32,7 @@ public function transformConsumable(Consumable $consumable)
'location' => ($consumable->location) ? ['id' => (int) $consumable->location->id, 'name' => e($consumable->location->name)] : null,
'manufacturer' => ($consumable->manufacturer) ? ['id' => (int) $consumable->manufacturer->id, 'name' => e($consumable->manufacturer->name)] : null,
'supplier' => ($consumable->supplier) ? ['id' => $consumable->supplier->id, 'name'=> e($consumable->supplier->name)] : null,
'min_amt' => (int) $consumable->min_amt,
'min_amt' => Helper::sumThreshold($consumable->min_amt),
'model_number' => ($consumable->model_number != '') ? e($consumable->model_number) : null,
'remaining' => $consumable->numRemaining(),
'order_number' => e($consumable->order_number),
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Transformers/LicensesTransformer.php
Expand Up @@ -4,6 +4,7 @@

use App\Helpers\Helper;
use App\Models\License;
use App\Models\Setting;
use Illuminate\Support\Facades\Gate;
use Illuminate\Database\Eloquent\Collection;

Expand Down Expand Up @@ -38,7 +39,7 @@ public function transformLicense(License $license)
'expiration_date' => Helper::getFormattedDateObject($license->expiration_date, 'date'),
'seats' => (int) $license->seats,
'free_seats_count' => (int) $license->free_seats_count,
'min_amt' => ($license->min_amt) ? (int) ($license->min_amt) : null,
'min_amt' => Helper::sumThreshold($license->min_amt),
'license_name' => ($license->license_name) ? e($license->license_name) : null,
'license_email' => ($license->license_email) ? e($license->license_email) : null,
'reassignable' => ($license->reassignable == 1) ? true : false,
Expand Down
4 changes: 3 additions & 1 deletion resources/lang/en-US/general.php
Expand Up @@ -194,7 +194,9 @@
'manufacturers' => 'Manufacturers',
'markdown' => 'This field allows <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>.',
'min_amt' => 'Min. QTY',
'min_amt_help' => 'Minimum number of items that should be available before an alert gets triggered. Leave Min. QTY blank if you do not want to receive alerts for low inventory.',
'min_qty_increase' => 'Increase Alert Threshold',
'min_threshold_help' => 'This value is added to the standard threshold assigned in Notification settings. This gives you a higher threshold to be alerted to for low inventory.',
'min_amt_help' => 'Increase Minimum number of items that should be available before an alert gets triggered. Leave Min. QTY blank if you do not want to receive alerts for low inventory.',
'model_no' => 'Model No.',
'months' => 'months',
'moreinfo' => 'More Info',
Expand Down
17 changes: 9 additions & 8 deletions resources/views/partials/forms/edit/minimum_quantity.blade.php
@@ -1,18 +1,19 @@
<!-- Min QTY -->
<!-- Alert Threshold -->
<div class="form-group{{ $errors->has('min_amt') ? ' has-error' : '' }}">
<label for="min_amt" class="col-md-3 control-label">{{ trans('general.min_amt') }}</label>
<div class="col-md-9{{ (Helper::checkIfRequired($item, 'min_amt')) ? ' required' : '' }}">
<div class="col-md-2" style="padding-left:0px">
<label for="min_amt" class="col-md-3 control-label">{{ trans('general.min_qty_increase') }}</label>
<div class="col-md-9">
<div class="col-md-3" style="padding-left:0px">
<input class="form-control col-md-3" type="text" name="min_amt" id="min_amt" aria-label="min_amt" value="{{ old('min_amt', $item->min_amt) }}" />
<span>Standard Threshold: {{$setting->alert_threshold}}</span>
</div>
<div class="col-md-7" style="margin-left: -15px;">
<a href="#" data-tooltip="true" title="{{ trans('general.min_amt_help') }}"><i class="fas fa-info-circle" aria-hidden="true"></i>
<span class="sr-only">{{ trans('general.min_amt_help') }}</span>
<div class="col-md-7" style="margin-left: -15px;">
<a href="#" data-tooltip="true" title="{{ trans('general.min_threshold_help') }}"><i class="fas fa-info-circle" aria-hidden="true"></i>
<span class="sr-only">{{ trans('general.min_threshold_help') }}</span>
</a>

</div>
<div class="col-md-12">
{!! $errors->first('min_amt', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
{!! $errors->first('min_amt', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
</div>