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

Fix(revenue-share): add self-billed field to data exports #3149

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FiltersInput < BaseInputObject
argument :reason, [Types::CreditNotes::ReasonTypeEnum], required: false
argument :refund_status, [Types::CreditNotes::RefundStatusTypeEnum], required: false
argument :search_term, String, required: false
argument :self_billed, Boolean, required: false
end
end
end
Expand Down
1 change: 1 addition & 0 deletions app/graphql/types/data_exports/invoices/filters_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class FiltersInput < BaseInputObject
argument :payment_overdue, Boolean, required: false
argument :payment_status, [Types::Invoices::PaymentStatusTypeEnum], required: false
argument :search_term, String, required: false
argument :self_billed, Boolean, required: false
argument :status, [Types::Invoices::StatusTypeEnum], required: false
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/services/data_exports/csv/credit_notes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def self.headers
%w[
lago_id
sequential_id
partner_billing
issuing_date
customer_lago_id
customer_external_id
Expand Down Expand Up @@ -52,6 +53,7 @@ def serialize_item(credit_note, csv)
csv << [
serialized_note[:lago_id],
serialized_note[:sequential_id],
serialized_note[:self_billed],
serialized_note[:issuing_date],
serialized_note.dig(:customer, :lago_id),
serialized_note.dig(:customer, :external_id),
Expand Down
2 changes: 2 additions & 0 deletions app/services/data_exports/csv/invoices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def self.headers
%w[
lago_id
sequential_id
partner_billing
issuing_date
customer_lago_id
customer_external_id
Expand Down Expand Up @@ -54,6 +55,7 @@ def serialize_item(invoice, csv)
csv << [
serialized_invoice[:lago_id],
serialized_invoice[:sequential_id],
serialized_invoice[:self_billed],
serialized_invoice[:issuing_date],
serialized_invoice.dig(:customer, :lago_id),
serialized_invoice.dig(:customer, :external_id),
Expand Down
2 changes: 2 additions & 0 deletions schema.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/services/data_exports/csv/credit_notes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
[
credit_note.id,
credit_note.sequential_id,
credit_note.invoice.self_billed,
credit_note.issuing_date.iso8601,
credit_note.customer.id,
credit_note.customer.external_id,
Expand Down
5 changes: 4 additions & 1 deletion spec/services/data_exports/csv/invoices_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
payment_overdue:,
payment_status:,
search_term:,
self_billed:,
status:
}
end
Expand All @@ -33,6 +34,7 @@
let(:payment_overdue) { true }
let(:payment_status) { 'pending' }
let(:search_term) { 'service ABC' }
let(:self_billed) { false }
let(:status) { 'finalized' }

let(:serializer_klass) { class_double('V1::InvoiceSerializer') }
Expand All @@ -46,6 +48,7 @@
lago_id: 'invoice-lago-id-123',
sequential_id: 'SEQ123',
issuing_date: '2023-01-01',
self_billed: false,
customer: {
name: 'customer name',
lago_id: 'customer-lago-id-456',
Expand Down Expand Up @@ -86,7 +89,7 @@

it 'generates the correct CSV output' do
expected_csv = <<~CSV
invoice-lago-id-123,SEQ123,2023-01-01,customer-lago-id-456,CUST123,customer name,US,123456789,INV123,credit,pending,finalized,http://api.lago.com/invoice.pdf,USD,70000,1655,10500,334,1000,77511,2023-02-01,2023-12-22,false
invoice-lago-id-123,SEQ123,false,2023-01-01,customer-lago-id-456,CUST123,customer name,US,123456789,INV123,credit,pending,finalized,http://api.lago.com/invoice.pdf,USD,70000,1655,10500,334,1000,77511,2023-02-01,2023-12-22,false
CSV

expect(result).to be_success
Expand Down
3 changes: 2 additions & 1 deletion spec/services/data_exports/process_part_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
lago_id: 'invoice-lago-id-123',
sequential_id: 'SEQ123',
issuing_date: '2023-01-01',
self_billed: false,
customer: {
name: 'customer name',
lago_id: 'customer-lago-id-456',
Expand Down Expand Up @@ -50,7 +51,7 @@
describe "#call" do
it "processes the part" do
expected_csv = <<~CSV
invoice-lago-id-123,SEQ123,2023-01-01,customer-lago-id-456,CUST123,customer name,US,123456789,INV123,credit,pending,finalized,http://api.lago.com/invoice.pdf,USD,70000,1655,10500,334,1000,77511,2023-02-01,2023-12-22,false
invoice-lago-id-123,SEQ123,false,2023-01-01,customer-lago-id-456,CUST123,customer name,US,123456789,INV123,credit,pending,finalized,http://api.lago.com/invoice.pdf,USD,70000,1655,10500,334,1000,77511,2023-02-01,2023-12-22,false
CSV
expect(result).to be_success
expect(result.data_export_part.csv_lines).to eq(expected_csv)
Expand Down