Skip to content

Commit

Permalink
fix: qbd direct team testing fixes (#1095)
Browse files Browse the repository at this point in the history
* qbd direct team testing fixes

* Qbd direct bug fixes

* fixes

* PR fix
  • Loading branch information
DhaaraniCIT committed Dec 10, 2024
1 parent a11820f commit 77ed17b
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/app/core/models/db/task-log.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ export type TaskLogGetParams = {
type__in?: string[];
expense_group_ids?: number[];
task_type?: string[];
export_log__id__in?: number[];
id__in?: number[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel {
}

static defaultTopMemoOptions(): string[] {
return ["employee_name", "Expense/Report ID"];
return ["employee_name", "expense_key"];
}

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

return new FormGroup({
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),
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),
topMemoStructure: new FormControl(advancedSettings?.top_level_memo_structure && advancedSettings?.top_level_memo_structure.length > 0 ? advancedSettings?.top_level_memo_structure : this.defaultTopMemoOptions(), Validators.required),
exportSchedule: new FormControl(advancedSettings?.schedule_is_enabled ? advancedSettings?.schedule_is_enabled : false),
email: new FormControl(advancedSettings?.emails_selected ? advancedSettings?.emails_selected : null),
exportScheduleFrequency: new FormControl(advancedSettings?.schedule_is_enabled ? advancedSettings?.interval_hours : 1),
Expand All @@ -65,11 +65,6 @@ export class QbdDirectAdvancedSettingsModel extends AdvancedSettingsModel {

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

const topMemo: string[] = advancedSettingForm.controls.topMemoStructure.value;

const index = topMemo.indexOf('Expense/Report ID');
topMemo[index] = 'expense_key';

const allSelectedEmails: EmailOption[] = advancedSettingForm.get('email')?.value;

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

const advancedSettingPayload: QbdDirectAdvancedSettingsPost = {
line_level_memo_structure: advancedSettingForm.get('expenseMemoStructure')?.value ? this.formatMemoStructure(this.defaultMemoFields(), memo) : [],
top_level_memo_structure: advancedSettingForm.get('topMemoStructure')?.value ? topMemo : null,
top_level_memo_structure: advancedSettingForm.get('topMemoStructure')?.value ? advancedSettingForm.get('topMemoStructure')?.value : null,
schedule_is_enabled: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('exportSchedule')?.value : false,
emails_selected: advancedSettingForm.get('exportSchedule')?.value ? selectedEmailsEmails : [],
interval_hours: advancedSettingForm.get('exportSchedule')?.value ? advancedSettingForm.get('exportScheduleFrequency')?.value : null,
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/common/dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class DashboardService {
}

if (expenseGroupIds.length) {
const expenseKey = appName === AppName.INTACCT ? 'expense_group_ids' : appName === AppName.QBD_DIRECT ? 'export_log__id__in' : 'expense_group_id__in';
const expenseKey = appName === AppName.INTACCT ? 'expense_group_ids' : appName === AppName.QBD_DIRECT ? 'id__in' : 'expense_group_id__in';
apiParams[expenseKey] = expenseGroupIds;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
[options]="reimbursableExpenseGroupingFieldOptions"
[iconPath]="'question-square-outline'"
[placeholder]="'Select expense grouping'"
[isDisableTextRequired]="isReimbursableExportGroupDisabled()"
[isDisabled]="isReimbursableExportGroupDisabled()"
[formControllerName]="'reimbursableExportGroup'">
</app-configuration-select-field>
</div>
Expand Down Expand Up @@ -239,7 +241,8 @@
[iconPath]="'question-square-outline'"
[placeholder]="'Select expense grouping'"
[isDisableTextRequired]="true"
[isDisabled]="exportSettingsForm.get('creditCardExportType')?.value === QBDCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE || exportSettingsForm.get('creditCardExportType')?.value === QBDCorporateCreditCardExpensesObject.JOURNAL_ENTRY ? true : false"
[appName]="appName"
[isDisabled]="isCccExportGroupDisabled()"
[formControllerName]="'creditCardExportGroup'">
</app-configuration-select-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ export class QbdDirectExportSettingsComponent implements OnInit{
return true;
}

isCccExportGroupDisabled(): boolean {
if (this.exportSettingsForm.get('creditCardExportType')?.value === QBDCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE) {
return true;
}
if (this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value?.detail.account_type === 'AccountsPayable') {
return true;
}
return false;

}

isReimbursableExportGroupDisabled(): boolean {
if (this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.value?.detail.account_type === 'AccountsPayable' && this.exportSettingsForm.controls.reimbursableExportType.value === QbdDirectReimbursableExpensesObject.JOURNAL_ENTRY) {
return true;
}
return false;
}

reimbursableAccpuntOptions(): DestinationAttribute[] {
if (this.exportSettingsForm.controls.employeeMapping.value === EmployeeFieldMapping.EMPLOYEE) {
return this.destinationOptionsWatcher(['Bank', 'CreditCard', 'OtherCurrentLiability', 'LongTermLiability'], this.destinationAccounts);
Expand Down Expand Up @@ -182,9 +200,10 @@ export class QbdDirectExportSettingsComponent implements OnInit{

cccExportTypeWatcher(): void {
this.exportSettingsForm.controls.creditCardExportType.valueChanges.subscribe((creditCardExportTypeValue) => {
if (creditCardExportTypeValue === QBDCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE) {
this.exportSettingsForm.controls.creditCardExportGroup.patchValue(QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1].value);
this.exportSettingsForm.controls.creditCardExportGroup.disable();
this.creditCardExpenseGroupingFieldOptions = [QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1]];
}
});
}

Expand All @@ -211,6 +230,49 @@ export class QbdDirectExportSettingsComponent implements OnInit{
});
}

defaultAccountsPayableAccountWatcher() {
this.exportSettingsForm.controls.employeeMapping.valueChanges.subscribe((employeeMapping) => {
if (employeeMapping === EmployeeFieldMapping.EMPLOYEE) {
if (this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.value.detail.account_type === 'AccountsPayable') {
this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.patchValue(null);
if (this.exportSettingsForm.controls.nameInJE.value === EmployeeFieldMapping.EMPLOYEE && this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value.detail.account_type === 'AccountsPayable') {
this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.patchValue(null);
}
}
}
});
}

defaultCCCAccountsPayableAccountWatcher() {
this.exportSettingsForm.controls.nameInJE.valueChanges.subscribe((nameInJE) => {
if (nameInJE === EmployeeFieldMapping.EMPLOYEE && this.exportSettingsForm.controls.employeeMapping.value === EmployeeFieldMapping.EMPLOYEE && this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value.detail.account_type === 'AccountsPayable') {
this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.patchValue(null);
}
});
}

cccExportGroupingWatcher() {
this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.valueChanges.subscribe((defaultCCCAccountsPayableAccountNameValue: QbdDirectDestinationAttribute) => {
if (defaultCCCAccountsPayableAccountNameValue?.detail?.account_type === 'AccountsPayable') {
this.exportSettingsForm.controls.creditCardExportGroup.patchValue(QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1].value);
this.exportSettingsForm.controls.creditCardExportGroup.disable();
} else {
this.exportSettingsForm.controls.creditCardExportGroup.enable();
}
});
}

reimburesmentExpenseGroupingWatcher() {
this.exportSettingsForm.controls.defaultReimbursableAccountsPayableAccountName.valueChanges.subscribe((defaultReimbursableAccountsPayableAccountNameValue: QbdDirectDestinationAttribute) => {
if (defaultReimbursableAccountsPayableAccountNameValue?.detail?.account_type === 'AccountsPayable') {
this.exportSettingsForm.controls.reimbursableExportGroup.patchValue(QbdDirectExportSettingModel.expenseGroupingFieldOptions()[1].value);
this.exportSettingsForm.controls.reimbursableExportGroup.disable();
} else {
this.exportSettingsForm.controls.reimbursableExportGroup.enable();
}
});
}

destinationOptionsWatcher(detailAccountType: string[], destinationOptions: QbdDirectDestinationAttribute[]): DestinationAttribute[] {
return destinationOptions.filter((account: QbdDirectDestinationAttribute) => detailAccountType.includes(account.detail.account_type));
}
Expand All @@ -224,6 +286,14 @@ export class QbdDirectExportSettingsComponent implements OnInit{
this.reimbursableExpenseGroupWatcher();

this.cccExpenseGroupWatcher();

this.defaultAccountsPayableAccountWatcher();

this.defaultCCCAccountsPayableAccountWatcher();

this.cccExportGroupingWatcher();

this.reimburesmentExpenseGroupingWatcher();
}

private setupCCCExpenseGroupingDateOptions(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px !tw-font-400 !tw-leading-4" [innerH
(onChange)="onMultiSelectChange()">
<ng-template let-value pTemplate="selectedItems" >
<div *ngIf="form.get(formControllerName)?.value?.length>0" class="tw-flex">
<p *ngFor="let name of value;let i = index">{{ name | titlecase | snakeCaseToSpaceCase }}<span *ngIf="i !== value?.length-1">,&nbsp;</span></p>
<p *ngFor="let name of value;let i = index">{{ getMemo(name) }}<span *ngIf="i !== value?.length-1">,&nbsp;</span></p>
</div>
<div *ngIf="form.get(formControllerName)?.value?.length === 0" class="tw-text-placeholder">
{{ placeholder }}
Expand All @@ -26,7 +26,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px !tw-font-400 !tw-leading-4" [innerH
<p class="tw-text-sub-text-color tw-text-14-px">{{ gens | titlecase | snakeCaseToSpaceCase }}</p>
</div> -->
<div>
<p class="tw-text-14-px">{{ memo | titlecase | snakeCaseToSpaceCase }}</p>
<p class="tw-text-14-px">{{ getMemo(memo) }}</p>
</div>
</ng-template>
</p-multiSelect>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { TitleCasePipe } from '@angular/common';
import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { brandingConfig } from 'src/app/branding/branding-config';
import { SnakeCaseToSpaceCasePipe } from 'src/app/shared/pipes/snake-case-to-space-case.pipe';

@Component({
selector: 'app-configuration-multi-select',
Expand Down Expand Up @@ -49,6 +51,10 @@ export class ConfigurationMultiSelectComponent implements OnInit {
this.changeInMultiSelect.emit();
}

getMemo(memo: string): string {
return memo === 'expense_key' ? 'Expense/Report Id' : new SnakeCaseToSpaceCasePipe().transform(new TitleCasePipe().transform(memo));
}

// DragStart(memo: string) {
// This.currentlyDragging = memo;
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ <h5 *ngIf="formControllerName === 'cccExportType' && brandingConfig.brandId ===
</div>
<div *ngIf="!showExportPreview && isDisabled && isDisableTextRequired" class="sub-text tw-text-pretty">
<span>Auto-selected based on your export module</span>
<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>
</div>
<div *ngIf="brandingConfig.brandId !== 'co' && form.controls[formControllerName].value==='spent_at' && isOnboarding && form.get('cccExportType')?.value && form.get('cccExportGroup')?.value === 'REPORT'" class="sub-text">
<span>Using the Spend Date may lead to multiple single line<br>item entries.</span>
Expand Down

0 comments on commit 77ed17b

Please sign in to comment.