-
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
feat: Single credit line for Journal Entry #1017
Changes from 3 commits
9d25adf
35887c9
7a7acbe
08a2bdb
a7d3989
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 |
---|---|---|
|
@@ -206,6 +206,8 @@ export class NetsuiteExportSettingsComponent implements OnInit { | |
if (this.isOnboarding) { | ||
this.workspaceService.setOnboardingState(NetsuiteOnboardingState.IMPORT_SETTINGS); | ||
this.router.navigate([`/integrations/netsuite/onboarding/import_settings`]); | ||
} else if (this.isAdvancedSettingAffected()) { | ||
this.router.navigate(['/integrations/netsuite/main/configuration/advanced_settings']); | ||
Comment on lines
+209
to
+210
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. 🛠️ Refactor suggestion Reconsider Navigation Logic After Saving Settings In the |
||
} | ||
}, () => { | ||
this.isSaveInProgress = false; | ||
|
@@ -218,7 +220,59 @@ export class NetsuiteExportSettingsComponent implements OnInit { | |
this.router.navigate([`/integrations/netsuite/onboarding/connector`]); | ||
} | ||
|
||
private isAdvancedSettingAffected(): boolean { | ||
return (this.exportSettings?.configuration?.reimbursable_expenses_object !== NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY && this.exportSettingForm.value.reimbursableExportType === NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY) || (this.exportSettings?.configuration?.corporate_credit_card_expenses_object !== NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY && this.exportSettingForm.value.creditCardExportType === NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY); | ||
} | ||
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. 🛠️ Refactor suggestion Consider refactoring for improved readability. The Consider refactoring the method for improved readability: private isAdvancedSettingAffected(): boolean {
const isReimbursableChanged =
this.exportSettings?.configuration?.reimbursable_expenses_object !== NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY &&
this.exportSettingForm.value.reimbursableExportType === NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY;
const isCorporateCardChanged =
this.exportSettings?.configuration?.corporate_credit_card_expenses_object !== NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY &&
this.exportSettingForm.value.creditCardExportType === NetSuiteCorporateCreditCardExpensesObject.JOURNAL_ENTRY;
return isReimbursableChanged || isCorporateCardChanged;
} This refactored version separates the conditions for reimbursable and corporate card changes, making the code more readable and easier to maintain. |
||
|
||
private replaceContentBasedOnConfiguration(updatedConfiguration: string, existingConfiguration: string | undefined | null, exportType: string): string { | ||
const configurationUpdate = `You have changed the export type of $exportType expense from <b>$existingExportType</b> to <b>$updatedExportType</b>, | ||
which would impact a few configurations in the <b>Advanced settings</b>. <br><br>Please revisit the <b>Advanced settings</b> to check and enable the | ||
features that could help customize and automate your integration workflows.`; | ||
|
||
let content = ''; | ||
// If both are not none and it is an update case else for the new addition case | ||
if (updatedConfiguration && existingConfiguration) { | ||
content = configurationUpdate.replace('$exportType', exportType).replace('$existingExportType', existingConfiguration.toLowerCase().replace(/^\w/, (c: string) => c.toUpperCase())).replace('$updatedExportType', updatedConfiguration.toLowerCase().replace(/^\w/, (c: string) => c.toUpperCase())); | ||
} | ||
|
||
return content; | ||
} | ||
|
||
Comment on lines
+227
to
+240
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. 🛠️ Refactor suggestion Improve string manipulation and extract repeated logic. The Consider the following improvements:
Here's a refactored version: private capitalizeFirstLetter(str: string): string {
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
}
private replaceContentBasedOnConfiguration(updatedConfiguration: string, existingConfiguration: string | undefined | null, exportType: string): string {
if (updatedConfiguration && existingConfiguration) {
const existingExportTypeFormatted = this.capitalizeFirstLetter(existingConfiguration);
const updatedExportTypeFormatted = this.capitalizeFirstLetter(updatedConfiguration);
return `You have changed the export type of ${exportType} expense from <b>${existingExportTypeFormatted}</b> to <b>${updatedExportTypeFormatted}</b>,
which would impact a few configurations in the <b>Advanced settings</b>.<br><br>Please revisit the <b>Advanced settings</b> to check and enable the
features that could help customize and automate your integration workflows.`;
}
return '';
} This refactored version improves readability and reduces code duplication. |
||
private constructWarningMessage(): string { | ||
let content: string = ''; | ||
const existingReimbursableExportType = this.exportSettings?.configuration?.reimbursable_expenses_object; | ||
const existingCorporateCardExportType = this.exportSettings?.configuration?.corporate_credit_card_expenses_object; | ||
|
||
const updatedReimbursableExportType = this.exportSettingForm.value.reimbursableExportType ? this.exportSettingForm.value.reimbursableExportType : null; | ||
const updatedCorporateCardExportType = this.exportSettingForm.value.creditCardExportType ? this.exportSettingForm.value.creditCardExportType : null; | ||
|
||
let updatedExportType; | ||
let existingExportType; | ||
let exportType; | ||
|
||
if (existingReimbursableExportType !== updatedReimbursableExportType) { | ||
updatedExportType = updatedReimbursableExportType; | ||
existingExportType = existingReimbursableExportType; | ||
exportType = 'reimbursable'; | ||
} else if (existingCorporateCardExportType !== updatedCorporateCardExportType) { | ||
updatedExportType = updatedCorporateCardExportType; | ||
existingExportType = existingCorporateCardExportType; | ||
exportType = 'credit card'; | ||
} | ||
|
||
if (this.isAdvancedSettingAffected() && exportType) { | ||
content = this.replaceContentBasedOnConfiguration(updatedExportType, existingExportType, exportType); | ||
} | ||
|
||
return content; | ||
} | ||
|
||
Comment on lines
+241
to
+269
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. 🛠️ Refactor suggestion Simplify logic and handle multiple changes. The The current implementation only handles one change at a time. If both reimbursable and corporate card export types change, only the first change will be reported in the warning message. Consider refactoring the method to handle multiple changes and simplify the logic: private constructWarningMessage(): string {
const changes = [
{
type: 'reimbursable',
existing: this.exportSettings?.configuration?.reimbursable_expenses_object,
updated: this.exportSettingForm.value.reimbursableExportType
},
{
type: 'credit card',
existing: this.exportSettings?.configuration?.corporate_credit_card_expenses_object,
updated: this.exportSettingForm.value.creditCardExportType
}
];
return changes
.filter(change => change.existing !== change.updated && this.isAdvancedSettingAffected())
.map(change => this.replaceContentBasedOnConfiguration(change.updated, change.existing, change.type))
.join('<br><br>');
} This refactored version handles multiple changes, reduces redundancy, and improves readability. |
||
save(): void { | ||
if (this.isAdvancedSettingAffected() && this.exportSettings.configuration) { | ||
this.warningDialogText = this.constructWarningMessage(); | ||
this.isConfirmationDialogVisible = true; | ||
return; | ||
} | ||
this.constructPayloadAndSave({hasAccepted: true, event: ConfigurationWarningEvent.NETSUITE_EXPORT_SETTINGS}); | ||
} | ||
|
||
|
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.
🛠️ Refactor suggestion
Consider adding similar properties to Xero integration
The new properties added to the NetSuite integration (
singleCreditLineJELabel
andsingleCreditLineJESubLabel
) are also present in the QuickBooks Online integration. However, these properties are missing from the Xero integration. For consistency across integrations, consider:To check the current state of the Xero integration, run the following script: