-
Notifications
You must be signed in to change notification settings - Fork 103
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): use custom sections in pdf #3013
Merged
annvelents
merged 22 commits into
feat-invoice-custom-sections-create-applied-service
from
feat-invoice-custom-sections-pdf
Jan 14, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
cf55e77
WIP update customer with invoice_custom sections service
annvelents fb058d4
refactoring of the select and deselect services
annvelents f01229b
fix and add tests
annvelents fea9e5f
fix linter
annvelents 80fa2d5
refactor managing invoice_custom_sections
annvelents b419dc0
fix index on code uniqueness to apply only on not deleted ics
annvelents 7ba9e48
split index removing and addition
annvelents e910cd0
add usage of applied invoice custom sections in the invoices
annvelents e6d69b9
fix invocie custom sections code validation
annvelents a80db56
fix style for custom sections
annvelents ebd6bbf
add applied invoice custom sections to invoice payload
annvelents 0ad9617
use inline html for invoice custom sections instead of a helper
annvelents a0ada42
return previous usage of the partioal for invoice custom sections
annvelents 18aa7dd
fix linter
annvelents f2df069
fix ordering
annvelents f4ec5cb
qa fixes
annvelents 30f6cd1
pretty print
annvelents 93310f4
fix rebase
annvelents ee35162
tests fixes
annvelents 451fb10
fix array matchers
annvelents 9d421dc
changes in organization ics serializer
annvelents 44674be
add applied_invoice_custom_sections into invoice webhook payload
annvelents File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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
18 changes: 18 additions & 0 deletions
18
app/serializers/v1/invoices/applied_invoice_custom_section_serializer.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
module Invoices | ||
class AppliedInvoiceCustomSectionSerializer < ModelSerializer | ||
def serialize | ||
{ | ||
lago_id: model.id, | ||
lago_invoice_id: model.invoice_id, | ||
code: model.code, | ||
details: model.details, | ||
display_name: model.display_name, | ||
created_at: model.created_at.iso8601 | ||
} | ||
end | ||
end | ||
end | ||
end |
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
css: | ||
.invoice-custom-section { | ||
margin-top: 24px; | ||
border-bottom: 1px solid #D9DEE7; | ||
} | ||
|
||
.invoice-custom-section p.section-name { | ||
margin-bottom: 8px; | ||
} | ||
|
||
.invoice-custom-sections.body-3.mb-24 | ||
- applied_invoice_custom_sections.each do |section| | ||
.invoice-custom-section | ||
p.body-1.section-name = section.display_name | ||
p.body-3.mb-24 = LineBreakHelper.break_lines(section.details) |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
css: | ||
.invoice-custom-section { | ||
margin-top: 24px; | ||
border-bottom: 1px solid #D9DEE7; | ||
} | ||
|
||
.invoice-custom-section p.section-name { | ||
margin-bottom: 8px; | ||
} | ||
|
||
.invoice-custom-sections.body-3.mb-24 | ||
- applied_invoice_custom_sections.each do |section| | ||
.invoice-custom-section | ||
p.body-1.section-name = section.display_name | ||
p.body-3.mb-24 = LineBreakHelper.break_lines(section.details) |
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
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
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
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
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
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
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
32 changes: 32 additions & 0 deletions
32
spec/serializers/v1/invoices/applied_invoice_custom_section_serializer_spec.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe V1::Invoices::AppliedInvoiceCustomSectionSerializer, type: :serializer do | ||
subject(:serializer) { described_class.new(applied_invoice_custom_section) } | ||
|
||
let(:invoice) { create(:invoice) } | ||
let(:applied_invoice_custom_section) do | ||
create(:applied_invoice_custom_section, | ||
invoice:, | ||
code: 'custom_code', | ||
details: 'custom_details', | ||
display_name: 'Custom Display Name', | ||
created_at: Time.current) | ||
end | ||
|
||
describe '#serialize' do | ||
it 'serializes the applied invoice custom section correctly' do | ||
serialized_data = serializer.serialize | ||
|
||
expect(serialized_data).to include( | ||
lago_id: applied_invoice_custom_section.id, | ||
lago_invoice_id: applied_invoice_custom_section.invoice_id, | ||
code: 'custom_code', | ||
details: 'custom_details', | ||
display_name: 'Custom Display Name', | ||
created_at: applied_invoice_custom_section.created_at.iso8601 | ||
) | ||
end | ||
end | ||
end |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blocker here but maybe this should be turned into a scope. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not needed, because this sorting - by selected for organization, and then alphabetically - only needed in the graphql response... I can't see where else it will be useful... or do you mean it will be better for readability?
(in all other places we're usually using the selected sections and only sort them alphabetically)