Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Clone Settings complete reimbursable export settings #285

Merged
merged 59 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
59620b1
Employee Mapping and Import settings reimbursable
NileshPant1999 Jul 27, 2023
e0d34df
add support
NileshPant1999 Jul 27, 2023
84a44a2
add support
NileshPant1999 Jul 27, 2023
18ccfe3
add support
NileshPant1999 Jul 27, 2023
5f91d35
[CodeFactor] Apply fixes
code-factor Jul 27, 2023
0a6f17a
test fix
NileshPant1999 Jul 27, 2023
e5d19b2
Merge branch 'clone-settings-qbo' of https://github.com/fylein/fyle-q…
NileshPant1999 Jul 27, 2023
1ab311f
use legecy mat dialog
NileshPant1999 Jul 28, 2023
21a6914
foix
NileshPant1999 Jul 28, 2023
57f954b
export settings
NileshPant1999 Jul 29, 2023
375a1bc
test fix and minor updates
NileshPant1999 Jul 29, 2023
7206491
[CodeFactor] Apply fixes
code-factor Jul 29, 2023
5b569bf
lint fix
NileshPant1999 Jul 31, 2023
cacb30e
merge master;
NileshPant1999 Jul 31, 2023
f831fc8
lint test fix
NileshPant1999 Jul 31, 2023
c2d35d4
f
NileshPant1999 Jul 31, 2023
3c88a38
ccc export settings changes
NileshPant1999 Aug 1, 2023
c8335f9
fix comments
NileshPant1999 Aug 1, 2023
62f4809
[CodeFactor] Apply fixes
code-factor Aug 1, 2023
fdc9bc9
asd
NileshPant1999 Aug 1, 2023
e0f66fd
lint fix
NileshPant1999 Aug 1, 2023
34e7c03
Merge branch 'clone-settings-qbo-2' of https://github.com/fylein/fyle…
NileshPant1999 Aug 1, 2023
236296a
df
NileshPant1999 Aug 1, 2023
3ca82d8
add fix
NileshPant1999 Aug 1, 2023
7d394fa
fix
NileshPant1999 Aug 1, 2023
e592677
[CodeFactor] Apply fixes
code-factor Aug 1, 2023
4b31663
minor change
NileshPant1999 Aug 1, 2023
9367240
Merge branch 'clone-settings-ccc' of https://github.com/fylein/fyle-q…
NileshPant1999 Aug 1, 2023
e05a557
lint fix
NileshPant1999 Aug 1, 2023
5294818
initial draft
NileshPant1999 Aug 2, 2023
d9881cc
addition
NileshPant1999 Aug 2, 2023
01770a1
fix test
NileshPant1999 Aug 2, 2023
5f36a0c
lint fix
NileshPant1999 Aug 2, 2023
494b432
lint fix
NileshPant1999 Aug 2, 2023
c204612
Merge branch 'clone-settings-ccc' of https://github.com/fylein/fyle-q…
NileshPant1999 Aug 4, 2023
bfef99b
merged master
NileshPant1999 Aug 4, 2023
dd99f61
sad
NileshPant1999 Aug 4, 2023
495e575
asd
NileshPant1999 Aug 4, 2023
2f8f483
lint fix and add tests
NileshPant1999 Aug 10, 2023
b437e33
as
NileshPant1999 Aug 10, 2023
e3f7a31
asd
NileshPant1999 Aug 10, 2023
0776472
add more test
NileshPant1999 Aug 10, 2023
1bc3e80
add
NileshPant1999 Aug 10, 2023
4f4b75d
merged master
NileshPant1999 Aug 10, 2023
0fddde6
asd
NileshPant1999 Aug 11, 2023
9f93625
add more tests
NileshPant1999 Aug 11, 2023
1bf7548
add fix
NileshPant1999 Aug 11, 2023
dd1287c
comments resolved
NileshPant1999 Aug 16, 2023
7495e8d
oioi
NileshPant1999 Aug 16, 2023
3cfc3ef
comments relolved
NileshPant1999 Aug 16, 2023
fcc4898
comment resolved
NileshPant1999 Aug 16, 2023
a970033
clone settings corporate credit card export settings (#286)
NileshPant1999 Aug 18, 2023
8cbc9e9
merged master
NileshPant1999 Aug 18, 2023
f7acd13
conflicts fix
NileshPant1999 Aug 18, 2023
5d6e417
merged imported settings
NileshPant1999 Aug 18, 2023
b2a6b11
merged master
NileshPant1999 Aug 18, 2023
00ad64d
clone settings Advance Settings (#298)
NileshPant1999 Aug 23, 2023
e471be4
Bug fixes and increase test coverage for clone settings changes (#299)
NileshPant1999 Aug 28, 2023
d65fcd8
QA fixes for clone setting flow of QBO App (#300)
NileshPant1999 Sep 6, 2023
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
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { JwtHelperService, JWT_OPTIONS } from '@auth0/angular-jwt';
import { MatLegacySnackBarModule as MatSnackBarModule, MAT_LEGACY_SNACK_BAR_DEFAULT_OPTIONS as MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/legacy-snack-bar';
import { MatLegacyDialogModule as MatDialogModule } from '@angular/material/legacy-dialog';

import * as Sentry from '@sentry/angular';

Expand All @@ -24,7 +25,8 @@ import { GlobalErrorHandler } from './app.errorhandling';
HttpClientModule,
FormsModule,
ReactiveFormsModule,
MatSnackBarModule
MatSnackBarModule,
MatDialogModule,
],
providers: [
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FlexLayoutModule } from '@angular/flex-layout';
import { MatLegacyButtonModule as MatButtonModule } from '@angular/material/legacy-button';

import { LoginComponent } from './login/login.component';
import { LogoutComponent } from './logout/logout.component';
import { FyleCallbackComponent } from './fyle-callback/fyle-callback.component';
import { AuthComponent } from './auth.component';
import { AuthRoutingModule } from './auth-routing.module';
import { MatLegacyProgressSpinnerModule as MatProgressSpinnerModule } from '@angular/material/legacy-progress-spinner';
import { SharedLoginComponent } from './shared-login/shared-login.component';
import { MatLegacyProgressSpinnerModule as MatProgressSpinnerModule } from '@angular/material/legacy-progress-spinner';


@NgModule({
Expand All @@ -25,7 +24,8 @@ import { SharedLoginComponent } from './shared-login/shared-login.component';
AuthRoutingModule,
FlexLayoutModule,
MatButtonModule,
MatProgressSpinnerModule
MatProgressSpinnerModule,
MatButtonModule
]
})
export class AuthModule { }
5 changes: 3 additions & 2 deletions src/app/core/core.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { MatLegacyDialogModule as MatDialogModule } from '@angular/material/legacy-dialog';


@NgModule({
declarations: [],
imports: [
CommonModule
CommonModule,
MatDialogModule
]
})
export class CoreModule { }
45 changes: 45 additions & 0 deletions src/app/core/models/configuration/clone-setting.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { FormGroup } from "@angular/forms";
import { AdvancedSettingGet, AdvancedSettingModel, AdvancedSettingPost } from "./advanced-setting.model";
import { ExportSettingGet, ExportSettingModel, ExportSettingPost } from "./export-setting.model";
import { ImportSettingGet, ImportSettingModel, ImportSettingPost } from "./import-setting.model";
import { MappingSetting } from "../db/mapping-setting.model";
import { EmployeeSettingGet, EmployeeSettingModel, EmployeeSettingPost } from "./employee-setting.model";

export type CloneSetting = {
workspace_id: number,
export_settings: ExportSettingGet,
import_settings: ImportSettingGet,
advanced_settings: AdvancedSettingGet,
employee_mappings: EmployeeSettingGet
}

export type CloneSettingPost = {
export_settings: ExportSettingPost,
Import_settings: ImportSettingPost,
Advanced_settings: AdvancedSettingPost,
employee_mappings: EmployeeSettingPost
}

export type CloneSettingExist = {
is_available: boolean,
workspace_name: string
}

export class CloneSettingModel {
static constructPayload(cloneSettingsForm: FormGroup, customMappingSettings: MappingSetting[]): CloneSettingPost {

const exportSettingPayload = ExportSettingModel.constructPayload(cloneSettingsForm);
const importSettingPayload = ImportSettingModel.constructPayload(cloneSettingsForm, customMappingSettings);
const advancedSettingPayload = AdvancedSettingModel.constructPayload(cloneSettingsForm);
const employeeMappingPayload = EmployeeSettingModel.constructPayload(cloneSettingsForm);

const cloneSettingPayload: CloneSettingPost = {
export_settings: exportSettingPayload,
Import_settings: importSettingPayload,
Advanced_settings: advancedSettingPayload,
employee_mappings: employeeMappingPayload
};

return cloneSettingPayload;
}
}
12 changes: 8 additions & 4 deletions src/app/core/models/configuration/export-setting.model.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { UntypedFormGroup } from "@angular/forms";
import { CorporateCreditCardExpensesObject, ExpenseGroupingFieldOption, ExpenseState, CCCExpenseState, ExportDateType, ReimbursableExpensesObject } from "../enum/enum.model";
import { CorporateCreditCardExpensesObject, ExpenseGroupingFieldOption, ExpenseState, CCCExpenseState, ExportDateType, ReimbursableExpensesObject, AutoMapEmployee, EmployeeFieldMapping } from "../enum/enum.model";
import { ExpenseGroupSettingGet, ExpenseGroupSettingPost } from "../db/expense-group-setting.model";
import { DefaultDestinationAttribute, GeneralMapping } from "../db/general-mapping.model";
import { SelectFormOption } from "../misc/select-form-option.model";

export type ExportSettingWorkspaceGeneralSetting = {
export type ExportSettingWorkspaceGeneralSettingPost = {
reimbursable_expenses_object: ReimbursableExpensesObject | null,
corporate_credit_card_expenses_object: CorporateCreditCardExpensesObject | null
}

export interface ExportSettingWorkspaceGeneralSetting extends ExportSettingWorkspaceGeneralSettingPost {
is_simplify_report_closure_enabled: boolean
}

export type ExportSettingGeneralMapping = {
bank_account: DefaultDestinationAttribute,
default_ccc_account: DefaultDestinationAttribute,
Expand All @@ -20,7 +24,7 @@ export type ExportSettingGeneralMapping = {

export type ExportSettingPost = {
expense_group_settings: ExpenseGroupSettingPost,
workspace_general_settings: ExportSettingWorkspaceGeneralSetting,
workspace_general_settings: ExportSettingWorkspaceGeneralSettingPost,
general_mappings: ExportSettingGeneralMapping
}

Expand All @@ -32,7 +36,7 @@ export type ExportSettingGet = {
}

export interface ExportSettingFormOption extends SelectFormOption {
value: ExpenseState | CCCExpenseState | ReimbursableExpensesObject | CorporateCreditCardExpensesObject | ExpenseGroupingFieldOption | ExportDateType;
value: ExpenseState | CCCExpenseState | ReimbursableExpensesObject | CorporateCreditCardExpensesObject | ExpenseGroupingFieldOption | ExportDateType | AutoMapEmployee | EmployeeFieldMapping | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need AutoMapEmployee or EmployeeFieldMapping as a part of export setting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ashwin1111 this was an initial change, will remove it added it earlier forget to remove.

}

export class ExportSettingModel {
Expand Down
5 changes: 3 additions & 2 deletions src/app/core/models/configuration/import-setting.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ export interface ImportSettingFormOption extends SelectFormOption {

export class ImportSettingModel {
static constructPayload(importSettingsForm: UntypedFormGroup, customMappingSettings: MappingSetting[]): ImportSettingPost {

const emptyDestinationAttribute = {id: null, name: null};
const employeeSettingPayload: ImportSettingPost = {
const importSettingPayload: ImportSettingPost = {
workspace_general_settings: {
import_categories: importSettingsForm.get('chartOfAccount')?.value,
import_items: importSettingsForm.get('importItems')?.value,
Expand All @@ -67,7 +68,7 @@ export class ImportSettingModel {
},
mapping_settings: ImportSettingModel.formatMappingSettings(importSettingsForm.get('expenseFields')?.value, customMappingSettings)
};
return employeeSettingPayload;
return importSettingPayload;
}

static formatChartOfAccounts(chartOfAccounts: {enabled: boolean, name: string}[]): string[] {
Expand Down
7 changes: 5 additions & 2 deletions src/app/core/models/enum/enum.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ export enum ClickEvent {
UNMAPPED_MAPPINGS_FILTER = 'Unmapped Mappings Filter',
MAPPED_MAPPINGS_FILTER = 'Mapped Mappings Filter',
DISCONNECT_QBO = 'Disconnect QBO',
SYNC_DIMENSION = 'Sync Dimension'
SYNC_DIMENSION = 'Sync Dimension',
CLONE_SETTINGS_BACK = 'Clone Settings Back',
CLONE_SETTINGS_RESET = 'Clone Settings Reset'
}

export enum ProgressPhase {
Expand All @@ -197,7 +199,8 @@ export enum OnboardingStep {
EXPORT_SETTINGS = 'Export Settings',
IMPORT_SETTINGS = 'Import Settings',
ADVANCED_SETTINGS = 'Advanced Settings',
ONBOARDING_DONE = 'Onboarding Done'
ONBOARDING_DONE = 'Onboarding Done',
CLONE_SETTINGS = 'Clone Settings'
}

export enum UpdateEvent {
Expand Down
3 changes: 2 additions & 1 deletion src/app/core/models/misc/confirmation-dialog.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export type ConfirmationDialog = {
title: string,
primaryCtaText: string,
contents: string,
hideSecondaryCTA?: boolean
hideSecondaryCTA?: boolean,
hideWarningIcon?: boolean
};
41 changes: 41 additions & 0 deletions src/app/core/services/configuration/clone-setting.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { TestBed, getTestBed } from '@angular/core/testing';

import { CloneSettingService } from './clone-setting.service';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { mockCloneSettingsGet } from 'src/app/integration/onboarding/clone-settings/clone-settings.fixture';
import { environment } from 'src/environments/environment';
import { WorkspaceService } from '../workspace/workspace.service';

describe('CloneSettingService', () => {
let service: CloneSettingService;
let injector: TestBed;
let httpMock: HttpTestingController;
const API_BASE_URL = environment.api_url;
const workspace_id = environment.tests.workspaceId;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule
]
});
injector = getTestBed();
service = TestBed.inject(CloneSettingService);
httpMock = injector.inject(HttpTestingController);
});

it('should be created', () => {
expect(service).toBeTruthy();
});

it('should get Clone Settings', () => {
service.getCloneSettings().subscribe(value => {
expect(value).toEqual(mockCloneSettingsGet);
});
const req = httpMock.expectOne({
method: 'GET',
url: `${API_BASE_URL}/v2/workspaces/${workspace_id}/clone_settings/`
});
req.flush(mockCloneSettingsGet);
});
});
31 changes: 31 additions & 0 deletions src/app/core/services/configuration/clone-setting.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CloneSetting, CloneSettingExist, CloneSettingPost } from '../../models/configuration/clone-setting.model';
import { ApiService } from '../core/api.service';
import { WorkspaceService } from '../workspace/workspace.service';

@Injectable({
providedIn: 'root'
})

export class CloneSettingService {

workspaceId = this.workspaceService.getWorkspaceId();

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

checkCloneSettingsExists(): Observable<CloneSettingExist> {
return this.apiService.get(`/user/clone_settings/exists/`, {});
}

getCloneSettings(): Observable<CloneSetting> {
return this.apiService.get(`/v2/workspaces/${this.workspaceId}/clone_settings/`, {});
}

saveCloneSettings(cloneSettingsPayload: CloneSettingPost): Observable<CloneSetting> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

postClone...

return this.apiService.put(`/v2/workspaces/${this.workspaceId}/clone_settings/`, cloneSettingsPayload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ describe('ExportSettingService', () => {
},
workspace_general_settings: {
reimbursable_expenses_object: ReimbursableExpensesObject.BILL,
corporate_credit_card_expenses_object: CorporateCreditCardExpensesObject.BILL
corporate_credit_card_expenses_object: CorporateCreditCardExpensesObject.BILL,
is_simplify_report_closure_enabled: true
},
general_mappings: {
bank_account: { id: '1', name: 'Fyle' },
Expand Down Expand Up @@ -96,7 +97,8 @@ describe('ExportSettingService', () => {
},
workspace_general_settings: {
reimbursable_expenses_object: ReimbursableExpensesObject.BILL,
corporate_credit_card_expenses_object: CorporateCreditCardExpensesObject.BILL
corporate_credit_card_expenses_object: CorporateCreditCardExpensesObject.BILL,
is_simplify_report_closure_enabled: true
},
general_mappings: {
bank_account: { id: '1', name: 'Fyle' },
Expand Down
Loading