Skip to content

Commit

Permalink
fix: adjust fee serializer for pay in advance fees (#2914)
Browse files Browse the repository at this point in the history
## Context

In some scenarios, there was no `event_transaction_id` attached in fee
serializer

## Description

This PR simplifies method in serializer and ensure presence of
`event_transaction_id` value
  • Loading branch information
lovrocolic authored Dec 5, 2024
1 parent e81a3d2 commit 1b007db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions app/serializers/v1/fee_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,7 @@ def to_date
def pay_in_advance_charge_attributes
return {} unless model.pay_in_advance?

event = Event.find_by(
organization_id: model.subscription.organization,
id: model.pay_in_advance_event_id
)

{event_transaction_id: event&.transaction_id}
{event_transaction_id: model.pay_in_advance_event_transaction_id}
end

def applied_taxes
Expand Down
2 changes: 1 addition & 1 deletion spec/serializers/v1/fee_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
'external_subscription_id' => subscription.external_id,
'lago_customer_id' => customer.id,
'external_customer_id' => customer.external_id,
'event_transaction_id' => event.transaction_id,
'event_transaction_id' => fee.pay_in_advance_event_transaction_id,
'pay_in_advance' => true,
'invoiceable' => true
)
Expand Down

0 comments on commit 1b007db

Please sign in to comment.