Update create_adjustment to create with an amount of 0

Amount calculation is handled by VoucherAdjustmentService.calculate
This commit is contained in:
Gaetan Craig-Riou
2023-06-26 14:26:23 +10:00
parent 04bbea53e1
commit 60c0c54eb2
2 changed files with 5 additions and 6 deletions

View File

@@ -21,12 +21,11 @@ class Voucher < ApplicationRecord
# 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,

View File

@@ -45,8 +45,8 @@ describe Voucher do
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