Skip to content
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

fixes: qbd direct prod fix #1128

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class QbdDirectDashboardComponent implements OnInit {

this.importCodeFields = responses[5].import_settings?.import_code_fields;

this.chartOfAccounts = responses[5].import_settings.import_account_as_category ? responses[5].import_settings.chart_of_accounts : QbdDirectImportSettingModel.getChartOfAccountTypesList();
this.chartOfAccounts = responses[5].import_settings.import_account_as_category ? responses[5].import_settings.chart_of_accounts.map((item: string) => item.replace(/\s+/g, '')) : QbdDirectImportSettingModel.getChartOfAccountTypesList().map((item: string) => item.replace(/\s+/g, ''));

const queuedTasks: QbdDirectTaskLog[] = responses[2].results.filter((task: QbdDirectTaskLog) => this.exportLogProcessingStates.includes(task.status));
this.failedExpenseGroupCount = responses[2].results.filter((task: QbdDirectTaskLog) => task.status === TaskLogState.ERROR || task.status === TaskLogState.FATAL).length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class QbdDirectBaseMappingComponent implements OnInit {
this.cccExpenseObject = responses[0].credit_card_expense_export_type;
this.employeeFieldMapping = (responses[0].employee_field_mapping as unknown as FyleField);
this.nameInJE = responses[0].name_in_journal_entry;
this.chartOfAccounts = responses[1].import_settings.import_account_as_category ? responses[1].import_settings.chart_of_accounts : QbdDirectImportSettingModel.getChartOfAccountTypesList();
this.chartOfAccounts = responses[1].import_settings.import_account_as_category ? responses[1].import_settings.chart_of_accounts.map((item: string) => item.replace(/\s+/g, '')) : QbdDirectImportSettingModel.getChartOfAccountTypesList().map((item: string) => item.replace(/\s+/g, ''));

this.destinationField = this.getDestinationField(responses[0], responses[2].results);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class QbdDirectOnboardingConnectorComponent implements OnInit {

xmlFileContent: string;

isCompanyPathInvalid: boolean = true;
isCompanyPathInvalid: boolean;

password: string;

Expand Down Expand Up @@ -87,12 +87,12 @@ export class QbdDirectOnboardingConnectorComponent implements OnInit {
this.isDownloadfileLoading = true;
this.isCompanyPathInvalid = false;
this.qbdDirectConnectorService.postQbdDirectConntion({file_location: filePath}).subscribe((connectionResponse: QbdConnectorGet) => {
this.password = connectionResponse.password;
this.xmlFileContent = connectionResponse.qwc;
this.triggerManualDownload();
this.showDownloadLink = true;
this.password = connectionResponse.password;
this.xmlFileContent = connectionResponse.qwc;
Comment on lines +90 to +91
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security: Avoid storing sensitive data in component properties

Storing the password and XML content in component properties could expose sensitive data. Consider:

  1. Using a secure credential manager service
  2. Clearing sensitive data after use

Suggested approach:

// Create a secure service to handle credentials
@Injectable({providedIn: 'root'})
export class QbdCredentialService {
  private password: string;
  
  setPassword(pwd: string): void {
    this.password = pwd;
  }
  
  getPassword(): string {
    const pwd = this.password;
    this.password = undefined; // Clear after use
    return pwd;
  }
}

this.showDownloadLink = true;
this.isDownloadfileLoading = false;
this.triggerManualDownload();
});
Comment on lines 89 to 95
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add error handling to prevent stuck loading states

The subscription lacks error handling which could leave isDownloadfileLoading stuck as true if the request fails.

Add error handling:

 this.qbdDirectConnectorService.postQbdDirectConntion({file_location: filePath}).subscribe((connectionResponse: QbdConnectorGet) => {
   this.password = connectionResponse.password;
   this.xmlFileContent = connectionResponse.qwc;
   this.showDownloadLink = true;
   this.isDownloadfileLoading = false;
   this.triggerManualDownload();
+}, error => {
+  this.isDownloadfileLoading = false;
+  this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Failed to setup QBD connection');
 });

Committable suggestion skipped: line range outside the PR's diff.

this.isDownloadfileLoading = false;
} else {
this.isCompanyPathInvalid = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class DashboardErrorSectionComponent implements OnInit {
}

if (this.destinationField === AccountingField.ACCOUNT && this.appName === AppName.QBD_DIRECT) {
this.detailAccountType = this.chartOfAccounts;
this.detailAccountType = this.chartOfAccounts.map((item: string) => item.replace(/\s+/g, ''));
} else {
this.detailAccountType = undefined;
}
Expand Down
Loading