Skip to content

Commit

Permalink
Netsuite - Base (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 authored Feb 16, 2024
1 parent b8f3841 commit f519606
Show file tree
Hide file tree
Showing 115 changed files with 1,416 additions and 11 deletions.
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ do
sed -i $SED_EXTRA_ARGS "s?{{SAGE300_API_URL}}?${SAGE300_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{BUSINESS_CENTRAL_API_URL}}?${BUSINESS_CENTRAL_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{QBO_API_URL}}?${QBO_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{NETSUITE_API_URL}}?${NETSUITE_API_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{FYLE_APP_URL}}?${FYLE_APP_URL}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{CALLBACK_URI}}?${CALLBACK_URI}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{FYLE_CLIENT_ID}}?${FYLE_CLIENT_ID}?g" $f;
Expand Down
8 changes: 8 additions & 0 deletions src/app/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { HelperService } from 'src/app/core/services/common/helper.service';
import { AppUrl } from 'src/app/core/models/enum/enum.model';
import { ClusterDomainWithToken } from 'src/app/core/models/misc/token.model';
import { StorageService } from 'src/app/core/services/common/storage.service';
import { NetsuiteAuthService } from 'src/app/core/services/netsuite/netsuite-core/netsuite-auth.service';

@Component({
selector: 'app-login',
Expand All @@ -31,6 +32,7 @@ export class LoginComponent implements OnInit {
private router: Router,
private sage300AuthService: Sage300AuthService,
private siAuthService : SiAuthService,
private netsuiteAuthService: NetsuiteAuthService,
private storageService: StorageService,
private userService: UserService
) { }
Expand Down Expand Up @@ -68,13 +70,19 @@ export class LoginComponent implements OnInit {
this.helperService.setBaseApiURL(AppUrl.BUSINESS_CENTRAL);
this.businessCentralAuthService.loginWithRefreshToken(clusterDomainWithToken.tokens.refresh_token).subscribe();

this.helperService.setBaseApiURL(AppUrl.NETSUITE);
this.netsuiteAuthService.loginWithRefreshToken(clusterDomainWithToken.tokens.refresh_token).subscribe();


// Only local dev needs this, login happens via postMessage for prod/staging through webapp
if (!environment.production) {
this.userService.storeUserProfile(user);
this.helperService.setBaseApiURL(AppUrl.QBO);
this.qboAuthService.loginWithRefreshToken(clusterDomainWithToken.tokens.refresh_token).subscribe();
this.helperService.setBaseApiURL(AppUrl.INTACCT);
this.siAuthService.loginWithRefreshToken(clusterDomainWithToken.tokens.refresh_token).subscribe();
this.helperService.setBaseApiURL(AppUrl.NETSUITE);
this.netsuiteAuthService.loginWithRefreshToken(clusterDomainWithToken.tokens.refresh_token).subscribe();
this.redirect(redirectUri);
} else {
this.redirect(redirectUri);
Expand Down
17 changes: 14 additions & 3 deletions src/app/core/models/enum/enum.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export enum InAppIntegration {
TRAVELPERK = 'TravelPerk',
INTACCT = 'Sage Intacct',
SAGE300 = 'Sage 300 CRE',
BUSINESS_CENTRAL = 'Dynamics 365 Business Central'
BUSINESS_CENTRAL = 'Dynamics 365 Business Central',
NETSUITE = 'NetSuite'
}

export enum ToastSeverity {
Expand Down Expand Up @@ -73,7 +74,8 @@ export enum AppName {
INTACCT = 'Sage Intacct',
SAGE300 = 'Sage 300 CRE',
QBO = 'QuickBooks Online',
BUSINESS_CENTRAL = 'Dynamics 365 Business Central'
BUSINESS_CENTRAL = 'Dynamics 365 Business Central',
NETSUITE = 'NetSuite'
}

export enum AppNameInService {
Expand Down Expand Up @@ -156,6 +158,14 @@ export enum QBOOnboardingState {
CLONE_SETTINGS = 'CLONE_SETTINGS'
}

export enum NetsuiteOnboardingState {
CONNECTION = 'CONNECTION',
EXPORT_SETTINGS = 'EXPORT_SETTINGS',
IMPORT_SETTINGS = 'IMPORT_SETTINGS',
ADVANCED_CONFIGURATION = 'ADVANCED_CONFIGURATION',
COMPLETE = 'COMPLETE',
}

export enum Sage300OnboardingState {
CONNECTION = 'CONNECTION',
EXPORT_SETTINGS = 'EXPORT_SETTINGS',
Expand Down Expand Up @@ -443,7 +453,8 @@ export enum AppUrl {
SAGE300 = 'sage300',
BUSINESS_CENTRAL = 'business_central',
INTEGRATION = 'integration',
QBO = 'qbo'
QBO = 'qbo',
NETSUITE = 'netsuite'
}

export enum Sage300ExportType {
Expand Down
6 changes: 4 additions & 2 deletions src/app/core/models/integrations/integrations.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export type InAppIntegrationUrlMap = {
[InAppIntegration.INTACCT]: string,
[InAppIntegration.QBO]: string,
[InAppIntegration.SAGE300]: string,
[InAppIntegration.BUSINESS_CENTRAL]: string
[InAppIntegration.BUSINESS_CENTRAL]: string,
[InAppIntegration.NETSUITE]: string
}

export type AppUrlMap = {
Expand All @@ -40,4 +41,5 @@ export type AppUrlMap = {
[AppUrl.INTEGRATION]: string,
[AppUrl.BUSINESS_CENTRAL]: string
[AppUrl.QBO]: string
}
[AppUrl.NETSUITE]: string
}
4 changes: 3 additions & 1 deletion src/app/core/models/misc/tracking.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type TrackingAppMap = {
[AppName.INTACCT]: TrackingApp.INTACCT,
[AppName.QBO]: TrackingApp.QBO,
[AppName.TRAVELPERK]: TrackingApp.TRAVELPERK,
[AppName.NETSUITE]: TrackingApp.NETSUITE
}

export const trackingAppMap: TrackingAppMap = {
Expand All @@ -58,5 +59,6 @@ export const trackingAppMap: TrackingAppMap = {
[AppName.BAMBOO_HR]: TrackingApp.BAMBOO_HR,
[AppName.INTACCT]: TrackingApp.INTACCT,
[AppName.QBO]: TrackingApp.QBO,
[AppName.TRAVELPERK]: TrackingApp.TRAVELPERK
[AppName.TRAVELPERK]: TrackingApp.TRAVELPERK,
[AppName.NETSUITE]: TrackingApp.NETSUITE
};
13 changes: 13 additions & 0 deletions src/app/core/models/netsuite/db/netsuite-workspace.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { NetsuiteOnboardingState } from "../../enum/enum.model";
import { Workspace } from "../../db/workspaces.model";

export interface NetsuiteWorkspace extends Workspace {
fyle_org_id: string;
fyle_currency: string;
cluster_domain: string;
onboarding_state: NetsuiteOnboardingState;
last_synced_at: Date;
ccc_last_synced_at: Date;
source_synced_at: Date;
destination_synced_at: Date;
}
3 changes: 2 additions & 1 deletion src/app/core/services/common/helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export class HelperService {
[AppUrl.SAGE300]: environment.sage300_api_url,
[AppUrl.INTEGRATION]: `${this.apiBaseUrl}/${environment.production ? 'integrations-api/': ''}api`,
[AppUrl.BUSINESS_CENTRAL]: environment.business_central_api_url,
[AppUrl.QBO]: environment.production ? `${this.apiBaseUrl}/quickbooks-api/api` : environment.qbo_api_url
[AppUrl.QBO]: environment.production ? `${this.apiBaseUrl}/quickbooks-api/api` : environment.qbo_api_url,
[AppUrl.NETSUITE]: environment.production ? `${this.apiBaseUrl}/netsuite-api/api` : environment.netsuite_api_url
};

const apiUrl = apiUrlMap[module] ?? apiUrlMap.integration;
Expand Down
5 changes: 3 additions & 2 deletions src/app/core/services/common/workspace.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { StorageService } from './storage.service';
import { Observable } from 'rxjs';
import { AppUrl, BusinessCentralOnboardingState, IntacctOnboardingState, QBDOnboardingState, QBOOnboardingState, Sage300OnboardingState } from '../../models/enum/enum.model';
import { AppUrl, BusinessCentralOnboardingState, IntacctOnboardingState, NetsuiteOnboardingState, QBDOnboardingState, QBOOnboardingState, Sage300OnboardingState } from '../../models/enum/enum.model';
import { ApiService } from './api.service';
import { HelperService } from './helper.service';
import { AppUrlMap } from '../../models/integrations/integrations.model';
Expand Down Expand Up @@ -55,7 +55,8 @@ export class WorkspaceService {
[AppUrl.TRAVELPERK]: null,
[AppUrl.INTEGRATION]: '',
[AppUrl.BUSINESS_CENTRAL]: BusinessCentralOnboardingState.CONNECTION,
[AppUrl.QBO]: QBOOnboardingState.CONNECTION
[AppUrl.QBO]: QBOOnboardingState.CONNECTION,
[AppUrl.NETSUITE]: NetsuiteOnboardingState.CONNECTION
};
const onboardingState = this.storageService.get('onboarding-state');
return onboardingState ? onboardingState : appInitialOnboardingState[(this.helper.getAppName()) as AppUrl];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { NetsuiteAuthService } from './netsuite-auth.service';

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

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NetsuiteAuthService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiService } from '../../common/api.service';
import { Token } from 'src/app/core/models/misc/token.model';
import { HelperService } from '../../common/helper.service';
import { AppUrl } from 'src/app/core/models/enum/enum.model';

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

constructor(
private apiService: ApiService
) {}

loginWithRefreshToken(refresh_token: string): Observable<Token> {
return this.apiService.post('/auth/login_with_refresh_token/', { refresh_token });
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { NetsuiteHelperService } from './netsuite-helper.service';

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

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NetsuiteHelperService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiService } from '../../common/api.service';
import { WorkspaceService } from '../../common/workspace.service';
import { Cacheable } from 'ts-cacheable';

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

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

@Cacheable()
syncFyleDimensions() {
return this.apiService.post(`/workspaces/${this.workspaceService.getWorkspaceId()}/fyle/sync_dimensions/`, {});
}

@Cacheable()
syncNetsuiteDimensions() {
return this.apiService.post(`/workspaces/${this.workspaceService.getWorkspaceId()}/netsuite/sync_dimensions/`, {});
}

refreshFyleDimensions(): Observable<{}> {
return this.apiService.post(`/workspaces/${this.workspaceService.getWorkspaceId()}/fyle/refresh_dimensions/`, {});
}

refreshNetsuiteDimensions(): Observable<{}> {
return this.apiService.post(`/workspaces/${this.workspaceService.getWorkspaceId()}/netsuite/refresh_dimensions/`, {});
}
}
4 changes: 4 additions & 0 deletions src/app/integrations/integrations-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const routes: Routes = [
{
path: 'business_central',
loadChildren: () => import('./business-central/business-central.module').then(m => m.BusinessCentralModule)
},
{
path: 'netsuite',
loadChildren: () => import('./netsuite/netsuite.module').then(m => m.NetsuiteModule)
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/integrations/landing/landing.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export class LandingComponent implements OnInit {
[InAppIntegration.INTACCT]: '/integrations/intacct',
[InAppIntegration.QBO]: '/integrations/qbo',
[InAppIntegration.SAGE300]: '/integrations/sage300',
[InAppIntegration.BUSINESS_CENTRAL]: '/integrations/business_central'
[InAppIntegration.BUSINESS_CENTRAL]: '/integrations/business_central',
[InAppIntegration.NETSUITE]: '/integrations/netsuite'
};

readonly brandingConfig = brandingConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { NetsuiteConfigurationComponent } from './netsuite-configuration.component';
import { NetsuiteExportSettingsComponent } from '../../netsuite-shared/netsuite-export-settings/netsuite-export-settings.component';
import { NetsuiteImportSettingsComponent } from '../../netsuite-shared/netsuite-import-settings/netsuite-import-settings.component';
import { NetsuiteAdvancedSettingsComponent } from '../../netsuite-shared/netsuite-advanced-settings/netsuite-advanced-settings.component';
import { NetsuiteConnectorComponent } from '../../netsuite-shared/netsuite-connector/netsuite-connector.component';

const routes: Routes = [
{
path: '',
component: NetsuiteConfigurationComponent,
children: [
{
path: 'connector',
component: NetsuiteConnectorComponent
},
{
path: 'export_settings',
component: NetsuiteExportSettingsComponent
},
{
path: 'import_settings',
component: NetsuiteImportSettingsComponent
},
{
path: 'advanced_settings',
component: NetsuiteAdvancedSettingsComponent
}
]
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class NetsuiteConfigurationRoutingModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>netsuite-configuration works!</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { NetsuiteConfigurationComponent } from './netsuite-configuration.component';

describe('NetsuiteConfigurationComponent', () => {
let component: NetsuiteConfigurationComponent;
let fixture: ComponentFixture<NetsuiteConfigurationComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ NetsuiteConfigurationComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(NetsuiteConfigurationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-netsuite-configuration',
templateUrl: './netsuite-configuration.component.html',
styleUrls: ['./netsuite-configuration.component.scss']
})
export class NetsuiteConfigurationComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { NetsuiteConfigurationRoutingModule } from './netsuite-configuration-routing.module';


@NgModule({
declarations: [],
imports: [
CommonModule,
NetsuiteConfigurationRoutingModule
]
})
export class NetsuiteConfigurationModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { NetsuiteDashboardComponent } from './netsuite-dashboard.component';

const routes: Routes = [
{
path: 'dashboard',
component: NetsuiteDashboardComponent
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class NetsuiteDashboardRoutingModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>netsuite-dashboard works!</p>
Loading

0 comments on commit f519606

Please sign in to comment.