implement Spree::Order#invoiceable?

This will be used to filter the orders when running bulk print
This commit is contained in:
Mohamed ABDELLANI
2023-07-12 08:58:35 +01:00
parent 4f6ab69add
commit c921250d68
2 changed files with 21 additions and 0 deletions

View File

@@ -208,6 +208,10 @@ module Spree
completed_at.present?
end
def invoiceable?
complete? || resumed?
end
# Indicates whether or not the user is allowed to proceed to checkout.
# Currently this is implemented as a check for whether or not there is at
# least one LineItem in the Order. Feel free to override this logic in your

View File

@@ -140,6 +140,23 @@ describe Spree::Order do
end
end
context "#invoiceable?" do
it "should return true if the order is completed" do
allow(order).to receive_messages(complete?: true)
expect(order.invoiceable?).to be_truthy
end
it "should return true if the order is resumed" do
allow(order).to receive_messages(resumed?: true)
expect(order.invoiceable?).to be_truthy
end
it "should return false if the order is neither completed nor resumed" do
allow(order).to receive_messages(complete?: false, resumed?: false)
expect(order.invoiceable?).to be_falsy
end
end
context "checking if order is paid" do
context "payment_state is paid" do
before { allow(order).to receive_messages payment_state: 'paid' }