Skip to content

Commit

Permalink
Fix dynamics oauth url (#460)
Browse files Browse the repository at this point in the history
* testing

* testing

* testing

* testing

* testing

* testing

* testing fixes

---------

Co-authored-by: Fyle <[email protected]>
  • Loading branch information
DhaaraniCIT and Fyle authored Jan 22, 2024
1 parent 1ca49f4 commit 584c288
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 40 deletions.
1 change: 0 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ do
sed -i $SED_EXTRA_ARGS "s?{{REFINER_INTACCT_ONBOARDING_DONE_SURVEY_ID}}?${REFINER_INTACCT_ONBOARDING_DONE_SURVEY_ID}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{REFINER_INTACCT_EXPORT_DONE_SURVEY_ID}}?${REFINER_INTACCT_EXPORT_DONE_SURVEY_ID}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{BUSINESS_CENTRAL_OAUTH_REDIRECT_URI}}?${BUSINESS_CENTRAL_OAUTH_REDIRECT_URI}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{BUSINESS_CENTRAL_AUTHORIZE_URI}}?${BUSINESS_CENTRAL_AUTHORIZE_URI}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{BUSINESS_CENTRAL_OAUTH_CLIENT_ID}}?${BUSINESS_CENTRAL_OAUTH_CLIENT_ID}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{BRAND_NAME}}?${BRAND_NAME}?g" $f;
sed -i $SED_EXTRA_ARGS "s?{{WEBPAGE_TITLE}}?${WEBPAGE_TITLE}?g" $f;
Expand Down
1 change: 0 additions & 1 deletion scripts/setup_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const environment = {
travelperk_base_url: `${process.env.TRAVELPERK_BASE_URL ? process.env.TRAVELPERK_BASE_URL : '{{TRAVELPERK_BASE_URL}}'}`,
travelperk_client_id: `${process.env.TRAVELPERK_CLIENT_ID ? process.env.TRAVELPERK_CLIENT_ID : '{{TRAVELPERK_CLIENT_ID}}'}`,
business_central_oauth_redirect_uri: `${process.env.BUSINESS_CENTRAL_OAUTH_REDIRECT_URI ? process.env.BUSINESS_CENTRAL_OAUTH_REDIRECT_URI : '{{BUSINESS_CENTRAL_OAUTH_REDIRECT_URI}}'}`,
business_central_authorize_uri: `${process.env.BUSINESS_CENTRAL_AUTHORIZE_URI ? process.env.BUSINESS_CENTRAL_AUTHORIZE_URI : '{{BUSINESS_CENTRAL_AUTHORIZE_URI}}'}`,
business_central_oauth_client_id: `${process.env.BUSINESS_CENTRAL_OAUTH_CLIENT_ID ? process.env.BUSINESS_CENTRAL_OAUTH_CLIENT_ID : '{{BUSINESS_CENTRAL_OAUTH_CLIENT_ID}}'}`,
qbo_app_url: `${process.env.QBO_APP_URL ? process.env.QBO_APP_URL : '{{QBO_APP_URL}}'}`,
qbo_oauth_redirect_uri: `${process.env.QBO_OAUTH_REDIRECT_URI ? process.env.QBO_OAUTH_REDIRECT_URI : '{{QBO_OAUTH_REDIRECT_URI}}'}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class BusinessCentralBaseMappingComponent implements OnInit {
this.mappingService.getExportSettings()
]).subscribe(([mappingSettingsResponse, exportSettingsResponse]) => {
this.destinationField = this.getDestinationField(exportSettingsResponse, mappingSettingsResponse.results);
this.employeeFieldMapping = (exportSettingsResponse.employee_mapping as unknown as FyleField);
this.employeeFieldMapping = (exportSettingsResponse.employee_field_mapping as unknown as FyleField);
this.reimbursableExpenseObject = exportSettingsResponse.reimbursable_expenses_object;
this.cccExpenseObject = exportSettingsResponse.corporate_credit_card_expenses_object;
this.showAutoMapEmployee = exportSettingsResponse.auto_map_employees ? true : false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class BusinessCentralOnboardingConnectorComponent implements OnInit, OnDe

connectBusinessCentral(): void {
this.businessCentralConnectionInProgress = true;
const url = `${environment.business_central_authorize_uri}client_id=${environment.business_central_oauth_client_id}&redirect_uri=${environment.business_central_oauth_redirect_uri}&state=business_central_local_redirect&response_type=code`;
const url = `https://login.microsoftonline.com/organizations/oauth2/authorize?resource=https://api.businesscentral.dynamics.com&client_id=${environment.business_central_oauth_client_id}&redirect_uri=${environment.business_central_oauth_redirect_uri}&state=business_central_local_redirect&response_type=code`;

this.oauthCallbackSubscription = this.helperService.oauthCallbackUrl.subscribe((callbackURL: string) => {
const code = callbackURL.split('code=')[1].split('&')[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,16 @@ export class BusinessCentralOnboardingLandingComponent implements OnInit, OnDest

connectBusinessCentral(): void {
this.businessCentralConnectionInProgress = true;
const url = `${environment.business_central_authorize_uri}client_id=${environment.business_central_oauth_client_id}&redirect_uri=${environment.business_central_oauth_redirect_uri}&state=business_central_local_redirect&response_type=code`;

const url = `https://login.microsoftonline.com/organizations/oauth2/authorize?resource=https://api.businesscentral.dynamics.com&client_id=${environment.business_central_oauth_client_id}&redirect_uri=${environment.business_central_oauth_redirect_uri}&state=business_central_local_redirect&response_type=code`;
this.oauthCallbackSubscription = this.helperService.oauthCallbackUrl.subscribe((callbackURL: string) => {
const code = callbackURL.split('code=')[1].split('&')[0];
const code = callbackURL.split('code=')[1]?.split('&')[0];
this.postBusinessCentralCredentials(code);
});
this.helperService.oauthHandler(url);
}

private postBusinessCentralCredentials(code: string): void {
const payload: BusinessCentralConnectorPost = BusinessCentralConnectorModel.constructPayload(code, +this.workspaceService.getWorkspaceId());

this.businessCentralConnectorService.connectBusinessCentral(payload).subscribe(() => {
this.businessCentralHelperService.refreshBusinessCentralDimensions(true).subscribe(() => {
this.businessCentralConnectionInProgress = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@
[formControllerName]="'autoMapEmployee'">
</app-configuration-select-field>
</div>
<div *ngIf="exportSettingForm?.value.reimbursableExportType" class="tw-mt-16-px tw-bg-white tw-border tw-border-solid tw-border-separator tw-rounded-12-px">
<app-configuration-select-field
[form]="exportSettingForm"
[isFieldMandatory]="true"
[mandatoryErrorListName]="'how expenses to be grouped'"
[label]="'How should the expenses be grouped?'"
[subLabel]="'Expense can either be exported as single line items (Expense) or as a grouped report with multiple line items (Expense Report)'"
[options]="expenseGroupByOptions"
[iconPath]="'questionmark'"
[placeholder]="'Select expense grouping'"
[formControllerName]="'reimbursableExportGroup'"
[appName]="appName"
[exportTypeIconPathArray]="previewExpenseGroupTypeImagePath">
</app-configuration-select-field>
</div>
<div *ngIf="exportSettingForm?.value.reimbursableExportType" class="tw-mt-16-px tw-bg-white tw-border tw-border-solid tw-border-separator tw-rounded-12-px">
<app-configuration-select-field
[form]="exportSettingForm"
Expand All @@ -105,21 +120,7 @@
[formControllerName]="'reimbursableExportDate'">
</app-configuration-select-field>
</div>
<div *ngIf="exportSettingForm?.value.reimbursableExportType" class="tw-mt-16-px tw-bg-white tw-border tw-border-solid tw-border-separator tw-rounded-12-px">
<app-configuration-select-field
[form]="exportSettingForm"
[isFieldMandatory]="true"
[mandatoryErrorListName]="'how expenses to be grouped'"
[label]="'How should the expenses be grouped?'"
[subLabel]="'Expense can either be exported as single line items (Expense) or as a grouped report with multiple line items (Expense Report)'"
[options]="expenseGroupByOptions"
[iconPath]="'questionmark'"
[placeholder]="'Select expense grouping'"
[formControllerName]="'reimbursableExportGroup'"
[appName]="appName"
[exportTypeIconPathArray]="previewExpenseGroupTypeImagePath">
</app-configuration-select-field>
</div>

</div>
</div>
<div>
Expand Down Expand Up @@ -174,6 +175,21 @@
[formControllerName]="'defaultVendorName'">
</app-configuration-select-field>
</div>
<div *ngIf="exportSettingForm.value.cccExportType" class="tw-mt-16-px tw-bg-white tw-border tw-border-solid tw-border-separator tw-rounded-12-px">
<app-configuration-select-field
[form]="exportSettingForm"
[isFieldMandatory]="true"
[mandatoryErrorListName]="'how expenses to be grouped'"
[label]="'How should the expenses be grouped?'"
[subLabel]="'Expense can either be exported as single line items (Expense) or as a grouped report with multiple line items (Expense Report)'"
[options]="expenseGroupByOptions"
[iconPath]="'questionmark'"
[placeholder]="'Select expense grouping'"
[formControllerName]="'cccExportGroup'"
[appName]="appName"
[exportTypeIconPathArray]="previewExpenseGroupTypeImagePath">
</app-configuration-select-field>
</div>
<div *ngIf="!exportSettingForm.value?.reimbursableExpense && exportSettingForm.value.cccExportType === BusinessCentralExportType.JOURNAL_ENTRY" class="tw-mt-16-px tw-bg-white tw-border tw-border-solid tw-border-separator tw-rounded-12-px">
<app-configuration-select-field
[form]="exportSettingForm"
Expand Down Expand Up @@ -226,21 +242,6 @@
[formControllerName]="'cccExportDate'">
</app-configuration-select-field>
</div>
<div *ngIf="exportSettingForm.value.cccExportType" class="tw-mt-16-px tw-bg-white tw-border tw-border-solid tw-border-separator tw-rounded-12-px">
<app-configuration-select-field
[form]="exportSettingForm"
[isFieldMandatory]="true"
[mandatoryErrorListName]="'how expenses to be grouped'"
[label]="'How should the expenses be grouped?'"
[subLabel]="'Expense can either be exported as single line items (Expense) or as a grouped report with multiple line items (Expense Report)'"
[options]="expenseGroupByOptions"
[iconPath]="'questionmark'"
[placeholder]="'Select expense grouping'"
[formControllerName]="'cccExportGroup'"
[appName]="appName"
[exportTypeIconPathArray]="previewExpenseGroupTypeImagePath">
</app-configuration-select-field>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export class BusinessCentralExportSettingsComponent implements OnInit {
}

getExportDate(options: BusinessCentralExportSettingFormOption[]): BusinessCentralExportSettingFormOption[]{
if (this.exportSettingForm.value.reimbursableExpenseState === ExpenseGroupedBy.REPORT) {
return options.filter(option => option.value !== ExportDateType.SPENT_AT);
if (this.exportSettingForm.value.reimbursableExportGroup === ExpenseGroupedBy.REPORT) {
return options.filter(option => option.value === ExportDateType.LAST_SPENT_AT);
}
return options;
}
Expand Down

0 comments on commit 584c288

Please sign in to comment.