Skip to content

Commit

Permalink
travelperk folder creation (#490)
Browse files Browse the repository at this point in the history
travelperk creation
  • Loading branch information
DhaaraniCIT authored Mar 6, 2024
1 parent 5254a16 commit 0736f10
Show file tree
Hide file tree
Showing 93 changed files with 2,176 additions and 309 deletions.
1 change: 1 addition & 0 deletions scripts/setup_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const environment = {
netsuite_api_url: `${process.env.NETSUITE_API_URL ? process.env.NETSUITE_API_URL : '{{NETSUITE_API_URL}}'}`,
business_central_api_url: `${process.env.BUSINESS_CENTRAL_API_URL ? process.env.BUSINESS_CENTRAL_API_URL : '{{BUSINESS_CENTRAL_API_URL}}'}`,
qbo_api_url: `${process.env.QBO_API_URL ? process.env.QBO_API_URL : '{{QBO_API_URL}}'}`,
netsuite_api_url: `${process.env.NETSUITE_API_URL ? process.env.NETSUITE_API_URL : '{{NETSUITE_API_URL}}'}`,
cluster_domain_api_url: `${process.env.CLUSTER_DOMAIN_API_URL ? process.env.CLUSTER_DOMAIN_API_URL : '{{CLUSTER_DOMAIN_API_URL}}'}`,
fyle_app_url: `${process.env.FYLE_APP_URL ? process.env.FYLE_APP_URL : '{{FYLE_APP_URL}}'}`,
sentry_dsn: `${process.env.SENTRY_DSN ? process.env.SENTRY_DSN : '{{SENTRY_DSN}}'}`,
Expand Down
16 changes: 14 additions & 2 deletions src/app/branding/branding-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ const kbArticles: KbArticle = {
ADVANCED_SETTING: `${brandingConfig.helpArticleDomain}/en/articles/8911018-how-to-configure-the-fyle-dynamics-365-business-central-integration#h_9e9b1c5196`,
LANDING: `${brandingConfig.helpArticleDomain}/en/articles/8911018-how-to-configure-the-fyle-dynamics-365-business-central-integration`,
SKIP_EXPORT: `${brandingConfig.helpArticleDomain}/en/articles/7882821-how-to-skip-exporting-specific-expenses-from-fyle-to-sage-intacct`
},
TRAVELPERK: {
PAYMENT_PROFILE_SETTINGS: 'https://help.fylehq.com/en/articles/7193187-how-to-set-up-the-fyle-travelperk-integration#h_0f8ebdfa10',
ADVANCED_SETTING: 'https://help.fylehq.com/en/articles/7193187-how-to-set-up-the-fyle-travelperk-integration#h_281acb3026',
LANDING: 'https://help.fylehq.com/en/articles/7193187-how-to-set-up-the-fyle-travelperk-integration'
}
}
},
Expand Down Expand Up @@ -168,6 +173,11 @@ const kbArticles: KbArticle = {
ADVANCED_SETTING: `${brandingConfig.helpArticleDomain}/en/articles/8394683-how-to-configure-the-fyle-sage-intacct-integration#h_3f6718633c`,
LANDING: `${brandingConfig.helpArticleDomain}/en/articles/8394683-how-to-configure-the-fyle-sage-intacct-integration`,
SKIP_EXPORT: `${brandingConfig.helpArticleDomain}/en/articles/7882821-how-to-skip-exporting-specific-expenses-from-fyle-to-sage-intacct`
},
TRAVELPERK: {
PAYMENT_PROFILE_SETTINGS: 'https://help.fylehq.com/en/articles/7193187-how-to-set-up-the-fyle-travelperk-integration#h_0f8ebdfa10',
ADVANCED_SETTING: 'https://help.fylehq.com/en/articles/7193187-how-to-set-up-the-fyle-travelperk-integration#h_281acb3026',
LANDING: 'https://help.fylehq.com/en/articles/7193187-how-to-set-up-the-fyle-travelperk-integration'
}
}
}
Expand All @@ -184,7 +194,8 @@ const demoVideoLinks: DemoVideo = {
SAGE300: 'https://www.youtube.com/embed/2oYdc8KcQnk',
QBO: 'https://www.youtube.com/embed/b63lS2DG5j4',
// TODO: Update link for MS Dynamics
BUSINESS_CENTRAL: 'https://www.youtube.com/embed/2oYdc8KcQnk'
BUSINESS_CENTRAL: 'https://www.youtube.com/embed/2oYdc8KcQnk',
TRAVELPERK: 'https://www.youtube.com/embed/2oYdc8KcQnk'
}
},
co: {
Expand All @@ -194,7 +205,8 @@ const demoVideoLinks: DemoVideo = {
SAGE300: 'https://www.youtube.com/embed/2oYdc8KcQnk',
QBO: 'https://www.youtube.com/embed/b63lS2DG5j4',
// TODO: Update link for MS Dynamics
BUSINESS_CENTRAL: 'https://www.youtube.com/embed/2oYdc8KcQnk'
BUSINESS_CENTRAL: 'https://www.youtube.com/embed/2oYdc8KcQnk',
TRAVELPERK: 'https://www.youtube.com/embed/2oYdc8KcQnk'
}
}
};
Expand Down
1 change: 1 addition & 0 deletions src/app/core/models/branding/demo-video.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type DemoVideo = {
SAGE300: string;
QBO: string;
BUSINESS_CENTRAL: string;
TRAVELPERK: string;
}
}
};
7 changes: 6 additions & 1 deletion src/app/core/models/branding/kb-article.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ export type KbArticle = {
IMPORT_SETTING: string;
ADVANCED_SETTING: string;
SKIP_EXPORT: string;
}
},
BUSINESS_CENTRAL: {
IMPORT_SETTING: string;
EXPORT_SETTING: string;
ADVANCED_SETTING: string;
LANDING: string;
SKIP_EXPORT: string;
},
TRAVELPERK: {
PAYMENT_PROFILE_SETTINGS: string;
ADVANCED_SETTING: string;
LANDING: string;
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/app/core/models/common/import-settings.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ export class ImportSettingsModel {
}

static constructMappingSettingPayload(expenseFieldArray: ImportSettingMappingRow[]): ImportSettingMappingRow[] {
// First filter out objects where import_to_fyle is false
const filteredExpenseFieldArray = expenseFieldArray.filter((field: ImportSettingMappingRow) => field.destination_field && field.source_field);

// Then map over the filtered array
const mappingSettings = filteredExpenseFieldArray.map((field: ImportSettingMappingRow) => {
return {
source_field: field.source_field.toUpperCase(),
Expand Down
5 changes: 5 additions & 0 deletions src/app/core/models/common/select-form-option.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ export type SelectFormOption = {
value: string | null | number;
}

export type SelectFormLabel = {
label: string;
value: string;
}

export type EmailOption = {
email: string;
name: string;
Expand Down
48 changes: 37 additions & 11 deletions src/app/core/models/enum/enum.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ export enum BusinessCentralUpdateEvent {
ADVANCED_SETTINGS_BUSINESS_CENTRAL = 'Advanced Settings Business Central',
}

export enum TravelperkUpdateEvent {
CONNECT_TRAVELPERK = 'Connect TravelPerk',
PAYMENT_PROFILE_SETTINGS_TRAVELPERK = 'Import Settings TravelPerk',
ADVANCED_SETTINGS_TRAVELPERK = 'Advanced Settings TravelPerk',
}

export enum AppName {
BAMBOO_HR = 'BambooHR',
QBD = 'QuickBooks Desktop',
TRAVELPERK = 'Travelperk',
TRAVELPERK = 'TravelPerk',
INTACCT = 'Sage Intacct',
SAGE300 = 'Sage 300 CRE',
QBO = 'QuickBooks Online',
Expand Down Expand Up @@ -108,6 +114,8 @@ export enum Page {
EXPORT_SETTING_BUSINESS_CENTRAL = 'Export Settings BusinessCentral',
IMPORT_SETTINGS_BUSINESS_CENTRAL = 'Import Settings BusinessCentral',
ADVANCED_SETTINGS_BUSINESS_CENTRAL = 'Advanced Settings BusinessCentral',
PAYMENT_PROFILE_SETTINGS_TRAVELPERK = 'Payment Profile Settings TravelPerk',
ADVANCED_SETTINGS_TRAVELPERK = 'Advanced Settings TravelPerk',
}

export enum ClickEvent {
Expand Down Expand Up @@ -509,22 +517,22 @@ export enum AccountingExport {
}

export enum Operator {
IsNull = "isnull",
IExact = "iexact",
IContains = "icontains",
LessThan = "lt",
LessThanOrEqual = "lte"
IsNull = 'isnull',
IExact = 'iexact',
IContains = 'icontains',
LessThan = 'lt',
LessThanOrEqual = 'lte'
}

export enum JoinOption {
AND = "AND",
OR = "OR"
AND = 'AND',
OR = 'OR'
}

export enum CustomOperatorOption {
Is = "iexact",
IsEmpty = "is_empty",
IsNotEmpty = "is_not_empty"
Is = 'iexact',
IsEmpty = 'is_empty',
IsNotEmpty = 'is_not_empty'
}

export enum IntacctExportSettingDestinationOptionKey {
Expand Down Expand Up @@ -642,3 +650,21 @@ export enum CCCImportState {
APPROVED = 'approved',
PAID = 'closed'
}

export enum TravelPerkExpenseGroup {
SINGLE= 'SINGLE',
MULTIPLE = 'MULTIPLE'
}

export enum TravelPerkUserRole {
CARD_HOLDER = 'CARD_HOLDER',
TRAVELLER = 'TRAVELLER',
BOOKER = 'BOOKER'
}

export enum TravelPerkOnboardingState {
CONNECTION = 'CONNECTION',
PAYMENT_PROFILE_SETTINGS = 'PAYMENT_PROFILE_SETTINGS',
ADVANCED_SETTINGS = 'ADVANCED_SETTINGS',
COMPLETE = 'COMPLETE'
}
6 changes: 4 additions & 2 deletions src/app/core/models/misc/tracking.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import { QBDFieldMappingGet } from "../qbd/qbd-configuration/field-mapping.model
import { Sage300AdvancedSettingGet } from "../sage300/sage300-configuration/sage300-advanced-settings.model";
import { Sage300ExportSettingGet } from "../sage300/sage300-configuration/sage300-export-setting.model";
import { Sage300ImportSettingGet } from "../sage300/sage300-configuration/sage300-import-settings.model";
import { TravelperkAdvancedSettingPost } from "../travelperk/travelperk-configuration/travelperk-advanced-settings.model";
import { TravelperkPaymentProfileSettingResponse } from "../travelperk/travelperk-configuration/travelperk-payment-profile-settings.model";
import { AdvancedSettingsGet } from "../intacct/intacct-configuration/advanced-settings.model";
import { ExportSettingGet } from "../intacct/intacct-configuration/export-settings.model";
import { ImportSettingGet, ImportSettings } from "../intacct/intacct-configuration/import-settings.model";

export type UpdateEventAdditionalProperty = {
phase: ProgressPhase,
oldState: QBDAdvancedSettingsGet | QBDExportSettingGet | QBDFieldMappingGet | Sage300ExportSettingGet | Sage300ImportSettingGet | Sage300AdvancedSettingGet | null | BusinessCentralExportSettingGet | BusinessCentralImportSettingsGet | BusinessCentralAdvancedSettingsGet,
newState: QBDAdvancedSettingsGet | QBDExportSettingGet | QBDFieldMappingGet | Sage300ExportSettingGet | Sage300ImportSettingGet | Sage300AdvancedSettingGet | BusinessCentralExportSettingGet | BusinessCentralImportSettingsGet | BusinessCentralAdvancedSettingsGet
oldState: QBDAdvancedSettingsGet | QBDExportSettingGet | QBDFieldMappingGet | Sage300ExportSettingGet | Sage300ImportSettingGet | Sage300AdvancedSettingGet | null | BusinessCentralExportSettingGet | BusinessCentralImportSettingsGet | BusinessCentralAdvancedSettingsGet | TravelperkPaymentProfileSettingResponse | TravelperkAdvancedSettingPost,
newState: QBDAdvancedSettingsGet | QBDExportSettingGet | QBDFieldMappingGet | Sage300ExportSettingGet | Sage300ImportSettingGet | Sage300AdvancedSettingGet | BusinessCentralExportSettingGet | BusinessCentralImportSettingsGet | BusinessCentralAdvancedSettingsGet | TravelperkPaymentProfileSettingResponse | TravelperkAdvancedSettingPost
};

export type UpdateIntacctEventAdditionalProperty = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import { FormArray, FormControl, FormGroup, Validators } from "@angular/forms";
import { TravelPerkExpenseGroup } from "../../enum/enum.model";
import { SelectFormLabel, SelectFormOption } from "../../common/select-form-option.model";
import { TravelperkDestinationAttribuite } from "../travelperk.model";

interface TravelperkCategoryMapping {
[key: string]: {
id: string;
name: string;
};
}

export type TravelperkAdvancedSetting = {
default_employee_name: string,
default_employee_id: string,
default_category_name: string,
default_category_id: string,
description_structure: string[],
invoice_lineitem_structure: TravelPerkExpenseGroup,
category_mappings: TravelperkCategoryMapping
}

export interface TravelperkAdvancedSettingGet extends TravelperkAdvancedSetting {
id: number,
created_at: Date,
updated_at: Date,
org: number
}

type TravelperkAdvancedSettingArray = {
destination_name: SelectFormLabel;
source_name: TravelperkDestinationAttribuite | null;
}

type TravelperkAdvancedSettingFormArray = {
destinationName: SelectFormLabel;
sourceName: TravelperkDestinationAttribuite | null;
}

export interface TravelperkAdvancedSettingPost extends TravelperkAdvancedSetting { }

export class TravelperkAdvancedSettingModel {

static getDefaultCategory(): SelectFormLabel[] {
return [
{
label: 'Cars',
value: 'Cars'
},
{
label: 'Flights',
value: 'Flights'
},
{
label: 'Hotels',
value: 'Hotels'
},
{
label: 'Trains',
value: 'Trains'
}
];
}

static getExpenseGroup(): SelectFormOption[] {
return [
{
label: 'Single Expense',
value: TravelPerkExpenseGroup.SINGLE
},
{
label: 'Multiple Expenses',
value: TravelPerkExpenseGroup.MULTIPLE
}
];
}

static createFormGroup(data: TravelperkAdvancedSettingArray): FormGroup {
return new FormGroup ({
destinationName: new FormControl(data.destination_name || '', Validators.required),
sourceName: new FormControl(data.source_name || null, Validators.required),
isRequired: new FormControl(true)
});
}

static constructFormArray(arrayData: TravelperkAdvancedSettingGet, source_fields: TravelperkDestinationAttribuite[]): FormGroup[] {
const mappingPayload:FormGroup[] = [];
const defaultCategories = this.getDefaultCategory();
const categoryMapping = Object.keys(arrayData.category_mappings);
Object.entries(arrayData.category_mappings).forEach((value, index) => {
const findObjectByDestinationId = (array: TravelperkDestinationAttribuite[], id: string) => array?.find(item => item.source_id === id) || null;
const data: TravelperkAdvancedSettingArray = {
destination_name: {
label: categoryMapping[index] ? categoryMapping[index] : defaultCategories[index].label,
value: categoryMapping[index] ? categoryMapping[index] : defaultCategories[index].value
},
source_name: arrayData.category_mappings[categoryMapping[index]] ? findObjectByDestinationId(source_fields, arrayData.category_mappings[categoryMapping[index]].id) : null
};
mappingPayload.push(this.createFormGroup(data));
});
return mappingPayload;
}

static constructCategoryMapping(categoryMappingFieldArray: TravelperkAdvancedSettingFormArray[]) {
const data:TravelperkCategoryMapping = {};
categoryMappingFieldArray.forEach((item: TravelperkAdvancedSettingFormArray) => {
data[item.destinationName.value] = {
'name': item.sourceName?.value ? item.sourceName.value : '',
'id': item.sourceName?.source_id ? item.sourceName.source_id : ''
};
});

return data;
}

static mapAPIResponseToFormGroup(advancedSettings: TravelperkAdvancedSettingGet | null, sourceOptions: TravelperkDestinationAttribuite[]): FormGroup {
const defaultMemoOptions: string[] =['trip_id', 'trip_name', 'traveler_name', 'booker_name', 'merchant_name'];
const categoryMappings = advancedSettings ? this.constructFormArray(advancedSettings, sourceOptions) : [] ;
const findObjectByDestinationId = (array: TravelperkDestinationAttribuite[], id: string) => array?.find(item => item.source_id === id) || null;
return new FormGroup({
categoryMappings: new FormArray(categoryMappings),
descriptionStructure: new FormControl(advancedSettings?.description_structure ? advancedSettings?.description_structure : defaultMemoOptions),
defaultEmployee: new FormControl(advancedSettings?.default_employee_name ? advancedSettings?.default_employee_name : null),
defaultEmployeeId: new FormControl(advancedSettings?.default_employee_id ? advancedSettings?.default_employee_id : null),
defaultCategory: new FormControl(advancedSettings?.default_category_name ? findObjectByDestinationId(sourceOptions, advancedSettings.default_category_id) : null, Validators.required),
invoiceLineitemStructure: new FormControl(advancedSettings?.invoice_lineitem_structure ? advancedSettings.invoice_lineitem_structure : null, Validators.required),
searchOption: new FormControl('')
});
}

static createAdvancedSettingPayload(advancedSettingsForm: FormGroup): TravelperkAdvancedSettingPost {
return {
default_employee_name: advancedSettingsForm.get('defaultEmployee')?.value ? advancedSettingsForm.get('defaultEmployee')?.value : null,
default_employee_id: advancedSettingsForm.get('defaultEmployeeId')?.value ? advancedSettingsForm.get('defaultEmployeeId')?.value : null,
default_category_name: advancedSettingsForm.get('defaultCategory')?.value ? advancedSettingsForm.get('defaultCategory')?.value.value : null,
default_category_id: advancedSettingsForm.get('defaultCategory')?.value ? advancedSettingsForm.get('defaultCategory')?.value.source_id : null,
description_structure: advancedSettingsForm.get('descriptionStructure')?.value ? advancedSettingsForm.get('descriptionStructure')?.value : null,
invoice_lineitem_structure: advancedSettingsForm.get('invoiceLineitemStructure')?.value ? advancedSettingsForm.get('invoiceLineitemStructure')?.value : null,
category_mappings: this.constructCategoryMapping(advancedSettingsForm.value.categoryMappings)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { TravelPerkOnboardingState } from "../../enum/enum.model";

export type TravelPerkOnboardingStepperMap = {
[TravelPerkOnboardingState.CONNECTION]: number,
[TravelPerkOnboardingState.PAYMENT_PROFILE_SETTINGS]: number,
[TravelPerkOnboardingState.ADVANCED_SETTINGS]: number,
[TravelPerkOnboardingState.COMPLETE]: number,
}
Loading

0 comments on commit 0736f10

Please sign in to comment.