Ah, catering.. the bane of our existence!
The order for meals is sent through to catering, I believe, about 24 hours before the flight, based on the expected flight load.
When we board the aircraft, the most important duty of the galley crew is to count the meals (casserole dishes, which are loaded in the ovens already) and the trays. We report the number to the FSM. By this time the passengers are boarding and checkin is closed, so if the number of passengers has increased, extra meals are radioed for and brought on prior to door closing.
Usually the passenger load decreases rather than increases, so we generally end up with a few spares.
The ratio varies depending on the menu and route based on historical data of how many passengers miss out on their choice - we might have 30% fish, 70% beef on AKL-LAX, 50% fish 50% lamb on AKL-NRT, and 60% chicken 40% lamb on AKL-HKG. Each flight, the FSM includes in his report how many passengers missed out, to add to the data. The loadings may be adjusted if there's a consistent trend.
If there are complaints about a particular meal they are noted and the meal will be altered or removed for the next menu cycle. There was one in particular Trans-Tasman in the early days of the Express service that was so unpopular it was immediately removed after only about 2 weeks, but the particular dish escapes my memory.
Business Class used to be catered at 130% to increase the chances of our high value passengers getting their meal choice. Now that Premium Economy gets the same hot meal choices, I'm not sure if that's still the case, since the vastly increased number of hot meals means the chances of Business passengers missing out on their choice is very very remote.
Crew meals are economy class standard and are usually exactly the same meal as that flight's economy choices, plus a couple of vegetarians loaded. We also are able to order special meals for medical or religious reasons if we choose to do so.