Convert YearMonth to text
This commit is contained in:
parent
1509538afb
commit
e75a8ee2fb
|
|
@ -74,9 +74,12 @@ interface FormValues {
|
||||||
|
|
||||||
this.addChangeValue();
|
this.addChangeValue();
|
||||||
|
|
||||||
const row = this.lifeFormArray.controls[ i -1 ] as FormGroup;
|
const row : FormGroup = this.lifeFormArray.controls[ i - 1 ];
|
||||||
row.get( 'initialValueAsset' )?.setValue(asset.life[i].initial);
|
const lifeChange : AssetLifeChange = asset.life[i];
|
||||||
// row.get( 'year_month' )?.setValue( asset.life[i].when.toFormValue());
|
row.get( 'initialValueAsset' )?.setValue( lifeChange.initial);
|
||||||
|
const ym : YearMonth = lifeChange.when;
|
||||||
|
//const when_txt = ym.toFormValue();
|
||||||
|
row.get( 'year_month' )?.setValue( lifeChange.when.year +'-' + lifeChange.when.month );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,21 @@ export enum TypeDepreciation{
|
||||||
export class YearMonth{
|
export class YearMonth{
|
||||||
readonly year : number ;
|
readonly year : number ;
|
||||||
readonly month : number ;
|
readonly month : number ;
|
||||||
constructor( year_month:string ){
|
|
||||||
const [ year, month ] = year_month.split( '-').map(Number);
|
constructor( year_month:string | YearMonth ){
|
||||||
|
if (typeof year_month === 'string') {
|
||||||
|
const [year, month] = year_month.split('-').map(Number);
|
||||||
this.year = year;
|
this.year = year;
|
||||||
this.month =month;
|
this.month = month;
|
||||||
|
} else {
|
||||||
|
this.year = year_month.year;
|
||||||
|
this.month = year_month.month;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
toFormValue(){
|
|
||||||
return this.year + "-" + this.month;
|
toFormValue() {
|
||||||
|
return `${this.year}-${this.month.toString().padStart(2, '0')}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue