How to manage stock qty update?

I am using ERPNEXT6 and here instead of Sales Order doctype we are using a custom doctype Customer Agreement, using this doctype we are processing our sales.
We can add stock through Purchase Order (Usual flow), but we don’t understand how can we manege stock out after completing the Customer Agreement.
I found stock added both tabBin and tabStock Ledger Entry table which one should I consider and how? Any hints from code.