@zackb You kind of lost me with your logic I see few problems with that:
- Sales Order for 100 units/pieces.
- Item Fulfillment for 50 pieces.
- Shipped IF.
- Your script create invoice.
- Another IF for 50 pieces.
- Your script create another Invoice.,..
Don't understand what you mean with invoice everything not just that fulfillment?