mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-21 05:09:15 +00:00
Deduplicate order2 setup
This commit is contained in:
@@ -151,7 +151,23 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do
|
||||
end
|
||||
order
|
||||
}
|
||||
let!(:order2) { create(:order_with_distributor, distributor:) }
|
||||
|
||||
let!(:order2) {
|
||||
order2 = create(:order_with_distributor, distributor:, order_cycle_id: order_cycle2.id,
|
||||
ship_address_id: ship_address.id)
|
||||
|
||||
order2.line_items.create({ variant: variant2, quantity: 1, price: 50 })
|
||||
|
||||
# This will load the enterprise fees from the order cycle.
|
||||
# This is needed because the order instance was created
|
||||
# independently of the order_cycle.
|
||||
order2.recreate_all_fees!
|
||||
while !order2.completed?
|
||||
break unless order2.next!
|
||||
end
|
||||
|
||||
order2
|
||||
}
|
||||
|
||||
before do
|
||||
product.update!({
|
||||
@@ -172,22 +188,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do
|
||||
# - outgoing exchange (10) 1.5% = 0.15, 2.5% = 0.25
|
||||
# - line items (50) 1.5% = 0.75, 2.5% = 1.25
|
||||
|
||||
before do
|
||||
# adds a line items to the order on oc2
|
||||
order2.line_items.create({ variant: variant2, quantity: 1, price: 50 })
|
||||
order2.update!({
|
||||
order_cycle_id: order_cycle2.id,
|
||||
ship_address_id: ship_address.id
|
||||
})
|
||||
# This will load the enterprise fees from the order cycle.
|
||||
# This is needed because the order instance was created
|
||||
# independently of the order_cycle.
|
||||
order2.recreate_all_fees!
|
||||
while !order2.completed?
|
||||
break unless order2.next!
|
||||
end
|
||||
end
|
||||
|
||||
describe "orders" do
|
||||
# for supplier 1, oc1
|
||||
|
||||
@@ -607,22 +607,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do
|
||||
|
||||
let(:included_in_price) { true }
|
||||
|
||||
before do
|
||||
# adds a line items to the order on oc2
|
||||
order2.line_items.create({ variant: variant2, quantity: 1, price: 50 })
|
||||
order2.update!({
|
||||
order_cycle_id: order_cycle2.id,
|
||||
ship_address_id: ship_address.id
|
||||
})
|
||||
# This will load the enterprise fees from the order cycle.
|
||||
# This is needed because the order instance was created
|
||||
# independently of the order_cycle.
|
||||
order2.recreate_all_fees!
|
||||
while !order2.completed?
|
||||
break unless order2.next!
|
||||
end
|
||||
end
|
||||
|
||||
let(:coordinator_state_tax1){
|
||||
["Distributor", "Supplier1", "Yes", "oc1", "Adminstration", "admin", "Distributor",
|
||||
"tax_category", "State", "0.015", "19.21", "0.3", "19.51"].join(" ")
|
||||
@@ -763,19 +747,24 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do
|
||||
name: 'Another State Tax', amount: 0.02, included_in_price:)
|
||||
}
|
||||
|
||||
context "added tax" do
|
||||
before do
|
||||
# adds a line items to the order on oc2
|
||||
order2.line_items.create({ variant:, quantity: 1, price: 50 })
|
||||
order2.update!({
|
||||
order_cycle_id: order_cycle.id,
|
||||
ship_address_id: another_address.id
|
||||
})
|
||||
order2.recreate_all_fees!
|
||||
while !order2.completed?
|
||||
break unless order2.next!
|
||||
end
|
||||
let!(:order2) {
|
||||
# Ensure tax rates set up first
|
||||
state_tax_rate2
|
||||
|
||||
order2 = create(:order_with_distributor, distributor:, order_cycle_id: order_cycle.id,
|
||||
ship_address_id: another_address.id)
|
||||
|
||||
# adds a line items to the order on oc2
|
||||
order2.line_items.create({ variant:, quantity: 1, price: 50 })
|
||||
order2.recreate_all_fees!
|
||||
while !order2.completed?
|
||||
break unless order2.next!
|
||||
end
|
||||
|
||||
order2
|
||||
}
|
||||
|
||||
context "added tax" do
|
||||
let(:admin_state_tax1){
|
||||
[
|
||||
"Distributor", "Supplier1", "Yes", "oc1", "Adminstration", "admin",
|
||||
@@ -875,20 +864,6 @@ describe "Enterprise Summary Fee with Tax Report By Producer" do
|
||||
context "included tax" do
|
||||
let(:included_in_price) { true }
|
||||
|
||||
before do
|
||||
# adds a line items to the order on oc2
|
||||
order2.line_items.create({ variant:, quantity: 1, price: 50 })
|
||||
order2.update!({
|
||||
order_cycle_id: order_cycle.id,
|
||||
ship_address_id: another_address.id
|
||||
})
|
||||
|
||||
order2.recreate_all_fees!
|
||||
while !order2.completed?
|
||||
break unless order2.next!
|
||||
end
|
||||
end
|
||||
|
||||
let(:admin_state_tax1){
|
||||
[
|
||||
"Distributor", "Supplier1", "Yes", "oc1", "Adminstration", "admin",
|
||||
|
||||
Reference in New Issue
Block a user