POS discount by weight?

I am looking for a way to integrate a digital scale with the ERPNext POS.
Is it possible to have a script that can allow for discounting by weight via a barcode scan?

Here is my scenario:
I have customers that bring their own jars into the store to buy bulk food items. They weigh the jars and write down how heavy it is. When they get to checkout, I need a way to subtract the jar weight from the food weight.