A sales document used to bill a customer for a goods delivery or a service.
Deliveries and services which are carried out on the basis of sales orders are invoiced to the customer. If no complaints are made about the delivery, the business transaction is considered complete from the sales point of view.
When you create an invoice, you can refer to an order, a delivery, individual order or delivery items, or even partial quantities within an order item or a delivery item.
If you want to make sure that the goods are sent out before the invoice is created, you would create an invoice on the basis of the delivery.
If you want to receive money before you send the goods to the customer, you would create an invoice with reference to a sales order.
When you bill a customer for a service, you would probably refer to the sales order, since a service is usually based on an order, not a delivery.