Convert YearMonth to text
This commit is contained in:
parent
1509538afb
commit
e75a8ee2fb
|
|
@ -74,9 +74,12 @@ interface FormValues {
|
|||
|
||||
this.addChangeValue();
|
||||
|
||||
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());
|
||||
const row : FormGroup = this.lifeFormArray.controls[ i - 1 ];
|
||||
const lifeChange : AssetLifeChange = asset.life[i];
|
||||
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{
|
||||
readonly year : number ;
|
||||
readonly month : number ;
|
||||
constructor( year_month:string ){
|
||||
const [ year, month ] = year_month.split( '-').map(Number);
|
||||
this.year = year;
|
||||
this.month =month;
|
||||
|
||||
constructor( year_month:string | YearMonth ){
|
||||
if (typeof year_month === 'string') {
|
||||
const [year, month] = year_month.split('-').map(Number);
|
||||
this.year = year;
|
||||
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