-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 12 additions & 1 deletion
13
...tegrations/xero/xero-main/xero-mapping/xero-base-mapping/xero-base-mapping.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
<p>xero-base-mapping works!</p> | ||
<app-generic-mapping-v2 *ngIf="!isLoading" | ||
[isLoading]="isLoading" | ||
[destinationOptions]="destinationOptions" | ||
[employeeFieldMapping]="employeeFieldMapping" | ||
[sourceField]="sourceField" | ||
[destinationField]="destinationField" | ||
[showAutoMapEmployee]="showAutoMapEmployee" | ||
[appName]="AppName.QBO" | ||
[isCategoryMappingGeneric]="sourceField === FyleField.CATEGORY ? true : false" | ||
[displayName]="displayName" | ||
(triggerAutoMapEmployee)="triggerAutoMapEmployees()"> | ||
</app-generic-mapping-v2> |
84 changes: 83 additions & 1 deletion
84
...integrations/xero/xero-main/xero-mapping/xero-base-mapping/xero-base-mapping.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,97 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { forkJoin } from 'rxjs'; | ||
import { DestinationAttribute } from 'src/app/core/models/db/destination-attribute.model'; | ||
import { MappingSetting } from 'src/app/core/models/db/mapping-setting.model'; | ||
import { AccountingDisplayName, AccountingField, AppName, FyleField, MappingDestinationField, MappingSourceField, ToastSeverity, XeroCorporateCreditCardExpensesObject, XeroReimbursableExpensesObject } from 'src/app/core/models/enum/enum.model'; | ||
import { XeroWorkspaceGeneralSetting } from 'src/app/core/models/xero/db/xero-workspace-general-setting.model'; | ||
import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service'; | ||
import { MappingService } from 'src/app/core/services/common/mapping.service'; | ||
import { WorkspaceService } from 'src/app/core/services/common/workspace.service'; | ||
|
||
@Component({ | ||
selector: 'app-xero-base-mapping', | ||
templateUrl: './xero-base-mapping.component.html', | ||
styleUrls: ['./xero-base-mapping.component.scss'] | ||
}) | ||
export class XeroBaseMappingComponent implements OnInit { | ||
isLoading: boolean = true; | ||
|
||
constructor() { } | ||
destinationOptions: DestinationAttribute[]; | ||
|
||
employeeFieldMapping: FyleField; | ||
|
||
sourceField: string; | ||
|
||
destinationField: string; | ||
|
||
showAutoMapEmployee: boolean; | ||
|
||
reimbursableExpenseObject: XeroReimbursableExpensesObject | null; | ||
|
||
cccExpenseObject: XeroCorporateCreditCardExpensesObject | null; | ||
|
||
AppName = AppName; | ||
|
||
FyleField = FyleField; | ||
|
||
displayName: string | undefined = undefined; | ||
|
||
constructor( | ||
private route: ActivatedRoute, | ||
private mappingService: MappingService, | ||
private toastService: IntegrationsToastService, | ||
private workspaceService: WorkspaceService | ||
) { } | ||
|
||
triggerAutoMapEmployees(): void { | ||
this.isLoading = true; | ||
this.mappingService.triggerAutoMapEmployees().subscribe(() => { | ||
this.isLoading = false; | ||
this.toastService.displayToastMessage(ToastSeverity.INFO, 'Auto mapping of employees may take few minutes'); | ||
}, () => { | ||
this.isLoading = false; | ||
this.toastService.displayToastMessage(ToastSeverity.ERROR, 'Something went wrong, please try again'); | ||
}); | ||
} | ||
|
||
private getDestinationField(workspaceGeneralSetting: XeroWorkspaceGeneralSetting, mappingSettings: MappingSetting[]): string { | ||
if (this.sourceField === FyleField.EMPLOYEE) { | ||
return AccountingField.CONTACT; | ||
} else if (this.sourceField === FyleField.CATEGORY) { | ||
return AccountingField.ACCOUNT; | ||
} else if (this.sourceField === MappingSourceField.TAX_GROUP) { | ||
return MappingDestinationField.TAX_CODE; | ||
} | ||
|
||
return mappingSettings.find((setting) => setting.source_field === this.sourceField)?.destination_field || ''; | ||
} | ||
|
||
private setupPage(): void { | ||
this.sourceField = decodeURIComponent(this.route.snapshot.params.source_field.toUpperCase()); | ||
forkJoin([ | ||
this.workspaceService.getWorkspaceGeneralSettings(), | ||
this.mappingService.getMappingSettings() | ||
]).subscribe((responses) => { | ||
this.reimbursableExpenseObject = responses[0].reimbursable_expenses_object; | ||
this.cccExpenseObject = responses[0].corporate_credit_card_expenses_object; | ||
this.employeeFieldMapping = (responses[0].employee_field_mapping as unknown as FyleField); | ||
this.showAutoMapEmployee = responses[0].auto_map_employees ? true : false; | ||
|
||
this.destinationField = this.getDestinationField(responses[0], responses[1].results); | ||
|
||
this.mappingService.getPaginatedDestinationAttributes(this.destinationField, undefined, this.displayName).subscribe((responses) => { | ||
this.destinationOptions = responses.results; | ||
this.isLoading = false; | ||
}); | ||
}); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.route.params.subscribe(() => { | ||
this.isLoading = true; | ||
this.setupPage(); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters