-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update calculation of item amount reported to anrok to apply coupons
- Loading branch information
1 parent
4c79f92
commit bce2887
Showing
4 changed files
with
44 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe CreditNoteItem, type: :model do | ||
subject(:credit_note_item) { create(:credit_note_item) } | ||
|
||
it { is_expected.to belong_to(:credit_note) } | ||
it { is_expected.to belong_to(:fee) } | ||
|
||
describe '#sub_total_excluding_taxes_amount_cents' do | ||
let(:credit_note_item) { build(:credit_note_item, amount_cents: 100, fee: fee) } | ||
let(:fee) { build(:fee, amount_cents: 1000, precise_amount_cents: 1000, precise_coupons_amount_cents: 0) } | ||
|
||
context 'when there are no coupons applied' do | ||
it 'returns item amount with coupons applied' do | ||
expect(credit_note_item.sub_total_excluding_taxes_amount_cents).to eq(100) | ||
end | ||
end | ||
|
||
context 'when there are coupons applied' do | ||
let(:fee) { build(:fee, amount_cents: 1000, precise_amount_cents: 1000, precise_coupons_amount_cents: 20) } | ||
|
||
it 'returns item amount with coupons applied' do | ||
expect(credit_note_item.sub_total_excluding_taxes_amount_cents).to eq(98) | ||
end | ||
end | ||
end | ||
end | ||
|
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