title: Orders & Inventory DDD - Where should allocation/reservation be handled?
body: <p>I am trying to refactor a legacy order handling and stock system with into a cleaner service oriented event-driven architecture. However, I am having some difficulty deciding what service should be responsible for the reservation/allocation of stock.</p>
  
  <p>A brief overview of the current system</p>
  
  <ol>
  <li><p>Sales orders are placed with us via third party system but we do not necessarily have all order lines in stock.</p>
  
  <ul>
  <li>If an order item is in stock then we allocate/reserve the stock for that order straight away.</li>
  <li>However, if we do not have enough stock then we procure the stock from our suppliers via a purchasing system.</li>
  </ul></li>
  <li><p>When the item arrives from the supplier, the system will search through all open sales orders for the item and reserve/allocate the available stock to them, prioritising by sales order date. ***</p></li>
  </ol>
  
  <p>I have already identified two services that I think need to be developed</p>
  
  <ul>
  <li><p>Sales - Responsible for receiving the sales order and inserting into the database. Has domain entities such as Order, OrderLine etc.</p></li>
  <li><p>Inventory - Responsible for keeping track of how much stock is available in our warehouse. Has domain entities such as StockItem.</p></li>
  </ul>
  
  <p>However, as the allocation/reservation of stock concerns both inventory and sales I am not sure where the behaviour in point 2 above should be put.</p>
  
  <p>I welcome any help or thoughts on this.</p>