Skip to content

The open alternative to Salesforce, designed for AI.

Compile Is not on number and currency filters to neq (#27601)

Charles Bochetd1205ac0cb0c
diff --git a/packages/twenty-front/src/modules/object-record/record-filter/utils/__tests__/computeViewRecordGqlOperationFilter.test.ts b/packages/twenty-front/src/modules/object-record/record-filter/utils/__tests__/computeViewRecordGqlOperationFilter.test.ts
index 9a52e513824..5f3bd8d3727 100644
--- a/packages/twenty-front/src/modules/object-record/record-filter/utils/__tests__/computeViewRecordGqlOperationFilter.test.ts
+++ b/packages/twenty-front/src/modules/object-record/record-filter/utils/__tests__/computeViewRecordGqlOperationFilter.test.ts
@@ -1351,11 +1351,9 @@ describe('should work as expected for the different field types', () => {
},
},
{
- not: {
- annualRecurringRevenue: {
- amountMicros: {
- eq: 1000 * 1000000,
- },
+ annualRecurringRevenue: {
+ amountMicros: {
+ neq: 1000 * 1000000,
},
},
},
diff --git a/packages/twenty-shared/src/utils/filter/__tests__/turnRecordFilterIntoGqlOperationFilter.test.ts b/packages/twenty-shared/src/utils/filter/__tests__/turnRecordFilterIntoGqlOperationFilter.test.ts
index 3e7a28b75f9..6c78fc7e8fc 100644
--- a/packages/twenty-shared/src/utils/filter/__tests__/turnRecordFilterIntoGqlOperationFilter.test.ts
+++ b/packages/twenty-shared/src/utils/filter/__tests__/turnRecordFilterIntoGqlOperationFilter.test.ts
@@ -256,7 +256,7 @@ describe('turnRecordFilterIntoRecordGqlOperationFilter', () => {
fieldMetadataItemById,
});
- expect(result).toEqual({ not: { amount: { eq: 42 } } });
+ expect(result).toEqual({ amount: { neq: 42 } });
});
it('should handle GREATER_THAN_OR_EQUAL operand', () => {
@@ -783,6 +783,24 @@ describe('turnRecordFilterIntoRecordGqlOperationFilter', () => {
expect(result).toHaveProperty('revenue');
});
+
+ it('should handle IS_NOT on amountMicros', () => {
+ const result = turnRecordFilterIntoRecordGqlOperationFilter({
+ filterValueDependencies,
+ recordFilter: makeFilter(
+ 'f-currency',
+ RecordFilterOperand.IS_NOT,
+ '1000',
+ 'CURRENCY',
+ 'amountMicros',
+ ),
+ fieldMetadataItemById,
+ });
+
+ expect(result).toEqual({
+ revenue: { amountMicros: { neq: 1000000000 } },
+ });
+ });
});
describe('FULL_NAME filter', () => {
diff --git a/packages/twenty-shared/src/utils/filter/turnRecordFilterIntoGqlOperationFilter.ts b/packages/twenty-shared/src/utils/filter/turnRecordFilterIntoGqlOperationFilter.ts
index 487ff5a53ac..cdab80e2a91 100644
--- a/packages/twenty-shared/src/utils/filter/turnRecordFilterIntoGqlOperationFilter.ts
+++ b/packages/twenty-shared/src/utils/filter/turnRecordFilterIntoGqlOperationFilter.ts
@@ -682,11 +682,9 @@ const buildDirectFieldGqlOperationFilter = ({
};
case RecordFilterOperand.IS_NOT:
return {
- not: {
- [fieldMetadataItem.name]: {
- eq: parseNumericFilterValue(recordFilter.value),
- } as FloatFilter,
- },
+ [fieldMetadataItem.name]: {
+ neq: parseNumericFilterValue(recordFilter.value),
+ } as FloatFilter,
};
default:
throw new Error(
@@ -828,13 +826,11 @@ const buildDirectFieldGqlOperationFilter = ({
};
case RecordFilterOperand.IS_NOT:
return {
- not: {
- [fieldMetadataItem.name]: {
- amountMicros: {
- eq: parseNumericFilterValue(recordFilter.value) * 1000000,
- },
- } as CurrencyFilter,
- },
+ [fieldMetadataItem.name]: {
+ amountMicros: {
+ neq: parseNumericFilterValue(recordFilter.value) * 1000000,
+ },
+ } as CurrencyFilter,
};
default:
throw new Error(