Some changes in asset interface

This commit is contained in:
Artur 2024-10-13 19:10:14 +02:00
parent f930af39c1
commit b02119f12b
2 changed files with 93 additions and 98 deletions

View File

@ -6,7 +6,7 @@ import { ChatGPTComponent } from './chat-gpt/chat-gpt.component';
export const routes: Routes = [ export const routes: Routes = [
{ path: "", { path: "",
title: "Kalkulator amprtyzacyjny", title: "Kalkulator amortyzacyjny",
component:AssetCalculatorComponent }, component:AssetCalculatorComponent },
{ path: "about-me", { path: "about-me",
title:"O mnie", title:"O mnie",

View File

@ -15,105 +15,100 @@
<div class="container mt-5"> <div class="container mt-5">
<h1 class="heading text-center">Kalkulator amortyzacyjny</h1> <h1 class="heading text-center">Kalkulator amortyzacyjny</h1>
<div class="row"> <form [formGroup]=assetsDepreciationForm class="frame ">
<div class="col-6"> <div class="form-group row">
<form [formGroup]=assetsDepreciationForm class="frame"> <label for="initialValueSet" class="form-label col-3" >Wartość początkowa środka trwałego: </label>
<div class="form-group row"> <div class="col-3">
<label for="initialValueSet" class="col-7" >Wartość początkowa środka trwałego: </label> <input type="text" class="form-control" id="initialValueSet" aria-describedby="initialValueHelpInline" formControlName="initialValueSet" required
<div class="col-3"> [ngModel]="asset.initialValueAsset"
<input type="text" class="form-control" id="initialValueSet" aria-describedby="initialValueHelpInline" formControlName="initialValueSet" required (ngModelChange)="asset.initialValueAsset=$event" />
[ngModel]="asset.initialValueAsset" </div>
(ngModelChange)="asset.initialValueAsset=$event" /> <div class="col-auto">
<span>PLN</span>
</div>
@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>
}@else{
}
</div>
<div class="form-group row">
<label for="depreciationRate" class="form-label col-3" >Stawka amortyzacyjna w procentach :</label>
<div class="col-3">
<input type="text" class="form-control" id="depreciationRate" formControlName="depreciationRate"
[ngModel]="asset.depreciationRate | number:'1.2-2'"
(ngModelChange)="asset.depreciationRate=$event"/>
</div>
<div class="col-auto">
<span>%</span>
</div>
</div>
<div class="form-group row">
<label class="form-label col-3">Rok i miesiąc rozpoczęcia amortyzacji</label>
<div class="col-1">
<input type="number" class="form-control" formControlName="year"
[ngModel]=asset.year
(ngModelChange)="asset.year=$event;calculate()" />
</div>
<div class="col-1">
<input type="number" class="form-control" formControlName="month"
[ngModel]=asset.month
(ngModelChange)="asset.month=$event;calculate()" />
</div>
</div>
</div> <div class="form-group row">
<div class="col-auto"> <label class="form-label col-3">Metoda amortyzacji</label>
<span>PLN</span> <div class="col-3" >
</div> <select class="form-control" formControlName="typeDepreciation"
@if(assetsDepreciationForm.get('initialValueSet')?.invalid && assetsDepreciationForm.get('initialValueSet')?.touched){ [ngModel]=asset.type
<div class="text-danger col-auto"> Wartość niepoprawna!. Podaj kwotę w zł np 3000.05 (czyli 3000 zł i 5 gr)</div> (ngModelChange)="asset.type=$event;calculate()" >
}@else{ <option [ngValue]=TypeDepreciation.linear selected="selected">Liniowa</option>
} <option [ngValue]=TypeDepreciation.digressive >Dygresywna</option>
</div> </select>
<div class="form-group row"> </div>
<label for="depreciationRate" class="col-7">Stawka amortyzacyjna w procentach :</label>
<div class="col-3"> </div>
<input type="text" class="form-control" id="depreciationRate" formControlName="depreciationRate" @if( TypeDepreciation.digressive === asset.type ){
[ngModel]="asset.depreciationRate | number:'1.2-2'" <div class="form-group row">
(ngModelChange)="asset.depreciationRate=$event"/> <label for="factorValue" class="form-label col-3">Wspólczynnki degresji</label>
</div> <div class="col-auto" >
<div class="col-auto"> <input type="text" class="form-control" formControlName="factorValue"
<span>%</span> [ngModel]="asset.factorValue | number:'1.2-2' "
</div> (ngModelChange)="asset.factorValue=$event;calculate()"/>
</div>
<div class="form-group row">
<label class="col-7">Rok i miesiąc rozpoczęcia amortyzacji</label>
<div class="col">
<input type="number" class="form-control" formControlName="year"
[ngModel]=asset.year
(ngModelChange)="asset.year=$event;calculate()" />
</div>
<div class="col">
<input type="number" class="form-control" formControlName="month"
[ngModel]=asset.month
(ngModelChange)="asset.month=$event;calculate()" />
</div>
</div> </div>
</div>
}
<div class="form-group row"> <input class="btn btn-secondary col-auto" name="calculate"
<label class="col-7">Metoda amortyzacji</label> [disabled]=assetsDepreciationForm.invalid (click)=calculate() type="button" value="Wylicz ">
<div class="col" >
<select class="form-control" formControlName="typeDepreciation"
[ngModel]=asset.type
(ngModelChange)="asset.type=$event;calculate()" >
<option [ngValue]=TypeDepreciation.linear selected="selected">Liniowa</option>
<option [ngValue]=TypeDepreciation.digressive >Dygresywna</option>
</select>
</div>
</div> </form>
@if( TypeDepreciation.digressive === asset.type ){ <div class="mt-5">
<div class="form-group row"> <table class="table table-striped frame2">
<label for="factorValue" class="col-7">Wspólczynnki degresji</label> <thead>
<div class="col-auto" > <tr>
<input type="text" class="form-control" formControlName="factorValue" <th scope="col">Lp</th>
[ngModel]="asset.factorValue | number:'1.2-2' " <th scope="col">Rok</th>
(ngModelChange)="asset.factorValue=$event;calculate()"/> <th scope="col">Miesiąc</th>
</div> <th scope="col">Kwota odpisu</th>
</div> <th scope="col">Lączny odpis</th>
} </tr>
</thead>
<input class="btn btn-secondary col-auto" name="calculate" <tbody>
[disabled]=assetsDepreciationForm.invalid (click)=calculate() type="button" value="Wylicz "> @for (position of positions.positions; track $index) {
</form>
</div>
<div class="col-6">
<table class="table table-striped frame2">
<thead>
<tr>
<th scope="col">Lp</th>
<th scope="col">Rok</th>
<th scope="col">Miesiąc</th>
<th scope="col">Kwota odpisu</th>
<th scope="col">Lączny odpis</th>
</tr>
</thead>
<tbody>
@for (position of positions.positions; track $index) {
<tr [class]="clazz(position)" > <tr [class]="clazz(position)" >
<th scope="row">{{$index+1}}</th> <th scope="row">{{$index+1}}</th>
<td>{{ position.when.year }}</td> <td>{{ position.when.year }}</td>
<td>{{ position.when.month }}</td> <td>{{ position.when.month }}</td>
<td>{{ position.calculatedDepreciation | number:'1.2-2' }}</td> <td>{{ position.calculatedDepreciation | number:'1.2-2' }}</td>
<td>{{ position.sum | number:'1.2-2' }}</td> <td>{{ position.sum | number:'1.2-2' }}</td>
</tr> </tr>
} }
</tbody> </tbody>
</table> </table>
</div>
</div> </div>
</div> </div>