Commit c875ef02826701652bf6a11ce87768b01b5c8a4c
1 parent
2e873df939
Exists in
master
perapihan parsing
Showing 1 changed file with 7 additions and 2 deletions Side-by-side Diff
partner-simplepay.js
... | ... | @@ -133,12 +133,17 @@ function _composeCompleteSn(responseDataObj) { |
133 | 133 | const cleanedData = { |
134 | 134 | token: serial, |
135 | 135 | cust_name: _getPropertyFromObjectSafe(info, 'cust_name'), |
136 | - tariff: _getPropertyFromObjectSafe(info, 'kelas') + 'VA', | |
136 | + tariff: _getPropertyFromObjectSafe(info, 'kelas'), | |
137 | 137 | total_kwh: _getPropertyFromObjectSafe(info, 'size') |
138 | 138 | } |
139 | 139 | |
140 | + if (cleanedData && cleanedData.tariff && typeof cleanedData === 'string' && (cleanedData.tariff.search(/VA$/) < 0) ) { | |
141 | + cleanedData.tariff += 'VA'; | |
142 | + | |
143 | + } | |
144 | + | |
140 | 145 | if (cleanedData.cust_name) { |
141 | - cleanedData.cust_name = cleanedData.cust_name.replace(/\W+/g, ' ').trim().replace(/\W+/g, '-').toUpperCase(); | |
146 | + cleanedData.cust_name = cleanedData.cust_name.replace(/\W+/g, ' ').replace(/\W+/g, '-').replace(/-+$/, '').replace(/^-+/, '').toUpperCase(); | |
142 | 147 | } |
143 | 148 | |
144 | 149 | if (cleanedData.total_kwh) { |