Some changes with row life of asset

This commit is contained in:
Artur 2024-11-04 09:27:33 +01:00
parent aaa358d3b7
commit 1509538afb
2 changed files with 13 additions and 2 deletions

View File

@ -71,20 +71,28 @@ interface FormValues {
factorValue : asset.factorValue, factorValue : asset.factorValue,
}) })
for( let i = 1; i < asset.life.length; i++ ){ for( let i = 1; i < asset.life.length; i++ ){
this.addChangeValue(); this.addChangeValue();
// /this.lifeFormArray.controls[ i -1 ]..patchValue( asset.life[i].initial );
const row = this.lifeFormArray.controls[ i -1 ] as FormGroup;
row.get( 'initialValueAsset' )?.setValue(asset.life[i].initial);
// row.get( 'year_month' )?.setValue( asset.life[i].when.toFormValue());
} }
} }
} }
private controlsToAsset() : Asset { private controlsToAsset() : Asset {
const formValues = this.assetsDepreciationFormGroup.value as FormValues; const formValues = this.assetsDepreciationFormGroup.value as FormValues;
const when = new YearMonth( formValues.year_month ); const when = new YearMonth( formValues.year_month );
const asset = new Asset( formValues.depreciationRate, when, formValues.typeDepreciation, formValues.factorValue ); const asset = new Asset( formValues.depreciationRate, when, formValues.typeDepreciation, formValues.factorValue );
const creationlifeChange = new AssetLifeChange(when, formValues.initialValueAsset , 0, 0); const creationlifeChange = new AssetLifeChange(when, formValues.initialValueAsset , 0, 0);
asset.addChange( creationlifeChange ); asset.addChange( creationlifeChange );
for (let changeControlGroup of this.lifeFormArray.controls) {
for( let changeControlGroup of this.lifeFormArray.controls ) {
const initialValueAsset = changeControlGroup.get('initialValueAsset')?.value; const initialValueAsset = changeControlGroup.get('initialValueAsset')?.value;
const year_month = changeControlGroup.get('year_month')?.value; const year_month = changeControlGroup.get('year_month')?.value;
asset.addChange(new AssetLifeChange(new YearMonth(year_month), initialValueAsset, 0, 0)); asset.addChange(new AssetLifeChange(new YearMonth(year_month), initialValueAsset, 0, 0));

View File

@ -12,6 +12,9 @@ export class YearMonth{
this.month =month; this.month =month;
} }
toFormValue(){
return this.year + "-" + this.month;
}
} }