Merge pull request #11986 from Godmartinz/FD31357_depreciation

Fixes the calc of months and fixes typo of the word depreciation
This commit is contained in:
snipe 2022-10-17 14:44:46 -07:00 committed by GitHub
commit 1ec303931a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,14 +69,14 @@ 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'
{
if ($this->purchase_date) {
$months_passed = $this->purchase_date->diff(now())->m;
$months_passed = ($this->purchase_date->diff(now())->m)+($this->purchase_date->diff(now())->y*12);
} else {
return null;
}
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 == null) {
$current_value = $this->get_depreciation()->depreciation_min;