Skip to content

Commit

Permalink
Update create_adjustment to create with an amount of 0
Browse files Browse the repository at this point in the history
Amount calculation is handled by VoucherAdjustmentService.calculate
  • Loading branch information
rioug committed Jun 26, 2023
1 parent a211605 commit 9fccea3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions app/models/voucher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ def display_value
# but vouchers have complicated calculation so we can't easily use Spree::Calculator. We keep
# the same method to stay as consistent as possible.
#
# Creates a new voucher adjustment for the given order
# Creates a new voucher adjustment for the given order with an amount of 0
# The amount will be calculated via VoucherAdjustmentsService.calculate
def create_adjustment(label, order)
amount = compute_amount(order)

adjustment_attributes = {
amount: amount,
amount: 0,
originator: self,
order: order,
label: label,
Expand Down
4 changes: 2 additions & 2 deletions spec/models/voucher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
let(:voucher) { create(:voucher, code: 'new_code', enterprise: enterprise, amount: 25) }
let(:order) { create(:order_with_line_items, line_items_count: 3, distributor: enterprise) }

it 'includes the full voucher amount' do
expect(adjustment.amount.to_f).to eq(-25.0)
it 'includes an amount of 0' do
expect(adjustment.amount.to_f).to eq(0.0)
end

it 'has no included_tax' do
Expand Down

0 comments on commit 9fccea3

Please sign in to comment.