Some changes with comunications WS <--> Angular
This commit is contained in:
parent
199c02ab14
commit
6fa03e080c
|
|
@ -2,7 +2,7 @@ import {Component, OnInit } from '@angular/core';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} 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'
|
||||||
import {Asset, Positions, AssetPlanPosition } from './assets/asset';
|
import {Asset, Positions, AssetPlanPosition, TypeDepreciation } from './assets/asset';
|
||||||
import {AssetService} from './assets/service/asset.service'
|
import {AssetService} from './assets/service/asset.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
@ -37,6 +37,7 @@ import {AssetService} from './assets/service/asset.service'
|
||||||
[ngModel]="asset.year "
|
[ngModel]="asset.year "
|
||||||
(ngModelChange)="asset.year=$event;calculate()"
|
(ngModelChange)="asset.year=$event;calculate()"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<input type="number" id="month" name="month"
|
<input type="number" id="month" name="month"
|
||||||
[ngModel]="asset.month"
|
[ngModel]="asset.month"
|
||||||
(ngModelChange)="asset.month=$event;calculate()"
|
(ngModelChange)="asset.month=$event;calculate()"
|
||||||
|
|
@ -46,17 +47,21 @@ import {AssetService} from './assets/service/asset.service'
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Metoda amortyzacji</td>
|
<td>Metoda amortyzacji</td>
|
||||||
<td><select onchange="hideWskaznik()" id="rodzajAmortyzacji" name="metodaAmortyzacji" >
|
<td><select [ngModel]=asset.type
|
||||||
<option value="0" selected="selected"
|
(ngModelChange)="asset.type=$event;calculate() ">
|
||||||
>Liniowa</option>
|
<option [ngValue]="TypeDepreciation.linear" selected="selected">Liniowa</option>
|
||||||
<option value="1"
|
<option [ngValue]="TypeDepreciation.digressive" >Dygresywna</option>
|
||||||
>Dygresywna</option>
|
</select>
|
||||||
</select></td>
|
</td>
|
||||||
|
|
||||||
|
@if( TypeDepreciation.digressive === asset.type ){
|
||||||
<td id="wskaznik" style="display: block">
|
<td id="wskaznik" style="display: block">
|
||||||
<input type="text" id="factor" name="factor"
|
<input type="text" id="factor" name="factor"
|
||||||
[ngModel]="asset.factorValue | number:'1.2-2' "
|
[ngModel]="asset.factorValue | number:'1.2-2' "
|
||||||
(ngModelChange)="asset.factorValue=$event"/>
|
(ngModelChange)="asset.factorValue=$event;calculate()"/>
|
||||||
</td>
|
</td>
|
||||||
|
}
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<input class="btn btn-primary" name="calculate" (click)=calculate() type="button" value="Wylicz ">
|
<input class="btn btn-primary" name="calculate" (click)=calculate() type="button" value="Wylicz ">
|
||||||
|
|
||||||
|
|
@ -97,7 +102,7 @@ export class AssetCalculatorComponent implements OnInit{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TypeDepreciation = TypeDepreciation;
|
||||||
asset = new Asset();
|
asset = new Asset();
|
||||||
positions = new Positions();
|
positions = new Positions();
|
||||||
|
|
||||||
|
|
@ -115,6 +120,7 @@ export class AssetCalculatorComponent implements OnInit{
|
||||||
}
|
}
|
||||||
|
|
||||||
clazz(pos : AssetPlanPosition ){
|
clazz(pos : AssetPlanPosition ){
|
||||||
|
|
||||||
return pos.when.year % 2 === 0 ? "table-light" : "table-dark";
|
return pos.when.year % 2 === 0 ? "table-light" : "table-dark";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,16 @@
|
||||||
|
|
||||||
|
export enum TypeDepreciation{
|
||||||
|
linear, digressive
|
||||||
|
}
|
||||||
|
|
||||||
export class Asset {
|
export class Asset {
|
||||||
initialValueAsset = 2000;
|
initialValueAsset = 2000;
|
||||||
depreciationRate = 20;
|
|
||||||
year = 2024;
|
year = 2024;
|
||||||
month = 10;
|
month = 10;
|
||||||
|
|
||||||
|
type = TypeDepreciation.linear;
|
||||||
|
depreciationRate = 20;
|
||||||
factorValue = 2;
|
factorValue = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
let assetUrl: string ='https://api.arti24.eu/rest-api/assets/calculate';
|
let assetUrl: string ='https://api.arti24.eu/rest-api/assets/calculate';
|
||||||
|
//let assetUrl: string ='http://localhost:8801/rest-api/assets/calculate';
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue