-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(invoice_custom_sections): use custom sections in pdf (#3013)
Use applied invoice custom sections in PDFs and include them in invoice payload Also includes fixes found after QA
- Loading branch information
1 parent
901fa19
commit 2c5755f
Showing
26 changed files
with
144 additions
and
31 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
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