From 3683f509073e92ab2939727c7d284e5e82eb4fb4 Mon Sep 17 00:00:00 2001 From: Artur Date: Sun, 27 Oct 2024 22:36:09 +0100 Subject: [PATCH] Some changes in display of Calculator --- .../asset-calculator.component.html | 103 ++++++++++-------- .../asset-calculator.component.ts | 26 ++--- src/app/asset-calculator/assets/asset.ts | 5 +- 3 files changed, 70 insertions(+), 64 deletions(-) diff --git a/src/app/asset-calculator/asset-calculator.component.html b/src/app/asset-calculator/asset-calculator.component.html index 2efb875..264611d 100644 --- a/src/app/asset-calculator/asset-calculator.component.html +++ b/src/app/asset-calculator/asset-calculator.component.html @@ -13,69 +13,78 @@ } +
100% wide until small breakpoint
+
100% wide until medium breakpoint
+
100% wide until large breakpoint
+
100% wide until extra large breakpoint
+
100% wide until extra extra large breakpoint
+
Kalkulator amortyzacyjny
-
-
-
- +
+
+
-
- - -
- @if(assetsDepreciationFormGroup.get('initialValueSet')?.invalid && assetsDepreciationFormGroup.get('initialValueSet')?.touched){ -
Wartość niepoprawna!. Podaj kwotę w zł np 3000.05 (czyli 3000 zł i 5 gr)
- }@else{ - } - -
-
-
- +
+ + + @if(assetsDepreciationFormGroup.get('initialValueSet')?.invalid && assetsDepreciationFormGroup.get('initialValueSet')?.touched){ +
Wartość niepoprawna!. Podaj kwotę w zł np 3000.05 (czyli 3000 zł i 5 gr)
+ }@else{ + } + +
+
+ +
+
+
-
- +
+
-
-
- -
- -
-
- +
+
-
- -
- + +
+ +
+ +
+
+ +
+
+
-
+ @if( TypeDepreciation.digressive === typeDepreciation() ){ -
- -
- +
+
+ +
+
+
} @@ -99,7 +108,6 @@ Lp - Rok Miesiąc Zmiana @@ -108,9 +116,8 @@ @for( changeGroup of lifeFormArray.controls; track $index ) { {{$index+1}} - - - + + } diff --git a/src/app/asset-calculator/asset-calculator.component.ts b/src/app/asset-calculator/asset-calculator.component.ts index c8b9d18..df0e53d 100644 --- a/src/app/asset-calculator/asset-calculator.component.ts +++ b/src/app/asset-calculator/asset-calculator.component.ts @@ -18,8 +18,7 @@ export class AssetCalculatorComponent implements OnInit{ initialValueAsset = signal( 3000 ); depreciationRate = signal( 20 ); - year = signal( 2024 ); - month = signal( 10 ); + year_month = signal( "2024-10" ); typeDepreciation = signal< TypeDepreciation>( TypeDepreciation.linear ); factorValue = signal( 2 ); @@ -32,8 +31,7 @@ export class AssetCalculatorComponent implements OnInit{ assetsDepreciationFormGroup = 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() ), + year_month : new FormControl( ), typeDepreciation : new FormControl( this.typeDepreciation ), factorValue : new FormControl( this.factorValue, [Validators.required,Validators.max(2)] ), @@ -52,15 +50,14 @@ export class AssetCalculatorComponent implements OnInit{ } calculate(){ - const when = new YearMonth( this.year(), this.month() ) - const asset = new Asset( this.depreciationRate(), when, this.typeDepreciation(), this.factorValue() ) + const when = new YearMonth( this.year_month() ) + const asset = new Asset( this.depreciationRate(), when, this.typeDepreciation(), this.factorValue() ) const creationlifeChange = new AssetLifeChange( when, this.initialValueAsset(), 0, 0 ); asset.addChange( creationlifeChange ); for( let changeControlGroup of this.lifeFormArray.controls ){ const initialValueAsset = changeControlGroup.get('initialValueAsset')?.value; - const year = changeControlGroup.get('year')?.value; - const month= changeControlGroup.get('month')?.value - asset.addChange( new AssetLifeChange( new YearMonth( year, month ), initialValueAsset, 0, 0 )) ; + const year_month = changeControlGroup.get('year_month')?.value; + asset.addChange( new AssetLifeChange( new YearMonth( year_month ), initialValueAsset, 0, 0 )) ; } this.calculateForAsset( asset ); } @@ -108,13 +105,14 @@ export class AssetCalculatorComponent implements OnInit{ addChangeValue() { - const change = new AssetLifeChange(new YearMonth( this.year(), this.month()), 1000, 0, 0 ); + + const change = new AssetLifeChange(new YearMonth( this.year_month() ), 1000, 0, 0 ); const newFormGroup = new FormGroup( { - initialValueAsset: new FormControl( change.initial ), - year : new FormControl( change.when.year ), - month : new FormControl( change.when.month ) - } ) + initialValueAsset: new FormControl( change.initial ), + year_month : new FormControl( this.year_month() ) + } + ) this.lifeFormArray.push(newFormGroup); diff --git a/src/app/asset-calculator/assets/asset.ts b/src/app/asset-calculator/assets/asset.ts index 95282aa..43be609 100644 --- a/src/app/asset-calculator/assets/asset.ts +++ b/src/app/asset-calculator/assets/asset.ts @@ -6,7 +6,8 @@ export enum TypeDepreciation{ export class YearMonth{ readonly year : number ; readonly month : number ; - constructor( year: number, month:number ){ + constructor( year_month:string ){ + const [ year, month ] = year_month.split( '-').map(Number); this.year = year; this.month =month; @@ -59,7 +60,7 @@ export class Asset { export class AssetPlanPosition{ - when : YearMonth = new YearMonth(0,0); + when : YearMonth = new YearMonth('0-0'); calculatedDepreciation : number = 0; sum:number = 0; sumThisYear:number = 0;