-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(netsuite): Fix netsuite payment payload (#2790)
## Context Syncing netsuite payment started failing, so we need to change the payload format. ## Description Change payload body in Netsuite payment
- Loading branch information
1 parent
0a477cf
commit b91be98
Showing
8 changed files
with
105 additions
and
24 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
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
65 changes: 65 additions & 0 deletions
65
spec/services/integrations/aggregator/payments/payloads/netsuite_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,65 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Integrations::Aggregator::Payments::Payloads::Netsuite do | ||
let(:payload) { described_class.new(integration:, payment:) } | ||
let(:integration_customer) { create(:netsuite_customer, integration:, customer:) } | ||
let(:integration) { create(:netsuite_integration, organization:) } | ||
let(:customer) { create(:customer, organization:) } | ||
let(:organization) { create(:organization) } | ||
let(:payment) { create(:payment, payable: invoice, amount_cents: 100) } | ||
let(:integration_invoice) { create(:integration_resource, syncable: invoice) } | ||
|
||
let(:invoice) do | ||
create( | ||
:invoice, | ||
customer:, | ||
organization:, | ||
coupons_amount_cents: 2000, | ||
prepaid_credit_amount_cents: 4000, | ||
credit_notes_amount_cents: 6000, | ||
taxes_amount_cents: 200, | ||
issuing_date: DateTime.new(2024, 7, 8) | ||
) | ||
end | ||
|
||
let(:body) do | ||
{ | ||
'isDynamic' => true, | ||
'columns' => { | ||
'customer' => integration_customer.external_customer_id, | ||
'payment' => payment.amount_cents.div(100).to_f | ||
}, | ||
'options' => { | ||
'ignoreMandatoryFields' => false | ||
}, | ||
'type' => 'customerpayment', | ||
'lines' => [ | ||
{ | ||
'lineItems' => [ | ||
{ | ||
'amount' => payment.amount_cents.div(100).to_f, | ||
'apply' => true, | ||
'doc' => integration_invoice.external_id | ||
} | ||
], | ||
'sublistId' => 'apply' | ||
} | ||
] | ||
} | ||
end | ||
|
||
before do | ||
integration_customer | ||
integration_invoice | ||
end | ||
|
||
describe '#body' do | ||
subject(:body_call) { payload.body } | ||
|
||
it 'returns payload body' do | ||
expect(subject).to eq(body) | ||
end | ||
end | ||
end |