Skip to content

Commit 20ceda9

Browse files
committed
use only Pricing commands when managing offer
1 parent c16b991 commit 20ceda9

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

rails_application/app/controllers/client/orders_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def add_item
3838
end
3939
ActiveRecord::Base.transaction do
4040
command_bus.(
41-
Ordering::AddItemToBasket.new(
41+
Pricing::AddPriceItem.new(
4242
order_id: params[:id],
4343
product_id: params[:product_id]
4444
)

rails_application/app/controllers/orders_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ def add_item
6363
alert: "Product not available in requested quantity!" and return
6464
end
6565
ActiveRecord::Base.transaction do
66-
command_bus.(Ordering::AddItemToBasket.new(order_id: params[:id], product_id: params[:product_id]))
66+
command_bus.(Pricing::AddPriceItem.new(order_id: params[:id], product_id: params[:product_id]))
6767
end
6868
head :ok
6969
end
7070

7171
def remove_item
7272
item = Orders::OrderLine.where(order_uid: params[:id], product_id: params[:product_id]).first
7373
command_bus.(Pricing::RemovePriceItem.new(
74-
order_id: params[:id], product_id: params[:product_id], price: item.price, catalog_price: item.catalog_price)
74+
order_id: params[:id], product_id: params[:product_id], catalog_price: item.catalog_price)
7575
)
7676
head :ok
7777
end

rails_application/app/read_models/client_orders/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Configuration
4343
def call(event_store)
4444
event_store.subscribe(OrderHandlers::ExpireOrder, to: [Ordering::OrderExpired])
4545
event_store.subscribe(OrderHandlers::CancelOrder, to: [Fulfillment::OrderCancelled])
46-
event_store.subscribe(OrderHandlers::SubmitOrder, to: [Ordering::OrderPlaced])
46+
event_store.subscribe(OrderHandlers::SubmitOrder, to: [Fulfillment::OrderRegistered])
4747
event_store.subscribe(OrderHandlers::ConfirmOrder, to: [Fulfillment::OrderConfirmed])
4848
event_store.subscribe(AddItemToOrder, to: [Pricing::PriceItemAdded])
4949
event_store.subscribe(RemoveItemFromOrder, to: [Pricing::PriceItemRemoved])

rails_application/app/read_models/orders/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def call(event_store)
6767
event_store.subscribe(ChangeProductPrice.new, to: [Pricing::PriceSet])
6868
event_store.subscribe(CreateCustomer.new, to: [Crm::CustomerRegistered])
6969
event_store.subscribe(AssignCustomerToOrder.new, to: [Crm::CustomerAssignedToOrder])
70-
event_store.subscribe(SubmitOrder.new, to: [Ordering::OrderPlaced])
70+
event_store.subscribe(SubmitOrder.new, to: [Fulfillment::OrderRegistered])
7171
event_store.subscribe(ExpireOrder.new, to: [Ordering::OrderExpired])
7272
event_store.subscribe(ConfirmOrder.new, to: [Fulfillment::OrderConfirmed])
7373
event_store.subscribe(CancelOrder.new, to: [Fulfillment::OrderCancelled])

rails_application/app/services/client/orders/submit_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def call
3838

3939
def submit_order
4040
ActiveRecord::Base.transaction do
41-
command_bus.(Ordering::SubmitOrder.new(order_id: order_id))
41+
command_bus.(Pricing::AcceptOffer.new(order_id: order_id))
4242
command_bus.(Crm::AssignCustomerToOrder.new(order_id: order_id, customer_id: customer_id))
4343
end
4444
end

rails_application/app/services/orders/submit_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def call
3737

3838
def submit_order
3939
ActiveRecord::Base.transaction do
40-
command_bus.(Ordering::SubmitOrder.new(order_id: order_id))
40+
command_bus.(Pricing::AcceptOffer.new(order_id: order_id))
4141
command_bus.(Crm::AssignCustomerToOrder.new(order_id: order_id, customer_id: customer_id))
4242
end
4343
end

rails_application/test/services/client/orders/submit_service_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_successful_order_submission
1212

1313
run_command(Crm::RegisterCustomer.new(customer_id: customer_id, name: "John Doe"))
1414
prepare_product(product_id, "Async Remote", 49)
15-
run_command(Ordering::AddItemToBasket.new(order_id: order_id, product_id: product_id))
15+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id))
1616

1717
Client::Orders::SubmitService.call(order_id: order_id, customer_id: customer_id)
1818

@@ -32,9 +32,9 @@ def test_order_submission_with_unavailable_products
3232
prepare_product(product_id, "Async Remote", 49)
3333
run_command(Inventory::Supply.new(product_id: product_id, quantity: 1))
3434
run_command(Inventory::Reserve.new(product_id: product_id, quantity: 1))
35-
run_command(Ordering::AddItemToBasket.new(order_id: order_id, product_id: product_id))
35+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id))
3636
prepare_product(another_product_id, "Fearless Refactoring", 49)
37-
run_command(Ordering::AddItemToBasket.new(order_id: order_id, product_id: another_product_id))
37+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: another_product_id))
3838

3939
error = assert_raises(OrderHasUnavailableProducts) do
4040
SubmitService.new(order_id: order_id, customer_id: customer_id).call

rails_application/test/services/orders/submit_service_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_successful_order_submission
1111

1212
run_command(Crm::RegisterCustomer.new(customer_id: customer_id, name: "John Doe"))
1313
prepare_product(product_id, "Async Remote", 49)
14-
run_command(Ordering::AddItemToBasket.new(order_id: order_id, product_id: product_id))
14+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id))
1515

1616
Orders::SubmitService.call(order_id: order_id, customer_id: customer_id)
1717

@@ -31,9 +31,9 @@ def test_order_submission_with_unavailable_products
3131
prepare_product(product_id, "Async Remote", 49)
3232
run_command(Inventory::Supply.new(product_id: product_id, quantity: 1))
3333
run_command(Inventory::Reserve.new(product_id: product_id, quantity: 1))
34-
run_command(Ordering::AddItemToBasket.new(order_id: order_id, product_id: product_id))
34+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: product_id))
3535
prepare_product(another_product_id, "Fearless Refactoring", 49)
36-
run_command(Ordering::AddItemToBasket.new(order_id: order_id, product_id: another_product_id))
36+
run_command(Pricing::AddPriceItem.new(order_id: order_id, product_id: another_product_id))
3737

3838
error = assert_raises(Orders::OrderHasUnavailableProducts) do
3939
Orders::SubmitService.new(order_id: order_id, customer_id: customer_id).call

0 commit comments

Comments
 (0)