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

misc: add category to integration #2332

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

Conversation

annvelents
Copy link
Contributor

Context

We have integrations of different categories, but now define type of an integration is possible only by the name of integrations, so if we know that integration type is NetsuiteIntegration or XeroIntegration, then we can define that this is an accounting integration. Instead we can store category on the integration itself, which will allow us to have more generic components on the FE, find corresponding integration for an error (when error type is "accounting" we will know which integrations we need to look to be set up on a client)

Description

Added string :category to integrations table and serialized it to FE

@annvelents annvelents self-assigned this Jul 25, 2024
@annvelents annvelents marked this pull request as ready for review July 25, 2024 10:07
Integrations::AnrokIntegration.update_all(category: 'tax_provider') # rubocop:disable Rails/SkipsModelValidations
Integrations::NetsuiteIntegration.update_all(category: 'accounting') # rubocop:disable Rails/SkipsModelValidations
Integrations::XeroIntegration.update_all(category: 'accounting') # rubocop:disable Rails/SkipsModelValidations
Integrations::OktaIntegration.update_all(category: 'system') # rubocop:disable Rails/SkipsModelValidations
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Run it locally on 4000 integrations - took 0.04s

Copy link
Contributor

@ivannovosad ivannovosad left a comment

Choose a reason for hiding this comment

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

I'm thinking that if we don't necessarily need the category for BE feature/code at the moment to leave this PR open and lets get back to it later.

Or is it handy to have for some FE stuff? @ansmonjol @keellyp

@annvelents
Copy link
Contributor Author

actually I accidentally found more places that can be refactored using the concept of categories, moving this PR to draft and will update

@annvelents annvelents marked this pull request as draft July 25, 2024 15:26
@@ -106,7 +106,7 @@ def add_on_items
end

def should_sync_credit_note?
finalized? && customer.integration_customers.accounting_kind.any? { |c| c.integration.sync_credit_notes }
finalized? & customer.accounting_customer&.integration&.sync_credit_notes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to bitwise and because logical and returns value if it exist instead of true/false
So in our case if second half returns nil,
&& - returns nil for the whole operation
& - returns false for the whole operation,
no matter what first argument was

@annvelents annvelents changed the title add category to integration misc: add category to integration Jul 26, 2024
@annvelents annvelents marked this pull request as ready for review July 26, 2024 11:39
@@ -105,14 +116,7 @@ def preferred_document_locale
end

def provider_customer
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume you're keeping this method because it's used all over the place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, becasue there are quite a lot of places we're using it 🙈
but actually i think declaring this method as alias will be better 😅
thank you for putting my attention here

@annvelents annvelents force-pushed the misc-add-category-to-integrations branch from 99ceba1 to a610720 Compare July 26, 2024 16:13
@annvelents annvelents force-pushed the misc-add-category-to-integrations branch from 77ef290 to 3327258 Compare July 29, 2024 07:58
@lovrocolic
Copy link
Collaborator

I'm thinking that if we don't necessarily need the category for BE feature/code at the moment to leave this PR open and lets get back to it later.

Or is it handy to have for some FE stuff? @ansmonjol @keellyp

@ansmonjol @keellyp Do you think that having category would be handy on the FE side?

My feeling regarding this refactoring is that too many things got changed at once and it would require proper QA before getting merged.
However, it would be pretty complex to test everything at once (payment providers flow, accounting integration flow...), so I would prefer splitting this PR in few parts:

  • Adding category field if that makes sense for the FE team
  • Refactor payment providers
  • Refactor accounting/tax integrations
    @annvelents What do you think? Does it make sense to you?

@ansmonjol
Copy link
Collaborator

Switching to category may require a refactor on the FE side
What's the purpose behind that change?
It would be better tho cause today we check the typename so kinda appreciated

@annvelents
Copy link
Contributor Author

annvelents commented Jul 30, 2024

@ansmonjol the original reason was to make it easier to show error for integration, because we were going to associate errors with integrations, and when displaying errors having this doesn't seem right 🙈 :
"if (integration.type == 'AnrokIntegration' || integration.type == 'FutureTaxProvider') { puts 'tax error' }" (but this association was changed on the BE side, so it doesnt solve this problem anymore )
then I also looked at how currently integrations are displayed at the FE and realised it will be helpful for you to have categories - to display integrations page, because you have categories technically, but they are just static fields
also because then for example, while connecting customers with integrations, you'll be able to pull integrations with type "accounting" and iterate through them. As well as for validations: we will need only check that customer should have one integration with a specific category

@annvelents
Copy link
Contributor Author

@lovrocolic yes, I see why, will split it 😁

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

Successfully merging this pull request may close these issues.

5 participants