# prefix: SOBP
Feature: Bulk print sale-order packing slips and invoices
A supplier prints many sale orders at once. The matching orders are frozen into a background job at the moment
of the request, and the finished PDF is emailed to the person who asked.

Background:
Given a supplier user

Rule: A batch holds only the supplier's own orders that the document belongs to

    Scenario: SOBP-001 a packing-slip batch holds only Confirmed orders
      Given orders that are Confirmed, Placed and Delivered
      When the supplier starts a bulk packing-slip print for all matching orders
      Then the job holds only the Confirmed orders
      And the job is recorded under the supplier and the person who asked

    Scenario: SOBP-002 an invoice batch holds only invoiced orders
      Given orders that are Confirmed, Ready for Delivery and Delivered
      When the supplier starts a bulk invoice print for all matching orders
      Then the job holds only the Ready for Delivery and Delivered orders

    Scenario: SOBP-003 another supplier's and deleted orders never join a batch
      Given a Confirmed order of another supplier and a deleted Confirmed order of this supplier
      When the supplier starts a bulk print naming both
      Then neither order is in the job

    Scenario: SOBP-004 unticked orders are left out
      Given a filter matching two orders and one of them unticked
      When the supplier starts a bulk print
      Then the job holds only the order still ticked

Rule: A print that cannot work is refused before anything is queued

    Scenario Outline: SOBP-005 an empty batch is refused
      Given no order matches the filter in the statuses the document belongs to
      When the supplier starts a bulk <document> print
      Then the supplier is told <message>
      And no job is created

      Examples:
        | document     | message                                                              |
        | packing-slip | No orders in Packing matched the given filter — nothing to print.   |
        | invoice      | No invoiced orders matched the given filter — nothing to print.     |

    Scenario: SOBP-006 a filter matching too many orders is refused
      Given a filter matching more than 5,000 orders
      When the supplier starts a bulk print
      Then the supplier is told to narrow the filter
      And no job is created

    Scenario: SOBP-007 the status filter can narrow a batch but never widen it
      Given Ready for Delivery, Delivered and Placed orders
      When the supplier starts a bulk invoice print filtered to Ready for Delivery
      Then the job holds only the Ready for Delivery order
      And a filter on Placed finds nothing to print

Rule: Invoices can also be printed straight away, a few at a time

    Scenario: SOBP-008 on-demand printing is limited to the supplier's own orders and a small count
      Given a request to print another supplier's invoice
      Then it is not found
      And a request for more than 25 invoices is refused

Rule: Only supplier staff can print

    Scenario: SOBP-009 the customer side is refused
      Given the customer of a Confirmed order
      When they start a bulk print
      Then they are not authorized
      And no job is created
