Removing wrapper AssetDeprecations

This commit is contained in:
Artur 2024-11-19 22:06:53 +01:00
parent b863cdff91
commit 8893499650
4 changed files with 11 additions and 12 deletions

View File

@ -130,7 +130,7 @@
</tr>
</thead>
<tbody>
@for (position of amortizations.positions; track $index) {
@for (position of amortizations; track $index) {
<tr [class]="clazz(position)" class="text-center">
<th scope="row" >{{$index+1}}</th>
<td>{{ position.when.year }}</td>
@ -138,7 +138,7 @@
<td>{{ position.calculatedDepreciation | number:'1.2-2' }}</td>
<td>{{ position.sum | number:'1.2-2' }}</td>
</tr>
@if( 12 === position.when.month || $index === amortizations.positions.length-1){
@if( 12 === position.when.month || $index === amortizations.length-1){
<tr>
<td colspan="3">
</td>

View File

@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
import { ReactiveFormsModule, FormGroup, Validators, FormControl, FormBuilder, AbstractControl } from '@angular/forms';
import { DecimalPipe } from '@angular/common';
import {Asset, Positions, AssetPlanPosition, TypeDepreciation, YearMonth, AssetLifeChange, AssetDepreciationMethod, YearMonthUtil } from '../assets/asset';
import {Asset, AssetPlanPosition, TypeDepreciation, YearMonth, AssetLifeChange, AssetDepreciationMethod, YearMonthUtil } from '../assets/asset';
import {AssetService} from '../assets/service/asset.service'
import {TranslateModule} from "@ngx-translate/core";
@ -27,7 +27,7 @@ export class AssetCalculatorComponent implements OnInit, OnDestroy{
lifeFormArray ;
assetsDepreciationFormGroup : FormGroup;
amortizations = new Positions();
amortizations : AssetPlanPosition[]=[];
constructor(private fb: FormBuilder,
private assetService : AssetService){
@ -130,10 +130,10 @@ export class AssetCalculatorComponent implements OnInit, OnDestroy{
}
calculateToValues( positions:Positions ) {
calculateToValues( positions:AssetPlanPosition[] ) {
let sum = 0;
let sumThisYear = 0;
positions.positions.forEach(position => {
positions.forEach(position => {
position.calculatedDepreciation *= 0.01;
sum += position.calculatedDepreciation;
position.sum = sum;

View File

@ -120,6 +120,5 @@ export class AssetPlanPosition{
}
export class Positions {
positions : AssetPlanPosition[]=[];
}

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient} from '@angular/common/http';
import { Asset, Positions } from '../asset';
import { Asset, AssetPlanPosition } from '../asset';
import { Observable } from 'rxjs';
@ -20,8 +20,8 @@ export class AssetService {
constructor(private http: HttpClient) { }
calculate(asset: Asset) : Observable<Positions>{
return this.http.post<Positions>(this.assetUrl, asset) ;
calculate(asset: Asset) : Observable<AssetPlanPosition[]>{
return this.http.post<AssetPlanPosition[]>(this.assetUrl, asset) ;
}
}