-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: qbd direct team testing fixes #1095
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
@@ -239,7 +241,7 @@ | |
[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" | ||
[isDisabled]="isCccExportGroupDisabled()" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Inconsistency in disable text behavior between credit card and reimbursable export groups The code inspection reveals that the reimbursable export group dynamically sets both - [isDisableTextRequired]="true"
+ [isDisableTextRequired]="isCccExportGroupDisabled()" The implementation of both disable methods shows they handle different but valid business cases:
🔗 Analysis chainVerify consistency between credit card and reimbursable export group controls The change to use Consider making the credit card export group's - [isDisableTextRequired]="true"
+ [isDisableTextRequired]="isCccExportGroupDisabled()" Let's verify the implementation of the disable method: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for the implementation of isCccExportGroupDisabled method
ast-grep --pattern 'isCccExportGroupDisabled() {
$$$
}'
Length of output: 59 Script: #!/bin/bash
# Let's try a different pattern to find the method implementation
ast-grep --pattern 'isCccExportGroupDisabled'
# Also search with ripgrep for more context
rg "isCccExportGroupDisabled" -A 5
Length of output: 2242 Script: #!/bin/bash
# Let's find the reimbursable export group implementation for comparison
rg "isReimbursableExportGroupDisabled" -A 5
# Also search for any other configuration-select-field usage with isDisableTextRequired
rg "isDisableTextRequired" -B 2 -A 2
Length of output: 10525 |
||
[formControllerName]="'creditCardExportGroup'"> | ||
</app-configuration-select-field> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -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]]; | ||
} | ||
}); | ||
} | ||
|
||
|
@@ -211,6 +230,45 @@ 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); | ||
} | ||
}); | ||
} | ||
Comment on lines
+246
to
+252
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve error handling and code readability Similar to the previous method, this one needs improvements in error handling and null safety. Consider this safer implementation: 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);
+ this.exportSettingsForm.controls.nameInJE.valueChanges.subscribe({
+ next: (nameInJE) => {
+ const isEmployeeMapping = this.exportSettingsForm.controls.employeeMapping.value === EmployeeFieldMapping.EMPLOYEE;
+ const cccAccount = this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.value?.detail;
+
+ if (nameInJE === EmployeeFieldMapping.EMPLOYEE &&
+ isEmployeeMapping &&
+ cccAccount?.account_type === QbdDirectAccountType.ACCOUNTS_PAYABLE) {
+ this.exportSettingsForm.controls.defaultCCCAccountsPayableAccountName.patchValue(null);
+ }
+ },
+ error: (error) => {
+ console.error('Error in nameInJE subscription:', error);
}
});
}
|
||
|
||
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(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's have an else case to creditCardExportGroup.enable() it back |
||
}); | ||
} | ||
|
||
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(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's have an else case to reimbursableExportGroup.enable() it back |
||
}); | ||
} | ||
|
||
destinationOptionsWatcher(detailAccountType: string[], destinationOptions: QbdDirectDestinationAttribute[]): DestinationAttribute[] { | ||
return destinationOptions.filter((account: QbdDirectDestinationAttribute) => detailAccountType.includes(account.detail.account_type)); | ||
} | ||
|
@@ -224,6 +282,14 @@ export class QbdDirectExportSettingsComponent implements OnInit{ | |
this.reimbursableExpenseGroupWatcher(); | ||
|
||
this.cccExpenseGroupWatcher(); | ||
|
||
this.defaultAccountsPayableAccountWatcher(); | ||
|
||
this.defaultCCCAccountsPayableAccountWatcher(); | ||
Comment on lines
+289
to
+292
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Prevent memory leaks and improve watcher organization The watchers are correctly integrated, but there are two concerns:
Consider these improvements:
private subscriptions: Subscription[] = [];
private exportsettingsWatcher(): void {
// Group related watchers
// Credit card related
this.subscriptions.push(this.cccExportTypeWatcher());
this.subscriptions.push(this.cccExpenseGroupWatcher());
this.subscriptions.push(this.defaultCCCAccountsPayableAccountWatcher());
// Employee mapping related
this.subscriptions.push(this.employeeMappingWatcher());
this.subscriptions.push(this.defaultAccountsPayableAccountWatcher());
// Reimbursable related
this.subscriptions.push(this.reimbursableExpenseGroupWatcher());
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => subscription.unsubscribe());
}
defaultAccountsPayableAccountWatcher(): Subscription {
return this.exportSettingsForm.controls.employeeMapping.valueChanges.subscribe({
// ... existing implementation
});
} |
||
|
||
this.cccExportGroupingWatcher(); | ||
|
||
this.reimburesmentExpenseGroupingWatcher(); | ||
} | ||
|
||
private setupCCCExpenseGroupingDateOptions(): void { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix static method using instance reference.
The static analysis tool correctly identified use of
this
in a static context.📝 Committable suggestion
🧰 Tools
🪛 Biome (1.9.4)
[error] 55-55: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.
(lint/complexity/noThisInStatic)