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

Feat(invoice_custom_sections): api controllers #3007

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

Conversation

annvelents
Copy link
Contributor

Context

API controllers to support invoice_custom_sections functionality

Description

Added InvoiceCustomSectionsController and updated customers controller with two new actions

@annvelents annvelents force-pushed the feat-invoice-custom-sections-customer-update-mutation branch 3 times, most recently from 8dba59d to b99d81b Compare December 30, 2024 16:06
@annvelents annvelents force-pushed the feat-invoice-custom-sections-api-controller branch from 232645c to 8e753ee Compare December 30, 2024 16:22
@annvelents annvelents force-pushed the feat-invoice-custom-sections-customer-update-mutation branch 2 times, most recently from 7870b8d to 15a84d4 Compare January 9, 2025 13:31
Base automatically changed from feat-invoice-custom-sections-customer-update-mutation to main January 9, 2025 14:08
@annvelents annvelents force-pushed the feat-invoice-custom-sections-api-controller branch from 8d3de8e to 8927cbe Compare January 9, 2025 14:47
@annvelents annvelents marked this pull request as ready for review January 10, 2025 08:36
Comment on lines +14 to +16
organization: {
lago_id: model.organization_id
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we plan to add more organization details in this serializer? If no I would suggest to flatten it (not a blocker ;) )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, makes perfect sense, updating, thank you!

attr_reader :customer, :section_ids, :skip_invoice_custom_sections
attr_reader :customer, :section_ids, :skip_invoice_custom_sections, :section_codes

def raise_double_selection
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure of the naming here as result.validation_failure! is not raising an error but only marking the result object as failed and adding the error detail to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🙌

@skip_invoice_custom_sections = skip_invoice_custom_sections

super
end

def call
return result.not_found_failure!(resource: "customer") unless customer
raise_invalid_params if skip_invoice_custom_sections && section_ids.present?
raise_double_selection if !section_ids.nil? && !section_codes.nil?
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might need to return the result here (or am I missing something?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, yes, thanks

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.

2 participants