The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(shared): check currencyCode for currency code emptiness filters (#26691)
breken568a1fa6465a
diff --git a/packages/twenty-shared/src/utils/filter/utils/__tests__/getEmptyRecordGqlOperationFilter.test.ts b/packages/twenty-shared/src/utils/filter/utils/__tests__/getEmptyRecordGqlOperationFilter.test.tsindex a4936bedea8..4fe8f97084d 100644--- a/packages/twenty-shared/src/utils/filter/utils/__tests__/getEmptyRecordGqlOperationFilter.test.ts+++ b/packages/twenty-shared/src/utils/filter/utils/__tests__/getEmptyRecordGqlOperationFilter.test.ts@@ -115,6 +115,34 @@ describe('getEmptyRecordGqlOperationFilter', () => {expect(result).toHaveProperty('or');});+ it('should check amountMicros for the CURRENCY amountMicros sub-field', () => {+ const result = getEmptyRecordGqlOperationFilter(+ makeParams(+ FieldMetadataType.CURRENCY,+ ViewFilterOperand.IS_EMPTY,+ 'amountMicros',+ ),+ );++ expect(result).toEqual({+ or: [{ testField: { amountMicros: { is: 'NULL' } } }],+ });+ });++ it('should check currencyCode for the CURRENCY currencyCode sub-field', () => {+ const result = getEmptyRecordGqlOperationFilter(+ makeParams(+ FieldMetadataType.CURRENCY,+ ViewFilterOperand.IS_EMPTY,+ 'currencyCode',+ ),+ );++ expect(result).toEqual({+ or: [{ testField: { currencyCode: { is: 'NULL' } } }],+ });+ });+it('should handle ACTOR type', () => {const result = getEmptyRecordGqlOperationFilter(makeParams(FieldMetadataType.ACTOR),@@ -245,5 +273,19 @@ describe('getEmptyRecordGqlOperationFilter', () => {expect(result).toHaveProperty('not');});++ it('should negate the currencyCode check for the CURRENCY currencyCode sub-field', () => {+ const result = getEmptyRecordGqlOperationFilter(+ makeParams(+ FieldMetadataType.CURRENCY,+ ViewFilterOperand.IS_NOT_EMPTY,+ 'currencyCode',+ ),+ );++ expect(result).toEqual({+ not: { or: [{ testField: { currencyCode: { is: 'NULL' } } }] },+ });+ });});});diff --git a/packages/twenty-shared/src/utils/filter/utils/getEmptyRecordGqlOperationFilter.ts b/packages/twenty-shared/src/utils/filter/utils/getEmptyRecordGqlOperationFilter.tsindex aabf5639fe5..d8c78821253 100644--- a/packages/twenty-shared/src/utils/filter/utils/getEmptyRecordGqlOperationFilter.ts+++ b/packages/twenty-shared/src/utils/filter/utils/getEmptyRecordGqlOperationFilter.ts@@ -137,9 +137,10 @@ export const getEmptyRecordGqlOperationFilter = ({emptyRecordFilter = {or: [{- [correspondingField.name]: {- amountMicros: { is: 'NULL' },- } as CurrencyFilter,+ [correspondingField.name]:+ compositeFieldName === 'currencyCode'+ ? ({ currencyCode: { is: 'NULL' } } as CurrencyFilter)+ : ({ amountMicros: { is: 'NULL' } } as CurrencyFilter),},],};