Calculation of total amounts and quantities