-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4119b03
commit 9ea2e42
Showing
2 changed files
with
20 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 18 additions & 19 deletions
37
app/services/organizations/deselect_invoice_custom_section_service.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Organizations | ||
class DeselectInvoiceCustomSectionService < BaseService | ||
def initialize(section:) | ||
@section = section | ||
@organization = section.organization | ||
super | ||
end | ||
class DeselectInvoiceCustomSectionService < BaseService | ||
def initialize(section:) | ||
@section = section | ||
@organization = section.organization | ||
super | ||
end | ||
|
||
def call | ||
deselect_for_organization | ||
result | ||
end | ||
def call | ||
deselect_for_organization | ||
result | ||
end | ||
|
||
private | ||
private | ||
|
||
attr_reader :section, :organization | ||
attr_reader :section, :organization | ||
|
||
def deselect_for_organization | ||
return unless organization.selected_invoice_custom_sections.include?(section) | ||
def deselect_for_organization | ||
return unless organization.selected_invoice_custom_sections.include?(section) | ||
|
||
InvoiceCustomSectionSelection.where( | ||
organization_id: organization.id, invoice_custom_section_id: section.id | ||
).destroy_all | ||
result.section = section | ||
end | ||
InvoiceCustomSectionSelection.where( | ||
organization_id: organization.id, invoice_custom_section_id: section.id | ||
).destroy_all | ||
result.section = section | ||
end | ||
end | ||
end |