mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-18 04:39:14 +00:00
Update create_adjustment to create with an amount of 0
Amount calculation is handled by VoucherAdjustmentService.calculate
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user