Prepare to version with many changes of Asset

This commit is contained in:
Artur 2024-10-25 00:07:46 +02:00
parent db7147571d
commit 8ec034d5e2
3 changed files with 64 additions and 36 deletions

View File

@ -87,6 +87,9 @@
--> -->
</div> </div>
</form> </form>
<input class="btn btn-secondary col-auto" name="addChangeValue"
[disabled]=assetsDepreciationForm.invalid (click)=addChangeValue() type="button" value="Dodaj zmianę wartości ">
</div> </div>

View File

@ -2,7 +2,7 @@ import {Component, effect, OnInit, signal } from '@angular/core';
import {ReactiveFormsModule, FormGroup, Validators, FormControl} from '@angular/forms'; import {ReactiveFormsModule, FormGroup, Validators, FormControl} from '@angular/forms';
import {CurrencyPipe,DecimalPipe,PercentPipe} from '@angular/common'; import {CurrencyPipe,DecimalPipe,PercentPipe} from '@angular/common';
import {AssetsModule} from './assets/assets.module' import {AssetsModule} from './assets/assets.module'
import {Asset, Positions, AssetPlanPosition, TypeDepreciation } from './assets/asset'; import {Asset, Positions, AssetPlanPosition, TypeDepreciation, YearMonth, AssetLifeChange } from './assets/asset';
import {AssetService} from './assets/service/asset.service' import {AssetService} from './assets/service/asset.service'
@Component({ @Component({
@ -27,6 +27,11 @@ export class AssetCalculatorComponent implements OnInit{
// Asset // Asset
addChangeValue() {
throw new Error('Method not implemented.');
}
positions = new Positions(); positions = new Positions();
@ -48,14 +53,10 @@ export class AssetCalculatorComponent implements OnInit{
} }
calculate(){ calculate(){
const asset : Asset = { const when = new YearMonth( this.year(), this.month() )
initialValueAsset : this.initialValueAsset(), const asset = new Asset( this.depreciationRate(), when, this.typeDepreciation(), this.factorValue() )
depreciationRate : this.depreciationRate(), const creationlifeChange = new AssetLifeChange( when, this.initialValueAsset(), 0, 0 );
year : this.year(), asset.addChange(creationlifeChange);
month : this.month(),
type : this.typeDepreciation(),
factorValue : this.factorValue()
}
this.calculateForAsset( asset ); this.calculateForAsset( asset );
} }

View File

@ -3,39 +3,63 @@ export enum TypeDepreciation{
linear, digressive linear, digressive
} }
export interface Asset { export class YearMonth{
initialValueAsset : number ; readonly year : number ;
depreciationRate : number ; readonly month : number ;
type : TypeDepreciation; constructor( year: number, month:number ){
year : number;
month : number;
factorValue : number;
/*
constructor( initialValueAsset : number,
depreciationRate : number,
typeDepreciation : TypeDepreciation,
year : number,
month: number,
factorValue: number ){
this.initialValueAsset = initialValueAsset;
this.depreciationRate = depreciationRate;
this.type = typeDepreciation;
this.year = year; this.year = year;
this.month =month; this.month =month;
}
}
export class AssetLifeChange{
readonly when : YearMonth;
readonly initial : number;
readonly residual : number;
readonly depreciation : number;
constructor( when : YearMonth,
initial : number,
residual : number,
depreciation: number ){
this.when = when;
this.initial = initial;
this.residual = residual;
this.depreciation = depreciation;
}
}
export class Asset {
start : YearMonth ;
depreciationRate : number ;
type : TypeDepreciation;
factorValue : number;
life : AssetLifeChange[]=[];
addChange( change : AssetLifeChange){
this.life.push( change );
}
constructor( depreciationRate : number,
start : YearMonth,
type : TypeDepreciation,
factorValue : number ){
this.depreciationRate = depreciationRate;
this.start = start;
this.type = type;
this.factorValue = factorValue; this.factorValue = factorValue;
} }
*/
} }
export class YearMonth{
year : number = 0;
month :number = 0;
}
export class AssetPlanPosition{ export class AssetPlanPosition{
when : YearMonth = new YearMonth(); when : YearMonth = new YearMonth(0,0);
calculatedDepreciation : number = 0; calculatedDepreciation : number = 0;
sum:number = 0; sum:number = 0;
sumThisYear:number = 0; sumThisYear:number = 0;