Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2022-09-14 18:21:40 -07:00
commit 4ac3650d64
6 changed files with 43 additions and 11 deletions

View file

@ -589,7 +589,7 @@ class ReportsController extends Controller
\Log::debug('Added headers: '.$executionTime);
$assets = \App\Models\Company::scopeCompanyables(Asset::select('assets.*'))->with(
'location', 'assetstatus', 'assetlog', 'company', 'defaultLoc', 'assignedTo',
'location', 'assetstatus', 'company', 'defaultLoc', 'assignedTo',
'model.category', 'model.manufacturer', 'supplier');
if ($request->filled('by_location_id')) {

View file

@ -3,6 +3,7 @@
namespace App\Http\Transformers;
use App\Helpers\Helper;
use App\Models\Depreciable;
use App\Models\Depreciation;
use Gate;
use Illuminate\Database\Eloquent\Collection;
@ -19,13 +20,14 @@ class DepreciationsTransformer
return (new DatatablesTransformer)->transformDatatables($array, $total);
}
public function transformDepreciation(Depreciation $depreciation)
public function transformDepreciation(Depreciation $depreciation, Depreciable $monthly_depreciation)
{
$array = [
'id' => (int) $depreciation->id,
'name' => e($depreciation->name),
'months' => $depreciation->months.' '.trans('general.months'),
'depreciation_min' => $depreciation->depreciation_min,
'monthly_depreciation' => $monthly_depreciation->getMonthlyDepreciation(),
'created_at' => Helper::getFormattedDateObject($depreciation->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($depreciation->updated_at, 'datetime')
];

View file

@ -43,6 +43,7 @@ class AccessoryImporter extends ItemImporter
$this->log('No Matching Accessory, Creating a new one');
$accessory = new Accessory();
$this->item['model_number'] = $this->findCsvMatch($row, "model_number");
$this->item['min_amt'] = $this->findCsvMatch($row, "min_amt");
$accessory->fill($this->sanitizeItemForStoring($accessory));
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.

View file

@ -43,6 +43,7 @@ class ConsumableImporter extends ItemImporter
$consumable = new Consumable();
$this->item['model_number'] = $this->findCsvMatch($row, 'model_number');
$this->item['item_no'] = $this->findCsvMatch($row, 'item_number');
$this->item['min_amt'] = $this->findCsvMatch($row, "min_amt");
$consumable->fill($this->sanitizeItemForStoring($consumable));
//FIXME: this disables model validation. Need to find a way to avoid double-logs without breaking everything.
$consumable->unsetEventDispatcher();

View file

@ -68,21 +68,33 @@ class Depreciable extends SnipeModel
*/
public function getLinearDepreciatedValue() // TODO - for testing it might be nice to have an optional $relative_to param here, defaulted to 'now'
{
$months_remaining = $this->time_until_depreciated()->m + 12 * $this->time_until_depreciated()->y; //UGlY
$months_passed = $this->purchase_date->diff(now())->m;
$current_value = round(($months_remaining / $this->get_depreciation()->months) * $this->purchase_cost, 2);
if($months_passed >= $this->get_depreciation()->months){
//if there is a floor use it
if($this->get_depreciation()->deprecation_min->isNotEmpty()) {
if($this->get_depreciation()->depreciation_min > $current_value) {
$current_value = $this->get_depreciation()->depreciation_min;
$current_value=round($this->get_depreciation()->depreciation_min,2);
}else{
$current_value = 0;
}
}
if ($current_value < 0) {
$current_value = 0;
else {
// The equation here is (Purchase_Cost-Floor_min)*(Months_passed/Months_til_depreciated)
$current_value = round(($this->purchase_cost-($this->purchase_cost - ($this->get_depreciation()->depreciation_min)) * ($months_passed / $this->get_depreciation()->months)), 2);
}
return $current_value;
}
public function getMonthlyDepreciation(){
return ($this->purchase_cost-$this->get_depreciation()->depreciation_min)/$this->get_depreciation()->months;
}
/**
* @param onlyHalfFirstYear Boolean always applied only second half of the first year
* @return float|int

View file

@ -37,6 +37,22 @@
</IfModule>
Options -Indexes
<Files "web.config">
Deny from all
</Files>
# DENY ACCESS TO IIS CONFIG FILE
# Apache 2.2+
<IfModule !authz_core_module>
<Files "web.config">
Order allow,deny
Deny from all
</Files>
</IfModule>
# Apache 2.4+
<IfModule authz_core_module>
<Files "web.config">
Require all denied
</Files>
</IfModule>