diff --git a/src/app/app.component.html b/src/app/app.component.html index 0c7ec51..a013195 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -2,7 +2,7 @@
| O mnie | Kalkulator amortyzacyjny - | Środki trwałe + | Kursy
diff --git a/src/app/asset-calculator/asset-calculator.component.ts b/src/app/asset-calculator/asset-calculator.component.ts index 6bc9e45..c517a6f 100644 --- a/src/app/asset-calculator/asset-calculator.component.ts +++ b/src/app/asset-calculator/asset-calculator.component.ts @@ -29,14 +29,16 @@ export class AssetCalculatorComponent implements OnInit, OnDestroy{ lifeFormArray = new FormArray([]); - assetsDepreciationFormGroup = new FormGroup( { - initialValueAsset : new FormControl( 5000, [ Validators.required, this.currencyValidator ]), - rate : new FormControl( 20 ) , - year_month : new FormControl( "2024-10" ), - typeDepreciation : new FormControl( TypeDepreciation.linear ), - factor : new FormControl( 2/*, [Validators.required,Validators.max(2)]*/ ), + assetsDepreciationFormGroup = new FormGroup({ + initialValueAsset : new FormControl( 5000, [ Validators.required, this.currencyValidator ]), + rate : new FormControl( 20 ) , + year_month : new FormControl( "2024-10" ), + typeDepreciation : new FormControl( TypeDepreciation.linear ), + factor : new FormControl( 2/*, [Validators.required,Validators.max(2)]*/ ), - } ); + } as { + [key in keyof FormValues]: FormControl + }); constructor(private assetService : AssetService ){ this.assetsDepreciationFormGroup.valueChanges.subscribe( (value) => this.calculate() ); @@ -79,7 +81,7 @@ export class AssetCalculatorComponent implements OnInit, OnDestroy{ private controlsToAsset() : Asset { - const formValues = this.assetsDepreciationFormGroup.value as FormValues; + const formValues = this.assetsDepreciationFormGroup.getRawValue(); const when = new YearMonth( formValues.year_month ); const asset = new Asset( when ); diff --git a/src/app/assets/asset.ts b/src/app/assets/asset.ts index b9acdec..f8e301d 100644 --- a/src/app/assets/asset.ts +++ b/src/app/assets/asset.ts @@ -22,7 +22,7 @@ export class YearMonthUtil{ return ym.year + '-' + ym.month ; } - static toToday( ):YearMonth{ + static today( ):YearMonth{ const today = new Date(); return new YearMonth( today.getFullYear() + '-' +today.getMonth()+1 ); } diff --git a/src/app/fixed-asset/fixed-asset.component.ts b/src/app/fixed-asset/fixed-asset.component.ts index 2eba9a6..59a7137 100644 --- a/src/app/fixed-asset/fixed-asset.component.ts +++ b/src/app/fixed-asset/fixed-asset.component.ts @@ -96,7 +96,7 @@ export class FixedAssetComponent { const nrInv = control.get('nrInv')?.value; const initialValue = control.get('initialValue')?.value; - const yearMonth = YearMonthUtil.toToday(); + const yearMonth = YearMonthUtil.today(); const asset = new Asset( yearMonth ); const assetLifeChange = new AssetLifeChange( yearMonth, initialValue, 0, 0 ); asset.addChange( assetLifeChange );