Skip to content

Commit 77ed17b

Browse files
committed
fix: qbd direct team testing fixes (#1095)
* qbd direct team testing fixes * Qbd direct bug fixes * fixes * PR fix
1 parent a11820f commit 77ed17b

File tree

8 files changed

+89
-14
lines changed

8 files changed

+89
-14
lines changed

src/app/core/models/db/task-log.model.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ export type TaskLogGetParams = {
2323
type__in?: string[];
2424
expense_group_ids?: number[];
2525
task_type?: string[];
26-
export_log__id__in?: number[];
26+
id__in?: number[];
2727
};

src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.model.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel {
2626
}
2727

2828
static defaultTopMemoOptions(): string[] {
29-
return ["employee_name", "Expense/Report ID"];
29+
return ["employee_name", "expense_key"];
3030
}
3131

3232
static topMemoExpenseKeyNameConversion(keys: string[]): string[] {
@@ -52,7 +52,7 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel {
5252

5353
return new FormGroup({
5454
expenseMemoStructure: new FormControl(advancedSettings?.line_level_memo_structure && advancedSettings?.line_level_memo_structure.length > 0 ? this.formatMemoStructure(this.defaultMemoFields(), advancedSettings?.line_level_memo_structure) : this.defaultMemoFields(), Validators.required),
55-
topMemoStructure: new FormControl(advancedSettings?.top_level_memo_structure && advancedSettings?.top_level_memo_structure.length > 0 ? this.topMemoExpenseKeyNameConversion(advancedSettings?.top_level_memo_structure) : this.defaultTopMemoOptions(), Validators.required),
55+
topMemoStructure: new FormControl(advancedSettings?.top_level_memo_structure && advancedSettings?.top_level_memo_structure.length > 0 ? advancedSettings?.top_level_memo_structure : this.defaultTopMemoOptions(), Validators.required),
5656
exportSchedule: new FormControl(advancedSettings?.schedule_is_enabled ? advancedSettings?.schedule_is_enabled : false),
5757
email: new FormControl(advancedSettings?.emails_selected ? advancedSettings?.emails_selected : null),
5858
exportScheduleFrequency: new FormControl(advancedSettings?.schedule_is_enabled ? advancedSettings?.interval_hours : 1),
@@ -65,11 +65,6 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel {
6565

6666
static constructPayload (advancedSettingForm: FormGroup, adminEmails: EmailOption[]): QbdDirectAdvancedSettingsPost {
6767

68-
const topMemo: string[] = advancedSettingForm.controls.topMemoStructure.value;
69-
70-
const index = topMemo.indexOf('Expense/Report ID');
71-
topMemo[index] = 'expense_key';
72-
7368
const allSelectedEmails: EmailOption[] = advancedSettingForm.get('email')?.value;
7469

7570
const selectedEmailsEmails = allSelectedEmails?.filter((email: EmailOption) => adminEmails.includes(email));
@@ -80,7 +75,7 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel {
8075

8176
const advancedSettingPayload: QbdDirectAdvancedSettingsPost = {
8277
line_level_memo_structure: advancedSettingForm.get('expenseMemoStructure')?.value ? this.formatMemoStructure(this.defaultMemoFields(), memo) : [],
83-
top_level_memo_structure: advancedSettingForm.get('topMemoStructure')?.value ? topMemo : null,
78+
top_level_memo_structure: advancedSettingForm.get('topMemoStructure')?.value ? advancedSettingForm.get('topMemoStructure')?.value : null,
8479
schedule_is_enabled: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('exportSchedule')?.value : false,
8580
emails_selected: advancedSettingForm.get('exportSchedule')?.value ? selectedEmailsEmails : [],
8681
interval_hours: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('exportScheduleFrequency')?.value : null,

src/app/core/services/common/dashboard.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class DashboardService {
5858
}
5959

6060
if (expenseGroupIds.length) {
61-
const expenseKey = appName === AppName.INTACCT ? 'expense_group_ids' : appName === AppName.QBD_DIRECT ? 'export_log__id__in' : 'expense_group_id__in';
61+
const expenseKey = appName === AppName.INTACCT ? 'expense_group_ids' : appName === AppName.QBD_DIRECT ? 'id__in' : 'expense_group_id__in';
6262
apiParams[expenseKey] = expenseGroupIds;
6363
}
6464

src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
[options]="reimbursableExpenseGroupingFieldOptions"
9898
[iconPath]="'question-square-outline'"
9999
[placeholder]="'Select expense grouping'"
100+
[isDisableTextRequired]="isReimbursableExportGroupDisabled()"
101+
[isDisabled]="isReimbursableExportGroupDisabled()"
100102
[formControllerName]="'reimbursableExportGroup'">
101103
</app-configuration-select-field>
102104
</div>
@@ -239,7 +241,8 @@
239241
[iconPath]="'question-square-outline'"
240242
[placeholder]="'Select expense grouping'"
241243
[isDisableTextRequired]="true"
242-
[isDisabled]="exportSettingsForm.get('creditCardExportType')?.value === QBDCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE || exportSettingsForm.get('creditCardExportType')?.value === QBDCorporateCreditCardExpensesObject.JOURNAL_ENTRY ? true : false"
244+
[appName]="appName"
245+
[isDisabled]="isCccExportGroupDisabled()"
243246
[formControllerName]="'creditCardExportGroup'">
244247
</app-configuration-select-field>
245248
</div>

src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts

+71-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,24 @@ export class QbdDirectExportSettingsComponent implements OnInit{
101101
return true;
102102
}
103103

104+
isCccExportGroupDisabled(): boolean {
105+
if (this.exportSettingsForm.get('creditCardExportType')?.value === QBDCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE) {
106+
return true;
107+
}
108+
if (this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value?.detail.account_type === 'AccountsPayable') {
109+
return true;
110+
}
111+
return false;
112+
113+
}
114+
115+
isReimbursableExportGroupDisabled(): boolean {
116+
if (this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.value?.detail.account_type === 'AccountsPayable' && this.exportSettingsForm.controls.reimbursableExportType.value === QbdDirectReimbursableExpensesObject.JOURNAL_ENTRY) {
117+
return true;
118+
}
119+
return false;
120+
}
121+
104122
reimbursableAccpuntOptions(): DestinationAttribute[] {
105123
if (this.exportSettingsForm.controls.employeeMapping.value === EmployeeFieldMapping.EMPLOYEE) {
106124
return this.destinationOptionsWatcher(['Bank', 'CreditCard', 'OtherCurrentLiability', 'LongTermLiability'], this.destinationAccounts);
@@ -182,9 +200,10 @@ export class QbdDirectExportSettingsComponent implements OnInit{
182200

183201
cccExportTypeWatcher(): void {
184202
this.exportSettingsForm.controls.creditCardExportType.valueChanges.subscribe((creditCardExportTypeValue) => {
203+
if (creditCardExportTypeValue === QBDCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE) {
185204
this.exportSettingsForm.controls.creditCardExportGroup.patchValue(QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1].value);
186205
this.exportSettingsForm.controls.creditCardExportGroup.disable();
187-
this.creditCardExpenseGroupingFieldOptions = [QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1]];
206+
}
188207
});
189208
}
190209

@@ -211,6 +230,49 @@ export class QbdDirectExportSettingsComponent implements OnInit{
211230
});
212231
}
213232

233+
defaultAccountsPayableAccountWatcher() {
234+
this.exportSettingsForm.controls.employeeMapping.valueChanges.subscribe((employeeMapping) => {
235+
if (employeeMapping === EmployeeFieldMapping.EMPLOYEE) {
236+
if (this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.value.detail.account_type === 'AccountsPayable') {
237+
this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.patchValue(null);
238+
if (this.exportSettingsForm.controls.nameInJE.value === EmployeeFieldMapping.EMPLOYEE && this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value.detail.account_type === 'AccountsPayable') {
239+
this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.patchValue(null);
240+
}
241+
}
242+
}
243+
});
244+
}
245+
246+
defaultCCCAccountsPayableAccountWatcher() {
247+
this.exportSettingsForm.controls.nameInJE.valueChanges.subscribe((nameInJE) => {
248+
if (nameInJE === EmployeeFieldMapping.EMPLOYEE && this.exportSettingsForm.controls.employeeMapping.value === EmployeeFieldMapping.EMPLOYEE && this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value.detail.account_type === 'AccountsPayable') {
249+
this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.patchValue(null);
250+
}
251+
});
252+
}
253+
254+
cccExportGroupingWatcher() {
255+
this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.valueChanges.subscribe((defaultCCCAccountsPayableAccountNameValue: QbdDirectDestinationAttribute) => {
256+
if (defaultCCCAccountsPayableAccountNameValue?.detail?.account_type === 'AccountsPayable') {
257+
this.exportSettingsForm.controls.creditCardExportGroup.patchValue(QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1].value);
258+
this.exportSettingsForm.controls.creditCardExportGroup.disable();
259+
} else {
260+
this.exportSettingsForm.controls.creditCardExportGroup.enable();
261+
}
262+
});
263+
}
264+
265+
reimburesmentExpenseGroupingWatcher() {
266+
this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.valueChanges.subscribe((defaultReimbursableAccountsPayableAccountNameValue: QbdDirectDestinationAttribute) => {
267+
if (defaultReimbursableAccountsPayableAccountNameValue?.detail?.account_type === 'AccountsPayable') {
268+
this.exportSettingsForm.controls.reimbursableExportGroup.patchValue(QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1].value);
269+
this.exportSettingsForm.controls.reimbursableExportGroup.disable();
270+
} else {
271+
this.exportSettingsForm.controls.reimbursableExportGroup.enable();
272+
}
273+
});
274+
}
275+
214276
destinationOptionsWatcher(detailAccountType: string[], destinationOptions: QbdDirectDestinationAttribute[]): DestinationAttribute[] {
215277
return destinationOptions.filter((account: QbdDirectDestinationAttribute) => detailAccountType.includes(account.detail.account_type));
216278
}
@@ -224,6 +286,14 @@ export class QbdDirectExportSettingsComponent implements OnInit{
224286
this.reimbursableExpenseGroupWatcher();
225287

226288
this.cccExpenseGroupWatcher();
289+
290+
this.defaultAccountsPayableAccountWatcher();
291+
292+
this.defaultCCCAccountsPayableAccountWatcher();
293+
294+
this.cccExportGroupingWatcher();
295+
296+
this.reimburesmentExpenseGroupingWatcher();
227297
}
228298

229299
private setupCCCExpenseGroupingDateOptions(): void {

src/app/shared/components/configuration/configuration-multi-select/configuration-multi-select.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px !tw-font-400 !tw-leading-4" [innerH
1515
(onChange)="onMultiSelectChange()">
1616
<ng-template let-value pTemplate="selectedItems" >
1717
<div *ngIf="form.get(formControllerName)?.value?.length>0" class="tw-flex">
18-
<p *ngFor="let name of value;let i = index">{{ name | titlecase | snakeCaseToSpaceCase }}<span *ngIf="i !== value?.length-1">,&nbsp;</span></p>
18+
<p *ngFor="let name of value;let i = index">{{ getMemo(name) }}<span *ngIf="i !== value?.length-1">,&nbsp;</span></p>
1919
</div>
2020
<div *ngIf="form.get(formControllerName)?.value?.length === 0" class="tw-text-placeholder">
2121
{{ placeholder }}
@@ -26,7 +26,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px !tw-font-400 !tw-leading-4" [innerH
2626
<p class="tw-text-sub-text-color tw-text-14-px">{{ gens | titlecase | snakeCaseToSpaceCase }}</p>
2727
</div> -->
2828
<div>
29-
<p class="tw-text-14-px">{{ memo | titlecase | snakeCaseToSpaceCase }}</p>
29+
<p class="tw-text-14-px">{{ getMemo(memo) }}</p>
3030
</div>
3131
</ng-template>
3232
</p-multiSelect>

src/app/shared/components/configuration/configuration-multi-select/configuration-multi-select.component.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { TitleCasePipe } from '@angular/common';
12
import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core';
23
import { FormBuilder, FormGroup } from '@angular/forms';
34
import { brandingConfig } from 'src/app/branding/branding-config';
5+
import { SnakeCaseToSpaceCasePipe } from 'src/app/shared/pipes/snake-case-to-space-case.pipe';
46

57
@Component({
68
selector: 'app-configuration-multi-select',
@@ -49,6 +51,10 @@ export class ConfigurationMultiSelectComponent implements OnInit {
4951
this.changeInMultiSelect.emit();
5052
}
5153

54+
getMemo(memo: string): string {
55+
return memo === 'expense_key' ? 'Expense/Report Id' : new SnakeCaseToSpaceCasePipe().transform(new TitleCasePipe().transform(memo));
56+
}
57+
5258
// DragStart(memo: string) {
5359
// This.currentlyDragging = memo;
5460
// }

src/app/shared/components/configuration/configuration-select-field/configuration-select-field.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ <h5 *ngIf="formControllerName === 'cccExportType' && brandingConfig.brandId ===
9898
</div>
9999
<div *ngIf="!showExportPreview && isDisabled && isDisableTextRequired" class="sub-text tw-text-pretty">
100100
<span>Auto-selected based on your export module</span>
101+
<span *ngIf="(formControllerName === 'reimbursableExportGroup' || formControllerName === 'creditCardExportGroup') && appName === AppName.QBD_DIRECT && form.controls.creditCardExportType.value !== 'CREDIT_CARD_PURCHASE'"> Auto-selected when your default credit account is set to an Accounts Payable account</span>
101102
</div>
102103
<div *ngIf="brandingConfig.brandId !== 'co' && form.controls[formControllerName].value==='spent_at' && isOnboarding && form.get('cccExportType')?.value && form.get('cccExportGroup')?.value === 'REPORT'" class="sub-text">
103104
<span>Using the Spend Date may lead to multiple single line<br>item entries.</span>

0 commit comments

Comments
 (0)