New version 'amortyzacji' bez przycisku kalkulate.
This commit is contained in:
parent
d809a4c247
commit
c67c03ee3a
|
|
@ -15,13 +15,12 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
}
|
</style>
|
||||||
|
|
||||||
</style>\
|
<div class="container frame mt-5">
|
||||||
<div class="container frame">
|
|
||||||
|
|
||||||
<div class="card" style="width: 18rem;">
|
<div class="card" style="width: 18rem;">
|
||||||
<img src="ARTI-1.jpg" class="card-img-to" alt="Ja">
|
<img ngSrc="ARTI-1.jpg" width="200" height="350" priority class="card-img-to" alt="Ja">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">Wrocław</h5>
|
<h5 class="card-title">Wrocław</h5>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
import {NgOptimizedImage} from '@angular/common'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-about-me',
|
selector: 'app-about-me',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [],
|
imports: [NgOptimizedImage],
|
||||||
templateUrl: './about-me.component.html',
|
templateUrl: './about-me.component.html',
|
||||||
styleUrl: './about-me.component.css'
|
styleUrl: './about-me.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -18,67 +18,70 @@
|
||||||
<h1 class="heading text-center">Kalkulator amortyzacyjny</h1>
|
<h1 class="heading text-center">Kalkulator amortyzacyjny</h1>
|
||||||
|
|
||||||
<form [formGroup]=assetsDepreciationForm class="frame">
|
<form [formGroup]=assetsDepreciationForm class="frame">
|
||||||
|
|
||||||
<div class="align-items-start" >
|
<div class="align-items-start" >
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="initialValueSet" class="form-label col-auto" >Wartość początkowa środka trwałego:</label>
|
<label for="initialValueAsset" class="form-label col-auto" >Wartość początkowa środka trwałego:</label>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input type="text" class="form-control" id="initialValueSet" aria-describedby="initialValueHelpInline" formControlName="initialValueSet" required
|
<input type="number" class="form-control" id="initialValueAsset"
|
||||||
[ngModel]="asset.initialValueAsset"
|
aria-describedby="initialValueHelpInline"
|
||||||
(ngModelChange)="asset.initialValueAsset=$event" />
|
formControlName="initialValueAsset" required
|
||||||
|
[(ngModel)]=initialValueAsset >
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@if(assetsDepreciationForm.get('initialValueSet')?.invalid && assetsDepreciationForm.get('initialValueSet')?.touched){
|
@if(assetsDepreciationForm.get('initialValueSet')?.invalid && assetsDepreciationForm.get('initialValueSet')?.touched){
|
||||||
<div class="text-danger col-auto"> Wartość niepoprawna!. Podaj kwotę w zł np 3000.05 (czyli 3000 zł i 5 gr)</div>
|
<div class="text-danger col-auto"> Wartość niepoprawna!. Podaj kwotę w zł np 3000.05 (czyli 3000 zł i 5 gr)</div>
|
||||||
}@else{
|
}@else{
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="depreciationRate" class="form-label col-auto" >Stawka amortyzacyjna w procentach:</label>
|
<label for="depreciationRate" class="form-label col-auto" >Stawka amortyzacyjna w procentach:</label>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input type="text" class="form-control" id="depreciationRate" formControlName="depreciationRate"
|
<input type="number" class="form-control" id="depreciationRate"
|
||||||
[ngModel]="asset.depreciationRate | number:'1.2-2'"
|
formControlName="depreciationRate"
|
||||||
(ngModelChange)="asset.depreciationRate=$event"/>
|
[(ngModel)]=depreciationRate />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="form-label col-auto">Rok i miesiąc rozpoczęcia amortyzacji</label>
|
<label class="form-label col-auto">Rok i miesiąc rozpoczęcia amortyzacji</label>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input type="number" class="form-control" formControlName="year"
|
<input type="number" class="form-control" formControlName="year"
|
||||||
[ngModel]=asset.year
|
[(ngModel)]=year
|
||||||
(ngModelChange)="asset.year=$event;calculate()" />
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<input type="number" class="form-control" formControlName="month"
|
<input type="number" class="form-control" formControlName="month"
|
||||||
[ngModel]=asset.month
|
[(ngModel)]=month />
|
||||||
(ngModelChange)="asset.month=$event;calculate()" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="form-label col-auto">Metoda amortyzacji</label>
|
<label class="form-label col-auto">Metoda amortyzacji</label>
|
||||||
<div class="col-auto" >
|
<div class="col-auto" >
|
||||||
<select class="form-control" formControlName="typeDepreciation"
|
<select class="form-control" formControlName="typeDepreciation" [(ngModel)]=typeDepreciation >
|
||||||
[ngModel]=asset.type
|
|
||||||
(ngModelChange)="asset.type=$event;calculate()" >
|
|
||||||
<option [ngValue]=TypeDepreciation.linear selected="selected">Liniowa</option>
|
<option [ngValue]=TypeDepreciation.linear selected="selected">Liniowa</option>
|
||||||
<option [ngValue]=TypeDepreciation.digressive >Dygresywna</option>
|
<option [ngValue]=TypeDepreciation.digressive >Dygresywna</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@if( TypeDepreciation.digressive === asset.type ){
|
@if( TypeDepreciation.digressive === typeDepreciation() ){
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="factorValue" class="form-label col-auto">Wspólczynnki degresji</label>
|
<label for="factorValue" class="form-label col-auto">Wspólczynnki degresji</label>
|
||||||
<div class="col-auto" >
|
<div class="col-auto" >
|
||||||
<input type="text" class="form-control" formControlName="factorValue"
|
<input type="text" class="form-control" formControlName="factorValue"
|
||||||
[ngModel]="asset.factorValue | number:'1.2-2' "
|
[(ngModel)]=factorValue
|
||||||
(ngModelChange)="asset.factorValue=$event;calculate()"/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<!--
|
||||||
<input class="btn btn-secondary col-auto" name="calculate"
|
<input class="btn btn-secondary col-auto" name="calculate"
|
||||||
[disabled]=assetsDepreciationForm.invalid (click)=calculate() type="button" value="Wylicz ">
|
[disabled]=assetsDepreciationForm.invalid (click)=calculate() type="button" value="Wylicz ">
|
||||||
|
|
||||||
|
-->
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 {FormsModule, ReactiveFormsModule, FormControl, FormGroup, Validators} 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'
|
||||||
|
|
@ -14,26 +14,56 @@ import {AssetService} from './assets/service/asset.service'
|
||||||
})
|
})
|
||||||
export class AssetCalculatorComponent implements OnInit{
|
export class AssetCalculatorComponent implements OnInit{
|
||||||
|
|
||||||
assetsDepreciationForm = new FormGroup(
|
TypeDepreciation = TypeDepreciation;
|
||||||
{
|
|
||||||
initialValueSet : new FormControl( '', [Validators.required, this.currencyValidator]),
|
// Asset{}
|
||||||
depreciationRate: new FormControl('') ,
|
|
||||||
year : new FormControl(''),
|
initialValueAsset = signal<number>( 3000 );
|
||||||
month : new FormControl(''),
|
depreciationRate = signal<number>( 20 );
|
||||||
typeDepreciation: new FormControl( TypeDepreciation.linear ),
|
year = signal<number>( 2024 );
|
||||||
factorValue : new FormControl( 2,[Validators.required,Validators.max(2)] )
|
month = signal<number>( 10 );
|
||||||
|
typeDepreciation = signal< TypeDepreciation>( TypeDepreciation.linear );
|
||||||
|
factorValue = signal<number>( 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 ){
|
constructor(private assetService : AssetService ){
|
||||||
|
effect( () => { this.calculate();});
|
||||||
|
// this.assetsDepreciationForm.valueChanges.subscribe( (value)=> { this.calculateForAsset(value); });
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeDepreciation = TypeDepreciation;
|
|
||||||
asset = new Asset();
|
|
||||||
positions = new Positions();
|
|
||||||
|
|
||||||
calculate(){
|
calculate(){
|
||||||
this.assetService.calculate(this.asset).subscribe( positions => { this.positions=positions; this.calculateToValues() });
|
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() });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateToValues() {
|
calculateToValues() {
|
||||||
|
|
@ -57,8 +87,5 @@ export class AssetCalculatorComponent implements OnInit{
|
||||||
return regex.test(value) ? null : { invalidCurrency: true };
|
return regex.test(value) ? null : { invalidCurrency: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void{
|
|
||||||
this.calculate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,30 @@ export enum TypeDepreciation{
|
||||||
linear, digressive
|
linear, digressive
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Asset {
|
export interface Asset {
|
||||||
initialValueAsset = 3000.00;
|
initialValueAsset : number ;
|
||||||
|
depreciationRate : number ;
|
||||||
|
type : TypeDepreciation;
|
||||||
|
|
||||||
year = 2024;
|
year : number;
|
||||||
month = 10;
|
month : number;
|
||||||
|
|
||||||
type = TypeDepreciation.linear;
|
factorValue : number;
|
||||||
depreciationRate = 20;
|
/*
|
||||||
factorValue = 2;
|
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{
|
export class YearMonth{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue