invert boolean for fees

This commit is contained in:
Tykayn 2023-10-01 15:10:14 +02:00 committed by tykayn
parent e1f8e35ac4
commit 39479b858d
2 changed files with 65158 additions and 7 deletions

View File

@ -263,7 +263,7 @@ export default class {
if (mappingValueObject.convert_to_boolean_value) { if (mappingValueObject.convert_to_boolean_value) {
debugLog('convertProperty: is boolean_value_conversion') debugLog('convertProperty: is boolean_value_conversion')
convertedValue = this.convertToBooleanValue(originalValue) convertedValue = this.convertToYesOrNo(originalValue)
} else { } else {
debugLog('convertProperty: is NOT having boolean_value_conversion', mappingValueObject) debugLog('convertProperty: is NOT having boolean_value_conversion', mappingValueObject)
} }
@ -317,7 +317,7 @@ export default class {
// debug land // debug land
if (has_prise_type_combo_ccs) { if (has_prise_type_combo_ccs) {
newProperties['socket:type_2_combo:output'] = out; newProperties['socket:type_2_combo:output'] = out;
console.log('socket:type_2_combo:output', out, originalValue) // console.log('socket:type_2_combo:output', out, originalValue)
} }
if (we_use_max_output) { if (we_use_max_output) {
@ -353,6 +353,11 @@ export default class {
} }
if (configObject.invert_boolean_value) {
convertedValue = ! this.convertToBoolean(originalValue) ? 'yes' : 'no'
console.log('invert boolean', convertedValue, originalValue)
}
if (configObject.convert_to_phone) { if (configObject.convert_to_phone) {
@ -454,10 +459,7 @@ export default class {
* ---------------------- */ * ---------------------- */
debugLog('conditionnalConfig', conditionnalConfig) debugLog('conditionnalConfig', conditionnalConfig)
if (conditionnalConfig.invert_boolean_value) {
convertedValue = ! this.convertToBooleanValue(originalValue)
console.log('invert boolean', convertedValue, originalValue)
}
if (conditionnalConfig.ignore_this_data) { if (conditionnalConfig.ignore_this_data) {
debugLog(`on ignore cette clé car sa valeur "${originalValue}" est à exclure: `, pointKeyName, '=>', newKey) debugLog(`on ignore cette clé car sa valeur "${originalValue}" est à exclure: `, pointKeyName, '=>', newKey)
@ -531,7 +533,7 @@ export default class {
return convertedValue return convertedValue
} }
private convertToBooleanValue(originalValue: any) { private convertToYesOrNo(originalValue: any) {
debugLog('convertProperty: ==========> original value', originalValue) debugLog('convertProperty: ==========> original value', originalValue)
let convertedValue = ''; let convertedValue = '';
if (this.truthyValues.indexOf(originalValue) !== -1) { if (this.truthyValues.indexOf(originalValue) !== -1) {
@ -546,5 +548,20 @@ export default class {
} }
return convertedValue; return convertedValue;
} }
private convertToBoolean(originalValue: any) {
debugLog('convertProperty: ==========> original value', originalValue)
let convertedValue ;
if (this.truthyValues.indexOf(originalValue) !== -1) {
convertedValue = true
} else {
debugLog('convertProperty: ==========> !!! NOT in truthy values', originalValue)
}
if (this.falsyValues.indexOf(originalValue) !== -1) {
convertedValue = false
} else {
debugLog('convertProperty: ==========> !!! NOT in falsy values', originalValue)
}
return convertedValue;
}
} }

File diff suppressed because it is too large Load Diff