I have a question in my VB.NET POS Development and could't find a solution myself. I'm currently using
SalesReceipt(#Receipt_ID, Sales_Date, Receipt_Number, Customer_ID, Sales_BDiscount, Sales_ADiscount, Sales_Payment)
Customer(#Customer_ID, Customer_Name, Customer_Contact, Customer_Debt)
totalDebt = totalDebt + (Sales_Payment - Sales_ADiscount)
If you want to calculate
totalDebt per customer you can use query
SELECT Customer_ID, sum(Sales_Payment - Sales_ADiscount) as totalDebt FROM SalesReceipt GROUP BY Customer_ID
totalDebts aggregated by Customer_ID and can be used to update
Customer (all the looping and calculating is done by a database engine).
The query can also update be more complex to do even update for you.