-
Notifications
You must be signed in to change notification settings - Fork 109
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
- Loading branch information
1 parent
9fda024
commit 06d5433
Showing
2 changed files
with
68 additions
and
11 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
61 changes: 61 additions & 0 deletions
61
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,61 @@ | ||
# 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 | ||
{ | ||
'type' => 'customerpayment', | ||
'isDynamic' => true, | ||
'columns' => { | ||
'customer' => integration_customer.external_customer_id, | ||
'payment' => payment.amount_cents / 100.0, | ||
'autoapply' => true | ||
}, | ||
'applyTransactions' => [ | ||
{ | ||
'internalId' => integration_invoice&.external_id, | ||
'apply' => true, | ||
'amount' => payment.amount_cents / 100.0 | ||
} | ||
], | ||
'options' => { | ||
'ignoreMandatoryFields' => false | ||
} | ||
} | ||
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 |