Wrocław
diff --git a/src/app/about-me/about-me.component.ts b/src/app/about-me/about-me.component.ts
index bcac009..a2e4b92 100644
--- a/src/app/about-me/about-me.component.ts
+++ b/src/app/about-me/about-me.component.ts
@@ -1,9 +1,10 @@
import { Component } from '@angular/core';
+import {NgOptimizedImage} from '@angular/common'
@Component({
selector: 'app-about-me',
standalone: true,
- imports: [],
+ imports: [NgOptimizedImage],
templateUrl: './about-me.component.html',
styleUrl: './about-me.component.css'
})
diff --git a/src/app/asset-calculator/asset-calculator.component.html b/src/app/asset-calculator/asset-calculator.component.html
index e2471e3..29248fa 100644
--- a/src/app/asset-calculator/asset-calculator.component.html
+++ b/src/app/asset-calculator/asset-calculator.component.html
@@ -18,68 +18,71 @@
Kalkulator amortyzacyjny
diff --git a/src/app/asset-calculator/asset-calculator.component.ts b/src/app/asset-calculator/asset-calculator.component.ts
index 5cf9003..3d02cf9 100644
--- a/src/app/asset-calculator/asset-calculator.component.ts
+++ b/src/app/asset-calculator/asset-calculator.component.ts
@@ -1,4 +1,4 @@
-import {Component, OnInit } from '@angular/core';
+import {Component, computed, effect, OnInit ,signal } from '@angular/core';
import {FormsModule, ReactiveFormsModule, FormControl, FormGroup, Validators} from '@angular/forms';
import {CurrencyPipe,DecimalPipe,PercentPipe} from '@angular/common';
import {AssetsModule} from './assets/assets.module'
@@ -14,26 +14,56 @@ import {AssetService} from './assets/service/asset.service'
})
export class AssetCalculatorComponent implements OnInit{
- assetsDepreciationForm = new FormGroup(
- {
- initialValueSet : new FormControl( '', [Validators.required, this.currencyValidator]),
- depreciationRate: new FormControl('') ,
- year : new FormControl(''),
- month : new FormControl(''),
- typeDepreciation: new FormControl( TypeDepreciation.linear ),
- factorValue : new FormControl( 2,[Validators.required,Validators.max(2)] )
+ TypeDepreciation = TypeDepreciation;
+
+ // Asset{}
+
+ initialValueAsset = signal
( 3000 );
+ depreciationRate = signal( 20 );
+ year = signal( 2024 );
+ month = signal( 10 );
+ typeDepreciation = signal< TypeDepreciation>( TypeDepreciation.linear );
+ factorValue = signal( 2 );
+
+ // Asset
+
+
+ positions = new Positions();
+
+ assetsDepreciationForm = new FormGroup( {
+ initialValueAsset : new FormControl( this.initialValueAsset(), [ Validators.required, this.currencyValidator ]),
+ depreciationRate : new FormControl( this.depreciationRate() ) ,
+ year : new FormControl( this.year() ),
+ month : new FormControl( this.month() ),
+ typeDepreciation : new FormControl( this.typeDepreciation ),
+ factorValue : new FormControl( this.factorValue, [Validators.required,Validators.max(2)] )
} );
constructor(private assetService : AssetService ){
-
+ effect( () => { this.calculate();});
+// this.assetsDepreciationForm.valueChanges.subscribe( (value)=> { this.calculateForAsset(value); });
}
- TypeDepreciation = TypeDepreciation;
- asset = new Asset();
- positions = new Positions();
+ ngOnInit(): void{
+
+ }
+
+ calculate(){
+ const asset : Asset = {
+ initialValueAsset : this.initialValueAsset(),
+ depreciationRate : this.depreciationRate(),
+ year : this.year(),
+ month : this.month(),
+ type : this.typeDepreciation(),
+ factorValue : this.factorValue()
+ }
+ this.calculateForAsset( asset );
+ }
+
+ calculateForAsset( asset : Asset ) {
+ this.assetService.calculate( asset ).subscribe(
+ positions => { this.positions=positions; this.calculateToValues() });
- calculate() {
- this.assetService.calculate(this.asset).subscribe( positions => { this.positions=positions; this.calculateToValues() });
}
calculateToValues() {
@@ -57,8 +87,5 @@ export class AssetCalculatorComponent implements OnInit{
return regex.test(value) ? null : { invalidCurrency: true };
}
- ngOnInit(): void{
- this.calculate();
- }
}
diff --git a/src/app/asset-calculator/assets/asset.ts b/src/app/asset-calculator/assets/asset.ts
index 12b8cad..dfe6c09 100644
--- a/src/app/asset-calculator/assets/asset.ts
+++ b/src/app/asset-calculator/assets/asset.ts
@@ -3,15 +3,30 @@ export enum TypeDepreciation{
linear, digressive
}
-export class Asset {
- initialValueAsset = 3000.00;
-
- year = 2024;
- month = 10;
+export interface Asset {
+ initialValueAsset : number ;
+ depreciationRate : number ;
+ type : TypeDepreciation;
- type = TypeDepreciation.linear;
- depreciationRate = 20;
- factorValue = 2;
+ 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.month = month;
+ this.factorValue = factorValue;
+ }
+ */
}
export class YearMonth{