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

feat: onboarding basic setup #1055

Merged
merged 3 commits into from
Nov 13, 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
17 changes: 11 additions & 6 deletions src/app/branding/c1-contents-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ export const brandingConfig: BrandingConfiguration = config as BrandingConfigura
export const c1Contents = {
qbd_direct: {
landing: {
contentText: 'Import chart of accounts and projects from NetSuite and export expenses from your Expense Management account.',
contentText: 'Import data from QuickBooks Desktop to ' + brandingConfig.brandName + ' and export expenses from ' + brandingConfig.brandName + ' to QuickBooks Desktop',
guideHeaderText: 'How to setup your integration'
},
configuration: {
preRequisite: {
stepName: 'Prerequisites',
configurationHeaderText: 'Getting started',
configurationSubHeaderText: 'Begin your QuickBooks integration by completing the following steps.'
},
connector: {
configurationHeaderText: 'Connect to NetSuite subsidary',
configurationSubHeaderText: 'Expenses will be posted to the NetSuite subsidary selected here. You can\'t change the subsidary once they\'re configured.',
stepName: 'Connect to NetSuite',
configurationHeaderText: 'Connect to QuickBooks Desktop',
configurationSubHeaderText: 'Connect to QuickBooks desktop by completing the following steps.',
stepName: 'Connect to QuickBooks Desktop',
subLabel: 'Provide your credentials to establish a secure connection between your Expense Management and NetSuite account'
},
exportSetting: {
Expand Down Expand Up @@ -73,7 +78,7 @@ export const c1Contents = {
stepName: 'Advanced settings',
contentText: 'Customize the integration based on your accounting requirements.',
customizeSectionLabel: 'Customization',
customizeSectionSubLabel: 'In this section, you can customize the data that you\'d like to export from Fyle to QuickBooks Desktop You can choose what data points need to be exported and what shouldn\'t be.',
customizeSectionSubLabel: 'In this section, you can customize the data that you\'d like to export from ' + brandingConfig.brandName + ' to QuickBooks Desktop You can choose what data points need to be exported and what shouldn\'t be.',
automationLabel: 'Automation',
automationSubLabel: 'You can automate the export and sync of your data in this section.',
scheduleAutoExportLabel: 'Schedule automatic export',
Expand All @@ -88,7 +93,7 @@ export const c1Contents = {
otherPreferencesLabel: 'Other preferences',
otherPreferencesSubLabel: 'Based on your preference, you can choose whether you want to create any new records in QuickBooks Desktop from ' + brandingConfig.brandName + '.',
autoCreateMerchantsAsVendorsLabel: 'Auto-create merchants as vendors',
autoCreateMerchantsAsVendorsSubLabel: 'Fyle will auto-create a new vendor in QuickBooks Desktop if a merchant added by an employee does not have a corresponding match in QuickBooks Desktop. ',
autoCreateMerchantsAsVendorsSubLabel: '' + brandingConfig.brandName + ' will auto-create a new vendor in QuickBooks Desktop if a merchant added by an employee does not have a corresponding match in QuickBooks Desktop. ',
skipExportLabel: 'Skip export of specific expenses from ' + brandingConfig.brandName + ' to QuickBooks Desktop',
skipExportSubLabel: 'You could choose to skip expenses from ' + brandingConfig.brandName + ' to QuickBooks Desktop by setting up a conditional rule. ',
autoCreateReimbursableEnitityLabel: 'Auto create reimbursable enitity',
Expand Down
13 changes: 9 additions & 4 deletions src/app/branding/fyle-contents-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ export const brandingConfig: BrandingConfiguration = config as BrandingConfigura
export const fyleContents = {
qbd_direct: {
landing: {
contentText: 'Import data from NetSuite to ' + brandingConfig.brandName + ' and export expenses from ' + brandingConfig.brandName + ' to NetSuite. ',
contentText: 'Import data from QuickBooks Desktop to Fyle and export expenses from Fyle to QuickBooks Desktop',
guideHeaderText: 'Guide to setup your integrations'
},
configuration: {
preRequisite: {
stepName: 'Prerequisites',
configurationHeaderText: 'Getting started',
configurationSubHeaderText: 'Begin your QuickBooks integration by completing the following steps.'
},
connector: {
configurationHeaderText: 'Connect to NetSuite Tenant',
configurationSubHeaderText: 'Connect to the NetSuite Tenant from which you would like to import and export data. The ' + brandingConfig.brandName + ' org and NetSuite Tenant cannot be changed once the configuration steps are complete.',
stepName: 'Connect to NetSuite',
configurationHeaderText: 'Connect to QuickBooks desktop',
configurationSubHeaderText: 'Connect to QuickBooks desktop by completing the following steps.',
stepName: 'Connect to QuickBooks Desktop',
subLabel: 'Expenses will be posted to the NetSuite Tenant Mapping selected here. Once configured, you can not change ' + brandingConfig.brandName + ' organization or Tenant Mapping.'
},
exportSetting: {
Expand Down
5 changes: 5 additions & 0 deletions src/app/core/models/branding/content-configuration.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export type ContentConfiguration = {
guideHeaderText: string;
},
configuration: {
preRequisite: {
stepName: string;
configurationHeaderText: string;
configurationSubHeaderText: string;
}
connector: {
stepName: string;
subLabel: string;
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/models/common/helper.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FormGroup, Validators } from "@angular/forms";

export type checkBoxEvent = {
export type CheckBoxUpdate = {
id: number;
value: boolean;
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/models/db/workspaces.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export type Workspace = {
created_at: Date;
updated_at: Date;
}

export type WorkspaceOnboardingState = {
onboarding_state: string;
}
16 changes: 14 additions & 2 deletions src/app/core/models/enum/enum.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export enum QbdDirectOnboardingState {
CONFIRM_PRE_REQUISITES = 'CONFIRM_PRE_REQUISITES',
PENDING_QWC_UPLOAD = 'PENDING_QWC_UPLOAD',
INCORRECT_COMPANY_PATH = 'INCORRECT_COMPANY_PATH',
IN_CORRECT_PASSWORD = 'IN_CORRECT_PASSWORD',
INCORRECT_PASSWORD = 'INCORRECT_PASSWORD',
DESTINATION_SYNC_IN_PROGRESS = 'DESTINATION_SYNC_IN_PROGRESS',
DESTINATION_SYNC_COMPLETE = 'DESTINATION_SYNC_COMPLETE',
}
Expand All @@ -348,7 +348,8 @@ export enum ConfigurationCta {
CONTINUE = 'Continue',
SAVING = 'Saving',
SYNCING = 'Syncing',
UPDATE = 'Update connection'
UPDATE = 'Update connection',
NEXT = 'Next'
}

export enum QBDReimbursableExpensesObject {
Expand Down Expand Up @@ -883,3 +884,14 @@ export enum ThemeOption {
LIGHT = 'light',
DARK = 'dark'
}

export enum QBDPreRequisiteState {
COMPLETE = 'COMPLETE',
INCOMPLETE = 'INCOMPLETE'
}

export enum QBDConnectionStatus {
SUCCESS = 'SUCCESS',
INCORRECT_COMPANY_PATH = 'INCORRECT_COMPANY_PATH',
IN_CORRECT_PASSWORD = 'IN_CORRECT_PASSWORD'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { QBDPreRequisiteState } from "../../enum/enum.model";

export type QbdConnectorPost = {
file_location: string;
}

export type QbdConnectorGet = {
id: number,
workspace_id: number,
username: string,
password: string,
Comment on lines +10 to +11
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

Consider implementing secure password handling

The model exposes sensitive credentials as plain strings. Consider implementing proper encryption or secure handling mechanisms for the password field.

Recommendations:

  1. Never expose plain passwords in API responses
  2. Consider implementing a more secure authentication mechanism
  3. If password must be stored, ensure it's properly hashed/encrypted at the data layer

ticket_id: string,
file_location: string,
qwc: string,
created_at: Date,
updated_at: Date
}

export type QBDPrerequisiteObject = {
id: number,
label: string,
caption: string,
externalLink?: string,
iconName: string,
state: QBDPreRequisiteState
}

export type SyncDataType = {
attribute_type: string;
count: null | number
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { brandingContent, brandingFeatureConfig } from "src/app/branding/branding-config";
import { QbdDirectOnboardingState } from "../../enum/enum.model";
import { OnboardingStepper } from "../../misc/onboarding-stepper.model";

type QbdOnboardingStepperMap = {
[QbdDirectOnboardingState.YET_TO_START]: number;
[QbdDirectOnboardingState.CONFIRM_PRE_REQUISITES]: number;
[QbdDirectOnboardingState.CONNECTION]: number;
[QbdDirectOnboardingState.PENDING_QWC_UPLOAD]: number;
[QbdDirectOnboardingState.INCORRECT_COMPANY_PATH]: number;
[QbdDirectOnboardingState.INCORRECT_PASSWORD]: number;
[QbdDirectOnboardingState.DESTINATION_SYNC_IN_PROGRESS]: number;
[QbdDirectOnboardingState.DESTINATION_SYNC_COMPLETE]: number;
[QbdDirectOnboardingState.EXPORT_SETTINGS]: number;
[QbdDirectOnboardingState.IMPORT_SETTINGS]: number;
[QbdDirectOnboardingState.ADVANCED_SETTINGS]: number;
[QbdDirectOnboardingState.COMPLETE]: number;
}

export class QbdDirectOnboardingModel {
brandingContent = brandingContent.qbd_direct.configuration;

private onboardingSteps: OnboardingStepper[] = [
{
active: false,
completed: false,
step: this.brandingContent.preRequisite.stepName,
icon: 'arrow-tail-up-medium',
route: '/integrations/qbo/onboarding/pre_requisite',
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

Fix incorrect integration routes

The routes contain 'qbo' (QuickBooks Online) but this is a QBD (QuickBooks Desktop) integration model. This mismatch could cause routing issues.

Apply this pattern to fix all routes:

-  route: '/integrations/qbo/onboarding/pre_requisite',
+  route: '/integrations/qbd/onboarding/pre_requisite',

Also applies to: 37-37, 45-45, 53-53, 61-61

styleClasses: ['step-name-pre-requisite--text']
},
{
active: false,
completed: false,
step: this.brandingContent.connector.stepName,
icon: 'link-vertical-medium',
route: '/integrations/qbo/onboarding/connector',
styleClasses: ['step-name-connector--text !tw-left-[-70px]']
},
{
active: false,
completed: false,
step: this.brandingContent.exportSetting.stepName,
icon: 'arrow-tail-up-medium',
route: '/integrations/qbo/onboarding/export_settings',
styleClasses: ['step-name-export--text']
},
{
active: false,
completed: false,
step: this.brandingContent.importSetting.stepName,
icon: 'arrow-tail-down-medium',
route: '/integrations/qbo/onboarding/import_settings',
styleClasses: ['step-name-export--text']
},
{
active: false,
completed: false,
step: this.brandingContent.advancedSettings.stepName,
icon: 'gear-medium',
route: '/integrations/qbo/onboarding/advanced_settings',
styleClasses: ['step-name-advanced--text']
}
];

private readonly onboardingStateStepMap: QbdOnboardingStepperMap = {
[QbdDirectOnboardingState.YET_TO_START]: 1,
[QbdDirectOnboardingState.CONFIRM_PRE_REQUISITES]: 1,
[QbdDirectOnboardingState.CONNECTION]: 2,
[QbdDirectOnboardingState.PENDING_QWC_UPLOAD]: 2,
[QbdDirectOnboardingState.INCORRECT_COMPANY_PATH]: 2,
[QbdDirectOnboardingState.INCORRECT_PASSWORD]: 2,
[QbdDirectOnboardingState.DESTINATION_SYNC_IN_PROGRESS]: 2,
[QbdDirectOnboardingState.DESTINATION_SYNC_COMPLETE]: 2,
[QbdDirectOnboardingState.EXPORT_SETTINGS]: 3,
[QbdDirectOnboardingState.IMPORT_SETTINGS]: 4,
[QbdDirectOnboardingState.ADVANCED_SETTINGS]: 5,
[QbdDirectOnboardingState.COMPLETE]: 6
};

getOnboardingSteps(currentStep: string, onboardingState: QbdDirectOnboardingState): OnboardingStepper[] {
this.onboardingSteps.forEach(step => {
if (step.step.toLowerCase() === currentStep.toLowerCase()) {
step.active = true;
} else {
step.active = false;
}
});

for (let index = this.onboardingStateStepMap[onboardingState] - 1; index > 0; index--) {
this.onboardingSteps[index - 1].completed = true;
}

return this.onboardingSteps;
}
Comment on lines +81 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.

🛠️ Refactor suggestion

Improve method robustness and maintainability

The method has several areas for improvement:

  1. It mutates the private onboardingSteps array
  2. No validation for currentStep matching a valid step
  3. Case-insensitive comparison could be extracted

Consider this improved implementation:

+    private isStepMatch(step: string, currentStep: string): boolean {
+        return step.toLowerCase() === currentStep.toLowerCase();
+    }
+
     getOnboardingSteps(currentStep: string, onboardingState: QbdDirectOnboardingState): OnboardingStepper[] {
+        // Validate currentStep
+        if (!this.onboardingSteps.some(step => this.isStepMatch(step.step, currentStep))) {
+            throw new Error(`Invalid step: ${currentStep}`);
+        }
+
+        // Create a copy to avoid mutations
+        const steps = [...this.onboardingSteps];
+
-        this.onboardingSteps.forEach(step => {
+        steps.forEach(step => {
-          if (step.step.toLowerCase() === currentStep.toLowerCase()) {
+          if (this.isStepMatch(step.step, currentStep)) {
             step.active = true;
           } else {
             step.active = false;
           }
         });

         for (let index = this.onboardingStateStepMap[onboardingState] - 1; index > 0; index--) {
-          this.onboardingSteps[index - 1].completed = true;
+          steps[index - 1].completed = true;
         }

-        return this.onboardingSteps;
+        return steps;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
getOnboardingSteps(currentStep: string, onboardingState: QbdDirectOnboardingState): OnboardingStepper[] {
this.onboardingSteps.forEach(step => {
if (step.step.toLowerCase() === currentStep.toLowerCase()) {
step.active = true;
} else {
step.active = false;
}
});
for (let index = this.onboardingStateStepMap[onboardingState] - 1; index > 0; index--) {
this.onboardingSteps[index - 1].completed = true;
}
return this.onboardingSteps;
}
private isStepMatch(step: string, currentStep: string): boolean {
return step.toLowerCase() === currentStep.toLowerCase();
}
getOnboardingSteps(currentStep: string, onboardingState: QbdDirectOnboardingState): OnboardingStepper[] {
// Validate currentStep
if (!this.onboardingSteps.some(step => this.isStepMatch(step.step, currentStep))) {
throw new Error(`Invalid step: ${currentStep}`);
}
// Create a copy to avoid mutations
const steps = [...this.onboardingSteps];
steps.forEach(step => {
if (this.isStepMatch(step.step, currentStep)) {
step.active = true;
} else {
step.active = false;
}
});
for (let index = this.onboardingStateStepMap[onboardingState] - 1; index > 0; index--) {
steps[index - 1].completed = true;
}
return steps;
}

}
8 changes: 6 additions & 2 deletions src/app/core/services/common/workspace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { AppUrl, BusinessCentralOnboardingState, IntacctOnboardingState, Netsuit
import { ApiService } from './api.service';
import { HelperService } from './helper.service';
import { AppUrlMap } from '../../models/integrations/integrations.model';
import { Workspace } from '../../models/db/workspaces.model';
import { XeroWorkspace } from '../../models/xero/db/xero-workspace.model';
import { WorkspaceOnboardingState } from '../../models/db/workspaces.model';
import { QbdDirectWorkspace } from '../../models/qbd-direct/db/qbd-direct-workspaces.model';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -74,4 +74,8 @@ export class WorkspaceService {
getWorkspaceGeneralSettings(): Observable<any> {
return this.apiService.get(`/workspaces/${this.getWorkspaceId()}/settings/general/`, {});
}

updateWorkspaceOnboardingState(payload: WorkspaceOnboardingState): Observable<QbdDirectWorkspace> {
return this.apiService.patch(`/workspaces/${this.getWorkspaceId()}/onboarding_state/`, payload);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TestBed } from '@angular/core/testing';
import { QbdDirectConnectorService } from './qbd-direct-connector.service';

describe('QbdDirectConnectorService', () => {
xdescribe('QbdDirectConnectorService', () => {
let service: QbdDirectConnectorService;

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
import { Injectable } from '@angular/core';
import { ApiService } from '../../common/api.service';
import { WorkspaceService } from '../../common/workspace.service';
import { Observable } from 'rxjs';
import { QbdConnectorPost, QbdConnectorGet, SyncDataType } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-connector.model';

@Injectable({
providedIn: 'root'
})
export class QbdDirectConnectorService {

constructor() { }
constructor(
private apiService: ApiService,
private workspaceService: WorkspaceService
) { }

postQbdDirectConntion(payload: QbdConnectorPost): Observable<QbdConnectorGet> {
return this.apiService.post(`/workspaces/${this.workspaceService.getWorkspaceId()}/connector_settings/`, payload);
}

syncAttribuites(): Observable<SyncDataType[]> {
return this.apiService.get(`/workspaces/${this.workspaceService.getWorkspaceId()}/qbd/attribute_stats/`, {});
}
}

This file was deleted.

This file was deleted.

Loading
Loading