Skip to content

Commit

Permalink
version 2 of dateGrouping function
Browse files Browse the repository at this point in the history
  • Loading branch information
DhaaraniCIT committed Feb 12, 2025
1 parent 0642d91 commit 69cd298
Showing 1 changed file with 27 additions and 32 deletions.
59 changes: 27 additions & 32 deletions src/app/core/models/common/export-settings.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ export class ExportSettingModel {
static getCreditCardExpenseGroupingDateOptions(): SelectFormOption[] {
return [
{
label: 'Card Transaction Post Date',
label: 'Card transaction post date',
value: ExportDateType.POSTED_AT
},
{
label: 'Spend date',
value: ExportDateType.SPENT_AT
},
{
label: 'Last Spend date',
label: 'Last dpend date',
value: ExportDateType.LAST_SPENT_AT
},
{
label: brandingContent.common.currentDate,
label: 'Export date',
value: ExportDateType.CURRENT_DATE
}
];
Expand All @@ -112,7 +112,7 @@ export class ExportSettingModel {
static getReimbursableExpenseGroupingDateOption(): SelectFormOption[] {
return [
{
label: brandingContent.common.currentDate,
label: 'Export date',
value: ExportDateType.CURRENT_DATE
},
{
Expand All @@ -128,42 +128,37 @@ export class ExportSettingModel {
value: ExportDateType.APPROVED_AT
},
{
label: 'Last Spend date',
label: 'Last spend date',
value: ExportDateType.LAST_SPENT_AT
}
];
}

static dateGrouping(exportType:string, expenseGrouping: string, showApprovedDate: boolean, showVerificationDate: boolean): SelectFormOption[] {

const excludedDate = expenseGrouping === ExpenseGroupingFieldOption.EXPENSE_ID
? ExportDateType.LAST_SPENT_AT
: ExportDateType.SPENT_AT;

static dateGrouping(exportType: string, expenseGrouping: string, showApprovedDate: boolean, showVerificationDate: boolean): SelectFormOption[] {
// Determine the excluded date based on expenseGrouping
const excludedDate = expenseGrouping === ExpenseGroupingFieldOption.EXPENSE_ID

Check failure on line 139 in src/app/core/models/common/export-settings.model.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
? ExportDateType.LAST_SPENT_AT

Check failure on line 140 in src/app/core/models/common/export-settings.model.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
: ExportDateType.SPENT_AT;

Check failure on line 142 in src/app/core/models/common/export-settings.model.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
// Handle CCC export type
if (exportType === 'CCC') {
return this.getCreditCardExpenseGroupingDateOptions().filter(option => option.value !== excludedDate);
}

let dateOptions = this.getReimbursableExpenseGroupingDateOption();
let filterOptions: ExportDateType[] = [];

if (showApprovedDate) {
filterOptions.push(ExportDateType.VERIFIED_AT);
} else if (showVerificationDate) {
filterOptions.push(ExportDateType.APPROVED_AT);
}

filterOptions.push(excludedDate);

console.log(filterOptions, excludedDate)

const d = dateOptions.filter((item): item is { label: string; value: ExportDateType } =>
item.value !== null && !filterOptions.includes(item.value as ExportDateType))

console.log(d)

return d;


Check failure on line 147 in src/app/core/models/common/export-settings.model.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
// Get base date options
const dateOptions = this.getReimbursableExpenseGroupingDateOption();

Check failure on line 150 in src/app/core/models/common/export-settings.model.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
// Determine filter options based on showApprovedDate and showVerificationDate
const filterOptions = [
...(showApprovedDate ? [ExportDateType.VERIFIED_AT] : []),
...(showVerificationDate ? [ExportDateType.APPROVED_AT] : []),
excludedDate
];

Check failure on line 157 in src/app/core/models/common/export-settings.model.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
// Filter out excluded and unwanted dates
return dateOptions.filter(option =>

Check failure on line 159 in src/app/core/models/common/export-settings.model.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
option.value !== null && !filterOptions.includes(option.value as ExportDateType)
);
}

static filterDateOptions(exportDateType: ExportDateType, dateOptions: SelectFormOption[]){
Expand Down

0 comments on commit 69cd298

Please sign in to comment.