-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
intacct c1 import settings fix #962
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -57,20 +57,20 @@ export type IntacctDependentImportFields = { | |||||||||||
|
||||||||||||
export class ImportSettings { | ||||||||||||
static constructPayload(importSettingsForm: FormGroup, existingDependentFieldSettings: DependentFieldSetting | null): ImportSettingPost{ | ||||||||||||
const expenseFieldArray = importSettingsForm.value.expenseFields; | ||||||||||||
const expenseFieldArray = importSettingsForm.get('expenseFields')?.getRawValue(); | ||||||||||||
|
||||||||||||
// First filter out objects where import_to_fyle is false | ||||||||||||
const filteredExpenseFieldArray = expenseFieldArray.filter((field: MappingSetting) => field.destination_field && field.source_field); | ||||||||||||
|
||||||||||||
// Then map over the filtered array | ||||||||||||
const mappingSettings = filteredExpenseFieldArray.filter((field: MappingSetting) => field.source_field !== 'CATEGORY').map((field: MappingSetting) => { | ||||||||||||
return { | ||||||||||||
source_field: field.source_field.toUpperCase(), | ||||||||||||
destination_field: field.destination_field, | ||||||||||||
import_to_fyle: field.import_to_fyle, | ||||||||||||
is_custom: (field.source_field.toUpperCase() === 'PROJECT' || field.source_field.toUpperCase() === 'COST_CENTER') ? false : true, | ||||||||||||
source_placeholder: field.source_placeholder | ||||||||||||
}; | ||||||||||||
return { | ||||||||||||
source_field: field.source_field.toUpperCase(), | ||||||||||||
destination_field: field.destination_field, | ||||||||||||
import_to_fyle: field.import_to_fyle, | ||||||||||||
is_custom: (field.source_field.toUpperCase() === 'PROJECT' || field.source_field.toUpperCase() === 'COST_CENTER') ? false : true, | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify The ternary operator is unnecessary here. You can directly assign the negation of the condition to Apply this diff to simplify the assignment: -is_custom: (field.source_field.toUpperCase() === 'PROJECT' || field.source_field.toUpperCase() === 'COST_CENTER') ? false : true,
+is_custom: !(
+ field.source_field.toUpperCase() === 'PROJECT' ||
+ field.source_field.toUpperCase() === 'COST_CENTER'
+), Alternatively, for better readability, consider using -is_custom: (field.source_field.toUpperCase() === 'PROJECT' || field.source_field.toUpperCase() === 'COST_CENTER') ? false : true,
+is_custom: !['PROJECT', 'COST_CENTER'].includes(field.source_field.toUpperCase()), Committable suggestion
Suggested change
ToolsBiome
|
||||||||||||
source_placeholder: field.source_placeholder | ||||||||||||
}; | ||||||||||||
}); | ||||||||||||
|
||||||||||||
let dependentFieldSetting = null; | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle potential undefined
expenseFieldArray
to prevent runtime errorsIf
importSettingsForm.get('expenseFields')
returnsundefined
, thenexpenseFieldArray
will beundefined
, and callingexpenseFieldArray.filter(...)
will result in a runtime error. Consider providing a default empty array to prevent potential issues.Apply this diff to handle potential undefined
expenseFieldArray
:Committable suggestion