Skip to content

Commit

Permalink
Merge branch 'master' into Remove-push-notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunaj5 committed May 4, 2024
2 parents 2118b90 + 6000e2f commit f51a5c2
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 76 deletions.
1 change: 0 additions & 1 deletion android/variables.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ext {
androidxMaterialVersion = '1.6.1'
androidxBrowserVersion = '1.4.0'
androidxExifInterfaceVersion = '1.3.3'
firebaseMessagingVersion = '23.0.5'
playServicesLocationVersion = '20.0.0'
junitVersion = '4.13.2'
androidxJunitVersion = '1.1.3'
Expand Down
1 change: 0 additions & 1 deletion hooks/utils/google-credentials-android.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports.getGoogleCredentialsAndroid = (NATIVE_CONFIG) => `
{
"project_info": {
"project_number": "${process.env.FYLE_MOBILE_PROJECT_NUMBER}",
"firebase_url": "${process.env.FYLE_MOBILE_FIREBASE_URL}",
"project_id": "${process.env.FYLE_MOBILE_PROJECT_ID}",
"storage_bucket": "${process.env.FYLE_MOBILE_STORAGE_BUCKET}"
},
Expand Down
2 changes: 0 additions & 2 deletions hooks/utils/google-credentials-ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ module.exports.getGoogleCredentialsIos = (NATIVE_CONFIG) =>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>${process.env.FYLE_MOBILE_IOS_GOOGLE_APP_ID}</string>
<key>DATABASE_URL</key>
<string>${process.env.FYLE_MOBILE_FIREBASE_URL}</string>
</dict>
</plist>
`
10 changes: 0 additions & 10 deletions ios/App/App/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import UIKit
import Capacitor
import FirebaseCore
import FirebaseInstanceID
import FirebaseMessaging

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
Expand Down
13 changes: 13 additions & 0 deletions src/app/core/models/platform/platform-project.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export interface PlatformProject {
id: number;
org_id: string;
created_at: Date;
updated_at: Date;
name: string;
sub_project: string;
code: string;
display_name: string;
description: string;
is_enabled: boolean;
category_ids: number[];
}
12 changes: 6 additions & 6 deletions src/app/core/models/v2/project-v2.model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export interface ProjectV2 {
ap1_email: string;
ap1_full_name: string;
ap2_email: string;
ap2_full_name: string;
ap1_email?: string;
ap1_full_name?: string;
ap2_email?: string;
ap2_full_name?: string;
project_active: boolean;
project_approver1_id: string;
project_approver2_id: string;
project_approver1_id?: string;
project_approver2_id?: string;
project_code: string;
project_created_at: Date;
project_description: string;
Expand Down
14 changes: 7 additions & 7 deletions src/app/core/services/merge-expenses.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('MergeExpensesService', () => {
let corporateCreditCardExpenseService: jasmine.SpyObj<CorporateCreditCardExpenseService>;
let customInputsService: jasmine.SpyObj<CustomInputsService>;
let humanizeCurrencyPipe: jasmine.SpyObj<HumanizeCurrencyPipe>;
let projectService: jasmine.SpyObj<ProjectsService>;
let projectsService: jasmine.SpyObj<ProjectsService>;
let categoriesService: jasmine.SpyObj<CategoriesService>;
let dateService: jasmine.SpyObj<DateService>;
let taxGroupService: jasmine.SpyObj<TaxGroupService>;
Expand All @@ -121,7 +121,7 @@ describe('MergeExpensesService', () => {
]);
const customInputsServiceSpy = jasmine.createSpyObj('CustomInputsService', ['getAll']);
const humanizeCurrencyPipeSpy = jasmine.createSpyObj('HumanizeCurrencyPipe', ['transform']);
const projectServiceSpy = jasmine.createSpyObj('ProjectsService', ['getAllActive']);
const projectsServiceSpy = jasmine.createSpyObj('ProjectsService', ['getAllActive']);
const categoriesServiceSpy = jasmine.createSpyObj('CategoriesService', ['getAll', 'filterRequired']);
const dateServiceSpy = jasmine.createSpyObj('DateService', ['isValidDate']);
const taxGroupServiceSpy = jasmine.createSpyObj('TaxGroupService', ['get']);
Expand All @@ -134,7 +134,7 @@ describe('MergeExpensesService', () => {
{ provide: CorporateCreditCardExpenseService, useValue: corporateCreditCardExpenseServiceSpy },
{ provide: CustomInputsService, useValue: customInputsServiceSpy },
{ provide: HumanizeCurrencyPipe, useValue: humanizeCurrencyPipeSpy },
{ provide: ProjectsService, useValue: projectServiceSpy },
{ provide: ProjectsService, useValue: projectsServiceSpy },
{ provide: CategoriesService, useValue: categoriesServiceSpy },
{ provide: DateService, useValue: dateServiceSpy },
{ provide: TaxGroupService, useValue: taxGroupServiceSpy },
Expand All @@ -148,7 +148,7 @@ describe('MergeExpensesService', () => {
) as jasmine.SpyObj<CorporateCreditCardExpenseService>;
customInputsService = TestBed.inject(CustomInputsService) as jasmine.SpyObj<CustomInputsService>;
humanizeCurrencyPipe = TestBed.inject(HumanizeCurrencyPipe) as jasmine.SpyObj<HumanizeCurrencyPipe>;
projectService = TestBed.inject(ProjectsService) as jasmine.SpyObj<ProjectsService>;
projectsService = TestBed.inject(ProjectsService) as jasmine.SpyObj<ProjectsService>;
categoriesService = TestBed.inject(CategoriesService) as jasmine.SpyObj<CategoriesService>;
dateService = TestBed.inject(DateService) as jasmine.SpyObj<DateService>;
taxGroupService = TestBed.inject(TaxGroupService) as jasmine.SpyObj<TaxGroupService>;
Expand Down Expand Up @@ -404,7 +404,7 @@ describe('MergeExpensesService', () => {

describe('formatProjectOptions():', () => {
it('should return the project options', (done) => {
projectService.getAllActive.and.returnValue(of(projectsV1Data));
projectsService.getAllActive.and.returnValue(of(projectsV1Data));
// @ts-ignore
mergeExpensesService.formatProjectOptions(projectOptionsData).subscribe((res) => {
expect(res).toEqual(projectOptionsData);
Expand All @@ -413,7 +413,7 @@ describe('MergeExpensesService', () => {
});

it('should return the project options with label as project name if id matches with option', (done) => {
projectService.getAllActive.and.returnValue(of(projectsV1Data));
projectsService.getAllActive.and.returnValue(of(projectsV1Data));
// @ts-ignore
mergeExpensesService.formatProjectOptions({ ...projectOptionsData, value: 257528 }).subscribe((res) => {
expect(res).toEqual({ label: 'Customer Mapped Project', value: 257528 });
Expand All @@ -422,7 +422,7 @@ describe('MergeExpensesService', () => {
});

it('should return the project options when project is not present', (done) => {
projectService.getAllActive.and.returnValue(of([]));
projectsService.getAllActive.and.returnValue(of([]));
// @ts-ignore
mergeExpensesService.formatProjectOptions({ label: null, value: null }).subscribe((res) => {
expect(res).toEqual({ label: undefined, value: null });
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/merge-expenses.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class MergeExpensesService {
private corporateCreditCardExpenseService: CorporateCreditCardExpenseService,
private customInputsService: CustomInputsService,
private humanizeCurrency: HumanizeCurrencyPipe,
private projectService: ProjectsService,
private projectsService: ProjectsService,
private categoriesService: CategoriesService,
private dateService: DateService,
private taxGroupService: TaxGroupService
Expand Down Expand Up @@ -748,7 +748,7 @@ export class MergeExpensesService {
}

private formatProjectOptions(option: MergeExpensesOption<number>): Observable<MergeExpensesOption<number>> {
const projects$ = this.projectService.getAllActive().pipe(shareReplay(1));
const projects$ = this.projectsService.getAllActive().pipe(shareReplay(1));
return projects$.pipe(
map((projects) => {
const index = projects.map((project) => project.id).indexOf(option.value);
Expand Down
24 changes: 12 additions & 12 deletions src/app/core/services/projects.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const fixDate = (data) =>
}));

describe('ProjectsService', () => {
let projectService: ProjectsService;
let projectsService: ProjectsService;
let apiService: jasmine.SpyObj<ApiService>;
let apiV2Service: jasmine.SpyObj<ApiV2Service>;

Expand All @@ -46,18 +46,18 @@ describe('ProjectsService', () => {
},
],
});
projectService = TestBed.inject(ProjectsService);
projectsService = TestBed.inject(ProjectsService);
apiService = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
apiV2Service = TestBed.inject(ApiV2Service) as jasmine.SpyObj<ApiV2Service>;
});

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

it('should be able to fetch project by id', (done) => {
apiV2Service.get.and.returnValue(of(apiV2ResponseSingle));
projectService.getbyId(257528).subscribe((res) => {
projectsService.getbyId(257528).subscribe((res) => {
expect(res).toEqual(fixDate(apiV2ResponseSingle.data)[0]);
done();
});
Expand All @@ -71,7 +71,7 @@ describe('ProjectsService', () => {

it('should be able to fetch all active projects', (done) => {
apiService.get.and.returnValue(of(apiResponseActiveOnly));
projectService.getAllActive().subscribe((res) => {
projectsService.getAllActive().subscribe((res) => {
expect(res).toEqual(expectedReponseActiveOnly);
done();
});
Expand All @@ -86,7 +86,7 @@ describe('ProjectsService', () => {
it('should be able to fetch data when no params provided', (done) => {
apiV2Service.get.and.returnValue(of(apiV2ResponseMultiple));

projectService.getByParamsUnformatted({}).subscribe((res) => {
projectsService.getByParamsUnformatted({}).subscribe((res) => {
expect(res).toEqual(fixDate(apiV2ResponseMultiple.data));
done();
});
Expand All @@ -95,7 +95,7 @@ describe('ProjectsService', () => {
it('should be able to fetch data when params are provided', (done) => {
apiV2Service.get.and.returnValue(of(apiV2ResponseMultiple));

const result = projectService.getByParamsUnformatted(testProjectParams);
const result = projectsService.getByParamsUnformatted(testProjectParams);

result.subscribe((res) => {
expect(res).toEqual(expectedProjectsResponse);
Expand All @@ -107,19 +107,19 @@ describe('ProjectsService', () => {
});

it('should category list after filter as per project passed', () => {
const result = projectService.getAllowedOrgCategoryIds(testProjectV2, testActiveCategoryList);
const result = projectsService.getAllowedOrgCategoryIds(testProjectV2, testActiveCategoryList);
expect(result).toEqual(allowedActiveCategories);
});

it('should return whole category list if project passed is not present', () => {
const result = projectService.getAllowedOrgCategoryIds(null, testActiveCategoryList);
const result = projectsService.getAllowedOrgCategoryIds(null, testActiveCategoryList);
expect(result).toEqual(testActiveCategoryList);
});

it('should get project count restricted by a set of category IDs', (done) => {
apiService.get.and.returnValue(of(apiResponseActiveOnly));

const result = projectService.getProjectCount({ categoryIds: testCategoryIds });
const result = projectsService.getProjectCount({ categoryIds: testCategoryIds });
result.subscribe((res) => {
expect(res).toEqual(2);
done();
Expand All @@ -129,8 +129,8 @@ describe('ProjectsService', () => {
it('should get project count not restricted by a set of category IDs', (done) => {
apiService.get.and.returnValue(of(apiResponseActiveOnly));

const resultWithOutParam = projectService.getProjectCount();
const resultWithParam = projectService.getProjectCount({ categoryIds: null });
const resultWithOutParam = projectsService.getProjectCount();
const resultWithParam = projectsService.getProjectCount({ categoryIds: null });

resultWithOutParam.subscribe((res) => {
expect(res).toEqual(apiResponseActiveOnly.length);
Expand Down
36 changes: 36 additions & 0 deletions src/app/core/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ProjectV1 } from '../models/v1/extended-project.model';
import { ProjectParams } from '../models/project-params.model';
import { intersection } from 'lodash';
import { OrgCategory } from '../models/v1/org-category.model';
import { PlatformProject } from '../models/platform/platform-project.model';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -162,4 +163,39 @@ export class ProjectsService {
)
);
}

transformToV1Response(platformProject: PlatformProject[]): ProjectV1[] {
const projectV1 = platformProject.map((platformProject) => ({
id: platformProject.id,
created_at: platformProject.created_at,
updated_at: platformProject.updated_at,
name: platformProject.name,
sub_project: platformProject.sub_project,
code: platformProject.code,
org_id: platformProject.org_id,
description: platformProject.description,
active: platformProject.is_enabled,
org_category_ids: platformProject.category_ids,
}));

return projectV1;
}

transformToV2Response(platformProject: PlatformProject[]): ProjectV2[] {
const projectV2 = platformProject.map((platformProject) => ({
project_active: platformProject.is_enabled,
project_code: platformProject.code,
project_created_at: platformProject.created_at,
project_description: platformProject.description,
project_id: platformProject.id,
project_name: platformProject.name,
project_org_category_ids: platformProject.category_ids,
project_org_id: platformProject.org_id,
project_updated_at: platformProject.updated_at,
projectv2_name: platformProject.display_name,
sub_project_name: platformProject.sub_project,
}));

return projectV2;
}
}
8 changes: 4 additions & 4 deletions src/app/core/services/recently-used-items.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { recentUsedCategoriesRes } from '../mock-data/org-category-list-item.dat
describe('RecentlyUsedItemsService', () => {
let recentlyUsedItemsService: RecentlyUsedItemsService;
let apiService: jasmine.SpyObj<ApiService>;
let projectService: jasmine.SpyObj<ProjectsService>;
let projectsService: jasmine.SpyObj<ProjectsService>;

beforeEach(() => {
TestBed.configureTestingModule({
Expand All @@ -38,7 +38,7 @@ describe('RecentlyUsedItemsService', () => {
});
recentlyUsedItemsService = TestBed.inject(RecentlyUsedItemsService);
apiService = TestBed.inject(ApiService) as jasmine.SpyObj<ApiService>;
projectService = TestBed.inject(ProjectsService) as jasmine.SpyObj<ProjectsService>;
projectsService = TestBed.inject(ProjectsService) as jasmine.SpyObj<ProjectsService>;
});

it('should be created', () => {
Expand All @@ -56,14 +56,14 @@ describe('RecentlyUsedItemsService', () => {

describe('getRecentlyUsedProjects():', () => {
it('should get all the recently used projects', (done) => {
projectService.getByParamsUnformatted.and.returnValue(of(recentlyUsedProjectRes));
projectsService.getByParamsUnformatted.and.returnValue(of(recentlyUsedProjectRes));
const config = {
recentValues: recentlyUsedRes,
eou: apiEouRes,
categoryIds: ['16558', '16559', '16560', '16561', '16562'],
};
recentlyUsedItemsService.getRecentlyUsedProjects(config).subscribe((res) => {
expect(projectService.getByParamsUnformatted).toHaveBeenCalledOnceWith({
expect(projectsService.getByParamsUnformatted).toHaveBeenCalledOnceWith({
orgId: config.eou.ou.org_id,
active: true,
sortDirection: 'asc',
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/recently-used-items.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Currency, CurrencyName } from '../models/currency.model';
providedIn: 'root',
})
export class RecentlyUsedItemsService {
constructor(private apiService: ApiService, private projectService: ProjectsService) {}
constructor(private apiService: ApiService, private projectsService: ProjectsService) {}

getRecentlyUsed(): Observable<RecentlyUsed> {
return this.apiService.get('/recently_used');
Expand All @@ -30,7 +30,7 @@ export class RecentlyUsedItemsService {
config.recentValues.recent_project_ids.length > 0 &&
config.eou
) {
return this.projectService
return this.projectsService
.getByParamsUnformatted({
orgId: config.eou.ou.org_id,
active: true,
Expand Down
8 changes: 4 additions & 4 deletions src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export class AddEditMileagePage implements OnInit {
private reportService: ReportService,
private platformReportService: ReportsService,
private fb: FormBuilder,
private projectService: ProjectsService,
private projectsService: ProjectsService,
private mileageService: MileageService,
private mileageRatesService: MileageRatesService,
private transactionsOutboxService: TransactionsOutboxService,
Expand Down Expand Up @@ -467,7 +467,7 @@ export class AddEditMileagePage implements OnInit {
concatMap((project: ProjectV2) =>
activeCategories$.pipe(
map((activeCategories: OrgCategory[]) =>
this.projectService.getAllowedOrgCategoryIds(project, activeCategories)
this.projectsService.getAllowedOrgCategoryIds(project, activeCategories)
)
)
),
Expand Down Expand Up @@ -1160,7 +1160,7 @@ export class AddEditMileagePage implements OnInit {
}),
switchMap((projectId) => {
if (projectId) {
return this.projectService.getbyId(projectId);
return this.projectsService.getbyId(projectId);
} else {
return of(null);
}
Expand Down Expand Up @@ -1570,7 +1570,7 @@ export class AddEditMileagePage implements OnInit {
this.setupFilteredCategories(this.subCategories$);
this.projectCategoryIds$ = this.getProjectCategoryIds();
this.isProjectVisible$ = this.projectCategoryIds$.pipe(
switchMap((projectCategoryIds) => this.projectService.getProjectCount({ categoryIds: projectCategoryIds })),
switchMap((projectCategoryIds) => this.projectsService.getProjectCount({ categoryIds: projectCategoryIds })),
map((projectCount) => projectCount > 0)
);
this.comments$ = this.statusService.find('transactions', this.activatedRoute.snapshot.params.id as string);
Expand Down
Loading

0 comments on commit f51a5c2

Please sign in to comment.