Full tutorial posted here
You can also copy this setup and change the wastage parts to refund and use it as a refund setup too, with refund accounting etc