Purchase Receipt customization

We are running into an ERPNext logic dealing with the purchase receipt that we need to break to meet our needs. Currently the purchase receipt when saving or data importing dictates that received qty = accepted + rejected quantities. We can get that to work with no issue.

The problem is that we also accept blemished items that we pay the vendor less for and need to go into a warehouse we created called blemish. Using a client script I can get ERPNext to calculate the child table correctly, received qty = accepted + blemish + rejected. But as soon as we click save or attempt to do a data import we get the error “Received Qty must be equal to Accepted + Rejected Qty”.

We have tried custom apps and server scripts with no luck. Does anyone know how to past this? We need received qty = accepted + blemish + rejected when we save a purchase receipt so that each goes into its perspective warehouse and we can pay the vendor based on this.

Thanks

If accepting blemished items into a different warehouse is your only requirement (That too at a lower cost), then just create a new line in the receipt for the same item code. Just have a different accepted warehouse in that line item and different rate to accept the blemished items.