Skip to content

Commit

Permalink
fix(integrations): Fix payments sync when the invoice is not synced y…
Browse files Browse the repository at this point in the history
…et (#2125)

## Roadmap Task

👉  https://getlago.canny.io/feature-requests/p/integration-with-netsuite

## Context

Currently Lago does not support accounting integrations

## Description

This PR fixes the problem when the invoice for a payment is not synced
yet. In that case we let the payment sync job fail so that when it
retries the invoice is already synced.
  • Loading branch information
ivannovosad authored Jun 4, 2024
1 parent 7137bc7 commit 8895740
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/jobs/integrations/aggregator/payments/create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Payments
class CreateJob < ApplicationJob
queue_as 'integrations'

retry_on LagoHttpClient::HttpError, wait: :exponentially_longer, attempts: 3
retry_on LagoHttpClient::HttpError, wait: :exponentially_longer, attempts: 5

def perform(payment:)
result = Integrations::Aggregator::Payments::CreateService.call(payment:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def payload
'sublistId' => 'apply',
'lineItems' => [
{
'doc' => integration_invoice.external_id,
# If the invoice is not synced yet, lets raise an error and retry. (doc: nil is an invalid request)
'doc' => integration_invoice&.external_id,
'apply' => true,
'amount' => amount(payment.amount_cents, resource: invoice)
}
Expand Down

0 comments on commit 8895740

Please sign in to comment.