From 157944b77422b3af61f7c3ff9557387940275cd9 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 13 May 2022 18:01:06 -0700 Subject: [PATCH 1/5] Try conditiinal formatting to support apache 2.2 and 2.4 Signed-off-by: snipe --- public/.htaccess | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/public/.htaccess b/public/.htaccess index ef7365142c..f2c92b3005 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -37,6 +37,22 @@ Options -Indexes - - Deny from all - +# DENY ACCESS TO IIS CONFIG FILE + +# Apache 2.2+ + + + Order allow,deny + Deny from all + + + +# Apache 2.4+ + + + Require all denied + + + + + From d51eca20f092a38dbca65e35a8107a0d4f76dada Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Mon, 12 Sep 2022 18:11:48 -0500 Subject: [PATCH 2/5] Add min_amt field in Consumables and Accessories imports --- app/Importer/AccessoryImporter.php | 1 + app/Importer/ConsumableImporter.php | 1 + 2 files changed, 2 insertions(+) diff --git a/app/Importer/AccessoryImporter.php b/app/Importer/AccessoryImporter.php index f9c871fa7c..417075ef31 100644 --- a/app/Importer/AccessoryImporter.php +++ b/app/Importer/AccessoryImporter.php @@ -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. diff --git a/app/Importer/ConsumableImporter.php b/app/Importer/ConsumableImporter.php index cc24daa930..b0dea1f514 100644 --- a/app/Importer/ConsumableImporter.php +++ b/app/Importer/ConsumableImporter.php @@ -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(); From a0624fe179ea5fa72f4f6534753e206f8bd82852 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 14 Sep 2022 16:00:21 -0700 Subject: [PATCH 3/5] reworks the depreciation formula, includes months passed instead of months remaining --- app/Models/Depreciable.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Models/Depreciable.php b/app/Models/Depreciable.php index 0f3f73aa30..512e8dbff6 100644 --- a/app/Models/Depreciable.php +++ b/app/Models/Depreciable.php @@ -68,9 +68,10 @@ 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); + // The equation here is (Purchase_Cost-Floor_min)*(Months_passed/Months_til_depreciated) + $current_value= round((($this->purchase_cost-$this->get_depreciation()->depreciation_min)*($months_passed/$this->get_depreciation()->months)),2); if($this->get_depreciation()->depreciation_min > $current_value) { From 6b6a079440ac89d99fc47270ad197292d5131730 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 14 Sep 2022 17:01:18 -0700 Subject: [PATCH 4/5] fixes current value and monthly depreciation on reports and calculations --- .../Transformers/DepreciationsTransformer.php | 4 +++- app/Models/Depreciable.php | 23 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/Http/Transformers/DepreciationsTransformer.php b/app/Http/Transformers/DepreciationsTransformer.php index fe63aca696..717568f025 100644 --- a/app/Http/Transformers/DepreciationsTransformer.php +++ b/app/Http/Transformers/DepreciationsTransformer.php @@ -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') ]; diff --git a/app/Models/Depreciable.php b/app/Models/Depreciable.php index 512e8dbff6..20a28af40a 100644 --- a/app/Models/Depreciable.php +++ b/app/Models/Depreciable.php @@ -70,20 +70,31 @@ class Depreciable extends SnipeModel { $months_passed = $this->purchase_date->diff(now())->m; - // The equation here is (Purchase_Cost-Floor_min)*(Months_passed/Months_til_depreciated) - $current_value= round((($this->purchase_cost-$this->get_depreciation()->depreciation_min)*($months_passed/$this->get_depreciation()->months)),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 From 3192a68b06395536587dd02c6df81de82d88129c Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 14 Sep 2022 18:17:52 -0700 Subject: [PATCH 5/5] Pulled assetlog from custom report controller Signed-off-by: snipe --- app/Http/Controllers/ReportsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 57dd87d813..c7e5bf74ac 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -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')) {