@@ -104,24 +104,24 @@ const printStores = (stores) => {
104
104
const printHw = ( hw ) => {
105
105
const descrWidthMax = config . hwDisplay . descriptionWidth ;
106
106
const commentWidthMax = config . hwDisplay . commentWidth ;
107
+ const serialIdWidthMax = config . hwDisplay . serialIdWidth ;
107
108
let idWidth = 3 ;
108
109
let categoryWidth = 9 ;
109
110
let descrWidth = 6 ;
110
- let storeWidth = 6 ;
111
+ const purchDateWidth = 10 ;
111
112
let priceWidth = 6 ;
112
113
let curPriceWidth = 10 ;
113
114
let condWidth = 5 ;
114
115
let userWidth = 5 ;
115
- let maxWidth = 4 ;
116
116
let commentWidth = 8 ;
117
+ let serialIdWidth = 8 ;
117
118
118
119
const today = ( new Date ( ) ) . toISOString ( ) . substr ( 0 , 10 ) ;
119
120
let len ;
120
121
let i ;
121
122
hw . forEach ( ( item ) => {
122
123
//
123
124
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 ) ; }
125
125
if ( item . condition === 'new' ) { price = item . purchase_price ; }
126
126
item . current_price_calc = price ;
127
127
//
@@ -131,8 +131,6 @@ const printHw = (hw) => {
131
131
if ( len > categoryWidth ) { categoryWidth = len ; }
132
132
len = item . description ? Math . min ( descrWidthMax , item . description . length ) : 0 ;
133
133
if ( len > descrWidth ) { descrWidth = len ; }
134
- len = item . store . length ;
135
- if ( len > storeWidth ) { storeWidth = len ; }
136
134
len = item . purchase_price . toString ( ) . length ;
137
135
if ( len > priceWidth ) { priceWidth = len ; }
138
136
len = item . current_price_calc . toString ( ) . length ;
@@ -141,15 +139,15 @@ const printHw = (hw) => {
141
139
if ( len > condWidth ) { condWidth = len ; }
142
140
len = item . user . length ;
143
141
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 ; }
146
144
len = item . comment ? Math . min ( commentWidthMax , item . comment . length ) : 0 ;
147
145
if ( len > commentWidth ) { commentWidth = len ; }
148
146
} ) ;
149
147
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 :' ,
153
151
) ;
154
152
process . stdout . write ( str ) ;
155
153
str = '-' ;
@@ -161,16 +159,16 @@ const printHw = (hw) => {
161
159
str += '-+-' ;
162
160
for ( i = 0 ; i < descrWidth ; i += 1 ) { str += '-' ; }
163
161
str += '-+-' ;
164
- for ( i = 0 ; i < storeWidth ; i += 1 ) { str += '-' ; }
165
- str += '-+------------+- ' ;
162
+ for ( i = 0 ; i < purchDateWidth ; i += 1 ) { str += '-' ; }
163
+ str += '-+-' ;
166
164
for ( i = 0 ; i < priceWidth ; i += 1 ) { str += '-' ; }
167
165
str += '-+-' ;
168
166
for ( i = 0 ; i < curPriceWidth ; i += 1 ) { str += '-' ; }
169
167
str += '-+-' ;
170
- for ( i = 0 ; i < maxWidth ; i += 1 ) { str += '-' ; }
171
- str += '-+-' ;
172
168
for ( i = 0 ; i < userWidth ; i += 1 ) { str += '-' ; }
173
169
str += '-+-' ;
170
+ for ( i = 0 ; i < serialIdWidth ; i += 1 ) { str += '-' ; }
171
+ str += '-+-' ;
174
172
for ( i = 0 ; i < commentWidth ; i += 1 ) { str += '-' ; }
175
173
str += '-\n' ;
176
174
process . stdout . write ( str ) ;
@@ -182,13 +180,16 @@ const printHw = (hw) => {
182
180
const comment = item . comment
183
181
? ( item . comment . length <= commentWidthMax ? item . comment : `${ item . comment . substr ( 0 , commentWidthMax - 3 ) } ...` )
184
182
: '' ;
183
+ const serialId = item . serial_id
184
+ ? ( item . serial_id . length <= serialIdWidthMax ? item . serial_id : `${ item . serial_id . substr ( 0 , serialIdWidthMax - 3 ) } ...` )
185
+ : '' ;
185
186
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` ,
188
189
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 ,
192
193
) ;
193
194
process . stdout . write ( str ) ;
194
195
} ) ;
0 commit comments