# Subtracting cart quantity from Product quantity

Please, in my domain model I have two persistent entities "Cart" and "Product", I want to subtract the number of quantity( "Cart") from quantity ("Product") so that when I sell a product it will automatically subtract and update the product table.

I tried the math unit and also read the tutorials on https://my.webratio.com/learn/learningobject/how-to-use-math-unit, but it's not working.

I really need help with this.

Thank you.

### 1 Answers

Hi Tanko,

if you want to change the quantity in stock you can use the Math component. To understand your problem with this component you should better explain us the obtained behavior and errors.

First of all I suggest you to check your model in order to find problems. In this case you can run the Find Model Problems operation and solve any available error.

Moreover you could analyze the runtime application’s log files. For more details https://my.webratio.com/learn/learningobject/analyze-error-logs-v-72.