Skip to content

feat: resolve taxes for product fees - #6256

Open
endenis wants to merge 1 commit into
feat/BIL-584/product-integrations-mappingfrom
feat/BIL-586/resolve-taxes-on-fees
Open

feat: resolve taxes for product fees#6256
endenis wants to merge 1 commit into
feat/BIL-584/product-integrations-mappingfrom
feat/BIL-586/resolve-taxes-on-fees

Conversation

@endenis

@endenis endenis commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Context

Part of the "products and plans" project.

Product fees did not resolve taxes from rate cards.

Description

  • Resolve taxes using Rate Card -> Plan -> Customer -> Billing Entity.
  • Use the fee's billing entity for Product fees.
  • Mark affected draft invoices for refresh when rate rard taxes change.
  • Keep taxes on finalized invoice unchanged.

@endenis endenis self-assigned this Aug 31, 2026
@endenis
endenis marked this pull request as ready for review August 31, 2026 10:44
@lago-claude-ai-agent

Copy link
Copy Markdown
Contributor

Automated pre-review (advisory, not a required check) — verdict: HOLD · CI green

HOLD — Draft product invoices are not invalidated when an assigned rate-card tax itself is updated or deleted.

  • Extend tax update/delete invalidation to draft invoices whose product fees reference rate cards using that tax; Tax#applicable_customers does not include rate-card assignments, so these invoices retain stale tax amounts or snapshots.
  • Add focused regression coverage for updating and deleting a rate-card tax used by a draft product invoice.

billing_entity_taxes(customer.billing_entity_id)
end

def product_taxes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not the scope of this PR but the previous applicable_taxes is a bit problematic already. We perform the ApplyTaxesService and accidentally does a N+1 https://github.com/getlago/lago-api/blob/main/app/services/invoices/compute_amounts_from_fees.rb#L20. I'd add a task in Linear to tackle this and avoid continue with the same issue for product_taxes.

@taxes_by_code ||= rate_card.organization.taxes.where(code: tax_codes).index_by(&:code)
end

def refresh_draft_invoices

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question also for @rsempe @brunomiguelpinto do we need to apply the refresh for the rate_override as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants