Skip to content
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

5425 - Introducing support for all Composite Fields Import #5470

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

zaryanz
Copy link
Contributor

@zaryanz zaryanz commented May 20, 2024

Adding support for all Composite Fields while using the "import" functionality. This includes:

  • Currency
  • Address

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Summary

  • Introduced support for importing currency fields in the spreadsheet import functionality.
  • Added logic to handle 'Currency' field types, including template fields for 'Currency Code' and 'Amount Micros'.
  • Enhanced data import capabilities, particularly for financial data.

Notes

  • This change improves the comprehensiveness of data imports, especially for financial records.

isDefined(
record[`${amountMicros} (${field.name})`] ||
record[`${currencyCode} (${field.name})`],
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition isDefined(record[${amountMicros} (${field.name})] || record[${currencyCode} (${field.name})]) should be simplified to isDefined(record[${amountMicros} (${field.name})]) || isDefined(record[${currencyCode} (${field.name})]) for better readability and correctness.

@zaryanz zaryanz changed the title 5425 Introducing support for all Composite Fields Import 5425 WIP - Introducing support for all Composite Fields Import May 20, 2024
@zaryanz
Copy link
Contributor Author

zaryanz commented May 20, 2024

@charlesBochet Hi! An observation while importing data using a spreadsheet:
$1,000,000 is being saved as $1 after submitting and anything less than $1,000,000 is being saved as $0. Is this an existing issue that we are aware of or should we raise an issue for the same?
Screenshot 2024-05-20 at 3 43 59 PM
Screenshot 2024-05-20 at 3 43 23 PM

@FelixMalfait
Copy link
Member

Thanks @zaryanz! yes it's a best practise to store amounts in "micros" when dealing with currencies since database tend to be flaky with floats - but that's a database stuff that shouldn't be exposed to non-technical users that try to import via csv, so it would be great if you could make sure to automatically convert it by multiplying by 10^6. Thanks!

@zaryanz
Copy link
Contributor Author

zaryanz commented May 20, 2024

Thanks @FelixMalfait for pointing that out! Silly of me to overlook the "micros" part. Could you also please point me to the different Composite Fields for "Address"? As I couldn't mind any information on that in the issue.

@FelixMalfait
Copy link
Member

FelixMalfait commented May 20, 2024

Sure!

Linked issue: #5425

Address field: https://github.com/twentyhq/twenty/blob/main/packages/twenty-server/src/engine/metadata-modules/field-metadata/composite-types/address.composite-type.ts

Add it as a custom field type on an object to make sure it works :). It's not provisioned in any standard object for now

@zaryanz zaryanz changed the title 5425 WIP - Introducing support for all Composite Fields Import 5425 - Introducing support for all Composite Fields Import May 21, 2024
Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the help! I have left comments on the PR

@@ -80,6 +95,46 @@ export const useSpreadsheetRecordImport = (objectNameSingular: string) => {
field.label + ' (ID)',
),
});
} else if (field.type === FieldMetadataType.Currency) {
templateFields.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we extract the templateFields array build to an util?
I'm also not a big fan of templateFields naming. I would say availableFields

Once extracted to an util, could you also add unit tests?

@@ -108,22 +163,89 @@ export const useSpreadsheetRecordImport = (objectNameSingular: string) => {
for (const field of fields) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also extract this whole logic to an util and add unit tests?

@zaryanz
Copy link
Contributor Author

zaryanz commented May 30, 2024

Thanks for the comments! I'll have a look and make the required changes

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

  • Added support for importing all composite fields, including Currency and Address.
  • Updated ESLint rules to enforce the use of <Link> components over navigate functions.
  • Refactored Chrome extension to handle cookies, side panel behavior, and removed OAuth-related code.
  • Deleted extensive documentation files and related configurations, indicating a shift in documentation strategy.
  • Introduced new components and utilities for email templates and frontend skeleton loaders.

246 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@zaryanz
Copy link
Contributor Author

zaryanz commented Jun 27, 2024

Hey! Sorry for the delay here.. been too occupied.
Will work on the review comments this weekend. Thanks for the patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants