@@ -104,24 +104,24 @@ const printStores = (stores) => {
104104const printHw = ( hw ) => {
105105 const descrWidthMax = config . hwDisplay . descriptionWidth ;
106106 const commentWidthMax = config . hwDisplay . commentWidth ;
107+ const serialIdWidthMax = config . hwDisplay . serialIdWidth ;
107108 let idWidth = 3 ;
108109 let categoryWidth = 9 ;
109110 let descrWidth = 6 ;
110- let storeWidth = 6 ;
111+ const purchDateWidth = 10 ;
111112 let priceWidth = 6 ;
112113 let curPriceWidth = 10 ;
113114 let condWidth = 5 ;
114115 let userWidth = 5 ;
115- let maxWidth = 4 ;
116116 let commentWidth = 8 ;
117+ let serialIdWidth = 8 ;
117118
118119 const today = ( new Date ( ) ) . toISOString ( ) . substr ( 0 , 10 ) ;
119120 let len ;
120121 let i ;
121122 hw . forEach ( ( item ) => {
122123 //
123124 let price = config . hwItems . getAgedPrice ( item . purchase_price , item . purchase_date , today ) ;
124- if ( item . max_price !== null ) { price = Math . min ( item . max_price , price ) ; }
125125 if ( item . condition === 'new' ) { price = item . purchase_price ; }
126126 item . current_price_calc = price ;
127127 //
@@ -131,8 +131,6 @@ const printHw = (hw) => {
131131 if ( len > categoryWidth ) { categoryWidth = len ; }
132132 len = item . description ? Math . min ( descrWidthMax , item . description . length ) : 0 ;
133133 if ( len > descrWidth ) { descrWidth = len ; }
134- len = item . store . length ;
135- if ( len > storeWidth ) { storeWidth = len ; }
136134 len = item . purchase_price . toString ( ) . length ;
137135 if ( len > priceWidth ) { priceWidth = len ; }
138136 len = item . current_price_calc . toString ( ) . length ;
@@ -141,15 +139,15 @@ const printHw = (hw) => {
141139 if ( len > condWidth ) { condWidth = len ; }
142140 len = item . user . length ;
143141 if ( len > userWidth ) { userWidth = len ; }
144- len = item . max_price !== null ? item . max_price . toString ( ) . length : 0 ;
145- if ( len > maxWidth ) { maxWidth = len ; }
142+ len = item . serial_id !== null ? Math . min ( serialIdWidthMax , item . serial_id . length ) : 0 ;
143+ if ( len > serialIdWidth ) { serialIdWidth = len ; }
146144 len = item . comment ? Math . min ( commentWidthMax , item . comment . length ) : 0 ;
147145 if ( len > commentWidth ) { commentWidth = len ; }
148146 } ) ;
149147 let str = printf (
150- ` %-${ idWidth } s | A | M | %-${ condWidth } s | %-${ categoryWidth } s | %-${ descrWidth } s | %- ${ storeWidth } s | `
151- + `pur. date: | %-${ priceWidth } s | %-${ curPriceWidth } s | %-${ maxWidth } s | %-${ userWidth } s | comment:\n` ,
152- 'id:' , 'cond:' , 'category:' , 'descr:' , 'store:' , ' price:', 'cur.price:' , 'max :' , 'user :' ,
148+ ` %-${ idWidth } s | A | M | %-${ condWidth } s | %-${ categoryWidth } s | %-${ descrWidth } s | `
149+ + `pur. date: | %-${ priceWidth } s | %-${ curPriceWidth } s | %-${ userWidth } s | %-${ serialIdWidth } s | comment:\n` ,
150+ 'id:' , 'cond:' , 'category:' , 'descr:' , 'price:' , 'cur.price:' , 'user :' , 'serial_id :' ,
153151 ) ;
154152 process . stdout . write ( str ) ;
155153 str = '-' ;
@@ -161,16 +159,16 @@ const printHw = (hw) => {
161159 str += '-+-' ;
162160 for ( i = 0 ; i < descrWidth ; i += 1 ) { str += '-' ; }
163161 str += '-+-' ;
164- for ( i = 0 ; i < storeWidth ; i += 1 ) { str += '-' ; }
165- str += '-+------------+- ' ;
162+ for ( i = 0 ; i < purchDateWidth ; i += 1 ) { str += '-' ; }
163+ str += '-+-' ;
166164 for ( i = 0 ; i < priceWidth ; i += 1 ) { str += '-' ; }
167165 str += '-+-' ;
168166 for ( i = 0 ; i < curPriceWidth ; i += 1 ) { str += '-' ; }
169167 str += '-+-' ;
170- for ( i = 0 ; i < maxWidth ; i += 1 ) { str += '-' ; }
171- str += '-+-' ;
172168 for ( i = 0 ; i < userWidth ; i += 1 ) { str += '-' ; }
173169 str += '-+-' ;
170+ for ( i = 0 ; i < serialIdWidth ; i += 1 ) { str += '-' ; }
171+ str += '-+-' ;
174172 for ( i = 0 ; i < commentWidth ; i += 1 ) { str += '-' ; }
175173 str += '-\n' ;
176174 process . stdout . write ( str ) ;
@@ -182,13 +180,16 @@ const printHw = (hw) => {
182180 const comment = item . comment
183181 ? ( item . comment . length <= commentWidthMax ? item . comment : `${ item . comment . substr ( 0 , commentWidthMax - 3 ) } ...` )
184182 : '' ;
183+ const serialId = item . serial_id
184+ ? ( item . serial_id . length <= serialIdWidthMax ? item . serial_id : `${ item . serial_id . substr ( 0 , serialIdWidthMax - 3 ) } ...` )
185+ : '' ;
185186 str = printf (
186- ` %${ idWidth } s | %s | %s | %-${ condWidth } s | %-${ categoryWidth } s | %-${ descrWidth } s | %- ${ storeWidth } s | `
187- + `%s | %${ priceWidth } s | %${ curPriceWidth } s | %${ maxWidth } s | %-${ userWidth } s | %s\n` ,
187+ ` %${ idWidth } s | %s | %s | %-${ condWidth } s | %-${ categoryWidth } s | %-${ descrWidth } s | `
188+ + `%s | %${ priceWidth } s | %${ curPriceWidth } s | %- ${ userWidth } s | %-${ serialIdWidth } s | %s\n` ,
188189 item . id . toString ( ) , item . active ? 'x' : ' ' , item . available ? 'x' : ' ' , item . condition , item . category , descr ,
189- item . store , item . purchase_date , item . purchase_price . toString ( ) ,
190- item . active ? item . current_price_calc . toString ( ) : '' , item . max_price !== null ? item . max_price . toString ( ) : '' ,
191- item . user , comment ,
190+ item . purchase_date , item . purchase_price . toString ( ) ,
191+ item . active ? item . current_price_calc . toString ( ) : '' ,
192+ item . user , serialId , comment ,
192193 ) ;
193194 process . stdout . write ( str ) ;
194195 } ) ;
0 commit comments