New version of assets
This commit is contained in:
parent
9aa7529863
commit
cd5e726089
|
|
@ -1,11 +1,4 @@
|
|||
|
||||
<!--
|
||||
<div class="container-sm">100% wide until small breakpoint</div>
|
||||
<div class="container-md">100% wide until medium breakpoint</div>
|
||||
<div class="container-lg">100% wide until large breakpoint</div>
|
||||
<div class="container-xl">100% wide until extra large breakpoint</div>
|
||||
<div class="container-xxl">100% wide until extra extra large breakpoint</div> -->
|
||||
|
||||
<div class="container mt-5">
|
||||
|
||||
<div class="row">
|
||||
|
|
@ -13,76 +6,76 @@
|
|||
</div>
|
||||
|
||||
<div class="row m-1 col-lg-4">
|
||||
<form [formGroup]=assetsDepreciationFormGroup class="frame">
|
||||
<div class="form-group row align-items-center mb-1">
|
||||
<div class="col-5 col-lg-6 text-start">
|
||||
<label class="form-label" for="initialValueAsset" >Wartość początkowa ŚT:</label>
|
||||
</div>
|
||||
<div class="col col-lg">
|
||||
<input class="form-control" formControlName="initialValueAsset" [(ngModel)]=initialValueAsset
|
||||
type="number" id="initialValueAsset" required >
|
||||
|
||||
@if(assetsDepreciationFormGroup.get('initialValueSet')?.invalid && assetsDepreciationFormGroup.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>
|
||||
<form [formGroup]=assetsDepreciationFormGroup class="frame">
|
||||
<div class="form-group row align-items-center mb-1">
|
||||
<div class="col-5 col-lg-6 text-start">
|
||||
<label class="form-label" for="initialValueAsset" >Wartość początkowa ŚT:</label>
|
||||
</div>
|
||||
<div class="col col-lg">
|
||||
<input class="form-control" formControlName="initialValueAsset" [(ngModel)]=initialValueAsset
|
||||
type="number" id="initialValueAsset" required >
|
||||
|
||||
@if(assetsDepreciationFormGroup.get('initialValueSet')?.invalid && assetsDepreciationFormGroup.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>
|
||||
|
||||
<div class="form-group row align-items-center">
|
||||
<div class="col-5 col-lg-6 text-start ">
|
||||
<label class="form-label" for="depreciationRate" >Stawka amortyzacyjna:</label>
|
||||
</div>
|
||||
<div class="col-3 col-lg-3">
|
||||
<input class="form-control" formControlName="depreciationRate" [(ngModel)]=depreciationRate
|
||||
type="number" id="depreciationRate" />
|
||||
</div>
|
||||
<div class="col-1 col-lg-1 text-start">
|
||||
<label for="depreciationRate">%</label>
|
||||
</div>
|
||||
<div class="form-group row align-items-center">
|
||||
<div class="col-5 col-lg-6 text-start ">
|
||||
<label class="form-label" for="depreciationRate" >Stawka amortyzacyjna:</label>
|
||||
</div>
|
||||
<div class="col-3 col-lg-3">
|
||||
<input class="form-control" formControlName="depreciationRate" [(ngModel)]=depreciationRate
|
||||
type="number" id="depreciationRate" />
|
||||
</div>
|
||||
<div class="col-1 col-lg-1 text-start">
|
||||
<label for="depreciationRate">%</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row align-items-center ">
|
||||
<div class="col-5 col-lg-6 text-start ">
|
||||
<label class="form-label">Rozpoczęcie amortyzacji:</label>
|
||||
</div>
|
||||
<div class="col-7 col-lg-6">
|
||||
<input type="month" lang="pl" class="form-control" formControlName="year_month" id="year_month" [(ngModel)]=year_month placeholder="2024" />
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group row align-items-center ">
|
||||
<div class="col-5 col-lg-6 text-start ">
|
||||
<label class="form-label">Rozpoczęcie amortyzacji:</label>
|
||||
</div>
|
||||
<div class="col-7 col-lg-6">
|
||||
<input type="month" lang="pl" class="form-control" formControlName="year_month" id="year_month" [(ngModel)]=year_month placeholder="2024" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row align-items-center">
|
||||
<div class="col-5 col-lg text-start " >
|
||||
<label class="form-label">Metoda amortyzacji:</label>
|
||||
</div>
|
||||
<div class="col col-lg" >
|
||||
<select class="form-select" formControlName="typeDepreciation" [(ngModel)]=typeDepreciation >
|
||||
<option [ngValue]=TypeDepreciation.linear selected="selected">Liniowa</option>
|
||||
<option [ngValue]=TypeDepreciation.digressive >Dygresywna</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row align-items-center">
|
||||
<div class="col-5 col-lg text-start " >
|
||||
<label class="form-label">Metoda amortyzacji:</label>
|
||||
@if( TypeDepreciation.digressive === typeDepreciation() ){
|
||||
<div class="form-group row align-items-center">
|
||||
<div class="col-5 col-lg text-start ">
|
||||
<label for="factorValue" class="form-label">Wspólczynnki degresji</label>
|
||||
</div>
|
||||
<div class="col col-lg" >
|
||||
<select class="form-select" formControlName="typeDepreciation" [(ngModel)]=typeDepreciation >
|
||||
<option [ngValue]=TypeDepreciation.linear selected="selected">Liniowa</option>
|
||||
<option [ngValue]=TypeDepreciation.digressive >Dygresywna</option>
|
||||
</select>
|
||||
<input type="text" class="form-control" formControlName="factorValue" [(ngModel)]=factorValue />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if( TypeDepreciation.digressive === typeDepreciation() ){
|
||||
<div class="form-group row align-items-center">
|
||||
<div class="col-5 col-lg text-start ">
|
||||
<label for="factorValue" class="form-label">Wspólczynnki degresji</label>
|
||||
</div>
|
||||
<div class="col col-lg" >
|
||||
<input type="text" class="form-control" formControlName="factorValue" [(ngModel)]=factorValue />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<!-- <input class="btn btn-secondary col-auto" name="calculate"
|
||||
[disabled]=assetsDepreciationFormGroup.invalid (click)=calculate() type="button" value="Wylicz "> -->
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-1">
|
||||
<input class="btn btn-secondary col-auto" name="addChangeValue"
|
||||
[disabled]=assetsDepreciationFormGroup.invalid (click)=addChangeValue() type="button" value="Dodaj zmianę wartości ">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {Component, effect, computed, OnInit, signal } from '@angular/core';
|
||||
import {Component, effect, OnInit, signal } from '@angular/core';
|
||||
import {ReactiveFormsModule, FormGroup, Validators, FormControl, FormArray} from '@angular/forms';
|
||||
import {CurrencyPipe,DecimalPipe,PercentPipe, NgFor} from '@angular/common';
|
||||
|
||||
|
|
|
|||
|
|
@ -65,16 +65,8 @@ export class AssetsContainer{
|
|||
assets: Map<string,Asset> = new Map();
|
||||
|
||||
constructor(){
|
||||
this.initDefault();
|
||||
}
|
||||
|
||||
initDefault(){
|
||||
const yearMonth = new YearMonth('2024-11');
|
||||
this.assets.set('Inv01', new Asset( 1000, yearMonth, TypeDepreciation.linear, 20 ) );
|
||||
this.assets.set('Inv02', new Asset( 3000, yearMonth, TypeDepreciation.linear, 20 ) );
|
||||
this.assets.set('Inv03', new Asset( 5000, yearMonth, TypeDepreciation.linear, 15 ) );
|
||||
|
||||
}
|
||||
|
||||
delete( nrInv: string ){
|
||||
this.assets.delete(nrInv);
|
||||
|
|
|
|||
|
|
@ -1,66 +1,103 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { AssetsContainer, Asset } from '../asset-calculator/assets/asset';
|
||||
import { AssetsContainer, Asset, TypeDepreciation, YearMonth } from '../asset-calculator/assets/asset';
|
||||
import { ReactiveFormsModule, FormBuilder, FormGroup, Validators, FormControl, FormArray} from '@angular/forms';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-fixed-asset',
|
||||
standalone: true,
|
||||
imports: [],
|
||||
imports: [ReactiveFormsModule],
|
||||
template:`
|
||||
|
||||
<div class="container">
|
||||
|
||||
<h2 class="text-center m-2">Lista środków trwałych( prace w toku )</h2>
|
||||
<h2 class="text-center m-2">Lista środków trwałych</h2>
|
||||
<div class="table-responsive">
|
||||
<table id="assets" class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-2">Numer inwentarzowy</th>
|
||||
<th class="col-2">Zmiany wartości</th>
|
||||
<th class="col-2">Wartość</th>
|
||||
<th class="col-2">Metoda amortyzacji</th>
|
||||
<th class="col-2">Plan</th>
|
||||
<th class="col-2" ></th>
|
||||
<th class="col-2">Stawka</th>
|
||||
<th class="col-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for( asset of assetsContainer.getNrAssets(); track asset[0] ) {
|
||||
<tr>
|
||||
<td class="col-2"> {{asset[0]}} </td>
|
||||
<td class="col-2">
|
||||
<a href="/assets/Inv1/life-browsing"><b>1</b> zmian</a></td>
|
||||
<td class="col-2">
|
||||
<a href="/assets/Inv1/methods-browsing"><b>1</b> metod</a></td>
|
||||
|
||||
<td class="col-2"><a href="/assets/Inv1/plan-calculate"><b>Wylicz plan</b></a></td>
|
||||
<td class="col-2">
|
||||
<input type="button" class="btn btn-outline-secondary" (click)="delete(asset[0])" value="Usuń Składnik">
|
||||
</td>
|
||||
<tbody>
|
||||
|
||||
@for( assetFormGroup of assetFormArray.controls; track $index ) {
|
||||
<tr [formGroup] = "assetFormGroup">
|
||||
<td> <input class="form-control" formControlName="nr" type="text" readonly></td>
|
||||
<td> <input class="form-control" formControlName="initialValue" type="number" placeholder="Wprowadź wartość"></td>
|
||||
<td>
|
||||
<select class="form-select" formControlName="typeDepreciation" >
|
||||
<option [ngValue]=TypeDepreciation.linear selected="selected">Liniowa</option>
|
||||
<option [ngValue]=TypeDepreciation.digressive >Dygresywna</option>
|
||||
</select>
|
||||
</td>
|
||||
<td> <input class="form-control" formControlName="depreciationRate" type="number" /> </td>
|
||||
|
||||
<td class="col-2">
|
||||
<input type="button" class="btn btn-outline-secondary" (click)="delete($index)" value="Usuń Składnik">
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
}
|
||||
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<input type="button" (click)=initDefault() class="btn btn-outline-secondary" value="Zainicjuj domyślną listę">
|
||||
<input type="button" (click)=addNew() class="btn btn-outline-secondary" value="Dodaj Składnik">
|
||||
</div>
|
||||
`,
|
||||
styleUrl: './fixed-asset.component.css'
|
||||
})
|
||||
export class FixedAssetComponent {
|
||||
|
||||
static indexNr = 1;
|
||||
|
||||
TypeDepreciation = TypeDepreciation;
|
||||
|
||||
assetsContainer : AssetsContainer;
|
||||
|
||||
|
||||
assetFormArray : FormArray<FormGroup>;
|
||||
|
||||
|
||||
constructor(){
|
||||
constructor( private fb: FormBuilder ){
|
||||
|
||||
this.assetsContainer = new AssetsContainer ();
|
||||
this.assetFormArray = this.fb.array<FormGroup>([])
|
||||
|
||||
}
|
||||
initDefault(){
|
||||
this.assetsContainer.initDefault();
|
||||
|
||||
delete( index : number ){
|
||||
this.assetFormArray.removeAt( index );
|
||||
}
|
||||
|
||||
delete( nrInv : string){
|
||||
this.assetsContainer.delete( nrInv );
|
||||
addNew(){
|
||||
this.addNr("NrInv" + FixedAssetComponent.indexNr++ );
|
||||
}
|
||||
|
||||
|
||||
addNr( nrInv:string ):void{
|
||||
|
||||
const today = new Date();
|
||||
const year = today.getFullYear();
|
||||
const month = today.getMonth() + 1;
|
||||
const year_month = year +'-'+month;
|
||||
const yearMonth = new YearMonth( year_month ) ;
|
||||
const asset = new Asset( 20, yearMonth, TypeDepreciation.linear, 10 );
|
||||
|
||||
const newRow= this.fb.group({
|
||||
nr : [ nrInv ],
|
||||
initialValue : [ 10000 ],
|
||||
depreciationRate : [ 10 ],
|
||||
typeDepreciation : [ TypeDepreciation.linear ],
|
||||
year_month : [ year_month ]
|
||||
})
|
||||
this.assetFormArray.push( newRow );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue