The Prophet ﷺ used to send Abdullah ibn Rawahah (to Khaybar), and he would assess the amount of dates when they began to ripen before they were eaten (by the Jews). He would then give choice to the Jews that they have them (on their possession) by that assessment or could assign to them (Muslims) by that assignment, so that the (amount of) zakat could be calculated before the fruit became eatable and distributed (among the people). (Using translation from Abū Dāʾūd 3413)
شَأْنَ خَيْبَرَ كَانَ النَّبِيُّ ﷺ يَبْعَثُ ابْنَ رَوَاحَةَ إِلَى الْيَهُودِ فَيَخْرُصُ عَلَيْهِمُ النَّخْلَ حِينَ يَطِيبُ قَبْلَ أَنْ يُؤْكَلَ مِنْهُ ثُمَّ يُخَيِّرُونَ يَهُودَ أَنْ يَأْخُذُوهُ بِذَلِكَ الْخَرْصِ أَمْ يَدْفَعُونَهُ إِلَيْهِمْ بِذَلِكَ؟ وَإِنَّمَا كَانَ أَمْرُ النَّبِيِّ ﷺ بِالْخَرْصِ لِكَيْ يُحْصِيَ الزَّكَاةَ قَبْلَ أَنْ تُؤْكَلَ الثَّمَرَةُ وَيُفَرَّقَ