mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
Merge pull request #9937 from Godmartinz/depreciation_min_feature
adds a Floor value for depreciation models
This commit is contained in:
commit
4c13ddd0c5
|
@ -20,9 +20,9 @@ class DepreciationsController extends Controller
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$this->authorize('view', Depreciation::class);
|
$this->authorize('view', Depreciation::class);
|
||||||
$allowed_columns = ['id', 'name', 'months', 'created_at'];
|
$allowed_columns = ['id','name','months','depreciation_min','created_at'];
|
||||||
|
|
||||||
$depreciations = Depreciation::select('id', 'name', 'months', 'user_id', 'created_at', 'updated_at');
|
$depreciations = Depreciation::select('id','name','months','depreciation_min','user_id','created_at','updated_at');
|
||||||
|
|
||||||
if ($request->filled('search')) {
|
if ($request->filled('search')) {
|
||||||
$depreciations = $depreciations->TextSearch($request->input('search'));
|
$depreciations = $depreciations->TextSearch($request->input('search'));
|
||||||
|
|
|
@ -69,6 +69,7 @@ class DepreciationsController extends Controller
|
||||||
$depreciation->name = $request->input('name');
|
$depreciation->name = $request->input('name');
|
||||||
$depreciation->months = $request->input('months');
|
$depreciation->months = $request->input('months');
|
||||||
$depreciation->user_id = Auth::id();
|
$depreciation->user_id = Auth::id();
|
||||||
|
$depreciation->depreciation_min = $request->input('depreciation_min');
|
||||||
|
|
||||||
// Was the asset created?
|
// Was the asset created?
|
||||||
if ($depreciation->save()) {
|
if ($depreciation->save()) {
|
||||||
|
@ -126,6 +127,7 @@ class DepreciationsController extends Controller
|
||||||
// Depreciation data
|
// Depreciation data
|
||||||
$depreciation->name = $request->input('name');
|
$depreciation->name = $request->input('name');
|
||||||
$depreciation->months = $request->input('months');
|
$depreciation->months = $request->input('months');
|
||||||
|
$depreciation->depreciation_min = $request->input('depreciation_min');
|
||||||
|
|
||||||
// Was the asset created?
|
// Was the asset created?
|
||||||
if ($depreciation->save()) {
|
if ($depreciation->save()) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ class DepreciationsTransformer
|
||||||
'months' => $depreciation->months.' '.trans('general.months'),
|
'months' => $depreciation->months.' '.trans('general.months'),
|
||||||
'created_at' => Helper::getFormattedDateObject($depreciation->created_at, 'datetime'),
|
'created_at' => Helper::getFormattedDateObject($depreciation->created_at, 'datetime'),
|
||||||
'updated_at' => Helper::getFormattedDateObject($depreciation->updated_at, 'datetime'),
|
'updated_at' => Helper::getFormattedDateObject($depreciation->updated_at, 'datetime'),
|
||||||
|
'depreciation_min' =>($depreciation->depreciation_min),
|
||||||
];
|
];
|
||||||
|
|
||||||
$permissions_array['available_actions'] = [
|
$permissions_array['available_actions'] = [
|
||||||
|
|
|
@ -72,6 +72,10 @@ class Depreciable extends SnipeModel
|
||||||
$months_remaining = $this->time_until_depreciated()->m + 12 * $this->time_until_depreciated()->y; //UGlY
|
$months_remaining = $this->time_until_depreciated()->m + 12 * $this->time_until_depreciated()->y; //UGlY
|
||||||
$current_value = round(($months_remaining / $this->get_depreciation()->months) * $this->purchase_cost, 2);
|
$current_value = round(($months_remaining / $this->get_depreciation()->months) * $this->purchase_cost, 2);
|
||||||
|
|
||||||
|
if($this->get_depreciation()->depreciation_min > $current_value) {
|
||||||
|
|
||||||
|
$current_value=$this->get_depreciation()->depreciation_min;
|
||||||
|
}
|
||||||
if ($current_value < 0) {
|
if ($current_value < 0) {
|
||||||
$current_value = 0;
|
$current_value = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,13 @@ class DepreciationPresenter extends Presenter
|
||||||
'visible' => true,
|
'visible' => true,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
"field" => 'depreciation_min',
|
||||||
|
"searchable" => false,
|
||||||
|
"sortable" => true,
|
||||||
|
"title" => trans('admin/depreciations/table.depreciation_min'),
|
||||||
|
"visible" => true,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'field' => 'actions',
|
'field' => 'actions',
|
||||||
'searchable' => false,
|
'searchable' => false,
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddDepreciationMinimumValue extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('depreciations', function (Blueprint $table) {
|
||||||
|
$table->decimal('depreciation_min', 8,2)->after('months')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('depreciations', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('depreciation_min');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ return [
|
||||||
'asset_depreciations' => 'Asset Depreciations',
|
'asset_depreciations' => 'Asset Depreciations',
|
||||||
'create' => 'Create Depreciation',
|
'create' => 'Create Depreciation',
|
||||||
'depreciation_name' => 'Depreciation Name',
|
'depreciation_name' => 'Depreciation Name',
|
||||||
|
'depreciation_min' => 'Floor Value of Depreciation',
|
||||||
'number_of_months' => 'Number of Months',
|
'number_of_months' => 'Number of Months',
|
||||||
'update' => 'Update Depreciation',
|
'update' => 'Update Depreciation',
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,6 @@ return [
|
||||||
'months' => 'Months',
|
'months' => 'Months',
|
||||||
'term' => 'Term',
|
'term' => 'Term',
|
||||||
'title' => 'Name ',
|
'title' => 'Name ',
|
||||||
|
'depreciation_min' => 'Floor Value',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -4,10 +4,11 @@ return [
|
||||||
|
|
||||||
'asset_tag' => 'Asset Tag',
|
'asset_tag' => 'Asset Tag',
|
||||||
'asset_model' => 'Model',
|
'asset_model' => 'Model',
|
||||||
'book_value' => 'Value',
|
'book_value' => 'Current Value',
|
||||||
'change' => 'In/Out',
|
'change' => 'In/Out',
|
||||||
'checkout_date' => 'Checkout Date',
|
'checkout_date' => 'Checkout Date',
|
||||||
'checkoutto' => 'Checked Out',
|
'checkoutto' => 'Checked Out',
|
||||||
|
'current_value' => 'Current Value',
|
||||||
'diff' => 'Diff',
|
'diff' => 'Diff',
|
||||||
'dl_csv' => 'Download CSV',
|
'dl_csv' => 'Download CSV',
|
||||||
'eol' => 'EOL',
|
'eol' => 'EOL',
|
||||||
|
|
|
@ -22,5 +22,15 @@
|
||||||
</div>
|
</div>
|
||||||
{!! $errors->first('months', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first('months', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Depreciation Minimum -->
|
||||||
|
<div class="form-group {{ $errors->has('depreciation_min') ? ' has-error' : '' }}">
|
||||||
|
<label for="depreciation_min" class="col-md-3 control-label">
|
||||||
|
{{ trans('admin/depreciations/general.depreciation_min') }}
|
||||||
|
</label>
|
||||||
|
<div class="col-md-2" style="padding-left:0px">
|
||||||
|
<input class="form-control" name="depreciation_min" id="depreciation_min" value="{{ Request::old('depreciation_min', $item->depreciation_min) }}" style="width: 80px; margin-left:15px" />
|
||||||
|
</div>
|
||||||
|
{!! $errors->first('depreciation_min', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
|
</div>
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
|
|
@ -463,7 +463,28 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
@if (($asset->model) && ($asset->depreciation))
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-2">
|
||||||
|
<strong>
|
||||||
|
{{ trans('admin/hardware/table.current_value') }}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="col-md-6" style="margin-left:-15px;">
|
||||||
|
@if (($asset->id) && ($asset->location))
|
||||||
|
{{ $asset->location->currency }}
|
||||||
|
@elseif (($asset->id) && ($asset->location))
|
||||||
|
{{ $asset->location->currency }}
|
||||||
|
@else
|
||||||
|
{{ $snipeSettings->default_currency }}
|
||||||
|
@endif
|
||||||
|
{{ \App\Helpers\Helper::formatCurrencyOutput($asset->getDepreciatedValue() )}}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
@if ($asset->order_number)
|
@if ($asset->order_number)
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
|
|
Loading…
Reference in a new issue