diff --git a/app/views/split_checkout/_voucher_section.cable_ready.haml b/app/views/split_checkout/_voucher_section.cable_ready.haml index a989f14af5d0..f036c130e594 100644 --- a/app/views/split_checkout/_voucher_section.cable_ready.haml +++ b/app/views/split_checkout/_voucher_section.cable_ready.haml @@ -12,7 +12,7 @@ = t("split_checkout.step2.voucher.voucher", voucher_amount: voucher_adjustment.originator.display_value) = link_to t("split_checkout.step2.voucher.remove_code"), voucher_adjustment_path(id: voucher_adjustment.id), method: "delete", data: { confirm: t("split_checkout.step2.voucher.confirm_delete") } - # TODO: this might not be true, ie payment method include fee which wouldn't be covered by voucher, tax implication raise total to be bigger than voucher other ? - - if voucher_adjustment.originator.value > order.total + - if voucher_adjustment.originator.amount > order.total .checkout-input %span.formError.standalone = t("split_checkout.step2.voucher.warning_forfeit_remaining_amount") diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index 420389b087bf..d83fad4c13a7 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -720,7 +720,8 @@ end context "with voucher available" do - let!(:voucher) { Voucher.create(code: 'some_code', enterprise: distributor) } + let!(:voucher) { Voucher.create(code: 'some_code', enterprise: distributor, amount: amount) } + let(:amount) { 15 } before do visit checkout_step_path(:payment) @@ -738,7 +739,7 @@ end it "adds a voucher to the order" do - expect(page).to have_content("$10.00 Voucher") + expect(page).to have_content("$15.00 Voucher") expect(order.reload.voucher_adjustments.length).to eq(1) end end @@ -1024,7 +1025,6 @@ end context "when the terms have been accepted in the past" do - context "with a dedicated ToS file" do before do @@ -1113,13 +1113,15 @@ end describe "vouchers" do - let(:voucher) { Voucher.create(code: 'some_code', enterprise: distributor) } + let(:voucher) { Voucher.create(code: 'some_code', enterprise: distributor, amount: 6) } before do # Add voucher to the order voucher.create_adjustment(voucher.code, order) + # Update order so voucher adjustment is properly taken into account order.update_order! + VoucherAdjustmentsService.calculate(order) visit checkout_step_path(:summary) end @@ -1127,6 +1129,7 @@ it "shows the applied voucher" do within ".summary-right" do expect(page).to have_content "some_code" + expect(page).to have_content "-6" end end end diff --git a/spec/system/consumer/split_checkout_tax_incl_spec.rb b/spec/system/consumer/split_checkout_tax_incl_spec.rb index 5cb07f67bbd6..ea51694aae58 100644 --- a/spec/system/consumer/split_checkout_tax_incl_spec.rb +++ b/spec/system/consumer/split_checkout_tax_incl_spec.rb @@ -136,7 +136,7 @@ end context "when using a voucher" do - let!(:voucher) { Voucher.create(code: 'some_code', enterprise: distributor) } + let!(:voucher) { Voucher.create(code: 'some_code', enterprise: distributor, amount: 10) } it "will include a tax included amount on the voucher adjustment" do visit checkout_step_path(:details) @@ -149,7 +149,7 @@ fill_in "Enter voucher code", with: voucher.code click_button("Apply") - # Choose payment ?? + # Choose payment click_on "Next - Order summary" click_on "Complete order" diff --git a/spec/system/consumer/split_checkout_tax_not_incl_spec.rb b/spec/system/consumer/split_checkout_tax_not_incl_spec.rb index 4fa0f0531a85..d99dd604c734 100644 --- a/spec/system/consumer/split_checkout_tax_not_incl_spec.rb +++ b/spec/system/consumer/split_checkout_tax_not_incl_spec.rb @@ -144,7 +144,7 @@ end context "when using a voucher" do - let!(:voucher) { Voucher.create(code: 'some_code', enterprise: distributor) } + let!(:voucher) { Voucher.create(code: 'some_code', enterprise: distributor, amount: 10) } it "will include a tax included amount on the voucher adjustment" do visit checkout_step_path(:details) @@ -156,7 +156,6 @@ fill_in "Enter voucher code", with: voucher.code click_button("Apply") - # Choose payment ?? click_on "Next - Order summary" click_on "Complete order"